/* =============================================================
   Stratum — styles.css
   Dark sedimentary aesthetic. Cool near-blacks (hue ~250),
   off-white text, two accents only (gain green / loss red).
   Backgrounds in OKLCH recovered from the design prototype.
   ============================================================= */

:root {
  /* Sediment-tonal backgrounds — slight tonal variation per layer */
  --bg-deep:   oklch(0.120 0.006 252);  /* page base */
  --bg-mid:    oklch(0.140 0.006 252);  /* section band */
  --bg-up:     oklch(0.165 0.006 250);  /* raised card */
  --bg-bright: oklch(0.205 0.008 250);  /* highlight / input */

  /* Foreground */
  --text:       oklch(0.94 0.004 250);  /* cool off-white */
  --text-mut:   oklch(0.66 0.010 250);  /* muted gray */
  --text-faint: oklch(0.50 0.010 250);  /* faint labels */

  /* Contact lines (hairlines doing structural work) */
  --hairline:        oklch(0.28 0.006 250);
  --hairline-strong: oklch(0.36 0.008 250);
  --contact:         oklch(0.48 0.014 250);  /* luminous geological contact line */

  /* Per-section sediment tones — near-blacks with an almost imperceptible
     warm/cool drift between layers. Individually subtle; cumulatively they
     give the page real depth when scrolled (the "core sample" effect). */
  --sed-hero:      oklch(0.158 0.006 250);  /* cool */
  --sed-holdings:  oklch(0.138 0.005 75);   /* faint warm */
  --sed-breakdown: oklch(0.170 0.007 248);  /* cool, raised */
  --sed-movers:    oklch(0.132 0.005 78);   /* faint warm, deeper */
  --sed-footer:    oklch(0.118 0.006 252);  /* deep */

  /* Two accents only — TUNE by eye vs prototype during QA */
  --gain: oklch(0.74 0.11 158);  /* muted cool green */
  --loss: oklch(0.66 0.13 25);   /* soft muted red */

  /* Strata-bar tonal ramp (near-black layers, no colour) */
  --strata-1: oklch(0.30 0.008 250);
  --strata-9: oklch(0.16 0.006 252);

  /* Type */
  --ui:   'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Rhythm */
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1180px;
}

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

/* The `hidden` attribute must always win. Class rules that set `display`
   (e.g. .modal, .footer) otherwise out-specify the UA [hidden] rule and
   leave "hidden" elements visible. Keep this authoritative. */
[hidden] { display: none !important; }

/* FIX #3: overscroll seam — html background is the load-bearing fix,
   overscroll-behavior is belt-and-braces. */
html, body {
  margin: 0;
  background: var(--bg-deep);
  overscroll-behavior: none;
}

body {
  font-family: var(--ui);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Sediment core viewed in cross-section: a subtle vertical tonal drift. */
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-bright) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-up) 0%, var(--bg-mid) 28%, var(--bg-deep) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

::selection { background: oklch(0.40 0.03 250); color: var(--text); }

/* Quiet scrollbar to match the dark editorial register (Firefox + WebKit). */
html { scrollbar-width: thin; scrollbar-color: oklch(0.32 0.008 250) var(--bg-deep); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: oklch(0.30 0.008 250);
  border-radius: 6px;
  border: 3px solid var(--bg-deep);   /* inset thumb so it reads thin */
}
::-webkit-scrollbar-thumb:hover { background: oklch(0.40 0.010 250); }
::-webkit-scrollbar-corner { background: var(--bg-deep); }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* numbers everywhere they appear */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.gain { color: var(--gain); }
.loss { color: var(--loss); }

/* ===================== SEDIMENT BANDING =====================
   Each major section is a full-column-width "stratum" on its own
   near-black tone, separated by a luminous contact line. The
   negative margin bleeds the band to the column edges; the matching
   padding restores content alignment (bounded by .app, so no
   horizontal overflow). */
.dashboard > section,
.footer,
.bedrock {
  position: relative;
  margin-left: calc(-1 * var(--gutter));
  margin-right: calc(-1 * var(--gutter));
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* Luminous contact line at the top edge of each band — brighter in the
   middle, fading at the ends, like a geological contact viewed in section.
   Hero is omitted (it sits directly under the masthead's own rule). */
.dashboard > section:not(#hero)::before,
.footer::before,
.bedrock::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--contact) 16%, var(--contact) 84%, transparent);
  opacity: 0.55;
  pointer-events: none;
}

#hero       { background: var(--sed-hero);      padding-top: 4px;  padding-bottom: 40px; }
#holdings   { background: var(--sed-holdings);   padding-top: 44px; padding-bottom: 44px; margin-top: 0; }
#breakdowns { background: var(--sed-breakdown);  padding-top: 44px; padding-bottom: 48px; margin-top: 0; }
#movers     { background: var(--sed-movers);     padding-top: 44px; padding-bottom: 48px; margin-top: 0; }

/* ===================== MASTHEAD ===================== */
.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(28px, 6vh, 64px) 0 28px;
  border-bottom: 1px solid var(--hairline);
}
.wordmark {
  font-family: 'Spectral', serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1;
  margin: 0;
  letter-spacing: 0.01em;
}
.tagline {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: clamp(14px, 2.2vw, 17px);
  color: var(--text-mut);
  margin: 10px 0 0;
}
.masthead__controls { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

.pill, .chip {
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mut);
  background: var(--bg-up);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.pill:hover, .chip:hover { border-color: var(--hairline-strong); color: var(--text); }

/* ===================== SECTION HEADS ===================== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
}
.section-head__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}
.section-head__meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.section-head__sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin: -8px 0 18px;
}
.link-quiet {
  font-size: 12px;
  color: var(--text-mut);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.link-quiet:hover { color: var(--text); border-bottom-color: var(--hairline-strong); }

/* ===================== EMPTY STATE ===================== */
.empty-state { padding: clamp(40px, 10vh, 96px) 0 64px; }

.import-zone { display: flex; flex-direction: column; }

.import-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 20px;
  border: 1px solid var(--hairline);
  border-bottom: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.import-row:first-child { border-radius: 4px 4px 0 0; }
.import-zone .import-row:last-of-type { border-bottom: 1px solid var(--hairline); border-radius: 0 0 4px 4px; }
.import-row:hover,
.import-row:focus-visible,
.import-row.is-dragover {
  background: var(--bg-up);
  border-color: var(--hairline-strong);
  outline: none;
}
.import-row.is-dragover { border-style: dashed; }
.import-row__text { display: flex; flex-direction: column; gap: 3px; }
.import-row__name { font-weight: 600; font-size: 15px; }
.import-row__desc { font-size: 12.5px; color: var(--text-mut); }
.import-row__action {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.import-row__status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--gain);
  margin-right: 10px;
}

.import-error {
  margin: 18px 0 0;
  padding: 12px 16px;
  border: 1px solid var(--loss);
  border-radius: 4px;
  color: var(--loss);
  font-size: 13px;
  line-height: 1.45;
  background: oklch(0.20 0.02 25 / 0.25);
}

.empty-footnote {
  margin: 36px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

/* ===================== HERO ===================== */
.dashboard { padding-top: 0; }

.depth-marker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin: 28px 0 14px;
}
.hero__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  /* luminous contact rules top & bottom (gradient, not flat gray) */
  border: 1px solid transparent;
  border-left: 0; border-right: 0;
  border-image: linear-gradient(90deg, transparent, var(--contact) 12%, var(--contact) 88%, transparent) 1;
}
.hero__cell {
  padding: 26px 28px 28px;
  border-left: 1px solid var(--hairline);
}
.hero__cell:first-child { border-left: none; padding-left: 4px; }
.hero__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.hero__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(26px, 4.4vw, 38px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
}
/* Dim the cents so the integer portion carries the weight (matches prototype).
   Opacity, not colour, so it also dims the green/red P/L figure in-hue. */
.hero__value .hero-dec { opacity: 0.5; font-weight: 400; }
.hero__sub { font-family: var(--mono); font-size: 13px; color: var(--text-mut); margin-top: 8px; }

.hero__meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 14px 4px 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}
.hero__meta .stale { color: var(--loss); }

/* notice (unsupported currency) */
.notice {
  margin: 18px 0 0;
  padding: 10px 14px;
  border-left: 2px solid var(--loss);
  background: var(--bg-up);
  color: var(--text-mut);
  font-size: 12.5px;
}

/* ===================== HOLDINGS TABLE ===================== */
.holdings { margin-top: 48px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--hairline); }
.holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  white-space: nowrap;
}
.holdings-table th {
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: right;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  user-select: none;
}
.holdings-table th:hover { color: var(--text); }
.holdings-table th.sorted { color: var(--text); }
.holdings-table th .arrow { font-size: 9px; margin-left: 4px; color: var(--text-mut); }
.holdings-table th.col-left, .holdings-table td.col-left { text-align: left; }
.holdings-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  text-align: right;
  color: var(--text);
}
.holdings-table tbody tr:hover td { background: var(--bg-up); }
.col-idx { color: var(--text-faint); font-size: 11px; }
.col-ticker { font-weight: 600; color: var(--text); }
.col-name { font-family: var(--ui); color: var(--text-mut); font-size: 12.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.col-prefix { color: var(--text-faint); font-size: 11px; margin-right: 2px; }

.broker-pill {
  display: inline-block;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mut);
  background: var(--bg-bright);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 2px 7px;
}
.badge-unsupported {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--loss);
  letter-spacing: 0.04em;
}

/* ===================== BREAKDOWNS ===================== */
.breakdowns {
  margin-top: 56px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}
.card {
  /* raised sediment slab — subtle top-lit gradient so it reads as a layer
     sitting proud of the breakdown band, not a flat panel */
  background: linear-gradient(180deg, oklch(0.190 0.006 250), oklch(0.158 0.006 250));
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 22px 24px 26px;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.04);   /* faint top edge highlight */
}

/* ---- strata bar (signature) ---- */
.strata {
  display: grid;
  grid-template-columns: 56px 14px 1fr;  /* depth axis | tick gutter | bands */
  gap: 0;
  margin-top: 8px;
  min-height: 360px;
}
.strata__axis { position: relative; border-right: 1px solid var(--hairline); }
.strata__axis-tick {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.strata__gutter { position: relative; }
/* Continuous P/L rail: one full-height element (gradient set inline), thin so
   it reads as annotation alongside the bar, not a competing visualisation. */
.strata__rail {
  position: absolute;
  right: 4px;          /* sits just left of the bands */
  top: 0;
  bottom: 0;           /* full bar height — no percentage rounding, no seams */
  width: 2px;
  border-radius: 1px;
}
.strata__bands { display: flex; flex-direction: column; border: 1px solid var(--hairline); border-left: none; }
.strata__band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  min-height: 1px;
  border-bottom: 1px solid oklch(0.10 0.004 252 / 0.7);
  overflow: hidden;
  /* sediment texture: faint top-lit sheen over the per-band tone (set inline) */
  background-image: linear-gradient(180deg, oklch(1 0 0 / 0.05), oklch(0 0 0 / 0.07));
}
.strata__band:last-child { border-bottom: none; }
.strata__band-label { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text); }
.strata__band-weight { font-family: var(--mono); font-size: 11.5px; color: var(--text-mut); }

/* ---- segmented bars (broker / currency) ---- */
.segbar {
  display: flex;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0 18px;
  border: 1px solid var(--hairline);
}
/* base colour set inline per segment; this overlay adds inner sediment
   texture (top-lit sheen) so even a single-segment bar isn't a flat slab */
.segbar__seg {
  height: 100%;
  border-right: 1px solid var(--bg-deep);
  background-image: linear-gradient(180deg, oklch(1 0 0 / 0.09), oklch(0 0 0 / 0.10));
}
.segbar__seg:last-child { border-right: none; }
.split-list { display: flex; flex-direction: column; gap: 8px; }
.split-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 12px;
  align-items: baseline;
  font-size: 13px;
}
.split-row__swatch { width: 10px; height: 10px; border-radius: 2px; align-self: center; }
.split-row__key { font-family: var(--ui); }
.split-row__pct { font-family: var(--mono); color: var(--text-mut); text-align: right; }
.split-row__val { font-family: var(--mono); color: var(--text); text-align: right; }

/* ===================== MOVERS ===================== */
.movers { margin-top: 56px; }
.movers__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.movers__col-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}
.mover-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: baseline;
  padding: 9px 0;
  font-family: var(--mono);
  font-size: 13px;
}
.mover-row__ticker { font-weight: 600; }
.mover-empty { color: var(--text-faint); font-family: var(--mono); font-size: 12px; padding: 9px 0; }

/* ===================== FOOTER ===================== */
.footer {
  /* horizontal padding comes from the band rule; only set vertical here so
     the bleed alignment is preserved. Flush band (no margin-top), contact
     line drawn by ::before. */
  padding-top: 26px;
  padding-bottom: 40px;
  background: var(--sed-footer);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}
.footer .stale { color: var(--loss); }
.footer__links { display: flex; gap: 18px; }
.footer__link { color: var(--text-mut); cursor: pointer; background: none; border: none; font: inherit; padding: 0; }
.footer__link:hover { color: var(--loss); }

/* ===================== BEDROCK / CAPYBARA ===================== */
.bedrock {
  position: relative;
  min-height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 24px;
  /* contact line via ::before; deepest tone, settling to true bedrock */
  background: linear-gradient(180deg, var(--sed-footer), oklch(0.095 0.004 252));
}
.bedrock__caption {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
/* Desaturate the sprite for the cool palette (CSS filter, not a redraw).
   Suppress the walk-bob entrance; the ambient eye-blink is retained. */
.bedrock .capyjonny-art {
  filter: grayscale(1) brightness(0.92) drop-shadow(0 2px 4px oklch(0.08 0 0 / 0.4));
  animation: none;
  width: 200px;
}

/* ===================== MODALS ===================== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: oklch(0.06 0 0 / 0.6); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--bg-mid);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 20px 60px oklch(0.05 0 0 / 0.5);
}
.modal__panel--wide { width: min(640px, 100%); }
.modal__title { font-family: var(--ui); font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; margin: 0 0 18px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal__note { font-size: 12px; color: var(--text-faint); line-height: 1.5; margin: 18px 0 0; }

.fx-field { display: flex; flex-direction: column; gap: 8px; }
.fx-field__label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-mut); }
.fx-field__input {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--text);
  background: var(--bg-bright);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 12px 14px;
  width: 100%;
}
.fx-field__input:focus { outline: none; border-color: var(--hairline-strong); }
.fx-updated { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); margin: 10px 0 0; }
.fx-updated.stale { color: var(--loss); }

.btn { font-family: var(--ui); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; border-radius: 4px; padding: 9px 18px; cursor: pointer; border: 1px solid var(--hairline); }
.btn--ghost { background: transparent; color: var(--text-mut); }
.btn--ghost:hover { color: var(--text); border-color: var(--hairline-strong); }
.btn--solid { background: var(--text); color: var(--bg-deep); border-color: var(--text); }
.btn--solid:hover { background: var(--text-mut); }
.btn--replace { font-family: var(--mono); font-size: 11px; padding: 6px 12px; }

/* ===================== SETTLE ANIMATION =====================
   Transform-only — NEVER opacity. Opacity entrances leave content
   invisible when the animation clock is paused (offscreen tabs). */
@keyframes settle {
  0%   { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}
.settle { animation: settle 300ms cubic-bezier(0.22, 1, 0.36, 1); }

@media (prefers-reduced-motion: reduce) {
  .settle { animation: none; }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 720px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__cell { border-left: none; border-top: 1px solid var(--hairline); padding-left: 4px; }
  .hero__cell:first-child { border-top: none; }
  .movers__grid { grid-template-columns: 1fr; gap: 28px; }
  .masthead { flex-direction: column; }
}
