/* Soft Bauhaus — design tokens. Every color has exactly one job:
   blue = structure/rules/de-words · yellow = reward/progress/het-words
   red = attention/exceptions/errors · teal = interface voice & success */

:root {
  color-scheme: light;
  --paper: #f2f8f5;
  --card: #ffffff;
  --ink: #21302b;
  --blue: #456990;
  --red: #b83242;
  --yellow: #dfa32d;
  --teal: #246f6a;
  --teal-pale: #bfdfe1;
  --grey: #526a62;
  --yellow-ink: #825700;
  --on-blue: #ffffff;

  --radius: 10px;
  --radius-lg: 16px;

  --font-display: Futura, 'Avenir Next', 'Century Gothic', 'Helvetica Neue', sans-serif;
  --font-body: 'Helvetica Neue', Helvetica, Arial, sans-serif;

  --shadow-press: 0 4px 0 0 var(--teal-pale);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #17211e;
    --card: #212e2a;
    --ink: #e7efeb;
    --blue: #7fa5c9;
    --red: #f38f98;
    --yellow: #e6b54c;
    --teal: #5fb0aa;
    --teal-pale: #2c4746;
    --grey: #a0b5ad;
    --yellow-ink: #edc66d;
    --on-blue: #17211e;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
    --paper: #17211e;
    --card: #212e2a;
    --ink: #e7efeb;
    --blue: #7fa5c9;
    --red: #f38f98;
    --yellow: #e6b54c;
    --teal: #5fb0aa;
    --teal-pale: #2c4746;
    --grey: #a0b5ad;
    --yellow-ink: #edc66d;
    --on-blue: #17211e;
}

/* Shared day/night control, also used by the static reference pages. */
theme-switch { display: inline-flex; flex-shrink: 0; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; flex-shrink: 0;
  border: 2px solid var(--teal-pale); border-radius: 50%;
  background: var(--card); color: var(--teal); cursor: pointer;
  transition: border-color 180ms, transform 180ms;
}
.theme-toggle:hover { border-color: var(--teal); }
.theme-toggle:active { transform: scale(.9); }
.theme-toggle:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.theme-icon { width: 24px; height: 24px; overflow: visible; }
.theme-sun, .theme-moon {
  transform-origin: 12px 12px;
  transition: transform 450ms cubic-bezier(.2,.8,.2,1), opacity 250ms;
}
.theme-moon { opacity: 0; transform: rotate(-80deg) scale(.4); }
[data-theme="dark"] .theme-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
[data-theme="dark"] .theme-moon { opacity: 1; transform: rotate(0) scale(1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 350ms; }
@media (max-width: 480px) {
  .bar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle, .theme-sun, .theme-moon { transition: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* Справочник — prerendered, crawlable grammar pages.

   NOTE: this file is never imported by Vite. `scripts/build-reference.ts`
   concatenates src/styles/tokens.css + this file into dist/spravochnik.css,
   so the design tokens stay single-sourced (both themes included) while the
   static pages need no bundler. Same color roles as everywhere else:
   blue = structure/de-words · yellow = het-words/verbs · red = exceptions
   only · teal = interface voice. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
}

h1, h2, h3, .btn { font-family: var(--font-display); letter-spacing: 0.02em; }

a { color: var(--teal); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--teal); color: var(--card); padding: 8px 16px; border-radius: 999px; }
.skip:focus { left: 8px; z-index: 10; }

/* ---------- chrome ---------- */
.bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  max-width: 900px; margin: 0 auto; padding: 20px 24px 16px;
}
.bar-spacer { flex: 1; }
.bar-link { color: var(--grey); text-decoration: none; font-size: 14.5px; }
.bar-link:hover { color: var(--teal); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; text-decoration: none; white-space: nowrap;
  border-radius: 999px; padding: 13px 26px;
  font-weight: 700; font-size: 13.5px; letter-spacing: 0.08em; text-transform: uppercase;
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn-primary { background: var(--teal); color: var(--card); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-bar { padding: 9px 20px; font-size: 12px; }

.wrap { max-width: 900px; margin: 0 auto; padding: 0 24px 72px; }

.crumbs { font-size: 14px; color: var(--grey); margin: 18px 0 6px; }
.crumbs a { color: var(--grey); }
.crumbs a:hover { color: var(--teal); }

/* ---------- headings ---------- */
h1 {
  overflow-wrap: anywhere; hyphens: auto;
  font-size: clamp(30px, 5vw, 46px); line-height: 1.05; font-weight: 800;
  margin: 10px 0 12px;
}
.meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 22px; padding-bottom: 22px;
  border-bottom: 3px solid var(--teal-pale);
}
.tag {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  border: 2px solid var(--teal-pale); color: var(--grey);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.tag-level { border-color: var(--blue); color: var(--blue); }
.intro { font-size: 18.5px; color: var(--ink); margin: 0 0 34px; }

/* ---------- rule cards ---------- */
.rule {
  background: var(--card); border: 2.5px solid var(--teal-pale);
  border-radius: var(--radius-lg); padding: 26px 28px; margin: 0 0 20px;
}
.rule h2 { font-size: 21px; margin: 0 0 12px; }
.rule p { margin: 0 0 16px; }
.rule strong { color: var(--blue); }

.examples { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.examples li {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 18px; align-items: baseline;
  padding: 11px 14px; background: var(--paper); border-radius: var(--radius);
  border-left: 4px solid var(--teal-pale);
}
.examples .nl { font-weight: 700; }
.examples .ru { color: var(--grey); }
.examples .note {
  grid-column: 1 / -1; font-size: 13.5px; color: var(--grey); font-style: italic;
}

/* red is reserved for genuine traps — this is the one place it appears */
.attention {
  margin: 18px 0 0; padding: 14px 18px;
  border: 2.5px solid var(--red); border-radius: var(--radius);
  color: var(--ink); font-size: 15.5px;
}
.attention b { color: var(--red); text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; }

/* ---------- vocabulary ---------- */
.vocab-wrap { overflow-x: auto; border: 2.5px solid var(--teal-pale); border-radius: var(--radius-lg); }
table { border-collapse: collapse; width: 100%; background: var(--card); font-size: 15.5px; }
th, td { padding: 11px 16px; text-align: left; border-bottom: 2px solid color-mix(in srgb, var(--teal-pale) 55%, transparent); }
thead th {
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.07em;
  font-size: 12px; color: var(--grey); border-bottom: 2.5px solid var(--teal-pale);
}
tbody tr:last-child td { border-bottom: none; }
td.nl { font-weight: 700; }
.art-de { color: var(--blue); }
.art-het { color: var(--yellow-ink); }

.reference-index-title { hyphens: none; font-size: clamp(26px, 4vw, 42px); line-height: 1.15; }
.reference-jumps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 28px; }
.reference-jumps a { display: inline-flex; align-items: center; min-height: 44px; border: 2px solid var(--teal-pale); border-radius: 999px; padding: 8px 14px; font-size: 14px; text-decoration: none; }
.reference-jumps a:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.mod { scroll-margin-top: 16px; }
td.ru { color: var(--grey); }

h2.block { font-size: 24px; margin: 40px 0 16px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- CTA into the app ---------- */
.cta {
  margin: 40px 0 0; padding: 28px 30px; text-align: center;
  background: var(--card); border: 3px solid var(--teal); border-radius: var(--radius-lg);
}
.cta p { margin: 0 0 18px; color: var(--grey); }
.cta b { color: var(--ink); }
.cta .btn { max-width: 100%; white-space: normal; }

/* ---------- prev / next ---------- */
.pager { display: flex; gap: 14px; justify-content: space-between; margin-top: 34px; flex-wrap: wrap; }
.pager a {
  flex: 1 1 260px; text-decoration: none; color: inherit;
  background: var(--card); border: 2.5px solid var(--teal-pale);
  border-radius: var(--radius-lg); padding: 16px 20px;
}
.pager a:hover { border-color: var(--teal); }
.pager span { display: block; font-size: 12.5px; color: var(--grey); text-transform: uppercase; letter-spacing: 0.1em; }
.pager b { font-family: var(--font-display); font-size: 15.5px; }
.pager .next { text-align: right; }

/* ---------- index ---------- */
.mod { margin: 0 0 30px; }
.mod h2 {
  font-size: 20px; margin: 0 0 4px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.mod .blurb { color: var(--grey); font-size: 15px; margin: 0 0 12px; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lesson-list a {
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
  text-decoration: none; color: inherit;
  background: var(--card); border: 2px solid var(--teal-pale);
  border-radius: var(--radius); padding: 11px 16px;
}
.lesson-list a:hover { border-color: var(--teal); }
.lesson-list .par { color: var(--grey); font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* ---------- footer ---------- */
.foot {
  border-top: 3px solid var(--teal-pale);
  max-width: 900px; margin: 0 auto; padding: 26px 24px 48px;
  color: var(--grey); font-size: 14px;
}
.foot p { margin: 0 0 8px; }

@media (max-width: 640px) {
  body { font-size: 16.5px; }
  .rule { padding: 20px 20px; }
  .examples li { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Shared by the landing, app and built reference. The cockatoo uses the
   captain's integer pixel grid and palette; its feet stay fixed on the final e. */
.wordmark {
  display: inline-block;
  flex-shrink: 0;
  padding-top: 28px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
}
.wordmark .wordmark-first { color: var(--blue); }
.wordmark .dot { color: var(--yellow); }
.brand-name { text-transform: lowercase; }
.wordmark-perch { position: relative; display: inline-block; }
.wordmark-cockatoo {
  position: absolute;
  left: -14px;
  bottom: calc(100% - 14px);
  width: 32px;
  height: 40px;
  pointer-events: none;
  image-rendering: pixelated;
  background-image: url('/brand/cockatoo-light.png');
  background-repeat: no-repeat;
  background-size: 96px 40px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark-cockatoo { background-image: url('/brand/cockatoo-dark.png'); }
}
:root[data-theme="dark"] .wordmark-cockatoo { background-image: url('/brand/cockatoo-dark.png'); }
/* Discrete redrawn poses: no rotated/scaled pixels, idle loop or speech. */
@keyframes cockatoo-curious {
  0%, 100% { background-position: 0 0; }
  25%, 55% { background-position: -32px 0; }
  70%, 85% { background-position: -64px 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .wordmark:focus-visible .wordmark-cockatoo { animation: cockatoo-curious 850ms steps(1, end) 1; }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .wordmark:hover .wordmark-cockatoo { animation: cockatoo-curious 850ms steps(1, end) 1; }
}

/* Authored rule layouts, shared by lesson cards and the static справочник.
   C: relationships made visible; B: a focused example when prose is sufficient. */
.structured-rule { container-type: inline-size; }
.rule.structured-rule h2, .rule-card.structured-rule h3 {
  font-family: var(--font-display); font-size: 20px; line-height: 1.4;
  margin: 0 0 18px; padding: 0; border: 0; display: block;
}
.structured-rule .rule-takeaway {
  font-size: 19px; font-weight: 600; line-height: 1.55;
  margin: 0 0 20px; color: var(--ink);
}
.structured-rule .rule-explanation { margin: 20px 0; }
.structured-rule .rule-explanation .body {
  font-size: 16.5px; line-height: 1.65; margin: 0 0 12px; white-space: pre-line;
}
.structured-rule .rule-explanation .body strong { color: var(--ink); }
.structured-rule .nl { display: block; font-size: 18px; font-weight: 500; line-height: 1.65; color: var(--ink); }
.structured-rule .ru, .structured-rule .note {
  display: block; font-size: 14.5px; line-height: 1.55;
  color: color-mix(in srgb, var(--ink) 70%, var(--grey)); margin-top: 4px;
}
.structured-rule .note { font-size: 14px; }
.structured-rule .example {
  display: block; padding: 12px 0; margin: 0; border: 0;
  border-top: 1px solid var(--teal-pale); background: transparent; border-radius: 0;
}
.structured-rule .rule-example-line { display: flex; align-items: baseline; gap: 8px; }
.structured-rule .rule-example-line .nl { min-width: 0; }
.structured-rule .speak-btn { flex-shrink: 0; }
.structured-rule .rule-primary-example {
  padding: 16px 18px; background: var(--paper); border: 0;
  border-left: 3px solid var(--teal-pale); border-radius: 0 8px 8px 0;
}
.structured-rule .rule-primary-example .nl { font-size: 22px; }
.structured-rule .rule-section-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 6px; color: color-mix(in srgb, var(--ink) 70%, var(--grey));
}
.structured-rule .rule-mark {
  color: var(--ink); font-weight: 700; border-radius: 3px;
  padding: 1px 0; background: color-mix(in srgb, var(--blue) 14%, var(--card));
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.structured-rule .rule-mark-verb, .structured-rule .rule-mark-het {
  background: color-mix(in srgb, var(--yellow) 25%, var(--card));
  text-decoration: underline; text-decoration-color: var(--yellow); text-underline-offset: 4px;
}
.structured-rule .rule-mark-de, .structured-rule .rule-mark-subject {
  text-decoration: underline; text-decoration-color: var(--blue); text-underline-offset: 4px;
}
.structured-rule .rule-sentence { margin: 0; }
.structured-rule .rule-positions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.structured-rule .rule-position {
  flex: 1 1 auto; padding: 12px; border: 2px solid var(--teal-pale);
  border-radius: var(--radius); background: var(--paper); min-width: 0;
}
.structured-rule .rule-position-label { display: block; font-size: 12px; line-height: 1.4; margin-bottom: 8px; }
.structured-rule .rule-position [lang=nl] { display: block; font-size: 20px; font-weight: 600; }
.structured-rule .rule-position-verb { border-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 20%, var(--card)); }
.structured-rule .rule-position-subject { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--card)); }
.structured-rule figcaption { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.structured-rule .rule-comparison table { table-layout: fixed; width: 100%; border-collapse: collapse; margin: 0; font-size: 16px; }
.structured-rule .rule-comparison th {
  text-align: left; font-size: 14px; font-weight: 500; padding: 0 12px 10px 0;
  border: 0; border-bottom: 2px solid var(--teal-pale); color: var(--ink); background: transparent;
  text-transform: none; letter-spacing: normal;
}
.structured-rule .rule-comparison td { vertical-align: top; padding: 14px 12px 14px 0; border: 0; border-bottom: 1px solid var(--teal-pale); }
.structured-rule .rule-comparison td:last-child, .structured-rule .rule-comparison th:last-child { padding-right: 0; }
.structured-rule .rule-comparison .speak-btn { margin-top: 4px; }
.structured-rule .rule-comparison .rule-pair-has-note td { border-bottom: 0; padding-bottom: 0; }
.structured-rule .rule-comparison .rule-pair-note { padding-top: 0; }
.structured-rule .rule-contrast .example { border: 0; padding: 0; }
.structured-rule .rule-contrast .rule-example-line { flex-wrap: wrap; }
.structured-rule .rule-inventory { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0 16px; margin: 0; }
.structured-rule .rule-inventory > div { padding: 12px 0; border-bottom: 1px solid var(--teal-pale); }
.structured-rule .rule-inventory dt { font-size: 20px; font-weight: 600; color: var(--blue); }
.structured-rule .rule-inventory dd { margin: 4px 0 0; font-size: 14px; line-height: 1.55; }
.structured-rule .rule-conditions { margin: 0; }
.structured-rule .rule-condition { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--teal-pale); }
.structured-rule .rule-condition dt { font-size: 15px; line-height: 1.55; font-weight: 600; }
.structured-rule .rule-condition dd { margin: 0; min-width: 0; }
.structured-rule .rule-condition .example { border: 0; padding: 0; }
.structured-rule .attention {
  border: 0; border-left: 4px solid var(--red); padding: 12px 16px; margin: 20px 0 0;
  border-radius: 0 var(--radius) var(--radius) 0; max-width: none;
  background: color-mix(in srgb, var(--red) 7%, var(--card)); font-size: 14.5px;
}
.structured-rule .attention b { display: block; color: var(--red); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
@container (max-width: 440px) {
  .structured-rule .rule-positions { flex-direction: column; }
  .structured-rule .rule-position { display: grid; grid-template-columns: 95px minmax(0, 1fr); align-items: center; gap: 10px; }
  .structured-rule .rule-position-label { margin: 0; }
  .structured-rule .rule-condition { grid-template-columns: 1fr; gap: 8px; }
  .structured-rule .rule-comparison .nl { font-size: 17px; overflow-wrap: anywhere; }
  .structured-rule .rule-primary-example .nl { font-size: 20px; }
}
@media (max-width: 520px) {
  .rule-card.structured-rule, .rule.structured-rule { padding: 20px 16px; }
}

.structured-rule .rule-cell-label { display: none; }
@container (max-width: 440px) {
  .structured-rule .rule-comparison[data-columns="3"] thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .structured-rule .rule-comparison[data-columns="3"] table,
  .structured-rule .rule-comparison[data-columns="3"] tbody,
  .structured-rule .rule-comparison[data-columns="3"] tr { display: block; }
  .structured-rule .rule-comparison[data-columns="3"] tr:not(:first-child) { margin-top: 12px; }
  .structured-rule .rule-comparison[data-columns="3"] td:not(.rule-pair-note) {
    display: grid; grid-template-columns: minmax(80px, 1fr) minmax(0, 1.65fr);
    gap: 0 12px; padding: 10px 0; border-bottom: 1px solid var(--teal-pale);
  }
  .structured-rule .rule-comparison[data-columns="3"] .rule-cell-label {
    display: block; grid-column: 1; grid-row: 1 / span 3; font-size: 13px;
    line-height: 1.5; font-weight: 500;
  }
  .structured-rule .rule-comparison[data-columns="3"] td > .nl,
  .structured-rule .rule-comparison[data-columns="3"] td > .ru,
  .structured-rule .rule-comparison[data-columns="3"] td > .speak-btn { grid-column: 2; }
  .structured-rule .rule-comparison[data-columns="3"] .rule-pair-note { display: block; padding: 0 0 10px; }
}
