/* Site styles (sk-01). Every value comes from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--mist);
  color: var(--ink);
  font-family: var(--font-bn);
  font-size: var(--fs-base);
  line-height: var(--lh-ui);
  -webkit-font-smoothing: antialiased;
}

.latin { font-family: var(--font-latin); }
a { color: var(--kite); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--kite-deep); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--river); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Skip link — the reader jumps straight to the text. */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--paper); color: var(--ink);
  padding: var(--gap-sm) var(--gap); border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar {
  max-width: 1080px; margin: 0 auto; padding: var(--gap-sm) var(--gap-lg);
  display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: var(--gap-sm);
  font-size: var(--fs-xl); color: var(--ink); text-decoration: none;
}
.brand svg { width: 34px; height: 24px; color: var(--kite); flex: none; }
.brand:hover { color: var(--ink); }
.site-nav { display: flex; gap: var(--gap-xs); flex-wrap: wrap; }
.site-nav a {
  padding: 6px 14px; border-radius: var(--radius-pill);
  color: var(--ink-soft); text-decoration: none; font-size: var(--fs-sm);
}
.site-nav a:hover { background: var(--river-wash); color: var(--river); }
.site-nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: var(--gap-sm); }

.chip {
  display: inline-flex; align-items: center; gap: var(--gap-xs);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: none; color: var(--ink-soft);
  padding: 5px 13px; font-size: var(--fs-sm);
}
.chip:hover { border-color: var(--river); color: var(--river); }

/* ── Layout ── */
main { max-width: 1080px; margin: 0 auto; padding: 0 var(--gap-lg) 80px; }
.prose { max-width: var(--measure); }
h1 { font-size: var(--fs-3xl); font-weight: 400; line-height: 1.25; margin: 0 0 var(--gap-sm); }
h2 { font-size: var(--fs-xl); font-weight: 400; margin: 0 0 var(--gap-sm); }
h3 { font-size: var(--fs-lg); font-weight: 400; margin: 0 0 var(--gap-xs); }
p { margin: 0 0 var(--gap); }
.lede { font-size: var(--fs-lg); color: var(--ink-soft); }
.muted { color: var(--faint); font-size: var(--fs-sm); }

/* ── Cards ── */
.grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--gap);
  color: inherit; text-decoration: none; min-height: 116px;
}
.card:hover { border-color: var(--kite); box-shadow: var(--shadow); color: inherit; }
.card .eyebrow { font-size: var(--fs-xs); color: var(--river); letter-spacing: .04em; }
.card .title { font-size: var(--fs-lg); line-height: 1.35; }
.card .by { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: auto; }

/* A work restricted in this country is SHOWN, with the reason. */
.card.restricted { border-style: dashed; opacity: .75; }
.card.restricted .title { color: var(--ink-soft); }
.card .lock {
  font-size: var(--fs-xs); color: var(--kite); line-height: 1.45; margin-top: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-block; border: 1px solid transparent;
  border-radius: var(--radius-pill); padding: 10px 22px;
  font-size: var(--fs-base); text-decoration: none;
}
.btn-primary { background: var(--kite); color: #fff; }
.btn-primary:hover { background: var(--kite-deep); color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--ink); background: none; }
.btn-ghost:hover { border-color: var(--river); color: var(--river); }

/* ── Footer ── */
.site-footer { border-top: 1px solid var(--line); margin-top: var(--gap-xl); }
.foot {
  max-width: 1080px; margin: 0 auto; padding: 22px var(--gap-lg);
  display: flex; gap: var(--gap-lg); flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--faint);
}
.site-footer a { color: var(--faint); }

/* ── The reader (sk-02) ── */
.reader-top {
  display: flex; align-items: center; gap: var(--gap-sm);
  flex-wrap: wrap; padding: var(--gap) 0 0;
}
.back { color: var(--ink-soft); text-decoration: none; font-size: var(--fs-sm); padding: 6px 4px; }
.back:hover { color: var(--kite); }
.reader-tools { margin-left: auto; display: flex; gap: var(--gap-xs); }

.sheet {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 40em; margin: var(--gap) auto 0;
  padding: clamp(26px, 6vw, 60px);
}
.sheet h1 { font-size: var(--fs-2xl); margin: 0 0 2px; }
.sheet .w-meta { font-size: var(--fs-xs); color: var(--river); letter-spacing: .05em; margin: 0 0 4px; }
.sheet .w-by { font-size: var(--fs-base); color: var(--ink-soft); margin: 0 0 6px; }
.sheet .w-src { font-size: var(--fs-xs); color: var(--faint); margin: 0 0 var(--gap-lg); }

/* The reading column. Its size is the reader's choice and nothing else scales. */
.sheet .sec p {
  font-size: var(--reading-size, 19px);
  line-height: var(--lh-reading);
  margin: 0 0 1.15em;
  text-wrap: pretty;
}
.sec { margin-bottom: var(--gap-lg); }
.sec-title {
  font-size: var(--fs-lg); color: var(--ink-soft); font-weight: 400;
  margin: var(--gap-lg) 0 var(--gap-sm);
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.sec:first-of-type .sec-title { margin-top: 0; }

.toc {
  background: var(--river-wash); border-radius: var(--radius-sm);
  padding: var(--gap) var(--gap-lg); margin: 0 0 var(--gap-lg);
}
.toc h2 { font-size: var(--fs-base); color: var(--river); margin: 0 0 var(--gap-xs); }
.toc ol { margin: 0; padding-left: 1.3em; columns: 2; column-gap: var(--gap-lg); }
.toc li { font-size: var(--fs-sm); margin-bottom: 4px; break-inside: avoid; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--kite); text-decoration: underline; }
@media (max-width: 620px) { .toc ol { columns: 1; } }

.w-foot { border-top: 1px solid var(--line); margin-top: var(--gap-lg); padding-top: var(--gap); }
.w-foot p { margin: 0 0 4px; }

/* ── Rows: author lists and library listings (sk-03) ── */
.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: baseline; gap: var(--gap);
  padding: 12px 4px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; flex-wrap: wrap;
}
.row:hover { background: var(--river-wash); color: inherit; }
.row-title { font-size: var(--fs-lg); flex: 1; min-width: 12em; }
.row-meta { font-size: var(--fs-sm); color: var(--faint); white-space: nowrap; }

.crumbs { font-size: var(--fs-sm); color: var(--faint); padding-top: var(--gap); }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--kite); }

/* ── Country picker (sk-19) ── */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.country-chip { padding: 0; overflow: hidden; }
.country-chip select {
  font: inherit; font-size: var(--fs-sm); color: var(--ink-soft);
  background: none; border: none; padding: 5px 12px; cursor: pointer;
  appearance: none; max-width: 10em;
}
.country-chip select:focus { outline: none; }
.country-chip:focus-within { border-color: var(--river); }

/* The country the edge resolved, marked so the select shows it selected even
   though the HTML is one cached build for everyone. */
[data-country="BD"] .country-chip select option[value="BD"],
[data-country="IN"] .country-chip select option[value="IN"],
[data-country="CA"] .country-chip select option[value="CA"],
[data-country="US"] .country-chip select option[value="US"] { font-weight: 700; }

/* The country note: filled in by the client once availability is resolved. */
.geo-note { margin-top: var(--gap); }
.geo-note:empty { display: none; }
.row.restricted { opacity: .72; border-left: 2px solid var(--kite); padding-left: 10px; }
.row.restricted .row-title { color: var(--ink-soft); }
.row .lock { display: block; width: 100%; font-size: var(--fs-xs); color: var(--kite); }

/* ── Search (sk-06) ── */
.searchbox {
  display: flex; gap: var(--gap-sm); align-items: center;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 8px 8px 18px;
  max-width: 40em;
}
.searchbox input {
  flex: 1; min-width: 0; border: none; background: none;
  font: inherit; font-size: var(--fs-lg); color: var(--ink);
}
.searchbox input:focus { outline: none; }
.searchbox:focus-within { border-color: var(--river); }

.hit {
  display: block; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: var(--gap-sm);
  text-decoration: none; color: inherit;
}
.hit:hover { border-color: var(--kite); color: inherit; }
.hit .snip { font-size: var(--fs-lg); line-height: 1.7; margin: 0 0 6px; }
.hit mark { background: var(--kite-wash); color: var(--kite-deep); padding: 0 2px; border-radius: 3px; }
.hit .where { font-size: var(--fs-xs); color: var(--faint); }

/* The AI offer. River-teal because it is the machine's half of the page. */
.ai-offer {
  display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap;
  background: var(--river-wash); border-radius: var(--radius);
  padding: var(--gap) var(--gap-lg); margin: var(--gap) 0 var(--gap-lg);
  max-width: 40em;
}
.ai-offer svg { width: 34px; height: 24px; color: var(--river); flex: none; }
.ai-offer p { margin: 0; flex: 1; min-width: 14em; font-size: var(--fs-base); }
.ai-offer .cost { font-size: var(--fs-xs); color: var(--faint); display: block; margin-top: 4px; }

/* ── Front matter: kept, collapsed (skai-26) ── */
.front-matter {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 14px; margin: 0 0 var(--gap-lg); background: var(--mist);
}
.front-matter summary {
  cursor: pointer; font-size: var(--fs-sm); color: var(--ink-soft);
  list-style: none;
}
.front-matter summary::-webkit-details-marker { display: none; }
.front-matter summary::before { content: "▸ "; color: var(--faint); }
.front-matter[open] summary::before { content: "▾ "; }
.front-matter p {
  font-size: var(--fs-sm); color: var(--ink-soft);
  line-height: 1.7; margin: 8px 0 0;
}

/* Preprod banner (sk-04). Only rendered when SHANGKHACHIL_ENV=e2e.

   Deliberately loud and deliberately NOT in the palette: kite-chestnut and
   river-teal both mean something on this site, and borrowing either would make
   the banner read as part of the product. This is scaffolding, and it should
   look like scaffolding. */
.env-banner {
  background: var(--warn);
  color: var(--warn-ink);
  font: 500 13px/1.5 var(--font-latin);
  padding: 7px var(--gap);
  text-align: center;
  letter-spacing: .01em;
}
.env-banner strong {
  letter-spacing: .12em;
  font-weight: 700;
  margin-right: 6px;
}
.env-banner a {
  color: var(--warn-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 10px;
}
