/* =============================================================================
   dashboard.css — Projects Dashboard page only (/dashboard/).

   Loaded after site.css. Reuses shared foundation classes wherever possible
   (.section, .section--alt, .section__head, .eyebrow, .display-*, .body-l,
   .caption, .chip, .chip__dot, .tile, .figure__value/__label, .btn,
   .link-more) and only adds what's genuinely new: the
   breadcrumb, the hero chip row, case-study internals (KPI tiles, filters,
   charts, insight cards, method details), the Live SQL console, and the
   methods/about grid.

   Chart colors are read from CSS variables at render time by dashboard.js
   (getComputedStyle), so they stay in sync with the site's tokens and
   re-render automatically when [data-theme] changes. --dash-mono and the
   --dash-* chart palette below are the only tokens this file adds; --dash-sky
   aliases the site's --blue so it already flips with theme. The categorical
   order (sky, orange, aqua, yellow, magenta) is the validated order from the
   dataviz skill's palette method (node scripts/validate_palette.js): with the
   site's brand blue fixed as slot 1, this ordering clears the lightness,
   chroma, CVD-separation and normal-vision checks in both themes at up to 5
   series (our largest categorical field). Dark-mode steps are re-picked for
   the dark card surface, not a flip of the light hex. --dash-heat-0/1 are the
   single-hue sequential ramp (light-to-dark blue) used by the cohort heatmap.
============================================================================= */

:root {
  --dash-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --dash-sky: var(--blue);
  --dash-orange: #eb6834;
  --dash-aqua: #1baf7a;
  --dash-yellow: #eda100;
  --dash-magenta: #e87ba4;
  --dash-heat-0: #eaf2fc;
  --dash-heat-1: var(--blue);
}
:root[data-theme="dark"] {
  --dash-orange: #d95926;
  --dash-aqua: #199e70;
  --dash-yellow: #c98500;
  --dash-magenta: #d55181;
  --dash-heat-0: #132840;
  --dash-heat-1: var(--blue);
}

/* ---------- breadcrumb ---------- */
.breadcrumb {
  font-size: 14px;
  color: var(--ink-3);
  margin-bottom: clamp(20px, 3vw, 32px);
}
.breadcrumb a { color: inherit; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb__sep { margin: 0 6px; }

/* ---------- HERO ---------- */
.dash-hero { padding-top: clamp(132px, 17vw, 188px); }
.dash-hero__inner { position: relative; z-index: 1; }
.dash-hero .chip { margin-bottom: 24px; }
.dash-hero__title { max-width: 14ch; margin-top: 4px; }
.dash-hero__sub { margin-top: 22px; max-width: 640px; }
.dash-hero__note { margin-top: 14px; max-width: 640px; }

/* headline line-mask reveal, mirrors home.js's hero treatment */
.dash-hero__title .split-line-wrap { display: block; overflow: hidden; }
.dash-hero__title .split-line { display: block; padding-bottom: 0.08em; }

.dash-hero__chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 40px; }
.dash-case-chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 17px;
  min-width: 168px;
  transition: transform 0.24s var(--ease-out), border-color 0.24s ease, background 0.24s ease;
}
.section--alt .dash-case-chip { background: var(--bg); }
html.js .dash-case-chip:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.dash-case-chip .k {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--link);
}
.dash-case-chip .t { display: block; font-weight: 600; font-size: 14px; margin-top: 5px; color: var(--ink); }
.dash-chip-loading { color: var(--ink-3); font-size: 14px; }

/* ---------- sticky case nav (six pills, scroll-spy) ---------- */
/* --site-nav-h is set by dashboard.js (syncCaseNavWithSiteNav) from the shared nav's real
   measured height, so this sits flush under it with no gap (no hardcoded guess). The shared nav
   hides on scroll-down by adding "is-hidden" to [data-nav]; dashboard.js mirrors that onto this
   bar as "is-flush", which slides it up to top:0 in the same motion so there is never a moment
   with neither bar covering the dark hero, and never a gap above this bar once the site nav is
   gone. Opaque enough (92%) plus blur to read as a solid bar, not a see-through hint of one. */
.case-nav {
  position: sticky;
  top: var(--site-nav-h, 68px);
  z-index: 50;
  min-height: 54px; /* reserves its own space before JS populates pills, so it doesn't
                        shift the rest of the page down once the case data loads (CLS) */
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  transition: top 0.28s var(--ease-out);
}
.case-nav.is-flush { top: 0; }
@media (prefers-reduced-motion: reduce) { .case-nav { transition: none; } }
.case-nav__inner { display: flex; gap: 6px; overflow-x: auto; padding: 10px var(--pad); scrollbar-width: none; }
.case-nav__inner::-webkit-scrollbar { display: none; }
.case-nav__pill {
  flex: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.case-nav__pill:hover { color: var(--ink); background: var(--bg-alt); }
.case-nav__pill.is-active { color: var(--ink); background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); font-weight: 600; }

/* ---------- case study sections ---------- */
.case-sec { scroll-margin-top: 128px; padding-block: clamp(72px, 9vw, 128px); }
/* Separate consecutive case studies so one case's Method panel never butts into the next case's title. */
.case-sec + .case-sec { border-top: 1px solid var(--line); }
.case-head { max-width: 78ch; }
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.role-chips-label { font-size: 13px; color: var(--ink-3); font-weight: 500; align-self: center; margin-right: 2px; }
.role-chip {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}
.section--alt .role-chip { background: var(--card); }
.case-question {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: clamp(21px, 2.6vw, 30px);
  line-height: 1.28;
  margin-top: 24px;
  max-width: 30ch;
  color: var(--ink);
}

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 40px; }
@media (max-width: 760px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-tile { padding: 22px 22px; }
.kpi-num { font-size: clamp(24px, 2.8vw, 32px); font-weight: 700; letter-spacing: -0.015em; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
.kpi-label { color: var(--ink-2); font-size: 14px; font-weight: 500; margin-top: 6px; line-height: 1.4; }
.kpi-viz { display: block; width: 100%; height: 6px; margin-top: 14px; }
.kpi-viz--spark { height: 28px; }
.kpi-note { color: var(--ink-3); font-size: 12.5px; margin-top: 8px; line-height: 1.4; }

/* ---------- filters ---------- */
.filters-row { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 34px; }
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em; }
.segmented { position: relative; display: inline-flex; background: var(--bg-alt); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.section--alt .segmented { background: var(--card); }
/* .seg-thumb is the sliding active indicator: JS (positionSegThumb) sets its transform/size to
   the active button's own box, so switching filters animates a single pill sliding between
   options instead of each button independently swapping background. */
.seg-thumb {
  position: absolute; top: 0; left: 0; z-index: 0;
  background: var(--card); border-radius: 9px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), width 0.22s cubic-bezier(0.16, 1, 0.3, 1), height 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.section--alt .seg-thumb { background: var(--bg); }
.seg-btn { position: relative; z-index: 1; border: none; background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; padding: 8px 15px; border-radius: 9px; cursor: pointer; transition: color 0.2s; }
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .seg-thumb { transition: none; } }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 40px; }
@media (max-width: 860px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-fig { padding: 24px 22px 20px; }
.chart-fig h3 { font-weight: 700; font-size: 16px; letter-spacing: -0.005em; }
.chart-fig .chart-sub { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; line-height: 1.45; max-width: 64ch; }
.chart-mount { margin-top: 18px; min-height: 220px; position: relative; }
.chart-mount canvas { border-radius: 8px; }
.chart-mount .chart-loading { color: var(--ink-3); font-size: 13px; padding: 60px 0; text-align: center; }
.chart-fig figcaption.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.simple-table-wrap { overflow-x: auto; margin-top: 16px; }
table.data-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data-table th, table.data-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data-table th { color: var(--ink-3); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
table.data-table td.num, table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- finding / recommendation / in-role ---------- */
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 44px; }
@media (max-width: 860px) { .insight-grid { grid-template-columns: 1fr; } }
.insight-card { padding: 26px 24px; }
.insight-card.dark { background: var(--ink); border-color: var(--ink); }
:root[data-theme="dark"] .insight-card.dark { background: var(--card); }
.insight-card.dark p { color: rgba(255, 255, 255, 0.78); }
:root[data-theme="dark"] .insight-card.dark p { color: var(--ink-2); }
.insight-label { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; color: var(--blue); margin-bottom: 12px; }
.insight-card.dark .insight-label { color: #6cb4ff; }
:root[data-theme="dark"] .insight-card.dark .insight-label { color: var(--blue); }
.insight-card p { color: var(--ink-2); font-size: 15px; line-height: 1.6; }

/* ---------- method details ---------- */
details.method { margin-top: 40px; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 20px; padding: 6px 26px; }
.section--alt details.method { background: var(--card); }
details.method summary {
  cursor: pointer;
  padding: 18px 0;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
details.method summary::-webkit-details-marker { display: none; }
details.method summary::after { content: "+"; font-size: 20px; color: var(--ink-3); font-weight: 400; transition: transform 0.2s; }
details.method[open] summary::after { transform: rotate(45deg); }
.method-body { padding: 0 0 28px; }
.method-sub-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin: 22px 0 10px; }
.method-sub-label:first-child { margin-top: 4px; }
.source-line { font-size: 14.5px; color: var(--ink-2); line-height: 1.6; }
.source-line a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.source-stats { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.source-stats b { color: var(--ink-2); }
.caveat { font-size: 13.5px; color: var(--ink-3); margin-top: 8px; font-style: italic; }
ul.clean-list { padding-left: 20px; }
ul.clean-list li { color: var(--ink-2); font-size: 14px; line-height: 1.6; margin-bottom: 4px; }
.code-block { background: var(--ink); color: #d8f0ff; border-radius: 14px; padding: 18px 20px; overflow-x: auto; font-family: var(--dash-mono); font-size: 13px; line-height: 1.6; white-space: pre; margin-top: 8px; }
:root[data-theme="dark"] .code-block { background: #000; border: 1px solid var(--line); }
.run-sql-btn {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.run-sql-btn:hover { background: var(--blue-hover); }
.dict-wrap { overflow-x: auto; margin-top: 8px; }
table.dict-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.dict-table th, table.dict-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.dict-table th { color: var(--ink-3); font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.05em; }
table.dict-table td.colname { font-family: var(--dash-mono); font-size: 13px; color: var(--ink); }
table.dict-table td.coltype { color: var(--ink-3); font-family: var(--dash-mono); font-size: 12px; }

/* ---------- Live SQL ---------- */
.sql-explain { color: var(--ink-2); font-size: 16px; margin-top: 14px; max-width: 62ch; }
.sql-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; margin-top: 36px; align-items: start; }
@media (max-width: 900px) { .sql-layout { grid-template-columns: 1fr; } }
.sql-side { display: flex; flex-direction: column; gap: 22px; }
.sql-panel { padding: 18px 18px; }
.sql-panel h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 10px; }
.table-list-btn {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--dash-mono);
  font-size: 13px;
  color: var(--ink-2);
}
.table-list-btn:hover { background: var(--bg-alt); color: var(--ink); }
.section--alt .table-list-btn:hover { background: var(--bg); }
.table-list-btn .rows { color: var(--ink-3); font-family: var(--font); }
.sq-group { margin-bottom: 14px; }
.sq-group:last-child { margin-bottom: 0; }
.sq-group-title { font-size: 11px; color: var(--blue); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.sq-btn { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 8px; border-radius: 9px; cursor: pointer; color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.sq-btn:hover { background: var(--bg-alt); color: var(--ink); }
.section--alt .sq-btn:hover { background: var(--bg); }
.sql-main { padding: 20px; min-width: 0; }
.sql-editor-wrap { border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: #1d1d1f; }
.cm-editor { height: 160px; font-size: 13.5px; }
textarea#sql-fallback {
  width: 100%;
  height: 160px;
  resize: vertical;
  background: #1d1d1f;
  color: #d8f0ff;
  border: none;
  font-family: var(--dash-mono);
  font-size: 13.5px;
  padding: 14px 16px;
  line-height: 1.6;
}
textarea#sql-fallback:focus { outline: none; }
.sql-controls { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.run-btn {
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.run-btn:hover { opacity: 0.85; }
.run-btn:disabled { opacity: 0.5; cursor: wait; }
.sql-status { font-size: 13px; color: var(--ink-3); font-family: var(--dash-mono); }
.sql-results-wrap { margin-top: 18px; max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; min-width: 0; max-width: 100%; }
table.results-table { border-collapse: collapse; width: 100%; font-size: 13px; }
table.results-table th, table.results-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
table.results-table th { position: sticky; top: 0; background: var(--card); color: var(--ink-3); font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.05em; }
table.results-table td.num, table.results-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sql-error { color: #c62828; font-size: 13.5px; margin-top: 12px; background: #fdecea; border-radius: 10px; padding: 10px 14px; }
:root[data-theme="dark"] .sql-error { color: #ff8a80; background: rgba(255, 69, 58, 0.12); }

/* ---------- methods / about ---------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; margin-top: 40px; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; gap: 28px; } }
.about-block h3 { font-weight: 700; font-size: 18px; margin-bottom: 12px; }
.about-block p { color: var(--ink-2); font-size: 15px; line-height: 1.65; margin-bottom: 12px; }
.stack-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.stack-chip { font-size: 13px; font-weight: 500; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; }
.source-list { display: grid; gap: 14px; margin-top: 4px; }
.source-item { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.source-item:last-child { border-bottom: none; }
.source-item b { color: var(--ink); }
.source-item a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.source-item .lic { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  .dash-hero__title .split-line { transform: none !important; }
}
