/* Hallmark · genre: editorial · macrostructure: Workbench (adapted: product demo hero + manual) · tone: editorial reference manual · anchor hue: crimson 20°
 * theme: custom (tuned) — see tokens.css · enrichment: Tier A CSS candidate window · nav: N9 · footer: Ft2
 */

/* ── Base ─────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body { overflow-x: clip; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-lg);
}

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-kerning: normal;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--color-rule);
  text-underline-offset: 0.2em;
  transition: text-decoration-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
a:hover { text-decoration-color: var(--color-accent); color: var(--color-accent-deep); }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 2px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--color-paper-2);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  padding: 0.05em 0.35em;
  overflow-wrap: anywhere;
}
th code, td code { white-space: nowrap; overflow-wrap: normal; }

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-paper-2);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }

.skip {
  position: absolute;
  left: var(--space-sm);
  top: -10rem;
  background: var(--color-ink);
  color: var(--color-paper);
  padding: var(--space-2xs) var(--space-sm);
  z-index: 10;
}
.skip:focus { top: var(--space-sm); }

/* ── Masthead (N9 edge-aligned) ───────────────────── */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) 0;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2xs);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: inherit; }

.wordmark-pennant {
  /* The app icon's double pennant, in CSS. */
  align-self: center;
  width: 0.8rem;
  height: 1.05rem;
  background: var(--color-accent);
  clip-path: polygon(0 0, 100% 45%, 42% 45%, 100% 100%, 0 100%);
}

.wordmark-deva {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xl);
  line-height: 1;
}

.wordmark-latin {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.masthead-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-height: 44px;
  padding-inline: 10px;
  margin-right: -10px; /* optical: align the glyph, not its hit area, with the gutter */
  border-radius: 999px;
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
}

/* ── Hero ─────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: var(--space-2xl);
  align-items: center;
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-md) var(--space-3xl);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-display);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-md);
  overflow-wrap: anywhere;
  min-width: 0;
  text-wrap: balance;
}

.hero-intro {
  max-width: 34rem;
  color: var(--color-ink-2);
  font-size: var(--text-lg);
  line-height: 1.55;
}
.hero-intro p { margin: 0 0 var(--space-sm); }

.download { margin-top: var(--space-lg); max-width: 34rem; }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-weight: 700;
  font-size: var(--text-base);
  text-decoration: none;
  white-space: nowrap;
  padding: var(--space-xs) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 0 var(--color-accent-deep);
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn-download::after {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
}
.btn-download:hover { background: var(--color-accent-deep); color: var(--color-accent-ink); }
.btn-download:active { transform: translateY(1px); box-shadow: none; }

.download-meta {
  margin: var(--space-xs) 0 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.download-note {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  line-height: 1.5;
}
.download-note strong { color: var(--color-ink); }

/* ── Demo: the candidate window ───────────────────── */

.demo { margin: 0; min-width: 0; }

.demo-stage {
  position: relative;
  min-height: 19rem;
  padding: var(--space-xl) var(--space-lg);
  background: var(--color-paper-2);
  border-top: var(--rule-hair) solid var(--color-rule);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}

.demo-line {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-demo);
  line-height: 1.3;
  white-space: nowrap;
}

.demo-committed { color: var(--color-ink); }

.demo-marked {
  position: relative;
  font-family: var(--font-body);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--color-ink-2);
}
.demo-marked:empty { text-decoration: none; }

.demo-caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: -0.18em;
  background: var(--color-ink);
  animation: caret-blink 1.06s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

.demo-panel {
  list-style: none;
  position: absolute;
  left: var(--demo-panel-x, var(--space-lg));
  top: calc(var(--space-xl) + var(--text-demo) * 1.3 + var(--space-2xs));
  margin: 0;
  padding: var(--space-3xs);
  min-width: 10.5rem;
  background: var(--color-panel);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px -8px var(--color-shadow), 0 1px 2px var(--color-shadow);
  transition: opacity var(--dur-fast) var(--ease-out);
}
.demo-panel:empty { opacity: 0; }

.demo-panel li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  line-height: 1.5;
}

.demo-num {
  width: 1ch;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-muted);
}

.demo-panel li.is-selected { background: var(--color-accent); color: var(--color-accent-ink); }
.demo-panel li.is-selected .demo-num { color: var(--color-accent-ink); opacity: 0.8; }

.demo-caption {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* ── Traits strip ─────────────────────────────────── */

.traits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-xl);
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
  border-top: var(--rule-hair) solid var(--color-rule);
}
.traits p { margin: 0; color: var(--color-ink-2); line-height: 1.55; }
.traits strong {
  display: block;
  margin-bottom: var(--space-3xs);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-ink);
}

/* ── Guide: index + README sections ───────────────── */

.guide {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: var(--space-2xl);
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-md) var(--space-3xl);
  border-top: var(--rule-hair) solid var(--color-rule);
}

.guide-index { position: sticky; top: var(--space-lg); align-self: start; }
.guide-index-title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
}
.guide-index ol { list-style: none; margin: 0; padding: 0; border-left: var(--rule-hair) solid var(--color-rule); }
.guide-index li a {
  display: block;
  padding: var(--space-3xs) var(--space-sm);
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.guide-index li a:hover { color: var(--color-ink); border-left-color: var(--color-rule); }
.guide-index li a[aria-current="true"] { color: var(--color-ink); border-left-color: var(--color-accent); font-weight: 600; }

.guide-body { max-width: 46rem; min-width: 0; }

.doc-section + .doc-section {
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: var(--rule-hair) solid var(--color-rule-2);
}

.doc-section h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-2xl);
  line-height: 1.15;
  margin: 0 0 var(--space-md);
}

.doc-section p, .doc-section ol, .doc-section ul { margin: 0 0 var(--space-sm); max-width: 65ch; }
.doc-section li + li { margin-top: var(--space-2xs); }
.doc-section strong { font-weight: 700; }

.table-scroll {
  overflow-x: auto;
  margin: var(--space-md) 0 var(--space-lg);
  border-top: 2px solid var(--color-ink);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}

table { border-collapse: collapse; font-size: var(--text-sm); min-width: 100%; }
th, td {
  padding: var(--space-2xs) var(--space-sm);
  text-align: left;
  vertical-align: top;
  border-bottom: var(--rule-hair) solid var(--color-rule-2);
}
th { font-weight: 700; color: var(--color-ink); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:lang(ne), td { line-height: 1.5; }

/* The two-row vowel/consonant charts: key above, letter below. */
.table-scroll:has(thead th:nth-child(6)) th,
.table-scroll:has(thead th:nth-child(6)) td { text-align: center; }
.table-scroll:has(thead th:nth-child(6)) td {
  font-size: var(--text-xl);
  font-family: var(--font-display);
}

/* ── Footer (Ft2) ─────────────────────────────────── */

.colophon {
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) var(--space-xl);
  border-top: var(--rule-hair) solid var(--color-rule);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.colophon p { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-xs); }
.colophon a { white-space: nowrap; }

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 60rem) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); padding-top: var(--space-xl); }
  .traits { grid-template-columns: minmax(0, 1fr); gap: var(--space-md); }
  .guide { grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); }
  .guide-index { position: static; }
  .guide-index ol { display: flex; flex-wrap: wrap; border-left: 0; gap: var(--space-3xs) var(--space-2xs); }
  .guide-index li a { border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-sm); margin: 0; padding: var(--space-3xs) var(--space-xs); }
}

@media (max-width: 30rem) {
  .demo-stage { padding: var(--space-lg) var(--space-md); min-height: 17rem; }
  .demo-panel { top: calc(var(--space-lg) + var(--text-demo) * 1.3 + var(--space-2xs)); }
  .btn-download { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .demo-caret { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
