/* ============================================================
   Parser Latīnus — scholarly editorial aesthetic
   Cormorant + EB Garamond on ivory paper, oxford-blue ink,
   pompeian-red accents, manuscript-style restraint.
   ============================================================ */

:root {
  /* Palette — warm paper, deep ink, classical accents */
  --paper:        #fbf6ec;
  --paper-deep:   #f3ecdc;
  --paper-shade:  #ebe3d0;
  --ink:          #1a1814;
  --ink-soft:     #3a342c;
  --ink-muted:    #6b6354;
  --ink-faint:    #9a8e78;
  --rule:         #d4cdb8;
  --rule-soft:    #e6dfcb;
  --oxford:       #1f3357;
  --oxford-soft:  #3a4f76;
  --pompeii:      #8e2a22;
  --pompeii-soft: #b85049;
  --gold:         #a87c3e;
  --gold-soft:    #c9a063;

  /* Type */
  --display:      "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --body:         "EB Garamond", Georgia, "Times New Roman", serif;
  --mono:         "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* Geometry */
  --measure:      44rem;
  --gutter:       clamp(1.25rem, 4vw, 2.5rem);
  --rhythm:       1.65;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: var(--rhythm);
  font-feature-settings: "kern", "liga", "onum", "pnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

::selection {
  background: rgba(31, 51, 87, 0.18);
  color: var(--ink);
}

/* ---------- Paper grain overlay ---------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.42;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.38  0 0 0 0 0.30  0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- Masthead ---------- */
.masthead {
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(1.25rem, 3vw, 2rem);
  position: relative;
}
.masthead::after {
  content: "";
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: 0;
  width: min(var(--measure), calc(100% - var(--gutter) * 2));
  height: 1px;
  background: linear-gradient(to right,
    transparent 0%,
    var(--rule) 8%,
    var(--rule) 92%,
    transparent 100%);
}
.masthead-inner {
  max-width: var(--measure);
  margin: 0 auto;
  text-align: center;
}

.wordmark {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}
.wordmark-main {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2rem, 5.5vw, 3.3rem);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1;
  padding-left: 0.32em;   /* compensate visual centering for tracked caps */
}
.wordmark-rule {
  display: block;
  width: 7rem;
  height: 0;
  border-top: 1px solid var(--ink-faint);
  border-bottom: 1px solid var(--ink-faint);
  padding-top: 3px;
}
.wordmark-tag {
  font-family: var(--body);
  font-size: 0.95rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
}
.wordmark-tag em {
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Masthead link to the reader ---------- */
.masthead-link {
  position: absolute;
  top: clamp(1.4rem, 4vw, 2.4rem);
  right: var(--gutter);
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  text-decoration: none;
  color: var(--ink-muted);
  transition: color 200ms ease;
}
.masthead-link-text {
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}
.masthead-link-sub {
  font-family: var(--body);
  font-size: 0.82rem;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  transition: color 200ms ease;
}
.masthead-link:hover { color: var(--pompeii); }
.masthead-link:hover .masthead-link-sub { color: var(--pompeii-soft); }
.masthead-link:focus-visible {
  outline: 2px solid var(--oxford-soft);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- Tabs ---------- */
.tabs {
  padding: 1.5rem var(--gutter) 0;
  display: flex;
  justify-content: center;
}
.tabs-inner {
  display: flex;
  gap: clamp(1.2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
  padding: 0 0.5rem;
}
.tab {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0.6rem 0.4rem 0.9rem;
  cursor: pointer;
  font-family: var(--body);
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  position: relative;
  transition: color 200ms ease;
}
.tab-label {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}
.tab-sub {
  font-family: var(--display);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.tab::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 2px;
  background: var(--oxford);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 280ms cubic-bezier(0.7, 0, 0.2, 1);
}
.tab:hover { color: var(--ink-soft); }
.tab.is-active { color: var(--ink); }
.tab.is-active::after { transform: scaleX(1); }
.tab.is-active .tab-sub { color: var(--ink-muted); }

.mode-pane.is-hidden { display: none; }

/* ---------- Page ---------- */
.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--gutter) 4rem;
}

/* ---------- Composer (input section) ---------- */
.composer {
  margin-bottom: 3.5rem;
  animation: rise 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.composer-label {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
  cursor: text;
}
.composer-label-number {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--gold);
  font-variant: small-caps;
  letter-spacing: 0.05em;
  min-width: 1.3rem;
}
.composer-label-text {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.composer-field {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 1.5px solid var(--ink);
  transition: border-color 200ms ease;
}
.composer-field:focus-within {
  border-bottom-color: var(--oxford);
}
.composer-field:focus-within::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1.5px;
  height: 1.5px;
  background: var(--oxford);
  transform-origin: left center;
  animation: rule-in 380ms cubic-bezier(0.7, 0, 0.2, 1) forwards;
}

#input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  color: var(--ink);
  padding: 0.4rem 0 0.75rem;
  line-height: 1.15;
  letter-spacing: 0.005em;
  caret-color: var(--oxford);
}
#input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
  font-weight: 400;
}

.composer-submit {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 0.6rem 0.5rem;
  color: var(--ink-muted);
  transition: color 180ms ease, transform 180ms ease;
  align-self: flex-end;
}
.composer-submit:hover,
.composer-submit:focus-visible {
  color: var(--oxford);
  transform: translateX(2px);
  outline: none;
}
.composer-submit:active { transform: translateX(4px); }

.composer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.9rem;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

/* Custom toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  font-family: var(--body);
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-mark {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--ink-faint);
  background: transparent;
  position: relative;
  transition: border-color 180ms ease, background 180ms ease;
}
.toggle input:checked + .toggle-mark {
  border-color: var(--oxford);
  background: var(--oxford);
}
.toggle input:checked + .toggle-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(45deg, transparent 45%, var(--paper) 45%, var(--paper) 55%, transparent 55%),
                    linear-gradient(-45deg, transparent 45%, var(--paper) 45%, var(--paper) 55%, transparent 55%);
}
.toggle:hover .toggle-mark { border-color: var(--oxford); }
.toggle-text { color: var(--ink-soft); }
.toggle-text em { color: var(--ink-muted); font-style: italic; font-size: 0.88em; }

/* ---------- Composer extras (dropdown, action button, field group) ---------- */
.composer-field-group {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--body);
  font-size: 0.92rem;
  color: var(--ink-muted);
}
.dropdown-label {
  font-style: italic;
  color: var(--ink-muted);
}
.dropdown {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  font-family: var(--display);
  font-size: 1rem;
  color: var(--ink);
  padding: 0.15rem 1.4rem 0.15rem 0;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
                    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 8px) center, calc(100% - 3px) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  transition: border-color 200ms ease, color 200ms ease;
}
.dropdown:hover, .dropdown:focus-visible {
  border-bottom-color: var(--oxford);
  outline: none;
}
.dropdown-wide { min-width: 18rem; }

.action-button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--display);
  font-style: italic;
  font-size: 1rem;
  padding: 0.45rem 1.4rem;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
  letter-spacing: 0.02em;
}
.action-button:hover, .action-button:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.composer-hints kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-deep);
  color: var(--ink-soft);
}

/* ---------- Apparatus (results) ---------- */
.apparatus { min-height: 16rem; }

.empty-state {
  text-align: center;
  padding: 2rem 0;
  color: var(--ink-muted);
  animation: rise 900ms cubic-bezier(0.16, 1, 0.3, 1) 200ms both;
}
.empty-quote {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--ink-soft);
  line-height: 1.4;
  max-width: 30rem;
  margin: 0 auto 0.8rem;
}
.empty-attribution {
  font-family: var(--body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-faint);
  margin: 0 0 2rem;
}
.empty-divider {
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--gold);
  margin: 0 0 1.8rem;
  opacity: 0.7;
}
.empty-hint {
  max-width: 30rem;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-muted);
}

/* ---------- Word card ---------- */
.card {
  background: transparent;
  border-top: 1px solid var(--ink);
  padding: 1.6rem 0 1.4rem;
  animation: rise 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.card + .card { margin-top: 0.4rem; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}
.card-headword {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.2rem, 4.5vw, 2.8rem);
  margin: 0;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: 0.005em;
}
.card-enclitic {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--pompeii);
  font-feature-settings: "smcp";
}
.card-enclitic::before {
  content: "+ ";
  color: var(--pompeii-soft);
  font-style: normal;
}

.card-meta {
  font-family: var(--body);
  font-size: 0.96rem;
  color: var(--ink-muted);
  margin-bottom: 1.1rem;
  font-style: italic;
}
.card-meta .def {
  color: var(--ink-soft);
  font-style: normal;
}
.card-meta .pos {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-style: normal;
  margin-right: 0.4rem;
}

.card-forms {
  list-style: none;
  padding: 0;
  margin: 0;
}
.card-forms li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.35rem 0;
  font-family: var(--body);
  font-size: 1.05rem;
  color: var(--ink-soft);
  position: relative;
}
.card-forms li::before {
  content: "";
  width: 1.3rem;
  height: 1px;
  background: var(--ink-faint);
  flex-shrink: 0;
  align-self: center;
  transform: translateY(-1px);
}
.card-forms .feat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}
.card-forms .feat-sep {
  color: var(--ink-faint);
}
.card-forms .feat-tag {
  color: var(--ink-soft);
}
.card-forms .feat-tag.case,
.card-forms .feat-tag.tense {
  color: var(--oxford);
  font-style: italic;
}

.card-empty {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--pompeii);
  padding: 1.4rem 0;
  text-align: center;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  letter-spacing: 0.04em;
}
.card-empty .latin { color: var(--pompeii-soft); font-style: normal; font-variant: small-caps; letter-spacing: 0.1em; font-size: 1em; display: block; margin-top: 0.4rem; font-family: var(--body); }

/* ---------- Sentence view ---------- */
.sentence-view {
  animation: rise 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.sentence-text {
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  line-height: 1.5;
  color: var(--ink-soft);
  padding: 1.2rem 0 1.4rem;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  position: relative;
  text-align: left;
  letter-spacing: 0.005em;
}

.tok {
  cursor: pointer;
  position: relative;
  padding: 0 0.04em;
  color: var(--ink);
  transition: color 180ms ease;
  text-decoration: none;
}
.tok .tok-text {
  position: relative;
  display: inline-block;
  padding-bottom: 0.08em;
}
.tok .tok-text::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--ink-faint);
  opacity: 0;
  transition: opacity 200ms ease, background 200ms ease;
}
.tok:hover .tok-text::after { opacity: 1; }
.tok:hover { color: var(--oxford); }
.tok.is-active { color: var(--oxford); }
.tok.is-active .tok-text::after { opacity: 1; background: var(--oxford); height: 1.5px; }
.tok.is-empty { color: var(--ink-faint); font-style: italic; }
.tok.is-empty .tok-text::after { background: var(--pompeii-soft); opacity: 0.6; }
.tok-sep { color: var(--ink-muted); white-space: pre-wrap; }

.sentence-detail {
  padding: 1.6rem 0 0.4rem;
  min-height: 7rem;
}
.sentence-detail-placeholder {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-faint);
  text-align: center;
  padding: 1.8rem 0;
}

/* When a card is inside the sentence-detail, remove its top border (the
   sentence-text already provides the rule above the analysis area). */
.sentence-detail .card { border-top: none; padding-top: 0.4rem; }

/* ---------- Search results ---------- */
.search-results {
  animation: rise 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.search-summary {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-muted);
  padding: 0.6rem 0 1.4rem;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 1.5rem;
}
.search-summary strong {
  font-weight: 500;
  font-style: normal;
  color: var(--ink);
}
.search-summary .summary-lemma {
  color: var(--oxford);
}
.search-summary .summary-doc {
  color: var(--gold);
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: 0.06em;
}

.search-doc-group {
  margin-bottom: 2.5rem;
}
.search-doc-group:last-child { margin-bottom: 0; }
.search-doc-title {
  font-family: var(--display);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--ink);
  margin: 0 0 0.3rem;
  font-weight: 500;
}
.search-doc-title .doc-author {
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-size: 0.85em;
}
.search-doc-count {
  font-family: var(--body);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-faint);
  margin: 0 0 1.2rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
}

.hit {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1.2rem;
  padding: 0.75rem 0;
  border-bottom: 1px dotted var(--rule-soft);
  animation: rise 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.hit:last-child { border-bottom: none; }
.hit-cite {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--oxford);
  letter-spacing: 0.03em;
  padding-top: 0.18rem;
  text-align: right;
}
.hit-text {
  font-family: var(--display);
  font-size: 1.08rem;
  line-height: 1.5;
  color: var(--ink);
}
.hit-text mark {
  background: transparent;
  color: var(--pompeii);
  font-weight: 500;
  border-bottom: 1px solid var(--pompeii-soft);
  padding-bottom: 0.05em;
}

/* Stagger hit reveals */
.hit:nth-child(1) { animation-delay: 0ms; }
.hit:nth-child(2) { animation-delay: 30ms; }
.hit:nth-child(3) { animation-delay: 60ms; }
.hit:nth-child(4) { animation-delay: 90ms; }
.hit:nth-child(5) { animation-delay: 120ms; }
.hit:nth-child(6) { animation-delay: 150ms; }
.hit:nth-child(7) { animation-delay: 180ms; }
.hit:nth-child(8) { animation-delay: 210ms; }

/* ---------- Unparsed results ---------- */
.unparsed-results {
  animation: rise 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.coverage-bar {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 1.2rem 0;
  margin-bottom: 1.8rem;
}
.coverage-stats {
  font-family: var(--display);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin-bottom: 0.7rem;
}
.coverage-stats strong {
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  font-size: 1.4rem;
  font-family: var(--display);
}
.coverage-stats .pct-good { color: var(--oxford); }
.coverage-stats .pct-mid  { color: var(--gold); }
.coverage-stats .pct-low  { color: var(--pompeii); }
.coverage-stats .stat-doc {
  color: var(--ink-muted);
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  font-size: 0.9em;
}

.coverage-meter {
  height: 4px;
  background: var(--rule-soft);
  position: relative;
  overflow: hidden;
}
.coverage-meter-fill {
  height: 100%;
  background: var(--oxford);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 600ms cubic-bezier(0.7, 0, 0.2, 1);
}
.coverage-meter-fill.has-pct { transform: scaleX(var(--pct)); }

.unparsed-heading {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 0 0 0.8rem;
  font-weight: 400;
}

.unparsed-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.4rem 1.5rem;
}
.unparsed-list li {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-family: var(--body);
  font-size: 1rem;
  padding: 0.2rem 0;
  border-bottom: 1px dotted var(--rule-soft);
  animation: rise 250ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.unparsed-list .un-count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  min-width: 2.5rem;
  text-align: right;
}
.unparsed-list .un-word {
  font-family: var(--display);
  font-size: 1.1rem;
  color: var(--ink);
}

.loading-state {
  font-family: var(--display);
  font-style: italic;
  color: var(--ink-muted);
  text-align: center;
  padding: 3rem 0;
  font-size: 1.1rem;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---------- Colophon ---------- */
.colophon {
  margin: 5rem auto 0;
  max-width: 36rem;
  text-align: center;
  font-family: var(--body);
  font-size: 0.88rem;
  color: var(--ink-faint);
  line-height: 1.6;
}
.colophon-divider {
  width: 4rem;
  height: 6px;
  margin: 0 auto 1.5rem;
  background-image:
    radial-gradient(circle at 25% 50%, var(--gold) 1.5px, transparent 1.5px),
    radial-gradient(circle at 50% 50%, var(--gold) 1.5px, transparent 1.5px),
    radial-gradient(circle at 75% 50%, var(--gold) 1.5px, transparent 1.5px);
  opacity: 0.7;
}
.colophon-corpus {
  font-style: italic;
  color: var(--ink-muted);
}
.colophon-meta {
  margin-top: 0.6rem;
  font-style: italic;
  color: var(--ink-faint);
}

/* ---------- Animations ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rule-in {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Stagger card reveals */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 70ms; }
.card:nth-child(3) { animation-delay: 140ms; }
.card:nth-child(4) { animation-delay: 210ms; }
.card:nth-child(5) { animation-delay: 280ms; }
.card:nth-child(6) { animation-delay: 350ms; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Narrow viewport: keep the masthead + tabs from overflowing ----------

   Below ~600px the tracked wordmark and the centered tab bar can run past the
   viewport edges (the reader page is fluid; this page was not). These rules pull
   the wordmark down in size/tracking and let the tab bar scroll horizontally
   instead of clipping, without touching the desktop layout. */
@media (max-width: 600px) {
  /* Smaller cap and tighter tracking so 'Latin Parser' fits one line on phones. */
  .wordmark-main {
    font-size: clamp(1.5rem, 8vw, 2.4rem);
    letter-spacing: 0.18em;
    padding-left: 0.18em;
  }
  /* The masthead link sits inline at the top-right and was crowding the wordmark;
     let it stack normally so neither overlaps. */
  .masthead-link {
    position: static;
    align-items: center;
    margin: 0 auto 1.2rem;
  }
  /* The tab bar centers a fixed-width row; on narrow screens center-justify clips
     both ends. Make .tabs a horizontal scroller and left-align its inner row so a
     row wider than the viewport scrolls instead of being cut off. */
  .tabs {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tabs-inner {
    gap: 1.4rem;
    margin: 0 auto;
    min-width: max-content;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 540px) {
  body { font-size: 17px; }
  .composer-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }
  .card-headword { font-size: 2rem; }
  .sentence-text { font-size: 1.5rem; }
  .tabs-inner { gap: 1rem; }
  .tab-sub { display: none; }
  .masthead-link { position: static; align-items: center; margin: 0 auto 1.4rem; }
  .masthead-link-sub { display: none; }
  .hit { grid-template-columns: 1fr; gap: 0.3rem; }
  .hit-cite { text-align: left; }
  .dropdown-wide { min-width: 0; }
}

/* ---------- Very narrow (~390px): squeeze the wordmark a touch more ---------- */
@media (max-width: 400px) {
  .wordmark-main {
    font-size: clamp(1.3rem, 9vw, 1.9rem);
    letter-spacing: 0.12em;
    padding-left: 0.12em;
  }
}
