/* Shared timeline presentation. Data transforms remain in app.js/chart-ui.js. */

/* Canonical time-range control. Only real temporal selectors opt into this
   component; conceptual filters deliberately retain their own visual language. */
.time-range-tabs {
  --time-range-columns: 5;
  display: grid;
  grid-template-columns: repeat(var(--time-range-columns), minmax(42px, 1fr));
  width: 100%;
  min-width: 0;
  gap: 2px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  scrollbar-width: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.time-range-tabs::-webkit-scrollbar { display: none; }
.time-range-tabs--3 { --time-range-columns: 3; }
.time-range-tabs--5 { --time-range-columns: 5; }
.time-range-tabs--8 { --time-range-columns: 8; }
.time-range-tabs .timeline-filter-btn {
  position: relative;
  display: inline-flex;
  min-width: 42px;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  scroll-snap-align: start;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted-2);
  font-size: .76rem;
  font-weight: 750;
  white-space: nowrap;
  transition: color var(--transition-fast), box-shadow var(--transition-fast);
}
.time-range-tabs .timeline-filter-btn:hover {
  border: 0;
  background: transparent;
  color: var(--text);
}
.time-range-tabs .timeline-filter-btn[aria-pressed="true"] {
  border: 0;
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--accent);
  color: var(--text);
}
.time-range-tabs .timeline-filter-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tv-page-head .time-range-tabs,
.symbol-trading-head .time-range-tabs {
  flex: 0 1 31rem;
  max-width: 31rem;
  margin-left: auto;
}
.timeline-control-row > .time-range-tabs { flex: 1 1 27rem; max-width: 36rem; }
.symbol-tendency-head .time-range-tabs { width: min(100%, 22rem); }
.symbol-timing-panel > .time-range-tabs { width: min(100%, 16rem); }
.portfolio-chart-head .time-range-tabs { width: 100%; }
.portfolio-mobile-ranges.time-range-tabs { margin-bottom: 10px; }

.symbol-tab-panel.timeline-split{display:flex;flex-direction:column;gap:14px}
.symbol-tab-panel.timeline-split .symbol-chart-card{order:1;padding:0;overflow:hidden;border-color:color-mix(in srgb,var(--accent) 22%,var(--border))}
.symbol-tab-panel.timeline-split .timeline-ranges-card{order:2}
.symbol-chart-overview{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:20px;align-items:start;padding:14px 22px 12px;border-bottom:1px solid var(--hairline)}
.symbol-chart-overview-copy{display:grid;gap:5px;min-width:0}
.symbol-chart-overview h2{margin:0;color:var(--text);font-size:clamp(1rem,1.4vw,1.2rem);letter-spacing:-.03em}
.symbol-chart-overview p{margin:0;color:var(--muted);font-size:.78rem}
.symbol-chart-current{display:grid;grid-template-columns:auto auto;gap:2px 12px;align-items:baseline;text-align:right}
.symbol-chart-current>span:first-child{grid-column:1/-1;color:var(--muted-2);font-size:.65rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
.symbol-chart-current strong{font-size:clamp(1.15rem,2vw,1.55rem);font-variant-numeric:tabular-nums;letter-spacing:-.04em}
.symbol-chart-current em{font-style:normal;font-size:.8rem;font-weight:750;font-variant-numeric:tabular-nums}
.symbol-chart-current em.positive{color:var(--positive)}.symbol-chart-current em.negative{color:var(--negative)}
.symbol-chart-current small{grid-column:1/-1;color:var(--muted);font-size:.72rem;font-variant-numeric:tabular-nums}
.symbol-chart-card>.timeline-control-row{margin:0;padding:10px 22px 6px}
.symbol-chart-card>.timeline-pit-note{padding:0 22px}
/* Ranges pick the window; everything on this side changes what is drawn in it. */
.timeline-control-side{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:12px 16px}
.timeline-chart-legend{gap:16px}.timeline-chart-legend span{font-size:.72rem}
.timeline-pit-note{margin:0;overflow-wrap:anywhere;color:var(--muted-2);font-size:.68rem;line-height:1.45}
.timeline-pit-note[data-state="warning"]{color:var(--warning)}
/* One owner for the chart's height: the shell. Both children stretch to it and set no
   floor of their own, so the flex parent can size the plot to whatever the card has left.
   The competing `min-height` here is what made the SVG taller than its slot. */
.symbol-chart-card .timeline-chart-shell{margin:18px 0 4px}
/* The frame is the grid cell; the chart fills it out of flow. Out of flow is the
   point: in flow its viewBox ratio sets a minimum height of width/3, which the
   card's min-content then inherits and the panel has to scroll to fit. */
.timeline-chart-frame{position:relative;min-height:0;min-width:0}
.symbol-chart-card .timeline-chart{position:absolute;inset:0;width:100%;height:100%}
.symbol-chart-card .timeline-y-axis{height:100%;min-height:0}
/* The date row places each label at a percentage of its OWN width, so it only lands on
   the gridlines while it spans exactly the box the plot spans. Both run edge to edge at
   every width — the breathing room comes from the chart's own padX, inside the SVG. */
.symbol-chart-card .timeline-axis{padding-bottom:9px}
.timeline-price-area{fill:url(#symbol-price-area);pointer-events:none}
.timeline-price-line{fill:none;stroke:var(--chart-line);stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round;vector-effect:non-scaling-stroke;pointer-events:none}
.timeline-chart-grid{stroke:var(--hairline);stroke-width:1;vector-effect:non-scaling-stroke;pointer-events:none}
.timeline-hover-surface:focus{outline:none}.timeline-hover-surface:focus-visible{stroke:var(--accent);stroke-width:2;stroke-dasharray:6 5}
.timeline-hover-tooltip{min-width:min(310px,calc(100vw - 24px));max-width:340px;gap:7px;white-space:normal}
.timeline-tooltip-values{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px 12px}
.timeline-tooltip-values span{display:flex;justify-content:space-between;gap:10px}
.timeline-tooltip-values b{color:var(--text);font-weight:750;font-variant-numeric:tabular-nums}
.timeline-tooltip-change{font-size:.72rem!important}.timeline-tooltip-change.positive{color:var(--positive)}.timeline-tooltip-change.negative{color:var(--negative)}

.performance-chart-summary{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))}
.performance-metric-tabs [data-performance-metric="all"]{font-weight:800}
.performance-series-legend{display:flex;flex-wrap:wrap;gap:7px;margin:0 0 10px}
.performance-legend-button{display:inline-flex;align-items:center;gap:7px;min-height:32px;padding:5px 9px;border:1px solid var(--hairline);border-radius:999px;background:var(--surface-2);color:var(--muted);font-size:.68rem;font-weight:750;cursor:pointer}
.performance-legend-button::before{content:"";width:15px;height:3px;border-radius:2px;background:var(--series-color)}
.performance-legend-button[aria-pressed="false"]{opacity:.48;text-decoration:line-through}
.performance-line{stroke:var(--series-color,var(--accent));stroke-dasharray:var(--series-dash,none);vector-effect:non-scaling-stroke}
.performance-focus-dot{fill:var(--surface);stroke:var(--series-color);stroke-width:2.4;vector-effect:non-scaling-stroke;pointer-events:none}
.performance-crosshair{stroke:var(--accent);stroke-width:1.2;stroke-dasharray:5 5;opacity:.62;vector-effect:non-scaling-stroke;pointer-events:none}
.performance-hover-surface{fill:transparent;touch-action:pan-y;cursor:crosshair}
.performance-hover-surface:focus{outline:none}.performance-hover-surface:focus-visible{stroke:var(--accent);stroke-width:2;stroke-dasharray:6 5}
.performance-tooltip{min-width:190px;max-width:280px;padding:10px 11px}
.performance-tooltip-time{display:block;margin-bottom:7px;color:var(--muted);font-size:.68rem}
.performance-tooltip-values{display:grid;gap:5px}
.performance-tooltip-row{display:grid;grid-template-columns:10px minmax(0,1fr) auto;gap:7px;align-items:center}
.performance-tooltip-row i{width:8px;height:8px;border-radius:50%;background:var(--series-color)}
.performance-tooltip-row b{font-variant-numeric:tabular-nums}
.performance-tooltip-live{display:block;margin-top:7px;color:var(--accent-strong);font-size:.62rem;font-weight:750}

@media(max-width:640px){
  .tv-page-head .time-range-tabs { order: 3; }
  .tv-page-head .time-range-tabs,
  .symbol-trading-head .time-range-tabs,
  .timeline-control-row > .time-range-tabs,
  .symbol-tendency-head .time-range-tabs,
  .symbol-timing-panel > .time-range-tabs {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    margin-left: 0;
  }
  .symbol-chart-overview{grid-template-columns:minmax(0,1fr);gap:11px;padding:13px 14px 11px}
  .symbol-chart-current{text-align:left;justify-content:start}
  .symbol-chart-card>.timeline-control-row{padding:10px 14px 6px}
  .symbol-chart-card>.timeline-pit-note{padding:0 14px}
  .timeline-control-side{justify-content:flex-start}
  .symbol-chart-card .timeline-chart-shell{grid-template-columns:minmax(0,1fr) 55px;gap:5px;margin:16px 0 4px;min-height:250px}
  .symbol-chart-card .timeline-axis{grid-template-columns:minmax(0,1fr) 55px;gap:5px;font-size:.68rem}
  .timeline-hover-tooltip{position:fixed;left:12px!important;right:12px;bottom:12px;top:auto!important;transform:none;max-width:none;min-width:0}
  .performance-series-legend{flex-wrap:nowrap;overflow-x:auto;padding-bottom:2px;scrollbar-width:none}
  .performance-tooltip{left:8px!important;right:8px;top:8px!important;max-width:none}
}

@media(prefers-reduced-motion:reduce){
  .time-range-tabs .timeline-filter-btn{transition:none}
  .timeline-price-line,.performance-line,.timeline-hover-guide,.performance-crosshair{transition:none!important}
}
