/* tejaswee shared stylesheet, v1
 *
 * Every custom property lives on :root. Projects change one thing, --accent, through
 * data-accent on <body> (set from projects.yaml). Gold stays the link and focus colour
 * everywhere so the family reads as one site.
 *
 * Dark mode follows prefers-color-scheme; theme.js lets a reader pin light, dark or gold,
 * which sets data-theme on <html>. Gold is only ever pinned: the system never picks it.
 *
 * Bump the /assets/v1/ segment for breaking changes so browser caches don't fight you.
 */

/* ---------- fonts (subset, split by script with unicode-range) ---------- */

@font-face {
  font-family: "TJ Display";
  src: url("fonts/eczar-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-017F, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0300-036F, U+1E00-1EFF, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215;
}
@font-face {
  font-family: "TJ Display";
  src: url("fonts/eczar-devanagari.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+200C-200D, U+20B9, U+25CC, U+A8E0-A8FF;
}
@font-face {
  font-family: "TJ Sans";
  src: url("fonts/plex-sans-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-017F, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0300-036F, U+1E00-1EFF, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215;
}
@font-face {
  font-family: "TJ Sans";
  src: url("fonts/plex-sans-devanagari-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+200C-200D, U+20B9, U+25CC, U+A8E0-A8FF;
}
@font-face {
  font-family: "TJ Sans";
  src: url("fonts/plex-sans-devanagari-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+200C-200D, U+20B9, U+25CC, U+A8E0-A8FF;
}
@font-face {
  font-family: "TJ Mono";
  src: url("fonts/plex-mono-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* ---------- tokens: light (default) ---------- */

:root {
  /* palette */
  --ink: #17140F;
  --paper: #F3F0E7;
  --surface: #FFFDF8;
  --gold: #C08A1E;        /* hairlines, marks, underline colour, fills behind dark text */
  --gold-deep: #7A5510;   /* gold as text on the ground; focus ring (5.9:1) */
  --muted: #6E675A;       /* 4.9:1 on paper, 5.5:1 on surface */
  --on-gold: #17140F;     /* text on a solid gold fill (6:1) */
  --rule: rgb(23 20 15 / 0.14);
  --rule-strong: rgb(23 20 15 / 0.34);
  --wash: #EAE5D7;        /* a step below paper: hovered rows, code, meters */
  --gold-wash: rgb(192 138 30 / 0.16);

  /* per-project accents: rules and marks only, never body text */
  --accent-gold: var(--gold);
  --accent-indigo: #2E3F6B;
  --accent-madder: #6B2F3A;
  --accent-green: #33604A;
  --accent-slate: #3A5560;
  --accent: var(--accent-gold);

  --focus: var(--gold-deep);

  /* state (derived from the palette; always paired with glyph + word) */
  --state-running: var(--muted);
  --state-stopped: var(--gold-deep);
  --state-failed-bg: var(--ink);
  --state-failed-fg: var(--paper);
  --state-attention: var(--gold);

  /* type: ratio 1.25 */
  --font-display: "TJ Display", "Eczar", Georgia, "Noto Serif Devanagari", serif;
  --font-sans: "TJ Sans", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI",
    "Noto Sans Devanagari", sans-serif;
  --font-mono: "TJ Mono", "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --step--2: 0.68rem;
  --step--1: 0.85rem;
  --step-0: 1.0625rem;
  --step-1: 1.33rem;
  --step-2: 1.66rem;
  --step-3: 2.07rem;
  --step-4: 2.59rem;
  --hero: clamp(4rem, 16vw, 9rem);
  --measure: 68ch;

  /* space: 4px base */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;

  --radius: 2px;
  --page-max: 72rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);

  color-scheme: light;
}

/* ---------- tokens: dark ---------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="gold"]) {
    --ink: #ECE5D5;
    --paper: #14110C;
    --surface: #1D1913;
    --gold: #C99A3A;
    --gold-deep: #E0B65A;
    --muted: #A69E8D;
    --on-gold: #14110C;
    --rule: rgb(236 229 213 / 0.14);
    --rule-strong: rgb(236 229 213 / 0.34);
    --wash: #27221A;
    --gold-wash: rgb(201 154 58 / 0.18);
    --accent-indigo: #9DAEDD;
    --accent-madder: #D49AA4;
    --accent-green: #8DC0A2;
    --accent-slate: #9CBAC4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #ECE5D5;
  --paper: #14110C;
  --surface: #1D1913;
  --gold: #C99A3A;
  --gold-deep: #E0B65A;
  --muted: #A69E8D;
  --on-gold: #14110C;
  --rule: rgb(236 229 213 / 0.14);
  --rule-strong: rgb(236 229 213 / 0.34);
  --wash: #27221A;
  --gold-wash: rgb(201 154 58 / 0.18);
  --accent-indigo: #9DAEDD;
  --accent-madder: #D49AA4;
  --accent-green: #8DC0A2;
  --accent-slate: #9CBAC4;
  color-scheme: dark;
}

/* ---------- tokens: gold ----------
 * A deep-gold reading of the light theme, in the family of a panchang page: a dusky
 * gold ground, a lighter gold for cards, dark brown ink, bronze and maroon. Nothing is
 * near-white, so it glares less than light. Every pairing is checked: ink 8.1:1 on the
 * ground and 9.5:1 on cards, muted 5.5:1, gold-deep 5:1, the ground on every accent fill
 * at least 4.9:1, gold hairlines 3:1. Accents are darkened here because they carry the
 * ground as text; gold as an accent fill steps down to gold-deep for the same reason. */
:root[data-theme="gold"] {
  --ink: #22150A;
  --paper: #D3A95C;
  --surface: #DEB872;
  --gold: #7E5310;
  --gold-deep: #5A3408;
  --muted: #4A3118;
  --on-gold: #F3DDAE;
  --rule: rgb(58 34 10 / 0.22);
  --rule-strong: rgb(58 34 10 / 0.45);
  --wash: #C69A4E;
  --gold-wash: rgb(126 83 16 / 0.22);
  --accent-gold: var(--gold-deep);
  --accent-indigo: #26345A;
  --accent-madder: #5E1E1E;
  --accent-green: #22452F;
  --accent-slate: #2A3F48;
  color-scheme: light;
}

[data-accent="gold"] { --accent: var(--accent-gold); }
[data-accent="indigo"] { --accent: var(--accent-indigo); }
[data-accent="madder"] { --accent: var(--accent-madder); }
[data-accent="green"] { --accent: var(--accent-green); }
[data-accent="slate"] { --accent: var(--accent-slate); }

/* ---------- base ---------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 var(--s4);
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); margin-top: var(--s7); }
h3 { font-size: var(--step-1); }

p, ul, ol, dl, pre, table { margin: 0 0 var(--s4); }
p, li { max-width: var(--measure); }
:lang(sa), :lang(hi), :lang(ne) { line-height: 1.75; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a:hover { color: var(--gold-deep); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

hr { border: 0; border-top: 1px solid var(--gold); margin: var(--s6) 0; width: 4rem; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--wash); padding: 0.05em 0.3em; border-radius: var(--radius); }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; font-size: var(--step--1); color: var(--muted); border-bottom-color: var(--rule-strong); }
.table-scroll { overflow-x: auto; }

::selection { background: var(--gold-wash); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--s4);
  top: -10rem;
  background: var(--surface);
  padding: var(--s2) var(--s4);
  border: 2px solid var(--focus);
  z-index: 10;
}
.skip-link:focus { top: var(--s4); }

html:not(.js) .js-only { display: none !important; }
.js .no-js-only { display: none !important; }

.glyph { font-family: var(--font-sans); }

/* ---------- layout ---------- */

.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.page { flex: 1; padding-block: var(--s6) var(--s8); }
.prose { max-width: var(--measure); }

.site-header { border-bottom: 1px solid var(--gold); background: var(--paper); }
.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2) var(--s4);
  padding-block: var(--s3);
}
.wordmark { text-decoration: none; display: inline-flex; align-items: baseline; gap: var(--s2); }
.wordmark-deva { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); line-height: 1.2; }
.wordmark-latin { font-size: var(--step--1); color: var(--muted); }
.wordmark:hover .wordmark-latin { color: var(--gold-deep); }
.site-header-project {
  font-size: var(--step--1);
  padding-left: var(--s4);
  border-left: 1px solid var(--rule-strong);
}
.theme-toggle {
  margin-left: auto;
  font: inherit;
  font-size: var(--step--1);
  color: var(--muted);
  background: none;
  border: 0;
  padding: var(--s1) 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 0.22em;
}
.theme-toggle:hover { color: var(--gold-deep); text-decoration-color: var(--gold); }

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: var(--s5);
  font-size: var(--step--1);
  color: var(--muted);
}
.site-footer p { margin: 0; }

/* ---------- hub: hero and cards ---------- */

.hero { padding-block: var(--s7) var(--s6); }
.hero-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--hero);
  line-height: 1.15;
  margin: 0;
}
.hero-latin {
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--muted);
  margin: 0 0 var(--s5);
  padding-top: var(--s3);
  border-top: 1px solid var(--gold);
  display: inline-block;
  min-width: 6rem;
}
.hero-line { font-size: var(--step-1); line-height: 1.45; max-width: 36ch; margin: 0; }

.section-title { font-size: var(--step-1); margin: var(--s6) 0 var(--s4); }

.card-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--s5);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card-grid > li { max-width: none; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-height: 9rem;
  padding: var(--s5) var(--s5) var(--s4);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
}
.card-title { font-size: var(--step-2); margin: 0; }
.card-link { text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; }
.card-link:focus-visible { outline: none; }
.card:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.card:hover .card-link, .card-link:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 2px;
}
.card-tagline { color: var(--muted); margin: 0; }
.card-status { margin: auto 0 0; font-size: var(--step--1); color: var(--muted); }

.card.is-offline {
  background: transparent;
  border-style: dashed;
  border-top: 3px solid var(--rule-strong);
}
.card.is-offline .card-title { color: var(--muted); }

@media (min-width: 42rem) {
  .card.is-featured { grid-column: span 2; }
}
.card.is-featured .card-title { font-size: var(--step-3); }
.card.is-featured::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--s3));
  top: var(--s5);
  width: 2px;
  height: 2.5rem;
  background: var(--gold);
}

/* ---------- project pages ---------- */

.project-head {
  padding-block: var(--s5) var(--s4);
  margin-bottom: var(--s6);
  border-bottom: 3px solid var(--accent);
}
.project-head h1 { margin-bottom: var(--s2); }
.project-head p { color: var(--muted); margin: 0; }

.todo {
  border-left: 2px solid var(--gold);
  padding: var(--s2) var(--s4);
  background: var(--surface);
  font-size: var(--step--1);
  max-width: var(--measure);
}
.todo strong { color: var(--gold-deep); }

.item-list { list-style: none; padding: 0; margin: 0 0 var(--s6); }
.item-list > li {
  max-width: none;
  padding-block: var(--s4);
  border-bottom: 1px solid var(--rule);
}
.item-list > li:first-child { border-top: 1px solid var(--rule); }
.item-title { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; margin: 0; }
.item-meta { font-size: var(--step--1); color: var(--muted); margin: 0; }

.deva { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.6; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s5);
  max-width: 40rem;
}

/* ---------- components ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-height: 2.25rem;
  padding: 0.35em 0.9em;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-strong { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-strong:hover { color: var(--paper); background: var(--gold-deep); border-color: var(--gold-deep); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); border-color: var(--rule-strong); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
@media (pointer: coarse) { .btn { min-height: 2.75rem; } }

.field { margin-bottom: var(--s5); max-width: 40rem; }
.field label { display: block; font-weight: 600; font-size: var(--step--1); margin-bottom: var(--s1); }
.field-optional { font-weight: 400; color: var(--muted); }
.field-hint { font-size: var(--step--1); color: var(--muted); margin: 0 0 var(--s2); }
.field-error { font-size: var(--step--1); color: var(--ink); margin: var(--s1) 0 0; font-weight: 600; }
.field-error::before { content: "■ "; color: var(--gold-deep); }
.field.has-error input, .field.has-error textarea { border-color: var(--gold-deep); border-left-width: 3px; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.45em 0.6em;
}
select { width: auto; }
textarea { resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); }

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  padding: 0.05em 0.5em;
  font-size: var(--step--1);
  line-height: 1.5;
  border-radius: var(--radius);
  white-space: nowrap;
}
.pill-sub { font-size: var(--step--2); opacity: 0.85; }
.pill-running, .pill-activating, .pill-deactivating { color: var(--state-running); }
.pill-stopped { color: var(--state-stopped); box-shadow: inset 0 0 0 1px var(--state-stopped); }
.pill-failed { background: var(--state-failed-bg); color: var(--state-failed-fg); font-weight: 600; }
.pill-unknown { color: var(--muted); border: 1px dashed var(--rule-strong); }

.tag-attention {
  display: inline-block;
  padding: 0.05em 0.5em;
  font-size: var(--step--1);
  font-weight: 600;
  background: var(--state-attention);
  color: var(--on-gold);
  border-radius: var(--radius);
  white-space: nowrap;
}

.empty-state, .error-state { padding-block: var(--s6); max-width: var(--measure); }
.empty-state { border-top: 1px solid var(--rule); color: var(--muted); }
.empty-state-title { font-family: var(--font-display); font-size: var(--step-1); color: var(--ink); margin-bottom: var(--s2); }
.error-state h1 { font-size: var(--step-3); }

.notice {
  border-left: 3px solid var(--gold);
  background: var(--surface);
  padding: var(--s3) var(--s4);
  max-width: var(--measure);
}

/* ---------- motion ---------- */

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