/* ==========================================================================
   Sparklingj Portfolio Board

   A delivery board for one operator's portfolio: a matrix of projects
   against the five stages of getting something live. Dark slate surfaces,
   hairline rules, one blue ordinal ramp for pipeline position, and the
   reserved status palette for what a live check actually returned.

   The palette tokens live on :root so that body, which sits outside
   .viz-root, can resolve them too. Light and dark are two steps of the
   same ramps, selected explicitly by the theme toggle.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces */
  --plane:        #0f1419;
  --surface:      #161b22;
  --surface-2:    #1c232c;
  --surface-3:    #232b36;

  /* Ink */
  --text:         #f0efec;
  --text-2:       #c3c2b7;
  --muted:        #898781;

  /* Structure */
  --rule:         #232b36;
  --rule-strong:  #323b47;
  --focus:        #6da7ec;

  /* Pipeline ordinal ramp — dark surface, validated (monotone L, gaps, single hue) */
  --stage-1:      #184f95;
  --stage-2:      #256abf;
  --stage-3:      #3987e5;
  --stage-4:      #6da7ec;
  --stage-5:      #9ec5f4;

  /* Ink for a glyph sitting inside a stage fill — whichever of black or
     white contrasts better against that step (all five clear 3:1). */
  --stage-1-ink: #ffffff;
  --stage-2-ink: #ffffff;
  --stage-3-ink: #0b0b0b;
  --stage-4-ink: #0b0b0b;
  --stage-5-ink: #0b0b0b;

  /* Status — reserved, never used for identity.
     The glyph colours are the reference steps, tuned for use as marks.
     Text needs its own step: on the light surface the raw warning step is
     only 1.76:1, and the raw critical step is 3.60:1 on the dark surface. */
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;

  --good-text:    #0ca30c;
  --warning-text: #fab219;
  --serious-text: #ec835a;
  --critical-text: #e66767;

  --font-display: "Bahnschrift", "DIN Alternate", "Segoe UI", sans-serif;
  --font-text:    "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono:    "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;

  --radius:       3px;
  --gap:          1px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --plane:        #eef0f3;
  --surface:      #f9fafb;
  --surface-2:    #ffffff;
  --surface-3:    #f2f4f7;

  --text:         #0b0b0b;
  --text-2:       #52514e;
  --muted:        #6f6d66;

  --rule:         #e1e0d9;
  --rule-strong:  #c8c7c0;
  --focus:        #1c5cab;

  --stage-1:      #6da7ec;
  --stage-2:      #3987e5;
  --stage-3:      #256abf;
  --stage-4:      #184f95;
  --stage-5:      #0d366b;

  --stage-1-ink: #0b0b0b;
  --stage-2-ink: #0b0b0b;
  --stage-3-ink: #ffffff;
  --stage-4-ink: #ffffff;
  --stage-5-ink: #ffffff;

  --good-text:    #006300;
  --warning-text: #7a5400;
  --serious-text: #a34318;
  --critical-text: #b32b2b;
}

.viz-root {
  min-height: 100vh;
  background: var(--plane);
  color: var(--text);
}

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

/* An element with `display` set by a class rule would otherwise ignore the
   hidden attribute — the drawer and the scrim both set display/position. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--plane);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__identity { display: flex; align-items: center; gap: 13px; }

.mark {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  background: var(--stage-3);
  position: relative;
  flex: none;
}
.mark::after {
  content: "";
  position: absolute;
  inset: 8px 7px;
  background: var(--surface);
  clip-path: polygon(0 0, 26% 0, 26% 34%, 74% 34%, 74% 0, 100% 0, 100% 100%, 74% 100%, 74% 66%, 26% 66%, 26% 100%, 0 100%);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.wordmark__sub {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.stamp {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--muted); }
.btn--ghost { background: transparent; }
.btn__glyph { font-size: 13px; line-height: 1; color: var(--text-2); }
.btn[aria-pressed="true"] { background: var(--stage-3); border-color: var(--stage-3); color: #fff; }
.btn[aria-pressed="true"] .btn__glyph { color: #fff; }

:where(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ lead */

.board {
  max-width: 1500px;
  margin: 0 auto;
  padding: 26px 28px 72px;
}

.lead {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 28px;
  align-items: start;
  margin-bottom: 22px;
}

.hero {
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.hero__figure {
  margin: 0;
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.hero__of {
  font-size: 30px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}
.hero__label {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.hero__support {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}

/* funnel — one column per stage, bar height = projects that reached it */
.funnel {
  margin: 0;
  padding: 20px 24px 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.funnel__head { margin-bottom: 16px; }
.funnel__head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}
.funnel__note {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.funnel__track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  align-items: end;
  height: 132px;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 0;
}

.funnel__col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.funnel__value {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--text);
}
.funnel__bar {
  width: 100%;
  max-width: 24px;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--stage-x, var(--stage-3));
}
.funnel__bar--empty { background: var(--surface-3); }

.funnel__legend {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 10px 0 0;
  padding: 0;
}
.funnel__legend li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
  min-width: 0;
}
.funnel__key {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex: none;
  background: var(--stage-x, var(--stage-3));
}
.funnel__legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.tile {
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.tile__label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.tile__value {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}
.tile__support {
  margin: 7px 0 0;
  font-size: 12px;
  color: var(--text-2);
}

/* -------------------------------------------------------------- attention */

.attention {
  margin-bottom: 26px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--warning-text);
  border-radius: var(--radius);
}
.attention__title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}
.attention__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--warning);
  color: #0b0b0b;
  font-size: 12px;
  font-weight: 700;
}
.attention__sub {
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--text-2);
}
.attention__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attention__list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
}
.attention__list li:first-child { border-top: 0; padding-top: 0; }
.attention__project { font-weight: 600; white-space: nowrap; }
.attention__detail { color: var(--text-2); }

/* -------------------------------------------------------------- projects */

.projects__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.projects__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}
.projects__count { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.filters {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.field { display: flex; }
.field--search input { min-width: 216px; }
.filters input[type="search"],
.filters select {
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}
.filters input[type="search"]::placeholder { color: var(--muted); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  padding: 6px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--stage-3); margin: 0; }

/* the matrix */
.grid {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.grow {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) minmax(180px, 0.95fr) minmax(150px, 0.85fr) minmax(190px, 1.15fr);
  align-items: center;
  gap: 18px;
  padding: 11px 18px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
  background: var(--surface);
  transition: background 120ms ease;
}
.grow:first-child { border-top: 0; }
.grow:hover { background: var(--surface-2); }
.grow:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.grow--head {
  cursor: default;
  background: var(--surface-2);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  padding-top: 8px;
  padding-bottom: 8px;
}
.grow--head:hover { background: var(--surface-2); }

.grow__project { min-width: 0; }
.grow__name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
}
.grow__sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grow__stage { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pipeline { display: flex; gap: 3px; align-items: center; }
.pipeline__seg {
  width: 22px; height: 9px;
  border-radius: 2px;
  background: var(--surface-3);
  flex: none;
}
.pipeline__seg--reached { background: var(--stage-x); }
.pipeline__seg--skipped {
  background: repeating-linear-gradient(
    45deg,
    var(--stage-x) 0 2px,
    transparent 2px 4px
  );
  box-shadow: inset 0 0 0 1px var(--stage-x);
}
.grow__stage-label {
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grow__live { min-width: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.chip__glyph {
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  flex: none;
}
.chip--good .chip__glyph { color: var(--good-text); }
.chip--critical .chip__glyph { color: var(--critical-text); }
.chip--warning .chip__glyph { color: var(--warning-text); }
.chip--serious .chip__glyph { color: var(--serious-text); }
.grow__live-url {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grow__live-url a { color: inherit; text-decoration: none; }
.grow__live-url a:hover { text-decoration: underline; }

.grow__git { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); min-width: 0; }
.grow__git-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grow__git-line strong { color: var(--text); font-weight: 600; }
.grow__git-dirty { color: var(--warning-text); }
.grow__git-none { color: var(--muted); font-family: var(--font-text); font-size: 12px; }

.grow__action {
  font-size: 12.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}

/* table view — the accessible twin of the matrix */
.table-view {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-x: auto;
}
.table-view table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table-view th, .table-view td {
  text-align: left;
  padding: 9px 14px;
  border-top: 1px solid var(--rule);
  vertical-align: top;
}
.table-view thead th {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 500;
  background: var(--surface-2);
  white-space: nowrap;
}
.table-view tbody tr:hover { background: var(--surface-2); }
.table-view td:nth-child(6) { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- drawer */

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.62);
  z-index: 30;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--rule-strong);
  z-index: 31;
  display: flex;
  flex-direction: column;
}
.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--rule);
}
.drawer__kind {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.drawer__head h2 {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}
.drawer__body { padding: 18px 22px 40px; overflow-y: auto; }

.dsection { margin-bottom: 22px; }
.dsection h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-2);
}
.dsection p { margin: 0 0 9px; font-size: 13.5px; color: var(--text-2); }
.dsection ul { margin: 0; padding-left: 17px; }
.dsection li { font-size: 13px; color: var(--text-2); margin-bottom: 5px; }

.kv { display: grid; grid-template-columns: 116px 1fr; gap: 5px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text-2); font-family: var(--font-mono); font-size: 12px; word-break: break-word; }

.stagebar { display: flex; flex-direction: column; gap: 7px; }
.stagebar__row {
  display: grid;
  grid-template-columns: 16px 104px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-2);
}
.stagebar__mark {
  width: 14px; height: 14px;
  border-radius: 3px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text);
}
.stagebar__mark--reached { background: var(--stage-x); }
.stagebar__mark--skipped {
  background: repeating-linear-gradient(45deg, var(--stage-x) 0 3px, transparent 3px 6px);
  box-shadow: inset 0 0 0 1px var(--stage-x);
}
.stagebar__reason { color: var(--muted); font-size: 12px; }

.callout {
  padding: 11px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--warning-text);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-2);
}
.callout--critical { border-left-color: var(--critical-text); }

/* --------------------------------------------------------------- tooltip */

.tooltip {
  position: fixed;
  z-index: 40;
  max-width: 290px;
  padding: 8px 11px;
  background: var(--surface-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
.tooltip strong { display: block; margin-bottom: 2px; font-weight: 600; }
.tooltip span { color: var(--text-2); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .lead { grid-template-columns: 1fr; }
  .grow { grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(140px, 0.9fr); }
  .grow__action { display: none; }
  .grow--head .col-action { display: none; }
}

@media (max-width: 760px) {
  .board { padding: 18px 16px 56px; }
  .topbar { padding: 12px 16px; }
  .stamp { display: none; }
  .hero__figure { font-size: 52px; }
  .grow { grid-template-columns: 1fr; gap: 9px; padding: 14px 16px; }
  .grow--head { display: none; }
  .funnel__track { height: 108px; gap: 8px; }
  .funnel__legend { gap: 8px; }
  .funnel__legend li { flex-direction: column; align-items: flex-start; gap: 4px; }
}

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