/* Fonts are self-hosted (static/fonts, SIL OFL, licenses alongside); variable files, one per script. */
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/figtree-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/figtree-latin.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: 'Shantell Sans';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url(fonts/shantell-sans-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Shantell Sans';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url(fonts/shantell-sans-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Shantell Sans';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url(fonts/shantell-sans-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Shantell Sans';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url(fonts/shantell-sans-latin.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;
}

:root {
  --ground: #F3F0FF;
  --ink: #1C1638;
  --muted: #4B4566;
  --accent: #5B3FD9;
  --accent-dark: #36209A;
  --line: #DCD5F7;
  --error-bg: #FFE4DC;
  --error-ink: #8A2A12;
  --display: 'Shantell Sans', system-ui, sans-serif;
  --body: 'Figtree', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  overflow-wrap: break-word;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
}

/* Mobile first. The desktop layout is at the bottom (min-width: 900px). */

.page {
  max-width: 1120px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 24px 32px;
  display: flex;
  flex-direction: column;
}

main { flex: 1; display: flex; flex-direction: column; }
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; margin-top: 48px; padding: 16px 0 8px; border-top: 1px solid var(--line); font-size: 14px; }

a { color: var(--accent-dark); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Phones: logo and languages on the first row, the page links on a full-width row below.
   Desktop: one row, languages last. */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 44px; margin-bottom: 24px; }
.top form { margin: 0; }
.nav { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; font-size: 15px; }
.logo { margin-right: auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-size: 22px; font-weight: 800; color: var(--accent); text-decoration: none; }

.link {
  font: inherit;
  font-weight: 600;
  color: var(--accent-dark);
  background: none;
  border: 0;
  padding: 12px 4px;
  cursor: pointer;
  text-decoration: none;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 36px;
  font-weight: 800;
  line-height: 1.12;
}
.hero { display: flex; flex-direction: column; gap: 12px; }
.lead { margin: 0; color: var(--muted); max-width: 32ch; }
.home .lead { max-width: 42ch; }
.hero .hint { margin: 0; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }

/* Home: hero, sticker board, then the buttons pinned to the bottom of the screen. */
.home { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.home .actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; text-align: center; }

/* Landing page, below the hero: three steps, then a closing call to action. */
.button.secondary { background: #FFFFFF; color: var(--accent-dark); box-shadow: inset 0 0 0 2px var(--line); }
.button.secondary:hover { background: var(--line); }
.button.light { background: #FFFFFF; color: var(--accent-dark); }
.button.light:hover { background: var(--ground); }
.sticker small { display: block; margin-top: 0.1em; font-family: var(--body); font-size: 0.5em; font-weight: 600; color: var(--muted); }
.steps { margin-top: 56px; }
.steps h2, .cta h2 { margin: 0 0 20px; font-family: var(--display); font-size: 28px; line-height: 1.15; }
.steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 16px; }
.steps li { padding: 20px; border-radius: 24px; background: #FFFFFF; }
.steps h3 { margin: 16px 0 4px; font-size: 19px; }
.steps p { margin: 0; color: var(--muted); }
.step-visual { height: 64px; display: flex; align-items: center; }
.step-visual .sticker { position: static; transform: rotate(-3deg); font-size: 22px; }
.pills { display: flex; gap: 4px; }
.pills span { padding: 4px 10px; border-radius: 999px; background: var(--ground); color: var(--accent-dark); font-size: 13px; font-weight: 700; }
.pills .on { background: var(--accent); color: #FFFFFF; }
.step-visual .rated { align-self: auto; background: var(--ground); font-size: 15px; }
.cta { margin-top: 32px; padding: 32px 24px; border-radius: 28px; background: var(--accent); color: #FFFFFF; text-align: center; }
.cta .button { max-width: 360px; height: auto; min-height: 58px; margin: 0 auto; padding: 8px 20px; text-align: center; }

/* Done screens (study, guest lesson): one centred message. */
.done { align-items: center; text-align: center; }
.done .lead { margin: 0 auto; }
.done .button { max-width: 320px; }

/* Form pages: one centred column. */
.narrow { width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* Decorative word stickers, scattered by the s* classes below. Sizes are in em, so
   changing the board's font-size scales the whole board. */
.stickers { position: relative; height: 290px; font-size: 1rem; }
.sticker, .slot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: rotate(var(--r));
  border-radius: 0.7em;
  white-space: nowrap;
}
.sticker {
  padding: 0.35em 0.7em;
  border: 0.17em solid #FFFFFF;
  box-shadow: 0 3px 10px rgba(28, 22, 56, 0.16);
  font-family: var(--display);
  font-size: 1.35em;
  font-weight: 700;
}
.slot { padding: 0.7em 1.05em; border: 2.5px dashed #A99BE6; color: #5B4FA0; font-weight: 600; }
.yellow { background: #FFD84D; }
.sky { background: #8CC8FF; }
.mint { background: #7ADBB0; }
.peach { background: #FFB59A; }
.s1 { --x: 2%; --y: 4%; --r: -6deg; font-size: 1.9em; }
.s2 { --x: 64%; --y: 26%; --r: 7deg; }
.s3 { --x: 9%; --y: 42%; --r: 3deg; font-size: 1.5em; }
.s4 { --x: 1%; --y: 70%; --r: -4deg; }
.s5 { --x: auto; right: 2%; --y: 68%; --r: 5deg; }

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #FFFFFF;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--accent-dark); }

.form { display: flex; flex-direction: column; }
.form label { font-weight: 600; margin-bottom: 6px; }
.form input {
  height: 54px;
  padding: 0 18px;
  margin-bottom: 18px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
}
.form input:focus { border-color: var(--accent); }
.form .hint { margin: -12px 0 18px; font-size: 15px; color: var(--muted); }
.form .button { margin-top: 6px; }

.error {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--error-bg);
  color: var(--error-ink);
  font-weight: 600;
}

/* Study page: the word is a big sticker; its answer fills a label where the reveal button was,
   so nothing moves. On phones the buttons sit at the bottom (thumb reach). */
.study { flex: 1; gap: 16px; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 32px; }
.card-top .hint { margin: 0; font-size: 15px; color: var(--muted); }
.rated { align-self: flex-start; margin: 0; padding: 4px 12px; border-radius: 999px; background: #FFFFFF; color: var(--accent-dark); font-size: 14px; font-weight: 600; }
.card { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; }
.word {
  max-width: 100%;
  padding: 0.12em 0.5em 0.2em;
  border: 6px solid #FFFFFF;
  border-radius: 24px;
  background: #FFD84D;
  box-shadow: 0 4px 14px rgba(28, 22, 56, 0.16);
  transform: rotate(-2deg);
  font-size: 48px;
  overflow-wrap: break-word;
  hyphens: auto;
}
/* Noun stickers take the article's colour, so gender sticks along with the word. */
.word.der { background: #8CC8FF; }
.word.die { background: #FFB59A; }
.word.das { background: #7ADBB0; }
/* The pronunciation button is a second, smaller sticker stuck on the word's corner. */
.word-wrap { position: relative; max-width: calc(100% - 24px); margin-bottom: 12px; }
.say {
  position: absolute;
  right: -24px;
  bottom: -16px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 4px solid #FFFFFF;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(28, 22, 56, 0.22);
  transform: rotate(8deg);
}
.say:hover, .say.playing { background: var(--accent-dark); }
.say:active { transform: rotate(8deg) scale(0.92); }
.say svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.say .cone { fill: currentColor; }
/* The plural pairs with the word, in its font but not its gender colour (plurals have none).
   The umlaut and ending, what the learner must memorise, are marked like a dictionary's ¨-er.
   Hidden until the answer opens; visibility keeps its space, so the card doesn't move. */
.plural { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 10px; max-width: 100%; margin: -4px 0 0; }
.plural-label { font-size: 15px; font-weight: 600; color: var(--muted); }
.plural-form { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.plural-form b { color: var(--accent); text-decoration: underline 3px; text-underline-offset: 5px; }
.card:not(:has(.answer[open])) .plural { visibility: hidden; opacity: 0; }
.pos { margin: -8px 0 0; font-size: 14px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.answer { width: 100%; margin-top: 8px; }
.answer summary { list-style: none; }
.answer summary::-webkit-details-marker { display: none; }
.answer[open] summary { display: none; }
.translation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  margin: 0;
  padding: 10px 20px;
  border-radius: 18px;
  background: #FFFFFF;
  box-shadow: 0 3px 10px rgba(28, 22, 56, 0.1);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
}
.rate { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
/* Rating comes after seeing the answer: until then the buttons are dimmed and ignore clicks. */
.study:not(:has(.answer[open])) .rate .button { opacity: 0.4; pointer-events: none; }
.rate .button.pressed { background: var(--accent-dark); transform: scale(0.95); }
.rate .button { flex-direction: column; gap: 2px; height: auto; min-height: 64px; padding: 8px 4px; border-radius: 18px; font-size: 16px; line-height: 1.2; }
.rate small { font-size: 12px; font-weight: 400; opacity: 0.8; }
.rate kbd { display: none; }
.rate-help { margin: 12px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); text-align: center; }

/* Language switcher: small codes, the current one filled. */
.langs { display: flex; gap: 2px; }
.langs a { padding: 4px 6px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--accent-dark); }
.langs [aria-current] { color: var(--accent-dark); box-shadow: inset 0 0 0 1.5px var(--accent); }
.login { padding: 8px 18px; border-radius: 999px; background: var(--accent); color: #FFFFFF; font-weight: 700; text-decoration: none; }
.login:hover { background: var(--accent-dark); }

/* Current page in the top bar: a thick violet bar under the item, plus darker text on plain links. */
.nav [aria-current="page"] { position: relative; color: var(--ink); }
.nav [aria-current="page"]::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 2px; height: 4px; border-radius: 999px; background: var(--accent); }
.nav .login[aria-current="page"] { color: #FFFFFF; background: var(--accent-dark); }
.nav .login[aria-current="page"]::after { left: 14px; right: 14px; bottom: -8px; }
.prose { display: flex; flex-direction: column; gap: 12px; }
.prose h2 { margin: 12px 0 0; font-family: var(--display); font-size: 22px; }
.prose p { margin: 0; }
/* About: what each rating button does, its name shown as a small button. */
.prose dl { margin: 4px 0; display: grid; gap: 12px; }
.prose dl div { padding: 14px 16px; border-radius: 18px; background: #FFFFFF; }
.prose dt { display: inline-block; margin-bottom: 6px; padding: 2px 12px; border-radius: 999px; background: var(--accent); color: #FFFFFF; font-weight: 700; }
.prose dd { margin: 0; }

/* Settings: the daily limit, then progress as a meter, tiles and one bar per rating.
   Bars are <progress> elements because the CSP forbids inline widths. */
.panel { padding: 18px; border-radius: 22px; background: #FFFFFF; }
.settings h2, .stats h2 { margin: 0 0 12px; font-family: var(--display); font-size: 22px; }
.limit-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.limit-top .rated { background: var(--ground); }
.limit h2 { margin: 0; font-family: var(--body); font-size: 17px; font-weight: 700; }
.presets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 0 0 18px; padding: 4px; border-radius: 999px; background: var(--ground); }
.presets button { height: 44px; border: 0; border-radius: 999px; background: none; color: var(--accent-dark); font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; }
.presets button:hover { background: var(--line); }
.presets [aria-pressed="true"], .presets [aria-pressed="true"]:hover { background: var(--accent); color: #FFFFFF; }
.custom { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; }
.custom label { grid-column: 1 / -1; font-size: 15px; color: var(--muted); }
.custom input { margin: 0; height: 50px; }
.custom .button { margin: 0; width: auto; height: 50px; padding: 0 26px; font-size: 16px; }

.stats progress { display: block; width: 100%; height: 10px; border: 0; border-radius: 999px; background: var(--ground); appearance: none; overflow: hidden; }
.stats progress::-webkit-progress-bar { background: var(--ground); }
.stats progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.stats progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.today { margin-bottom: 10px; }
.today p { margin: 0; }
.today-label { color: var(--muted); font-weight: 600; }
.today .today-value { margin: 2px 0 12px; font-family: var(--display); font-size: 34px; font-weight: 800; line-height: 1.1; }
.today progress { height: 14px; }
.today .today-note { margin-top: 10px; font-size: 15px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 28px; }
.tiles div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 4px; padding: 14px; border-radius: 18px; background: #FFFFFF; }
.tiles dt { font-size: 13px; line-height: 1.3; color: var(--muted); }
.tiles dd { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1; }

.bars { margin: 0; padding: 8px 18px; }
.bars div { display: grid; grid-template-columns: 7em 1fr; align-items: center; gap: 12px; padding: 10px 0; }
.bars div + div { border-top: 1px solid var(--line); }
.bars dt { color: var(--muted); }
.bars dd { display: grid; grid-template-columns: 1fr 2.5ch; align-items: center; gap: 12px; margin: 0; font-weight: 700; text-align: right; }
.bars .unrated progress::-webkit-progress-value { background: var(--line); }
.bars .unrated progress::-moz-progress-bar { background: var(--line); }

.switch { margin: 0; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .button, .say { transition: background-color 120ms, transform 120ms; }
  .plural { transition: opacity 250ms, visibility 250ms; }
  .say.playing .wave1 { animation: wave 500ms ease-in-out infinite alternate; }
  .say.playing .wave2 { animation: wave 500ms 160ms ease-in-out infinite alternate; }
}
@keyframes wave { from { opacity: 0.2; } to { opacity: 1; } }

/* Desktop: text and buttons on the left, the sticker board on the right. */
@media (min-width: 900px) {
  .page { padding: 28px 48px 48px; }
  .top { margin-bottom: 32px; }

  h1 { font-size: 60px; line-height: 1.05; }
  .lead { font-size: 20px; }

  .home {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "hero stickers" "actions stickers";
    grid-template-rows: auto 1fr;
    column-gap: 64px;
    row-gap: 40px;
  }
  .home .hero { grid-area: hero; }
  .home .stickers { grid-area: stickers; height: 440px; font-size: 1.3rem; }
  .home .actions { grid-area: actions; margin-top: 0; max-width: 360px; text-align: left; align-items: stretch; }
  .steps { margin-top: 96px; }
  .steps h2, .cta h2 { font-size: 40px; }
  .steps ol { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .steps li { padding: 28px; }
  .cta { margin-top: 48px; padding: 56px 32px; }

  .narrow h1 { font-size: 44px; }
  .narrow .word { font-size: 64px; }
  .narrow .plural-form { font-size: 34px; }
  .logo { font-size: 24px; }
  .top { flex-wrap: nowrap; gap: 16px; }
  .nav { flex-basis: auto; gap: 0 16px; }
  .langs { order: 1; }
  .rate { gap: 8px; }
  .narrow.prose { max-width: 720px; }
  .prose dl { grid-template-columns: 1fr 1fr; }
  .study { flex: 0 0 auto; max-width: 520px; }
  .card { flex: 0 0 auto; min-height: 300px; }
  .rate kbd { display: block; margin-top: 2px; font: inherit; font-size: 11px; font-weight: 600; opacity: 0.6; }
}
