/* Dashboard: four chart panels locked to the viewport. Shared chrome and
   components come from site.css; the page width (82%) is set there too. */

.dashboard-page .site-header { margin-bottom: 12px; }

/* ---------- ticker tape ---------- */
.ticker-strip {
  flex: 0 0 auto;
  /* The widget lays out at 104px: symbol row, price row, then an attribution
     line. 76px shows symbol and price whole and clips only the attribution. */
  height: 76px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--bezel), var(--shadow-sm);
  animation: rise-in 0.45s var(--ease) 0.05s both;
}
.ticker-strip tv-ticker-tape { flex: 1; width: 100%; height: 100%; }

/* ---------- the grid ---------- */
.tradingview-grid {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  height: 100%;
  width: 100%;
  position: relative;
}
.tradingview-grid.show { display: grid; }

.tv-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--bezel), var(--shadow-sm);
  transition: border-color 0.2s var(--ease);
  animation: rise-in 0.5s var(--ease) both;
}
.tv-panel:nth-of-type(1) { animation-delay: 0.08s; }
.tv-panel:nth-of-type(2) { animation-delay: 0.12s; }
.tv-panel:nth-of-type(3) { animation-delay: 0.16s; }
.tv-panel:nth-of-type(4) { animation-delay: 0.2s; }
/* No lift on hover: each panel holds a live chart or a third-party iframe, and
   moving it would only buy a repaint. */
.tv-panel:hover { border-color: var(--border-strong); }

.tv-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0));
}

/* the symbol field: an input with its search glyph drawn inside it */
.tv-symbol-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}
.tv-symbol-field .icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.tv-symbol-field input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding-left: 33px;
  font-size: 13px;
}
.tv-symbol-field:focus-within .icon { color: var(--accent); }

.tv-panel-header button { height: 34px; flex: 0 0 auto; }
.tv-panel-header .icon-btn { width: 34px; color: var(--text-muted); }
.tv-panel-header .icon-btn:hover { color: var(--text); }

.ticker-select-trigger {
  position: relative;
  justify-content: flex-start;
  width: 190px;
  padding: 0 30px 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}
.ticker-select-trigger::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.6px solid var(--text-faint);
  border-bottom: 1.6px solid var(--text-faint);
  translate: 0 -70%;
  rotate: 45deg;
  transition: rotate 0.15s var(--ease), translate 0.15s var(--ease);
}
.ticker-select-trigger[aria-expanded='true'] {
  border-color: var(--accent-border);
  box-shadow: var(--bezel), var(--focus-ring);
}
.ticker-select-trigger[aria-expanded='true']::after { rotate: 225deg; translate: 0 -20%; }

/* theater toggle: one of two glyphs, chosen by its pressed state */
.dashboard-theater-toggle-btn .icon-collapse { display: none; }
.dashboard-theater-toggle-btn[aria-pressed='true'] { color: var(--accent); border-color: var(--accent-border); }
.dashboard-theater-toggle-btn[aria-pressed='true'] .icon-expand { display: none; }
.dashboard-theater-toggle-btn[aria-pressed='true'] .icon-collapse { display: block; }

/* ---------- chart surface ---------- */
.tv-widget {
  position: relative;
  flex: 1;
  min-height: 280px;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
}
.tradingview-widget-container {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  display: block !important;
  background-color: var(--surface) !important;
}
.tv-widget iframe {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  visibility: visible !important;
  opacity: 1 !important;
  border: 0 !important;
  background: transparent !important;
  z-index: 1 !important;
}

/* the price readout floating over each chart (built in dashboard-widgets.js) */
.chart-readout {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 8px 12px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: color-mix(in srgb, var(--well) 72%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}
.chart-readout-symbol {
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.chart-readout-symbol small { margin-left: 6px; color: var(--text-faint); font-size: 11px; font-weight: 500; }
.chart-readout-price {
  margin-top: 3px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chart-readout-price.up { color: var(--fresh); }
.chart-readout-price.down { color: var(--hangup); }

.chart-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 20;
  max-width: calc(100% - 20px);
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 12px;
  text-align: center;
  translate: -50% 0;
  box-shadow: var(--shadow-md);
  transition: opacity 0.3s var(--ease);
}
.chart-notice.is-leaving { opacity: 0; }

/* ---------- menus ---------- */
.ticker-overlay-menu,
.dashboard-theater-menu {
  position: fixed;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
}
.ticker-overlay-menu {
  z-index: 48;
  min-width: 360px;
  max-width: 520px;
  max-height: calc((var(--ticker-visible-rows, 6) * 38px) + 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.ticker-overlay-menu[hidden],
.dashboard-theater-menu[hidden] { display: none; }
.ticker-overlay-group-header {
  grid-column: 1 / -1;
  padding: 6px 4px 2px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ticker-overlay-option {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  justify-content: flex-start;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticker-overlay-option:hover { border-color: transparent; background: var(--light-soft); }
.ticker-overlay-option.is-active { background: var(--accent-soft); color: var(--accent-bright); }
.ticker-overlay-row { display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: center; gap: 4px; }
.ticker-overlay-row .ticker-overlay-option { min-width: 0; }
.ticker-overlay-delete {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-faint);
}
.ticker-overlay-delete:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--hangup) 14%, transparent);
  color: var(--hangup);
}

.dashboard-theater-menu {
  z-index: 42;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
}
.dashboard-theater-menu-btn {
  width: 100%;
  height: 34px;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.dashboard-theater-menu-btn:hover { border-color: transparent; background: var(--light-soft); }

/* ---------- theater mode ---------- */
body.dashboard-theater-mode { padding: 0; background: #000; }
body.dashboard-theater-mode > .page { width: 100vw !important; max-width: none !important; height: 100dvh; margin: 0; }
body.dashboard-theater-mode .site-header,
body.dashboard-theater-mode .ticker-strip { display: none; }
body.dashboard-theater-mode .main { overflow: visible; }
body.dashboard-theater-mode .tradingview-grid { position: fixed; inset: 0; z-index: 30; gap: 1px; background: #000; }
body.dashboard-theater-mode .tv-panel { border: 0; border-radius: 0; box-shadow: none; }
body.dashboard-theater-scope-panel .tradingview-grid { display: block !important; }
body.dashboard-theater-scope-panel .tv-panel { display: none; }
body.dashboard-theater-scope-panel .tv-panel.dashboard-theater-target { display: flex; width: 100vw; height: 100dvh; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .ticker-select-trigger { width: 150px; }
}

/* One column of four charts cannot share a locked viewport - each would be left
   shorter than its own header - so below this the page scrolls and each chart
   gets a height it can be read at. */
@media (max-width: 900px) {
  body.dashboard-page { height: auto; min-height: 100vh; overflow-y: auto; }
  body.dashboard-page .page { height: auto; min-height: calc(100vh - 2 * var(--page-pad)); }
  body.dashboard-page .main { overflow: visible; }
  .tradingview-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; height: auto; }
  .tv-panel { height: auto; min-height: 400px; }
  /* forty symbols scrolling past at phone width is a blur that costs a third
     of the screen */
  .ticker-strip { display: none; }
}

@media (max-width: 520px) {
  .tv-panel-header { flex-wrap: wrap; }
  .tv-symbol-field { flex: 1 1 100%; }
  .ticker-select-trigger { flex: 1 1 auto; width: auto; }
  .ticker-overlay-menu { min-width: 0; }
}
