/* The icon's colors: its blue gradient (top to bottom), and navy for text. */
:root {
    --bg: #f5f8fc;
    --surface: #ffffff;
    --text: #0a2342;
    --muted: #4a5d78;
    --line: #dbe4f0;
    --blue: #1f6fc7;
    --blue-top: #2c83db;
    --blue-bottom: #1657ab;
    --blue-soft: #e3eefb;
    --on-blue: #ffffff;
    --shadow: 0 1px 2px rgba(10, 35, 66, 0.06), 0 8px 30px rgba(10, 35, 66, 0.08);
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #071527;
        --surface: #0d2139;
        --text: #e8f0fa;
        --muted: #9fb3cc;
        --line: #1c3557;
        --blue: #6aaef0;
        --blue-soft: #0f2a4a;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 30px rgba(0, 0, 0, 0.35);
    }
}
:root[data-theme="dark"] {
    --bg: #071527;
    --surface: #0d2139;
    --text: #e8f0fa;
    --muted: #9fb3cc;
    --line: #1c3557;
    --blue: #6aaef0;
    --blue-soft: #0f2a4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased; overflow-x: clip;
}
main, .nav, .footer { max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
h1, h2 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }

.nav { display: flex; align-items: center; justify-content: space-between; padding-top: 20px; padding-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 28px; letter-spacing: -0.02em; }
.brand img { border-radius: 11px; }

.button {
    display: inline-block; padding: 12px 22px; border-radius: 999px;
    background: linear-gradient(180deg, var(--blue-top), var(--blue-bottom)); color: var(--on-blue);
    font-weight: 650; text-decoration: none; box-shadow: 0 4px 14px rgba(22, 87, 171, 0.3);
    transition: filter 120ms ease;
}
.button:hover { filter: brightness(1.08); }

/* Hero: the pitch on the left, the drawn player on the right. */
.hero { display: grid; grid-template-columns: 1fr 1.15fr; gap: 56px; align-items: center; padding: 48px 0 88px; }
.hero h1 { font-size: clamp(34px, 4.6vw, 54px); }
.hero .lead { margin-top: 20px; font-size: 19px; color: var(--muted); max-width: 34em; }
.hero .sites { margin-top: 14px; color: var(--muted); }
.hero .sites strong { color: var(--text); font-weight: 600; }
.hero .button { margin-top: 28px; }

/* The drawing of the overlay. Its colors are the overlay's (src/overlay/styles.ts), not the page's. */
.player {
    position: relative; aspect-ratio: 16 / 10; border-radius: 16px; overflow: visible;
    background: #071527; box-shadow: var(--shadow), 0 30px 60px rgba(10, 35, 66, 0.18);
}
.player-scene {
    position: absolute; inset: 0; border-radius: 16px; overflow: hidden;
    background:
        radial-gradient(ellipse 60% 40% at 72% 28%, rgba(186, 214, 245, 0.45), transparent 70%),
        radial-gradient(ellipse 80% 50% at 20% 85%, rgba(44, 131, 219, 0.55), transparent 70%),
        linear-gradient(180deg, #2a5a8f 0%, #1a3f6b 55%, #0d2645 100%);
}
.player-scene::after {
    /* A low hill, so it reads as a scene rather than a gradient. */
    content: ""; position: absolute; left: -10%; right: -10%; bottom: -30%; height: 70%;
    background: #0a2342; border-radius: 50% 50% 0 0;
}
.lines {
    position: absolute; left: 0; right: 0; bottom: 17%;
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 5%;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}
.line {
    background: rgba(8, 8, 8, 0.78); border-radius: 8px; padding: 6px 14px; max-width: 92%; text-align: center;
}
.target { color: #fff; font-weight: 600; font-size: clamp(14px, 1.9vw, 22px); line-height: 1.3; }
.native { color: #fde68a; font-size: clamp(12px, 1.5vw, 17px); line-height: 1.3; }
.word { position: relative; border-radius: 4px; }
.word.hovered { background: rgba(253, 230, 138, 0.25); }
.seekbar { position: absolute; left: 4%; right: 4%; bottom: 6%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
.seekbar span { display: block; width: 38%; height: 100%; border-radius: 2px; background: #2c83db; }

.popup {
    position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -8px);
    display: flex; flex-direction: column; width: max-content; min-width: 12em; overflow: hidden;
    background: #fff; color: #171717; border-radius: 12px; text-align: left; font-weight: 400;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 8px 28px rgba(0, 0, 0, 0.4);
    font-size: clamp(11px, 1.15vw, 14px); line-height: 1.25;
}
.popup-about { display: flex; flex-direction: column; gap: 3px; padding: 7px 10px 6px; }
.popup-head { display: flex; align-items: baseline; gap: 8px; }
.popup-word { font-size: 1.25em; font-weight: 600; }
.popup-lemma { color: #525252; font-weight: 500; }
.popup-lemma::before { content: "→ "; color: #a3a3a3; }
.popup-meaning { display: flex; align-items: baseline; gap: 7px; color: #262626; font-size: 1.05em; font-weight: 500; }
.popup-pos { padding: 1px 7px; border-radius: 999px; background: #eef2ff; color: #4f46e5; font-size: 0.7em; font-weight: 600; }
.popup-source { color: #a3a3a3; font-size: 0.75em; font-weight: 500; }
.popup-lookup {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
    background: #f5f5f4; border-top: 1px solid #e7e5e4; color: #57534e; font-size: 0.8em; font-weight: 500;
}
.popup-link { padding: 2px 7px; background: #fff; border-radius: 6px; box-shadow: 0 0 0 1px #e7e5e4; color: #171717; font-weight: 600; }

/* The language banner: a band across the page that scrolls on its own and by hand (banner.js). */
.langs { margin: 0 calc(50% - 50vw) 96px; padding: 28px 0 32px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.langs-title { text-align: center; color: var(--muted); font-weight: 600; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 20px; padding: 0 16px; }
.langs-scroller {
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; cursor: grab;
    -webkit-user-select: none; user-select: none; outline: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.langs-scroller::-webkit-scrollbar { display: none; }
.langs-scroller.dragging { cursor: grabbing; }
.langs-scroller:focus-visible .langs-list li { border-color: var(--blue); }
.langs-track { display: flex; width: max-content; padding: 2px 0; }
.langs-list { display: flex; gap: 12px; list-style: none; margin: 0; padding: 0 12px 0 0; }
.langs-list li {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 20px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--line); white-space: nowrap;
}
.lang-native { font-size: 22px; font-weight: 600; color: var(--text); }
.lang-name { font-size: 13px; color: var(--muted); }

/* Why it works */
.learn { padding-bottom: 96px; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.quote { margin: 0 0 32px; padding: 28px 32px; border-radius: 16px; background: var(--blue-soft); border-left: 4px solid var(--blue); }
.quote blockquote { margin: 0; font-size: clamp(20px, 2.2vw, 26px); line-height: 1.35; font-weight: 600; letter-spacing: -0.01em; }
.quote figcaption { margin-top: 12px; color: var(--muted); font-size: 15px; }
.feature { display: flex; flex-direction: column; }
.feature .cite { margin-top: auto; padding-top: 14px; font-size: 13.5px; line-height: 1.45; }
.feature .cite cite { font-style: italic; }
.quote a, .feature .cite a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.feature h3 { font-size: 19px; line-height: 1.25; letter-spacing: -0.01em; margin: 0; }
.feature p { margin-top: 8px; color: var(--muted); font-size: 15.5px; }

.section-title { font-size: clamp(26px, 3.2vw, 36px); margin-bottom: 28px; }

/* Scripts: a line of Chinese with pinyin, in the overlay's colors. */
.scripts { display: grid; grid-template-columns: 1fr 1.35fr; gap: 48px; align-items: center; padding-bottom: 96px; }
.scripts .section-title { margin-bottom: 14px; }
.scripts p { color: var(--muted); }
.ruby-demo {
    display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 44px 24px 40px; border-radius: 16px;
    background: linear-gradient(180deg, #1a3f6b, #0a2342); color: #fff; font-weight: 600; text-align: center;
    font-size: 44px; line-height: 1.7; box-shadow: var(--shadow); container-type: inline-size;
}
/* The line stays on one line: as big as fits the box (about 16em wide with its pinyin and the gaps between
   words), up to 44px. */
.ruby-line { font-size: min(1em, 5.7cqi); white-space: nowrap; }
.ruby-demo ruby { margin: 0 0.06em; }
.ruby-demo rt { font-size: 0.48em; font-weight: 500; opacity: 0.9; padding-bottom: 2px; }
.ruby-native {
    font-size: clamp(18px, 1.8vw, 22px); line-height: 1.4; font-weight: 500; color: #fde68a;
    padding: 2px 8px; border-radius: 6px; cursor: default; outline: none;
    transition: filter 150ms ease; will-change: filter;
}
/* As in the overlay: the hover highlight, the gap between words, and the blurred native line. */
.ruby-demo { position: relative; }
.demo-word { border-radius: 4px; cursor: default; outline: none; transition: background 100ms ease; }
.demo-word[data-gap] { margin-left: 0.3em; }
.demo-word[data-picked], .demo-word:focus-visible { background: rgba(253, 230, 138, 0.25); }
@media (hover: hover) { .demo-word:hover { background: rgba(253, 230, 138, 0.25); } }
.ruby-native[data-cover]:not([data-revealed]) { filter: blur(6px); }
@media (hover: hover) { .ruby-native[data-cover]:hover { filter: blur(0); } }
.ruby-native:focus-visible { filter: blur(0); box-shadow: 0 0 0 2px rgba(253, 230, 138, 0.5); }
.demo-hint { font-size: 13px; line-height: 1.4; font-weight: 400; color: rgba(255, 255, 255, 0.55); }
.hint-touch { display: none; }
@media (hover: none) { .hint-hover { display: none; } .hint-touch { display: inline; } }

/* The word popup, in the overlay's styles (.submerse-popup in src/overlay/styles.ts). */
.demo-popup {
    position: absolute; z-index: 5; padding-bottom: 6px; transform: translateY(-100%);
    font-size: 14px; line-height: 1.25; font-weight: 400; white-space: normal; text-align: left;
}
.demo-popup[hidden] { display: none; }
.demo-popup-card {
    display: flex; flex-direction: column; width: max-content; max-width: 19em; overflow: hidden;
    background: #fff; color: #171717; border-radius: 12px;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 8px 28px rgba(0, 0, 0, 0.4);
}
.demo-popup .popup-about { gap: 4px; padding: 8px 12px 7px; }
.demo-popup .popup-word { font-size: 1.5em; }
.demo-popup .popup-word rt { font-size: 0.45em; font-weight: 500; color: #737373; }
.demo-popup .popup-lookup a {
    padding: 2px 7px; background: #fff; border-radius: 6px; box-shadow: 0 0 0 1px #e7e5e4;
    color: #171717; font-weight: 600; text-decoration: none;
}
.demo-popup .popup-lookup a:hover { background: #fcd34d; box-shadow: 0 0 0 1px #f59e0b; }

/* Get it */
.get {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
    padding: 48px 24px 56px; margin-bottom: 64px; border-radius: 24px;
    background: linear-gradient(180deg, var(--blue-top), var(--blue-bottom)); color: var(--on-blue);
}
.get img { width: 180px; height: auto; }
.get h2 { font-size: clamp(26px, 3.2vw, 36px); }
.get p { color: rgba(255, 255, 255, 0.82); max-width: 32em; }

.footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--line);
    color: var(--muted); font-size: 14px;
}
.footer span:first-child { font-weight: 600; color: var(--text); }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }
.get .get-contact { font-size: 15px; }
.get-contact a { color: var(--on-blue); font-weight: 600; }

@media (max-width: 960px) {
    .hero { grid-template-columns: 1fr; gap: 72px; padding-top: 24px; }
    .features { grid-template-columns: 1fr 1fr; }
    .scripts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    main, .nav, .footer { padding-left: 16px; padding-right: 16px; }
    .features { grid-template-columns: 1fr; }
    .quote { padding: 22px 20px; }
    .ruby-demo { padding: 32px 12px 28px; }
    .brand { font-size: 24px; }
    .brand img { width: 40px; height: 40px; }
    .hero .lead { font-size: 17px; }
    .player { margin-top: 40px; }
    .popup { font-size: 11px; }
}
