/* Sikhitihas design tokens and shared components (design/REDESIGN.md).
   Day   = the Detective Wall (mockup C): brownish-greyish paper, felt depth, kesri thread, case-file type.
   Night = the Ratchet Dial (mockup A): graphite and machined metal, kesri needle, brass labels.
   <html data-theme="day|night"> picks the set; theme.js sets it before first paint.
   Every component here is built only from the tokens, so a page that uses the tokens follows the switch. */

:root {
  /* shape (--r-xs is for marks inside a line of text: a highlighted word, a glossary term) */
  --r-xs: 4px; --r-s: 8px; --r-m: 14px; --r-l: 20px; --r-pill: 999px;
  /* motion: one curve, three durations; all instant under prefers-reduced-motion (below) */
  --ease: cubic-bezier(.32, .72, 0, 1);
  --dur-1: 160ms; --dur-2: 320ms; --dur-3: 560ms;
  /* type */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Newsreader", Georgia, serif;
  --font-sans: "Atkinson Hyperlegible Next", "Noto Sans Gurmukhi", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-gurmukhi: "Noto Serif Gurmukhi", "Mukta Mahee", serif;
  --font-gurmukhi-sans: "Noto Sans Gurmukhi", "Mukta Mahee", sans-serif;
  /* layout */
  --bar-h: 3.75rem;
  --bar: var(--bar-h); /* the bar's real height; theme.js measures it (two rows on a phone) */
  --tap: 2.75rem; /* 44 px: the smallest control */
}

/* ---------- night: the instrument ---------- */
:root, :root[data-theme="night"] {
  color-scheme: dark;
  --bg: #15171a;
  --bg-2: #1b1e22;
  --bg-texture: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .93 0 0 0 0 .91 0 0 0 0 .87 0 0 0 .055 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --surface: #1f2226;
  --surface-2: #292d32;
  --ink: #ece7dd;
  --ink-2: #b9bec5;
  --ink-3: #8b9199; /* 5:1 on the surface, so eyebrows and captions stay readable */
  --line: rgba(236, 231, 221, .1);
  --line-2: rgba(236, 231, 221, .18);
  --accent: #ea8a2c;
  --accent-ink: #f2a35a;
  --accent-soft: rgba(234, 138, 44, .16);
  --brass: #c9a461;
  --thread: #ea8a2c;
  --river: #8db6da;
  --k-people: #ea8a2c;
  --k-orgs: #c9a461;
  --k-places: #8db6da;
  --k-events: #ece7dd;
  --k-debates: #b48ead;
  --shadow-1: inset 0 1px 0 rgba(255, 255, 255, .05), 0 2px 6px rgba(0, 0, 0, .5);
  --shadow-2: inset 0 1px 0 rgba(255, 255, 255, .06), 0 20px 40px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .4);
  --shadow-lift: inset 0 1px 0 rgba(255, 255, 255, .07), 0 30px 60px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .5);
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, Menlo, monospace;
  /* the instrument panel */
  --bar-bg: linear-gradient(180deg, #25292e 0%, #1d2024 60%, #191c1f 100%);
  --bar-ink: #ece7dd;
  --bar-ink-2: #8a9099;
  --bar-line: rgba(255, 255, 255, .08);
  --bar-well: rgba(0, 0, 0, .35);
  --bar-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), inset 0 -1px 0 rgba(0, 0, 0, .7), 0 10px 30px rgba(0, 0, 0, .35);
  --bar-raised: linear-gradient(180deg, #34393f, #272b30);
  --bar-brass: #c9a461; /* the brand's second word on the bar */
  --bar-color: #1d2024; /* <meta name="theme-color"> */
}

/* ---------- day: the wall ---------- */
:root[data-theme="day"] {
  color-scheme: light;
  --bg: #d9cdb5;
  --bg-2: #cfc1a5;
  --bg-texture: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='300'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='0.012 0.55' numOctaves='3' seed='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .18 0 0 0 0 .12 0 0 0 0 .06 0 0 0 .16 0'/></filter><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .2 0 0 0 0 .14 0 0 0 0 .08 0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23f)'/><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --surface: #f3ebd9;
  --surface-2: #e8dcc2;
  --ink: #1a1512;
  --ink-2: #4a3f35;
  --ink-3: #5f5244; /* faint, but 4.8:1 on the wall and 6.4:1 on the paper */
  --line: rgba(26, 21, 18, .14);
  --line-2: rgba(26, 21, 18, .24);
  --accent: #ea8a2c;
  --accent-ink: #8f4208; /* kesri as text: 4.5:1 on the wall, 6:1 on the paper */
  --accent-soft: rgba(234, 138, 44, .18);
  --brass: #7a5a24;
  --thread: #8e2f29;
  --river: #36618a;
  --k-people: #d9741a;
  --k-orgs: #8c6a2f;
  --k-places: #3f6f99;
  --k-events: #8e2f29;
  --k-debates: #6b4a86;
  --shadow-1: 0 1px 1px rgba(0, 0, 0, .22), 0 6px 12px -8px rgba(40, 25, 10, .5);
  --shadow-2: 0 1px 1px rgba(0, 0, 0, .22), 0 18px 30px -14px rgba(40, 25, 10, .6);
  --shadow-lift: 0 2px 3px rgba(0, 0, 0, .28), 0 26px 40px -16px rgba(40, 25, 10, .7);
  --font-mono: "Courier Prime", "Courier New", ui-monospace, monospace;
  /* the wooden batten above the wall */
  --bar-bg: linear-gradient(#2a211b, #1a1410);
  --bar-ink: #f1e9d8;
  --bar-ink-2: #a8977f;
  --bar-line: rgba(255, 255, 255, .09);
  --bar-well: rgba(255, 255, 255, .05);
  --bar-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 6px 18px -8px rgba(0, 0, 0, .9);
  --bar-raised: linear-gradient(#5a4532, #3d2e22);
  --bar-brass: #d2ad66;
  --bar-color: #1f1813;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-texture), var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
:lang(pa) { font-family: var(--font-gurmukhi); }
::selection { background: var(--accent-soft); }
a { color: var(--accent-ink); text-decoration-color: color-mix(in srgb, var(--accent-ink) 40%, transparent); text-underline-offset: .16em; }
a:hover { text-decoration-color: currentColor; }
/* one focus ring everywhere: kesri, 2 px, following each control's own corners; text links get small ones */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a:focus-visible, .term:focus-visible, mark:focus-visible { border-radius: var(--r-xs); }
.dagger { font-family: Georgia, "Times New Roman", serif; } /* † is outside the fonts' Latin subset: a system glyph saves a download */
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gur { font-family: var(--font-gurmukhi); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow { font: 500 .72rem/1.2 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
:lang(pa) .eyebrow, .eyebrow:lang(pa) { font-family: var(--font-gurmukhi-sans); letter-spacing: 0; font-size: .85rem; text-transform: none; }

/* ---------- top bar ----------
   The bar's labels are set in the sans in both themes (the mono belongs to the paper): switching day and night
   must not move a single label. The language pill has one width for both words, so the tools never shift. */
.top-bar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem;
  min-height: var(--bar-h); padding: 0 1.1rem;
  background: var(--bar-bg); color: var(--bar-ink); box-shadow: var(--bar-shadow);
}
/* The site's name, top left on every page: "Sikhitihas" typeset in the display face, ਸਿੱਖ ਇਤਿਹਾਸ small beneath it in
   Noto Serif Gurmukhi. Same in both themes (the bar is dark in both) and both languages: the name is the brand.
   .brand-mark is the logo's place before the wordmark: no width until a logo file exists. When the owner's
   design/logo-inbox/ delivers icon.svg, copy it to site/icon.svg and set, on :root,
   --logo-w: 2rem; --logo-gap: .6rem; --logo-img: url("/icon.svg");   and the mark appears on every page. */
.brand { display: inline-flex; align-items: center; min-height: var(--tap); padding-block: 0; color: var(--bar-ink); text-decoration: none; white-space: nowrap; border-radius: var(--r-s); }
.brand-mark { flex: none; width: var(--logo-w, 0px); height: 2rem; margin-right: var(--logo-gap, 0px); background: var(--logo-img, none) center / contain no-repeat; }
.brand-word { display: flex; flex-direction: column; gap: .15rem; }
.brand-en { font: 500 1.5rem/1 var(--font-display); letter-spacing: .005em; color: var(--bar-ink); }
.brand-pa { font: 700 .74rem/1.3 var(--font-gurmukhi); color: var(--bar-brass); }
.site-links {
  --fade-l: 0px; --fade-r: 0px;
  display: flex; gap: .15rem; min-width: 0; overflow-x: auto; scrollbar-width: none;
  scroll-snap-type: x proximity; scroll-padding-inline: 1rem; overscroll-behavior-x: contain; scroll-behavior: smooth;
  mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}
/* auto margins centre the row when it fits and leave it scrolling from the first link when it does not
   (justify-content: center would push "Timeline" out of reach on the left) */
.site-links a:first-child { margin-left: auto; }
.site-links a:last-child { margin-right: auto; }
.site-links.links-scrolled { --fade-l: 2.4rem; }   /* theme.js: links lie beyond the left edge */
.site-links.links-more { --fade-r: 2.4rem; }       /* theme.js: links lie beyond the right edge */
.site-links::-webkit-scrollbar { display: none; }
.site-links a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .9rem; white-space: nowrap; scroll-snap-align: start;
  font: 600 .72rem/1 var(--font-sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--bar-ink-2); text-decoration: none; border-radius: var(--r-pill);
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
:lang(pa) .site-links a { font-family: var(--font-gurmukhi-sans); font-size: .95rem; letter-spacing: 0; text-transform: none; }
.site-links a:hover { color: var(--bar-ink); }
.site-links a[aria-current="page"] { color: var(--bar-ink); background: var(--bar-well); box-shadow: inset 0 0 0 1px var(--bar-line); }
.site-links a[aria-current="page"]::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: .5rem; vertical-align: .1em; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.saved-count { margin-left: .3rem; color: var(--accent); font-weight: 700; }
.bar-tools { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.lang-link {
  display: inline-grid; place-items: center; min-width: 5.5rem; min-height: var(--tap); padding: 0 .85rem;
  font: 600 .95rem/1 var(--font-gurmukhi); color: var(--bar-ink); text-decoration: none;
  border-radius: var(--r-pill); background: var(--bar-well); box-shadow: inset 0 0 0 1px var(--bar-line);
  transition: color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.lang-link:lang(en) { font-family: var(--font-sans); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.lang-link:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.icon-btn {
  position: relative; flex: none; display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  color: var(--bar-ink-2); border-radius: 50%; background: var(--bar-well); box-shadow: inset 0 0 0 1px var(--bar-line);
  transition: color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.icon-btn:hover { color: var(--bar-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .led { position: absolute; right: .45rem; top: .45rem; width: .4rem; height: .4rem; border-radius: 50%; background: rgba(0, 0, 0, .35); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .8); transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
.icon-btn[aria-pressed="true"] { color: var(--bar-ink); }
.icon-btn[aria-pressed="true"] .led { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
/* the day/night switch shows the mode you would go to */
.theme-switch .ico-sun, .theme-switch .ico-moon { grid-area: 1 / 1; transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
:root[data-theme="night"] .theme-switch .ico-moon, :root[data-theme="day"] .theme-switch .ico-sun { opacity: 0; transform: rotate(-60deg) scale(.6); }
.search-open {
  display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: 0 .95rem;
  font: 600 .72rem/1 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--bar-ink-2);
  border-radius: var(--r-pill); background: var(--bar-well); box-shadow: inset 0 0 0 1px var(--bar-line);
  transition: color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
:lang(pa) .search-open { font-family: var(--font-gurmukhi-sans); font-size: .95rem; letter-spacing: 0; text-transform: none; }
.search-open:hover, .search-open[aria-expanded="true"] { color: var(--bar-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.search-open svg { width: 1.1rem; height: 1.1rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: var(--tap); padding: 0 1.1rem;
  font: 500 .76rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-pill); box-shadow: var(--shadow-1);
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), translate var(--dur-1) var(--ease);
}
:lang(pa) .btn { font-family: var(--font-gurmukhi-sans); font-size: .95rem; letter-spacing: 0; text-transform: none; }
.btn:hover { color: var(--ink); border-color: var(--accent); translate: 0 -1px; }
.btn[aria-pressed="true"] { color: var(--accent-ink); border-color: var(--accent); }
.btn-main { background: var(--accent); color: #1a1512; border-color: var(--accent); }
.btn-main:hover { color: #1a1512; background: color-mix(in srgb, var(--accent) 85%, #fff); }
.btn-quiet { background: none; box-shadow: none; border-style: dashed; }

/* ---------- chips and pins (a chip names a kind; a pin is a link to a page, with a knot in its kind's colour) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 1.9rem; padding: 0 .7rem;
  font: 500 .68rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
}
:lang(pa) .chip { font-family: var(--font-gurmukhi-sans); font-size: .85rem; letter-spacing: 0; text-transform: none; }
.pin {
  display: inline-flex; align-items: center; gap: .55rem; min-height: var(--tap); padding: .4rem .9rem .4rem .7rem;
  font: 500 .95rem/1.3 var(--font-sans); color: var(--ink-2); text-decoration: none; text-align: left;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent); border: 1px solid var(--line); border-radius: var(--r-pill);
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.pin:hover { color: var(--ink); border-color: var(--accent); }
.pin:lang(pa) { font-family: var(--font-gurmukhi); }
.k-dot { flex: none; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ink-3); box-shadow: 0 0 6px color-mix(in srgb, currentColor 60%, transparent); }
/* --k is the kind's colour for a knot or line beside text that stays in ink (the day colours are too light as type) */
.k-people { --k: var(--k-people); color: var(--k); } .k-orgs { --k: var(--k-orgs); color: var(--k); } .k-places { --k: var(--k-places); color: var(--k); }
.k-events { --k: var(--k-events); color: var(--k); } .k-debates, .k-ideas { --k: var(--k-debates); color: var(--k); }
.k-dot.k-people, .k-dot.k-orgs, .k-dot.k-places, .k-dot.k-events, .k-dot.k-debates, .k-dot.k-ideas { background: currentColor; }
.k-dot.k-events { border-radius: 2px; }
:root[data-theme="day"] .k-dot { box-shadow: 0 1px 1px rgba(0, 0, 0, .35); }

/* ---------- cards and sheets (every panel on the site: one radius, one shadow family) ---------- */
.paper-card {
  position: relative; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-2);
}
.sheet {
  color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--shadow-lift);
}
.sheet::backdrop { background: rgba(8, 6, 5, .62); backdrop-filter: blur(3px); }
hr.rule { border: 0; width: 4rem; height: 2px; margin: 0; background: var(--accent); border-radius: 1px; }

/* ---------- motion: everything instant when the reader asks for less ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 0ms; --dur-2: 0ms; --dur-3: 0ms; }
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}

/* ---------- tablet and phone: the brand and tools on one row, the links on a second ----------
   One row needs about 1010 px (name, five links in either language, search, language, day/night, sound and room for
   the logo), so below 1080 px (an iPad held upright, 820 px; a small laptop) the links drop to a row of their own,
   centred, and every one fits. On a phone the row is a little tighter and, if the words are long, scrolls sideways
   from its first link. */
@media (max-width: 1079px) {
  .top-bar { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 .6rem; padding: .3rem .85rem .2rem 1.1rem; }
  .brand { grid-row: 1; }
  .bar-tools { grid-row: 1; grid-column: 2; }
  .site-links { grid-row: 2; grid-column: 1 / -1; margin: 0 -.85rem 0 -1.1rem; padding: 0 .85rem 0 1.1rem; scroll-padding-inline: 1.1rem; }
}
@media (max-width: 760px) {
  .top-bar { gap: 0 .6rem; padding: .3rem .6rem .2rem .85rem; }
  .brand-en { font-size: 1.35rem; }
  .bar-tools { gap: .25rem; }
  .site-links { margin: 0 -.6rem 0 -.85rem; padding: 0 .6rem 0 .85rem; scroll-padding-inline: .85rem; }
  .site-links a { padding: 0 .75rem; }
  .search-open { width: var(--tap); padding: 0; justify-content: center; }
  .search-open .search-label { display: none; }
  .lang-link { min-width: 4.6rem; padding: 0 .6rem; }
}
/* a common phone (375 to 400 px): a little tighter again, which leaves room beside the name for the logo's mark */
@media (max-width: 400px) {
  .brand-en { font-size: 1.25rem; }
  .bar-tools { gap: .15rem; }
  .lang-link { min-width: 4rem; padding: 0 .5rem; }
}
/* the narrowest phones (320 px): the name steps down a size and the language pill closes up, so the four tools
   keep their full 44 px and nothing meets the name */
@media (max-width: 359px) {
  .brand-en { font-size: 1.1rem; }
  .brand-pa { font-size: .68rem; }
  .bar-tools { gap: .1rem; }
  .lang-link { min-width: 3.6rem; padding: 0 .4rem; }
}
