/* thalai — shared styles
   Palette: cool paper + ink, one cobalt accent. Display: Bricolage Grotesque. Body: Source Serif 4. */

:root {
  color-scheme: light;
  --paper: #f3f5f7;
  --paper-raised: #fbfcfd;
  --ink: #17202b;
  --ink-2: #4d5866;
  --ink-3: #6b7684;
  --rule: #d5dbe2;
  --accent: #1f43b0;
  --accent-soft: #e2e8f8;
  --curve: #1f43b0;

  /* chart roles (validated default categorical, slots 1–4) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #7b5cd6;
  --series-6: #5b6b7a;
  --series-7: #c2398a;
  --grid: #e1e6ec;

  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;

  --measure: 38rem;
  --gutter: clamp(16px, 5vw, 64px);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper: #12161c;
    --paper-raised: #181d24;
    --ink: #e6eaef;
    --ink-2: #b4bcc6;
    --ink-3: #8c96a2;
    --rule: #2a313b;
    --accent: #8ea8ff;
    --accent-soft: #1d2640;
    --curve: #8ea8ff;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
  --series-5: #9378e6;
  --series-6: #8a99a8;
  --series-7: #d9569f;
    --grid: #232a33;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #12161c;
  --paper-raised: #181d24;
  --ink: #e6eaef;
  --ink-2: #b4bcc6;
  --ink-3: #8c96a2;
  --rule: #2a313b;
  --accent: #8ea8ff;
  --accent-soft: #1d2640;
  --curve: #8ea8ff;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #9378e6;
  --series-6: #8a99a8;
  --series-7: #d9569f;
  --grid: #232a33;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
}

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); margin-top: 3.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: 0.5rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }

.wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  padding: 0 var(--gutter);
  margin: 0 auto;
}
.wrap.wide { max-width: calc(880px + 2 * var(--gutter)); }

/* ---- site header ---- */
.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.site-nav { display: flex; gap: 1.25rem; font-family: var(--display); font-size: 1rem; }
.site-nav a { color: var(--ink-2); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

/* ---- landing hero: the rising curve ---- */
.hero { position: relative; padding-top: clamp(2rem, 8vw, 6rem); padding-bottom: 2rem; }
.hero-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(4.5rem, 2rem + 14vw, 11rem);
  line-height: 0.85;
  letter-spacing: -0.055em;
  margin: 0;
  font-variation-settings: "wdth" 85;
}
.hero-curve {
  display: block;
  width: 100%;
  height: auto;
  margin-top: -0.5rem;
  overflow: visible;
}
.hero-curve path.trace {
  fill: none;
  stroke: var(--curve);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: draw 2.4s cubic-bezier(.6,.05,.3,1) 0.2s forwards;
}
.hero-curve path.ghost { fill: none; stroke: var(--rule); stroke-width: 1.5; stroke-dasharray: 3 6; vector-effect: non-scaling-stroke; }
.hero-curve circle { fill: var(--curve); opacity: 0; animation: appear 0.3s ease 2.5s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .hero-curve path.trace { animation: none; stroke-dashoffset: 0; }
  .hero-curve circle { animation: none; opacity: 1; }
}
.hero-lede {
  font-size: clamp(1.25rem, 1rem + 0.8vw, 1.6rem);
  line-height: 1.4;
  max-width: 30ch;
  margin-top: 1.5rem;
  color: var(--ink);
}

/* ---- project list ---- */
.project-list { list-style: none; padding: 0; margin: 1.5rem 0 0; border-top: 1px solid var(--rule); }
.project-list li { margin: 0; border-bottom: 1px solid var(--rule); }
.project-list a, .project-list .p-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1.5rem;
  padding: 1.25rem 0;
  color: var(--ink);
  text-decoration: none;
}
.project-list a:hover .p-name { text-decoration: underline; text-decoration-thickness: 2px; }
.p-name { font-family: var(--display); font-weight: 600; font-size: 1.5rem; letter-spacing: -0.01em; }
.p-state { font-family: var(--display); font-size: 0.95rem; color: var(--ink-3); align-self: center; white-space: nowrap; }
.p-desc { grid-column: 1 / -1; color: var(--ink-2); max-width: 58ch; }

/* ---- generic page header ---- */
.page-head { padding-top: clamp(1.5rem, 5vw, 4rem); padding-bottom: 1rem; }
.page-head h1 { font-size: clamp(2.5rem, 1.5rem + 5vw, 4.5rem); letter-spacing: -0.035em; }
.page-head .sub { font-size: 1.25rem; color: var(--ink-2); margin-top: 1rem; max-width: 52ch; }
.crumbs { font-family: var(--display); font-size: 0.95rem; color: var(--ink-3); margin-bottom: 1rem; }
.crumbs a { color: var(--ink-3); }

/* ---- stack table ---- */
.stack { width: 100%; border-collapse: collapse; font-size: 1rem; margin: 1rem 0 1.5rem; }
.stack th, .stack td { text-align: left; vertical-align: top; padding: 0.7rem 0.75rem 0.7rem 0; border-bottom: 1px solid var(--rule); }
.stack th { font-family: var(--display); font-weight: 600; color: var(--ink-2); font-size: 0.95rem; }
.stack td:first-child { font-family: var(--display); font-weight: 600; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* ---- stages (a real sequence) ---- */
.stages { list-style: none; padding: 0; counter-reset: stage; margin: 1rem 0 1.5rem; }
.stages li {
  counter-increment: stage;
  position: relative;
  padding: 0 0 1.25rem 3rem;
  margin: 0;
}
.stages li::before {
  content: counter(stage);
  position: absolute;
  left: 0; top: 0.05rem;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: 1.5px solid var(--ink-3);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  display: grid; place-items: center;
  color: var(--ink-2);
}
.stages li[data-state="current"]::before { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.stages li[data-state="done"]::before { content: "✓"; border-color: var(--accent); color: var(--accent); }
.stages strong { font-family: var(--display); font-weight: 600; }
.stage-note { color: var(--ink-3); font-size: 0.95rem; }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.callout p:last-child { margin-bottom: 0; }

.go {
  display: inline-block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.7rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  border-radius: 4px;
}
.go:hover { background: var(--accent); }

/* ---- progress page: timeline + scoreboard ---- */
.jump { font-family: var(--display); font-size: 1rem; margin-top: 0.75rem; }

.tl-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 3rem;
  align-items: start;
  margin-top: 2rem;
}

.timeline { list-style: none; margin: 0; padding: 0 0 1rem; position: relative; }
.timeline::before {
  content: "";
  position: absolute; left: 21px; top: 0.5rem; bottom: 0;
  width: 2px; background: var(--rule);
}
.timeline > li { position: relative; margin: 0; padding: 0 0 1.75rem 64px; }

/* stage markers along the spine */
.tl-stage { padding-top: 1rem !important; padding-bottom: 1.25rem !important; }
.tl-stage h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--ink-2);
}
.tl-stage::before {
  content: "";
  position: absolute; left: 14px; top: 1.2rem;
  width: 16px; height: 16px;
  background: var(--paper);
  border: 2px solid var(--ink-3);
  transform: rotate(45deg);
}

/* the node on the spine */
.tl-node {
  position: absolute; left: 22px; top: 1rem;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink-3);
}
li[data-kind="milestone"] .tl-node { width: 22px; height: 22px; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--paper); }
li[data-kind="direction"] .tl-node { border-color: var(--accent); border-width: 3px; }
li[data-kind="result"] .tl-node {
  width: 44px; height: 44px; top: 1.4rem;
  background: var(--paper-raised); border: 2px solid var(--accent);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 0.8rem; color: var(--ink);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 4px var(--paper);
}

/* the bubble */
.tl-bubble {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.85rem 1.1rem 0.9rem;
  transition: border-color 0.2s;
}
.tl-bubble::before {
  content: "";
  position: absolute; left: -8px; top: 0.75rem;
  width: 14px; height: 14px;
  background: var(--paper-raised);
  border-left: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  transform: rotate(45deg);
  transition: border-color 0.2s;
}
li.is-active .tl-bubble, li.is-active .tl-bubble::before { border-color: var(--accent); }
li[data-kind="milestone"] .tl-bubble { border-width: 1px; }
.tl-meta { font-family: var(--display); font-size: 0.875rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.tl-kind { color: var(--ink-2); font-weight: 600; }
li[data-kind="direction"] .tl-kind, li[data-kind="milestone"] .tl-kind, li[data-kind="result"] .tl-kind { color: var(--accent); }
.tl-title { font-family: var(--display); font-weight: 600; font-size: 1.2rem; line-height: 1.25; margin: 0.2rem 0 0.35rem; letter-spacing: -0.01em; }
.tl-note { color: var(--ink-2); margin: 0; font-size: 1.0625rem; }
.tl-more { margin-top: 0.5rem; font-size: 1rem; color: var(--ink-2); }
.tl-more summary { font-family: var(--display); font-size: 0.9rem; color: var(--ink-3); cursor: pointer; }
.tl-more p { margin: 0.4rem 0 0; }
.tl-metrics { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 0.6rem; font-family: var(--display); font-size: 0.9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-metrics b { color: var(--ink); }
.tl-up { color: var(--series-3); }
.tl-next .tl-bubble { border-style: dashed; background: transparent; }
.tl-next .tl-bubble::before { background: var(--paper); border-left-style: dashed; border-bottom-style: dashed; }
.tl-next .tl-node { border-style: dashed; }

/* scoreboard */
.scoreboard {
  position: sticky; top: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-raised);
  padding: 1.1rem 1.1rem 1rem;
  font-family: var(--display);
}
.scoreboard p { margin: 0; }
.sb-when { font-size: 0.9rem; color: var(--ink-3); }
.sb-stage { font-weight: 600; font-size: 1.05rem; margin-top: 0.1rem !important; }
.sb-score { display: flex; flex-direction: column; margin-top: 1rem; }
.sb-num { font-size: 3.25rem; font-weight: 700; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.sb-num.is-empty { font-size: 1.15rem; font-weight: 600; letter-spacing: 0; line-height: 1.3; color: var(--ink-2); }
.sb-label { font-size: 0.875rem; color: var(--ink-3); margin-top: 0.3rem; }
.sb-delta { font-size: 0.95rem; color: var(--ink-2); margin-top: 0.4rem !important; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.sb-chart { margin-top: 0.75rem; }
.sb-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.sb-chart .sb-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sb-chart .sb-future { fill: none; stroke: var(--rule); stroke-width: 2; stroke-linejoin: round; }
.sb-chart .sb-dot { fill: var(--accent); }
.sb-chart .sb-dot-future { fill: var(--rule); }
.sb-chart .sb-now { fill: var(--paper-raised); stroke: var(--accent); stroke-width: 2.5; }
.sb-chart .sb-base { stroke: var(--rule); stroke-width: 1; }
.sb-chart text { font-family: var(--display); font-size: 10px; fill: var(--ink-3); }
.sb-facts { margin: 1rem 0 0; padding-top: 0.75rem; border-top: 1px solid var(--rule); display: grid; gap: 0.4rem; font-size: 0.875rem; }
.sb-facts div { display: flex; justify-content: space-between; gap: 1rem; }
.sb-facts dt { color: var(--ink-3); }
.sb-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .tl-layout { grid-template-columns: 1fr; gap: 0; }
  .scoreboard {
    order: -1;
    top: 0; z-index: 3;
    border-radius: 0; border-left: 0; border-right: 0;
    margin: 0 calc(-1 * var(--gutter)) 1.5rem;
    padding: 0.6rem var(--gutter);
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 1rem;
  }
  .sb-when { grid-column: 1; }
  .sb-stage { grid-column: 1; font-size: 0.95rem; }
  .sb-score { grid-column: 2; grid-row: 1 / span 2; margin: 0; align-items: flex-end; }
  .sb-num { font-size: 1.75rem; }
  .sb-num.is-empty { font-size: 0.9rem; text-align: right; max-width: 12ch; }
  .sb-label { font-size: 0.75rem; }
  .sb-delta, .sb-chart, .sb-facts { display: none; }
}

/* full charts */
.chart {
  margin: 1rem 0 2.5rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1rem 0.75rem;
  position: relative;
}
.chart-title { font-family: var(--display); font-weight: 600; font-size: 1.1rem; margin: 0 0 0.15rem; }
.chart-desc { font-size: 0.95rem; color: var(--ink-3); margin: 0 0 0.75rem; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-family: var(--display); fill: var(--ink-3); font-size: 12px; }
.chart svg .gridline { stroke: var(--grid); stroke-width: 1; }
.chart svg .baseline { stroke: var(--ink-3); stroke-width: 1; }
.chart svg .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart svg .series-dot { stroke: var(--paper-raised); stroke-width: 2; }
.chart svg .label { fill: var(--ink-2); font-weight: 600; }
.chart svg .crosshair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-empty {
  display: grid; place-items: center; text-align: center;
  min-height: 160px;
  color: var(--ink-3);
  font-size: 1rem;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 0.5rem;
}
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; font-family: var(--display); font-size: 0.9rem; color: var(--ink-2); margin: 0.5rem 0 0.25rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  min-width: 160px;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 2;
}
.tooltip .tt-head { font-weight: 600; margin-bottom: 0.2rem; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.35rem; }
details.data-table { font-size: 0.9rem; margin-top: 0.25rem; }
details.data-table summary { font-family: var(--display); color: var(--ink-3); cursor: pointer; padding: 0.25rem 0; }
details.data-table table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; margin-top: 0.5rem; }
details.data-table th, details.data-table td { text-align: left; padding: 0.3rem 0.75rem 0.3rem 0; border-bottom: 1px solid var(--rule); }

/* ---- footer ---- */
.site-foot {
  margin-top: 5rem;
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--ink-3);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}
.site-foot a { color: var(--ink-3); }
.theme-toggle {
  font: inherit; color: var(--ink-3); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em;
}

@media (max-width: 560px) {
  body { font-size: 1.0625rem; }
  .project-list a, .project-list .p-item { grid-template-columns: 1fr; }
  .p-state { align-self: start; }
}
