/* Palette matches sdsimmons.com global styles:
 *   body bg  #052437   | text      #b7d1c5
 *   links    #4ade80   | headings  #e2e8f0
 * so the embedded viewer looks native to the rest of the site.
 */
:root {
  --bg: #052437;
  --panel: #063047;
  --border: #0d4160;
  --text: #b7d1c5;
  --muted: #7fa391;
  --heading: #e2e8f0;
  --accent: #4ade80;
  --accent-hover: #b7d1c5;
  --red: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* Match the site body font stack exactly (Arial, sans-serif). Size bumped
   * from 14→16 to feel continuous with the Angular pages. */
  font-family: 'Arial', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 16px;
}
/* Match site h2/h3: bright near-white heading, bold weight. */
header h1 { font-size: 22px; margin: 0; font-weight: bold; color: var(--heading); }
header h1 a { color: var(--accent); text-decoration: underline; font-weight: bold; }
header h1 a:hover { color: var(--accent-hover); }
/* Meta info uses the site body text colour, not muted — same readability
 * contrast as paragraph copy elsewhere on the site. */
header #meta { color: var(--text); font-size: 14px; }
header #meta a { color: var(--accent); text-decoration: underline; font-weight: bold; }
header #meta a:hover { color: var(--accent-hover); }

#controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#controls button {
  background: var(--accent);
  border: 0;
  color: #052437;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}
#controls button:hover { background: var(--accent-hover); }
#scrubber {
  flex: 1;
  accent-color: var(--accent);
}
#now-label {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 110px;
}
#controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 6px;
  border-radius: 4px;
}

/* Use flex layout so main auto-fills available space without hardcoded heights */
main {
  display: grid;
  grid-template-columns: 38% 62%;
  grid-template-rows: repeat(3, 1fr);
  flex: 1;
  min-height: 0;
}
#left-col {
  display: grid;
  grid-row: 1 / span 3;
  /* Gource takes the top TWO rows (2/3 of main), evals panel takes the
   * bottom ONE row. This gives the animation more visual real estate while
   * still keeping evals-in-catalog visible alongside. */
  grid-template-rows: 2fr 1fr;
  overflow: hidden;
  min-height: 0;
}
#charts {
  grid-row: 1 / span 3;
}

#gource-pane {
  background: var(--panel);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
#chart-evals {
  background: var(--panel);
}
#video-status {
  position: absolute;
  top: 12px;
  left: 12px;
  color: var(--muted);
  font-size: 11px;
  background: rgba(0,0,0,0.5);
  padding: 4px 8px;
  border-radius: 3px;
  pointer-events: none;
  transition: opacity 0.25s;
}
#video-status.hidden { opacity: 0; }

/* Centered play overlay on the gource pane. Disappears once the user has
 * scrubbed or hit play for the first time (js toggles .hidden). */
#gource-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: #052437;
  border: 0;
  font-size: 32px;
  line-height: 80px;
  padding: 0;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  transition: opacity 0.2s, transform 0.15s;
  z-index: 2;
}
#gource-play-overlay:hover {
  background: var(--accent-hover);
  transform: translate(-50%, -50%) scale(1.05);
}
#gource-play-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
#gource-video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  /* Fill the pane completely — same visual weight as the chart-evals card
   * below (both span the full left column). Cropping the top/bottom black
   * margins of the source video is fine; the tree stays centered. */
  object-fit: cover;
}

#charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 0;
  overflow: hidden;
}
.chart {
  background: var(--panel);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Match site h3: bright heading colour, bold weight, normal casing, same
 * Arial as the rest of the site. */
.chart h3 {
  font-size: 13px;
  font-weight: bold;
  color: var(--heading);
  margin: 0 0 4px 0;
  letter-spacing: normal;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.chart h3::after {
  content: attr(data-unit);
  color: var(--text);
  font-weight: normal;
  font-size: 11px;
  opacity: 0.85;
}
.chart .legend {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text);
  margin: 0 0 4px 0;
  flex-wrap: wrap;
}
.chart .legend .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chart .legend .swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}
.chart .plot {
  flex: 1;
  min-height: 0;
  cursor: crosshair;
}
.chart .plot svg {
  width: 100%;
  height: 100%;
}

/* ----- Mobile / narrow screens: collapse to a single column. -----
 * On desktop, #left-col and #charts both span the full 3-row main grid
 * (grid-row: 1 / span 3) so they share the same row base. On mobile we need
 * to unwind that — stack everything vertically instead.
 */
@media (max-width: 900px) {
  html, body {
    overflow: auto;
    height: auto;
    display: block;  /* override desktop flex */
  }
  header { flex-wrap: wrap; }
  #controls { flex-wrap: wrap; }
  #scrubber { order: 100; flex-basis: 100%; }
  main {
    display: block;  /* unwind desktop grid */
    grid-template-columns: none;
    grid-template-rows: none;
    height: auto;
    flex: none;
  }
  #left-col {
    display: block;
    grid-row: auto;
    grid-template-rows: none;
    width: 100%;
  }
  /* Gource first, then evals — top 2 items on mobile, same reading order
   * the user explicitly asked for. */
  #gource-pane {
    height: 56vw;
    min-height: 240px;
    width: 100%;
  }
  #chart-evals {
    height: 220px;
    width: 100%;
  }
  #charts {
    display: grid;
    grid-row: auto;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, 220px);
    overflow: visible;
    width: 100%;
  }
  .chart { padding: 8px 12px; }
}

