/* =========================================================
   VOLATILITY ANALYSIS (admin-only)
   ---------------------------------------------------------
   Full-viewport two-pane layout. Symbol + expiry are driven
   by the global instr-bar at the top of the app — no per-
   pane selectors. Skew uses the IV already present in the
   /api/chain payload that powers the option-chain page;
   no extra fetches or compute.
   ========================================================= */

[data-page="vol"] {
  display: none;
}
[data-page="vol"].active {
  display: flex;
  flex-direction: column;
  /* Fill the viewport below the topbar (~49px) + instr-bar
   * (~38px). Favbar height (variable, set on :root by app.js's
   * wireNavFavorites) is subtracted too. The min(...) guard
   * keeps the page from collapsing to negative height on
   * absurdly small windows. */
  height: calc(100vh - 95px - var(--favbar-h));
  min-height: 360px;
  overflow: hidden;
  padding: 0;
}

[data-page="vol"] #vol-mount {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Loading / empty state */
.vol-empty {
  padding: 28px 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Header stats strip — sits above the chart grid. Each card is the
 * same chrome as the dashboard's `.dn-mc` metric cards so the
 * Volatility page reads consistent with Greeks Exposure / Net
 * Exposure Summary. */
.vol-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px;
  padding: 8px 8px 0;
  flex-shrink: 0;
}
.vol-stats .stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  display: flex; flex-direction: column; gap: 1px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.vol-stats .stat .lbl {
  font-size: 9.5px; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vol-stats .stat .val {
  font-size: 14px; font-weight: 700; color: var(--text);
  letter-spacing: -0.2px; line-height: 1.15;
  white-space: nowrap;
}
.vol-stats .stat .val.up    { color: var(--green); }
.vol-stats .stat .val.dn,
.vol-stats .stat .val.down  { color: var(--red); }
.vol-stats .stat .val.amber { color: var(--amber); }
.vol-stats .stat .val.ce    { color: #26a69a; }
.vol-stats .stat .val.pe    { color: #ef5350; }

/* Educational "what does this mean?" bar — sits between the stats
 * strip and the chart grid. Collapses to a single-line summary;
 * clicking expands the full primer. */
.vol-info {
  margin: 6px 8px 0;
  /* Theme-aware background — same as the page chrome below (panes
   * use var(--panel)), so the help bar reads as a transparent
   * accent rather than a filled block. Only the border + collapse
   * affordance separates it from the rest of the page. */
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
  overflow: hidden;
}
.vol-info summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 12px;
  display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.vol-info summary::-webkit-details-marker { display: none; }
.vol-info summary::before {
  content: '▸';
  color: var(--accent);
  font-size: 11px;
  transition: transform 0.15s ease;
}
.vol-info[open] summary::before { transform: rotate(90deg); }
.vol-info summary .vol-info-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
}
.vol-info summary .vol-info-t {
  font-weight: 600;
}
.vol-info summary .vol-info-s {
  color: var(--muted);
  font-weight: 400;
  font-size: 11.5px;
}
.vol-info-body {
  padding: 6px 14px 12px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  line-height: 1.45;
}
@media (max-width: 900px) {
  .vol-info-body { grid-template-columns: 1fr; }
}
.vol-info-body section {
  min-width: 0;
}
.vol-info-body h5 {
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--header-text);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.vol-info-body p {
  margin: 4px 0;
  color: var(--text);
  font-size: 11.5px;
}
.vol-info-body .vol-info-tag {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}
.vol-info-body .vol-info-tag.up   { border-color: var(--green); color: var(--green); }
.vol-info-body .vol-info-tag.dn   { border-color: var(--red);   color: var(--red); }
.vol-info-body .vol-info-tag.flat { border-color: var(--amber); color: var(--amber); }
.vol-info-body ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.vol-info-body li {
  margin-bottom: 3px;
  font-size: 11.5px;
}

/* 2-column split. Below 1100px stacks vertically. */
.vol-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1100px) {
  .vol-grid { grid-template-columns: 1fr; }
}

.vol-pane {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 0;
  min-width: 0;
}
.vol-pane-hd {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  flex-shrink: 0;
}
.vol-pane-hd h4 {
  margin: 0;
  font-size: 13px; font-weight: 600;
  color: var(--header-text);
  letter-spacing: -0.005em;
  margin-right: auto;
}
.vol-pane-hd .sm-lbl {
  font-size: 11px; color: var(--muted);
  margin-right: 4px;
}
.vol-pane .vol-canvas-wrap {
  flex: 1;
  /* Some browsers + Chart.js + parent flex layouts collapse the
   * canvas wrap to 0 px before the first render. A modest min-
   * height guarantees the chart actually draws on the first paint;
   * once the wrap measures > 0 the flex:1 takes over. */
  min-height: 280px;
  position: relative;
}
.vol-pane canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* StrikePicker host — give the dropdown trigger a min-width
 * so the price+ATM tag don't squish. */
.vol-pane-hd .vol-strike-host { display: inline-flex; }
.vol-pane-hd .vol-strike-host .sp-btn { min-width: 110px; }
