/* =========================================================
   OVERVIEW PAGE — overview.css
   Scoped styles for /overview. Does not touch main page.
   ========================================================= */

/* Allow vertical scroll on overview (main page locks it on desktop) */
@media (min-width: 900px) {
  body:has(.ov-grid) {
    overflow: auto !important;
    height: auto !important;
  }

  html:has(.ov-grid) {
    overflow: auto !important;
    height: auto !important;
  }
}

/* ── Navbar extras ───────────────────────────────────────── */
.navbar-back {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 16px;
  line-height: 1;
  margin-right: 2px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.navbar-back:hover { color: var(--accent); }

.navbar-sep {
  color: var(--border);
  font-size: 13px;
  margin: 0 4px;
  flex-shrink: 0;
}

.navbar-page {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ── Overview nav link (injected into main navbar) ───────── */
.navbar-overview-link {
  margin-left: auto;          /* push to the right */
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.navbar-overview-link:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.navbar-overview-link .nav-arrow {
  font-size: 9px;
  opacity: 0.6;
}

/* ── Period toggle ───────────────────────────────────────── */
.ov-controls {
  display: flex;
  align-items: center;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border-sub);
  background: var(--surface);
  position: sticky;
  top: 52px;   /* height of navbar */
  z-index: 50;
}

.ov-period-group {
  display: flex;
  gap: 4px;
}

.ov-period-btn {
  padding: 5px 12px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.15s;
}
.ov-period-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.ov-period-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Chart grid ──────────────────────────────────────────── */
.ov-grid {
  display: grid;
  padding: 16px;
  gap: 10px;

  /* 2 columns on very small phones */
  grid-template-columns: repeat(2, 1fr);
}

/* ~360px+: still 2 col but a bit more breathing room */
@media (min-width: 360px) {
  .ov-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ~560px: 3 columns */
@media (min-width: 560px) {
  .ov-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ~7-inch tablet / large phone ≈ 600-700px → 4 columns (≈8 visible) */
@media (min-width: 630px) {
  .ov-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Small desktop / large tablet */
@media (min-width: 900px) {
  .ov-grid {
    padding: 16px 20px;
    gap: 10px;
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Medium desktop */
@media (min-width: 1100px) {
  .ov-grid { grid-template-columns: repeat(5, 1fr); }
}

/* Wide desktop */
@media (min-width: 1380px) {
  .ov-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ── Single overview chart card ──────────────────────────── */
.ov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* NO overflow:hidden — would clip the floating popover */
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
  min-width: 0; /* prevent grid blowout */
}
.ov-card:hover { border-color: var(--accent); }

/* Ticker header row */
.ov-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 4px;
  gap: 4px;
  flex-shrink: 0;
}

.ov-ticker-symbol {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 18px);
}

/* Info icon — the ⓘ trigger */
.ov-info-icon {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
  transition: color 0.12s;
  padding: 1px 2px;
}
.ov-info-icon:hover { color: var(--accent); }

/* ── Body-level floating popover (positioned by JS) ─────── */
#ov-popover {
  position: fixed;
  z-index: 9999;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 230px;
  min-width: 140px;
  box-shadow: 0 6px 24px rgba(0,0,0,.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  white-space: normal;
}
#ov-popover.visible { opacity: 1; }

/* Price + change line */
.ov-card-price {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 8px 4px;
  flex-shrink: 0;
}
.ov-price-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.ov-price-chg {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.ov-price-chg.up   { color: var(--green); }
.ov-price-chg.down { color: var(--red);   }
.ov-price-chg.flat { color: var(--text-dim); }

/* Canvas wrapper with fixed aspect ratio */
.ov-canvas-wrap {
  position: relative;
  width: 100%;
  /* ~285×155 natural size → ratio 285/155 ≈ 1.84 */
  padding-bottom: 54%;
  flex-shrink: 0;
}
.ov-canvas-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Loading / error states */
.ov-card-status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 16px 8px;
  font-style: italic;
}
.ov-card-status.error { color: var(--red); }
