/* Editorial theme, ported from an early option-a.html + refined-2-shared.js
   mockup. Near-black warm charcoal, muted desaturated green/red, flat
   borderless cards, no glow (--glow-strength:0). This is the settled
   design direction; the mockup exploration itself isn't part of the
   published repo. */
:root {
  --page: #121316;
  --card: #1a1b1f;
  --card-border: rgba(255, 255, 255, 0.10);
  --text: #e8e7e4;
  --muted: #86858c;

  --green: #6fcf97;
  --red: #eb6f6f;
  --gray: #5c5d63;
  --blue: #7fb8d9;
  --mauve: #a98da0;
  --grid: rgba(255, 255, 255, 0.06);
  --glow-strength: 0;

  --font: "Century Gothic", "Futura", "Avenir Next", "Poppins", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
}

h1 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  letter-spacing: .04em;
  color: var(--text);
  text-transform: uppercase;
}

/* The mockup's fixed, non-scrolling 100vh layout, kept intact as its
   own section. The page as a whole scrolls (for the below-fold cards),
   but this section still fills exactly one screen on load, matching
   the settled design. */
.viewport-section {
  height: 100vh;
  overflow: hidden;
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; }
.title-frame { background: transparent; border: none; padding: 0; }
.title-frame { display: flex; align-items: baseline; gap: 10px; }
.sample-tag, .updated-tag { font-size: 9px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.tag-sep { font-size: 9px; color: var(--muted); opacity: .5; }

.periods { display: flex; gap: 0; align-items: center; }
.periods button {
  background: transparent; border: none; border-right: 1px solid var(--card-border); color: var(--muted);
  font-family: inherit; font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  padding: 5px 13px; cursor: pointer;
}
.periods button:last-of-type { border-right: none; }
.periods button.active { color: var(--text); font-weight: 600; }
.periods input[type=date] {
  background: transparent; border: 1px solid var(--card-border); color: var(--text);
  font-family: inherit; font-size: 10px; padding: 5px 6px; display: none; margin-left: 8px;
}
.periods.custom-active input[type=date] { display: inline-block; }

.card {
  background: var(--card); border-radius: 0;
  padding: 12px 14px; display: flex; flex-direction: column; min-height: 0;
}
.card h2 { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 8px; color: var(--muted); text-align: left; }
.fill { flex: 1; min-height: 0; }

/* Return sits in its own card, aligned with the benchmark column on the
   right (same grid columns as main-grid) so it and the three benchmarks
   can be read as one comparison at a glance. The other five KPIs roll
   over to the left, in a fixed order: Alpha, Beta, Sharpe, Max DD, Rate. */
.kpi-split { display: grid; grid-template-columns: 1fr 360px; gap: 12px; flex: 0 0 auto; }
.chart-kpi-row { display: flex; gap: 1px; background: var(--card-border); }
.mini-kpi { flex: 1; background: var(--card); padding: 9px 12px; text-align: left; }
.mini-kpi .l { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.mini-kpi .v { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 3px; }
.return-card { background: var(--card); padding: 9px 14px; display: flex; flex-direction: column; justify-content: center; }
.return-card .l { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.return-card .v { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 4px; }
.v.good { color: var(--green); }
.v.bad { color: var(--red); }
.v.neutral-blue { color: var(--blue); }
.v.neutral-red { color: var(--red); }

/* Shared grid rows across both columns, not independent flex columns.
   The bubble chart's bottom edge then lands exactly where the main
   chart's does, and the selected-ticker chart's bottom lands where the
   tiles row's does. Row 1 is 1fr (chart-card / bench-row+bubble-card).
   Row 2 is auto, sized by the tiles-row's content (calendar/positions
   grids), with the selected-card stretched to match it. */
.main-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 360px; grid-template-rows: 1fr auto; gap: 12px; }
.chart-card { grid-column: 1; grid-row: 1; min-height: 0; }
.right-top { grid-column: 2; grid-row: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
/* The footer lives here, below selected-card, both in the right
   column's row. tiles-row (left column, same row) then grows to match
   that row's total height, instead of leaving an empty strip on the
   left where no footer exists. */
.tiles-row { grid-column: 1; grid-row: 2; display: flex; gap: 12px; }
.right-bottom { grid-column: 2; grid-row: 2; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.selected-card { flex: 1; min-height: 0; }
.tile-card { flex: 1; min-width: 0; padding: 10px 12px; }
.tile-card.gauges { flex: 0.72; }
.tile-card h2 { margin-bottom: 6px; }

/* Twice as many cells, half the size. No room, or need, for in-cell
   text at this density; identity moves entirely to the hover tooltip.
   flex:1 with centered (not top-pinned) content: if tiles-row grows
   taller than these grids need (e.g. to match the right column's row),
   the extra space splits evenly above/below instead of leaving a dead
   gap at the bottom. */
.gridcal { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; align-content: center; flex: 1; min-height: 0; }
.gridN { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; align-content: center; flex: 1; min-height: 0; }
.cal-cell { border-radius: 0; aspect-ratio: 1; }

/* A wide color frame is the whole story here: gain/loss, regardless of
   long or short. Side and $ detail move to hover. */
.pos-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px; font-size: 11px; gap: 2px; aspect-ratio: 1; cursor: pointer;
  background: transparent; border: 6px solid;
}
.pt-ticker { font-weight: 600; letter-spacing: .02em; color: var(--text); }
.pt-pct { font-variant-numeric: tabular-nums; font-size: 10px; color: var(--muted); }

/* A dome on top of a U. Beta stays a normal gauge: flat bottom, arc up
   (a dome). Capital is mirrored on the vertical axis only, scaleY(-1):
   flat top, arc down (a U). Not a full 180deg rotation -- that would
   also mirror left-right and reverse the fill direction. The two
   gauge-mini halves sit directly adjacent, with no gap and no
   flex-basis given to anything else in gauge-circle, so their SVG arcs
   meet edge-to-edge and read as one circle.

   Plotly's built-in "number" is dropped (mode:'gauge' only, in app.js)
   for a custom name+value label per half. Each half gets its own name
   badge (Beta / Capital), so the reading is unambiguous, plus free
   placement: beta pulled up off the seam, capital pushed down below it.

   The long/short balance bar is lifted out of the flex flow and
   positioned by app.js's positionBalanceBar() directly over the
   measured seam. CSS only centers it horizontally; JS sets `top`
   precisely so the bar itself, not the title above it, lands on the
   seam.

   Plotly draws each half's arc inset within its own margin-adjusted
   plot box, not flush to the shared edge. However precisely the seam Y
   is measured, the two rendered arcs can still leave a hairline gap.
   Rather than fight that, ls-bar's own background (opaque, matching
   the card) is widened by JS to the arc's measured diameter. It
   becomes a covering strip across the seam, not a 140px bar floating
   over a gap, so the two halves read as one circle with a clean line,
   not two disjoint arcs. */
.gauge-circle { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.gauge-mini { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.gauge-mini .g { position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform-origin: center center; }
#gauge-cash-wrap .g { transform: scaleY(-1); }
.gauge-label { position: absolute; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 1; }
#gauge-beta-wrap .gauge-label { top: 62%; }
#gauge-cash-wrap .gauge-label { top: 34%; }
.gl-name { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.gl-value { font-size: 15px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ls-block {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 2;
}
.ls-title { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ls-bar { display: flex; width: 140px; height: 4px; overflow: hidden; background: var(--card); }

/* Slim: the padding around the numbers is small, not the numbers
   themselves. */
.bench-row { display: flex; gap: 1px; flex: 0 0 50px; background: var(--card-border); }
.bench-mini {
  flex: 1; background: var(--card); padding: 4px 9px; text-align: left;
  display: flex; flex-direction: column; justify-content: center; cursor: pointer;
}
.bench-mini .l { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.bench-mini .v { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; }

.bubble-card { flex: 1; min-height: 0; }

.footer {
  flex: 0 0 auto; background: var(--card); padding: 6px 14px;
  display: flex; justify-content: center; gap: 8px; font-size: 9px; color: var(--muted); letter-spacing: .04em;
}
.footer a { color: inherit; text-decoration: none; }
.footer a:hover { color: var(--text); }

.empty-note { color: var(--muted); font-size: 11px; padding: 8px 0; text-align: center; }

/* Below-fold: analytics with no slot in the ported viewport layout
   above (rolling Sharpe, utilization, trade histogram, ticker
   concentration). Same card language, one row. The column split (1fr
   360px, then 1/0.72/1 inside the first cell) mirrors main-grid's own
   split: same padding, same 12px gaps. Edges then line up with
   calendar/gauges/positions/today above. Only reached by scrolling. */
.below-fold { padding: 0 26px 32px; }
.chart-grid-below { display: grid; grid-template-columns: 1fr 360px; gap: 12px; }
.below-left { display: flex; gap: 12px; min-width: 0; }
.below-left > .card { flex: 1; min-width: 0; }
.below-left > .card.narrow { flex: 0.72; }
.fill-chart { height: 200px; }

@media (max-width: 820px) {
  .chart-grid-below { grid-template-columns: 1fr; }
  .below-left { flex-direction: column; }
  .below-fold { padding: 0 14px 24px; }

  /* Below this width the fixed-100vh single-screen layout (viewport-section)
     can't fit the desktop grid without clipping or overlap, so it switches
     to a normal flowing, vertically-stacked page instead. Every element
     that relied on a bounded ancestor height for its flex:1 children
     (chart-card, right-top, tiles-row's gauge tile, right-bottom) gets an
     explicit height here, since there's no longer a 100vh parent to
     distribute. Plotly's `responsive:true` (PLOTLY_CONFIG in app.js) picks
     up each new container size on its own -- no JS changes needed. */
  .viewport-section { height: auto; overflow: visible; padding: 16px 14px; gap: 14px; }

  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .title-frame { flex-wrap: wrap; row-gap: 4px; }
  /* flex:1 1 100% forces this onto its own full-width line instead of
     shrinking past its buttons' content size, which is what let the
     row run off the right edge instead of wrapping. */
  .periods { flex: 1 1 100%; flex-wrap: wrap; row-gap: 6px; }
  .periods input[type=date] { margin-left: 0; }

  .kpi-split { grid-template-columns: 1fr; }
  /* grid with minmax(0,1fr) tracks, not flex-wrap: a flex item's default
     min-width is its content size, which was pushing the row wider than
     the screen instead of wrapping. Grid tracks shrink to 0 by default. */
  .chart-kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; }
  .mini-kpi { min-width: 0; }

  .main-grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .chart-card { grid-column: 1; grid-row: auto; height: 300px; }
  .right-top { grid-column: 1; grid-row: auto; height: 320px; }
  .tiles-row { grid-column: 1; grid-row: auto; flex-direction: column; }
  .tile-card { flex: none; }
  /* .tile-card.gauges has the same specificity as the base rule's own
     flex: 0.72 (style.css:116), which wins on source order and leaves
     flex-basis at 0% -- meaning `height` alone gets ignored for main-size
     in this column-direction flex container. Setting flex-basis directly
     is what actually gives it 260px. */
  .tile-card.gauges { flex: 0 0 260px; }
  .right-bottom { grid-column: 1; grid-row: auto; height: 320px; }
}
