/* Scenewords viewer. Colours follow dictationtrainer.com: cream paper, deep-blue ink, mint.
   The word card follows the design board for the Anki cards (white card, warm greys, dark mint). */
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/plus-jakarta-sans-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/plus-jakarta-sans-vietnamese-wght-normal.woff2) format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
:root {
  --paper: #FCFAF4;
  --surface: #FFFFFF;
  --ink: #1B2433;
  --muted: #5B6575;
  --line: #E7E1D3;
  --mint: #3DC59B;
  --mint-ink: #0F7A5A; /* mint dark enough for text on paper (5.1:1) */
  --mint-wash: #E4F5EE;
  --veil: rgba(14, 22, 38, .55);
  /* the word card, from the Anki design board */
  --card-bg: #FFFFFF;
  --card-ink: #1D2521;
  --card-muted: #59645E;
  --card-body: #3F4A44;
  --card-mint: #0C7C5B;
  --card-box: #F4F5F2;
  --card-edge: #DADDD6;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .06);
  --ease: cubic-bezier(.22, .61, .36, 1); /* the site's motion curve */
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --round: "Plus Jakarta Sans", var(--text); /* the site's typeface; CJK falls back per language */
  color-scheme: light;
}
/* Dark: when the system asks for it, unless the reader chose light with the button (data-theme
   on <html>, set before the page paints); or whenever the reader chose dark. Same values twice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1626;
    --surface: #152036;
    --ink: #E8ECF2;
    --muted: #9AA6B8;
    --line: #26324A;
    --mint: #40DBAC;
    --mint-ink: #5FE3BB;
    --mint-wash: #133A35;
    --veil: rgba(4, 8, 16, .72);
    --card-bg: #172338;
    --card-ink: #E8ECF2;
    --card-muted: #9AA6B8;
    --card-body: #C4CCD7;
    --card-mint: #5FE3BB;
    --card-box: #202D45;
    --card-edge: #33415E;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1626;
  --surface: #152036;
  --ink: #E8ECF2;
  --muted: #9AA6B8;
  --line: #26324A;
  --mint: #40DBAC;
  --mint-ink: #5FE3BB;
  --mint-wash: #133A35;
  --veil: rgba(4, 8, 16, .72);
  --card-bg: #172338;
  --card-ink: #E8ECF2;
  --card-muted: #9AA6B8;
  --card-body: #C4CCD7;
  --card-mint: #5FE3BB;
  --card-box: #202D45;
  --card-edge: #33415E;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:lang(zh) { --text: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
:lang(ja) { --text: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP", sans-serif; }
:lang(ko) { --text: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", sans-serif; word-break: keep-all; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--round);
}
a { color: var(--mint-ink); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; border-radius: 6px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* masthead */
.masthead { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.25rem 1.75rem; }
.masthead-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; }
.wordmark {
  display: flex; align-items: center; gap: .55rem; margin: 0;
  font: 700 1.35rem/1 var(--round); letter-spacing: -.01em;
}
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.1rem; }
.langs { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .95rem; }
/* light or dark: the icon shows the look the button switches to */
.theme {
  display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer;
}
.theme:hover { border-color: var(--mint); color: var(--mint-ink); }
.theme svg { width: 1.1rem; height: 1.1rem; stroke-width: 2; }
.theme .to-light { display: none; }
:root[data-theme="dark"] .theme .to-light { display: block; }
:root[data-theme="dark"] .theme .to-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .to-light { display: block; }
  :root:not([data-theme="light"]) .theme .to-dark { display: none; }
}
.langs a { text-decoration: none; padding: .15rem 0; }
.langs a[aria-current="true"] { color: var(--ink); font-weight: 650; text-decoration: underline 2px var(--mint); text-underline-offset: 6px; }
.lede {
  max-width: 40rem; margin: 2.25rem 0 .75rem;
  font: 650 clamp(1.55rem, 1.15rem + 1.7vw, 2.4rem)/1.22 var(--round);
  letter-spacing: -.015em; text-wrap: balance;
}
.source { margin: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin: 1.5rem 0 0; }
.cta {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: .6rem 1.15rem;
  border-radius: 999px; background: var(--mint); color: #0E1626;
  font-weight: 650; text-decoration: none;
}
.cta:hover { filter: brightness(1.04); }
.quiet { font-weight: 600; }

/* toolbar */
.toolbar {
  position: sticky; top: 0; z-index: 2;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.toolbar { padding: .75rem 0 .6rem; }
.toolbar > * { max-width: 72rem; margin-inline: auto; padding-inline: 1.25rem; }
.search { display: block; }
.search input {
  width: 100%; max-width: 24rem; min-height: 2.6rem; padding: .55rem 1.1rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.search input::placeholder { color: var(--muted); }
.topics { display: flex; flex-wrap: wrap; gap: .4rem; padding-top: .6rem; padding-bottom: .15rem; }
.topics::-webkit-scrollbar { display: none; }
.topics button {
  flex: none; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer;
}
.topics button:hover { border-color: var(--mint); }

/* the wall */
main { max-width: 72rem; margin: 0 auto; padding: 1rem 1.25rem 3rem; overflow-x: clip; }
.topic { padding-top: 1.75rem; scroll-margin-top: 7.5rem; }
.topic[hidden] { display: none; }
.topic-head { display: flex; align-items: baseline; gap: .75rem; margin: 0 0 1rem; }
.topic-head h2 { margin: 0; font: 650 1.3rem/1.2 var(--round); }
.topic-head span { color: var(--muted); font-size: .9rem; }
.grid {
  display: grid; gap: 1.4rem 1rem; margin: 0; padding: 0; list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(9.25rem, 1fr));
}
.tile { display: block; color: inherit; text-decoration: none; }
.tile-pic { position: relative; display: block; aspect-ratio: 1; }
.tile-frame {
  position: absolute; inset: 0; overflow: hidden; isolation: isolate;
  border-radius: 14px; background: var(--line);
}
.tile-img, .tile-ghost {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%; object-fit: cover;
}
.tile-ghost { filter: grayscale(1); opacity: .35; }
.tile:hover .tile-frame { outline: 3px solid var(--mint); outline-offset: 0; }
.tile:focus-visible { outline: none; }
.tile:focus-visible .tile-frame { outline: 3px solid var(--mint); outline-offset: 3px; }
/* the ring a tile lights up with; only seen while .lighting runs */
.tile-ring {
  position: absolute; z-index: 1; left: 50%; top: 50%; width: 132%; height: 132%;
  border: 2px solid rgb(255 255 255 / .92); border-radius: 50%;
  box-shadow:
    0 0 0 1.5px color-mix(in srgb, var(--mint) 95%, transparent),
    0 0 14px color-mix(in srgb, var(--mint) 45%, transparent);
  opacity: 0; transform: translate(-50%, -50%) scale(.05); pointer-events: none;
}
.tile-word { display: block; margin-top: .5rem; font: 650 1.02rem/1.25 var(--round); }
.tile-gloss {
  display: block; margin-top: .1rem; color: var(--muted); font-size: .86rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.empty { padding: 3rem 0; color: var(--muted); text-align: center; }

/* word card: one card with two faces, laid out like the Anki cards on the design board.
   The front shows the picture, the "hear the word" button and the question; the back answers. */
dialog {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  margin: 0; padding: 1rem; border: 0; background: transparent; color: var(--card-ink);
  overflow: auto; overscroll-behavior: contain;
}
dialog[open] { display: grid; place-items: center; }
dialog::backdrop { background: var(--veil); }
.deck { width: min(27rem, 100%); display: flex; flex-direction: column; gap: .75rem; }
.deck-top { display: flex; justify-content: flex-end; margin: 0; }
.deck-nav { display: flex; justify-content: center; align-items: center; gap: .75rem; margin: 0; }
.round {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0;
  border: 0; border-radius: 999px; background: var(--card-bg); color: var(--card-ink);
  box-shadow: var(--card-shadow); cursor: pointer;
}
.round:disabled { opacity: .4; cursor: default; }
.turn {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; padding: 0 1.25rem;
  border: 0; border-radius: 999px; background: var(--mint); color: #0E1626;
  font: 700 .95rem/1.2 var(--round); cursor: pointer;
}
.turn svg { width: 1.1em; height: 1.1em; stroke-width: 2.4; }
.turn:hover, .round:not(:disabled):hover { filter: brightness(1.05); }

/* the card turns over; each face clips its own content to the rounded corners */
.card { display: grid; transform-style: preserve-3d; transform: perspective(1600px) rotateY(0deg); }
.card.is-back { transform: perspective(1600px) rotateY(180deg); }
.face {
  grid-area: 1 / 1; position: relative; display: flex; flex-direction: column; min-width: 0;
  overflow: clip; border-radius: 18px; background: var(--card-bg); box-shadow: var(--card-shadow);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.front { align-items: center; justify-content: center; gap: 14px; padding: 20px; }
.back { gap: 10px; padding: 22px 24px; transform: rotateY(180deg); }

/* front: the picture, in .frame a grey copy and the picture itself, clipped to the square; over it
   three rings that leave the square and cross the card */
.card-picture { position: relative; width: 100%; margin: 0; aspect-ratio: 1; cursor: pointer; }
.card-picture .frame { position: absolute; inset: 0; overflow: hidden; isolation: isolate; border-radius: 14px; background: var(--card-box); }
.card-picture .open { position: absolute; inset: 0; }
.card-picture img {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%; object-fit: cover;
}
.card-picture .ghost { display: none; }
.card-picture .ring {
  --peak: 1;
  position: absolute; z-index: 1; left: 50%; top: 50%; width: 190%; height: 190%;
  border: 3px solid rgb(255 255 255 / .95); border-radius: 50%;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--mint) 95%, transparent),
    0 0 24px color-mix(in srgb, var(--mint) 45%, transparent);
  opacity: 0; transform: translate(-50%, -50%) scale(.05); pointer-events: none;
}
.card-picture .r2 {
  --peak: .7; border-width: 2.5px;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--mint) 95%, transparent),
    0 0 18px color-mix(in srgb, var(--mint) 45%, transparent);
}
.card-picture .r3 {
  --peak: .45; border-width: 2px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mint) 95%, transparent);
}
.listen {
  position: relative; isolation: isolate; flex: none;
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid var(--card-edge); border-radius: 999px; background: var(--card-bg);
  color: var(--card-mint); font: 700 14px/1 var(--round); cursor: pointer;
}
.listen svg { width: 16px; height: 16px; stroke-width: 2; }
.listen:hover, .listen[aria-pressed="true"] { border-color: var(--mint); }
/* rings that leave the button while the word sounds (driven from app.js) */
.listen .wave {
  position: absolute; z-index: -1; inset: -1px;
  border: 2px solid var(--mint); border-radius: 999px;
  opacity: 0; pointer-events: none;
}
.prompt { margin: 0; color: var(--card-muted); font-size: 13px; line-height: 1.4; text-align: center; }

/* back: thumbnail and word, then the gloss, the English definition, the sentence, the link */
.head { display: flex; align-items: center; gap: 16px; }
.thumb {
  flex: none; width: 96px; height: 96px; overflow: hidden;
  border-radius: 12px; background: var(--card-box); cursor: pointer;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; container-type: inline-size; }
/* --chars is the word's length (set from app.js): a long word shrinks to fit its line */
.word {
  margin: 0; font: 800 clamp(1.3rem, calc(100cqi / (var(--chars, 7) * .62)), 2rem)/1.1 var(--round);
  letter-spacing: -.01em; overflow-wrap: anywhere; outline: none;
}
.say { margin: 0; color: var(--card-muted); font-size: 14px; }
.pos { color: var(--card-mint); font-weight: 700; text-decoration: none; }
.ipa { font-family: ui-monospace, Menlo, Consolas, monospace; }
.gloss { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.35; }
.gloss:empty { display: none; }
.def { margin: 0; color: var(--card-body); font-size: 14.5px; line-height: 1.55; }
.sentence {
  margin: 4px 0 0; padding: 12px 14px; border-radius: 12px;
  background: var(--card-box); font-size: 15px; line-height: 1.55;
}
.sentence strong { font-weight: 700; }
.spacer { flex: 1; min-height: 4px; }
/* inline, so a link that wraps keeps its arrow right after the last word */
.dictate { align-self: flex-start; color: var(--card-mint); font-size: 14px; font-weight: 700; line-height: 1.45; }
.dictate svg { display: inline-block; width: 14px; height: 14px; margin-left: 6px; vertical-align: -2px; stroke-width: 2.4; }

/* Motion: the keyframes, timings and curve of dictationtrainer.com, laid over static pictures.
   With "reduce motion" on, this block does not apply: nothing moves and every element is
   already in its final state. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes pg-rise { from { opacity: 0; transform: translateY(28px) scale(.98); } }
  @keyframes pg-fade { from { opacity: 0; } }
  @keyframes pg-open {
    from { clip-path: circle(0% at 50% 50%); }
    to { clip-path: circle(75% at 50% 50%); }
  }
  @keyframes pg-sat {
    0%, 45% { filter: grayscale(1) brightness(1.08); }
    100% { filter: grayscale(0) brightness(1); }
  }
  @keyframes pg-zoom { from { transform: scale(1.12); } }
  @keyframes pg-ring {
    0% { transform: translate(-50%, -50%) scale(.05); opacity: 0; }
    10% { opacity: var(--peak, 1); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
  }

  /* the card arrives, and turns over when asked */
  dialog[open] { animation: pg-rise 420ms var(--ease) both; }
  dialog[open]::backdrop { animation: pg-fade 240ms ease both; }
  .card { transition: transform 620ms var(--ease); }
  .card.no-turn { transition: none; }

  /* whenever the picture changes (opened from the wall, or stepped to with the arrows from either
     face): it opens from its centre inside three rings, grey to colour */
  .card[data-motion="wait"] .ghost,
  .card[data-motion="reveal"] .ghost {
    display: block; opacity: .35; filter: grayscale(1) blur(4px); transform: scale(1.06);
  }
  .card[data-motion="wait"] .open { clip-path: circle(0% at 50% 50%); }
  .card[data-motion="reveal"] .open { animation: pg-open 1000ms var(--ease) 200ms both; }
  .card[data-motion="reveal"] .pic {
    animation: pg-sat 1500ms ease 200ms both, pg-zoom 1300ms var(--ease) 200ms both;
  }
  .card[data-motion="reveal"] .ring { animation: pg-ring 1100ms var(--ease) 200ms both; }
  .card[data-motion="reveal"] .r2 { animation-delay: 380ms; }
  .card[data-motion="reveal"] .r3 { animation-delay: 560ms; }

  /* wall tiles start unlit (grey) and light up one after another as they come into view */
  .unlit .tile-img { filter: grayscale(1); opacity: .35; }
  .lit-wait .tile-img { clip-path: circle(0% at 50% 50%); }
  .lighting .tile-img { animation: pg-open 640ms var(--ease) both; }
  .lighting .tile-ring { animation: pg-ring 640ms var(--ease) both; }

  @media (hover: hover) {
    .tile-img { transition: transform .9s var(--ease); }
    .tile:hover .tile-img { transform: scale(1.04); }
  }
}

@media print {
  .unlit .tile-img { filter: none; opacity: 1; }
}

/* colophon */
.colophon {
  max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem;
}
.colophon p { max-width: 46rem; margin: 0 0 .5rem; }

@media (max-width: 760px) {
  .topics { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topic { scroll-margin-top: 7rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr)); gap: 1.1rem .75rem; }
  .lede { margin-top: 1.5rem; }
}
