/* ═══════════════════════════════════════════
   PDOOM story graph
   One series, so one ink: dots are light, filtered-out dots are dim,
   and red is kept for "now" and for the dot being read.
   ═══════════════════════════════════════════ */

.sg {
  --sg-surface: var(--bg-primary);
  --sg-dot: var(--text-primary);
  --sg-dot-off: #4a4a62;
  --sg-line: var(--text-muted);
  --sg-tick: #9a9ab0;
  max-width: 1052px; margin: 0 auto 18px;
  padding: 20px 20px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--sg-surface);
}

/* ── Heading, lede, time windows ── */
.sg-head {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 12px; margin-bottom: 14px;
}
.sg-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text-primary); margin-bottom: 4px;
}
.sg-lede {
  font-family: 'Crimson Pro', serif;
  font-size: 18px; line-height: 1.45;
  color: var(--text-secondary);
}
.sg-lede strong { color: var(--text-primary); font-weight: 600; }

.sg-ranges { display: flex; flex-wrap: wrap; gap: 6px; }
.sg-range {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.3px; text-transform: uppercase;
  min-height: 36px; padding: 4px 12px; border-radius: 18px;
  border: 1px solid var(--border-light);
  background: transparent; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.sg-range:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.sg-range.active { border-color: var(--accent-red); background: rgba(230,57,70,.12); color: var(--text-primary); }
.sg-range-count { margin-left: 2px; color: var(--text-muted); }
.sg-range.active .sg-range-count { color: var(--text-secondary); }
.sg-range:focus-visible, .sg-detail-open:focus-visible, .sg-plot:focus-visible { outline: 2px solid var(--accent-red); outline-offset: 2px; }

/* ── Plot ── */
.sg-axis-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 2px;
}
.sg-plot { border-radius: 6px; }
.sg-plot:focus:not(:focus-visible) { outline: none; }
.sg-plot--aim { cursor: pointer; }
.sg-svg { display: block; width: 100%; height: auto; overflow: visible; }

.sg-grid, .sg-era-line { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.sg-axis { stroke: var(--border-light); stroke-width: 1; shape-rendering: crispEdges; }
.sg-tick { font-family: 'JetBrains Mono', monospace; font-size: 10px; fill: var(--sg-tick); }
.sg-era { font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.6px; fill: var(--text-muted); }
.sg-empty { font-family: 'JetBrains Mono', monospace; font-size: 12px; fill: var(--text-secondary); }

.sg-area { fill: var(--sg-dot); opacity: 0.05; }
.sg-line { fill: none; stroke: var(--sg-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sg-leader { stroke: var(--sg-dot-off); stroke-width: 1; }

/* The stroke is a 2px ring in the surface colour, so stacked dots stay separate. */
.sg-dot { fill: var(--sg-dot); stroke: var(--sg-surface); stroke-width: 2; }
.sg-dot--off { fill: var(--sg-dot-off); }
.sg-dot--now { fill: var(--accent-red); }
.sg-ring { fill: none; stroke: var(--accent-red); stroke-width: 2; pointer-events: none; }
.sg-pulse {
  fill: none; stroke: var(--accent-red); stroke-width: 2;
  transform-box: fill-box; transform-origin: center;
  animation: sg-pulse 2.6s ease-out infinite;
}
@keyframes sg-pulse {
  0% { transform: scale(1); opacity: 0.75; }
  70%, 100% { transform: scale(3); opacity: 0; }
}

.sg-label {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  fill: var(--text-secondary);
  paint-order: stroke; stroke: var(--sg-surface); stroke-width: 3px; stroke-linejoin: round;
}
.sg--narrow .sg-label { font-size: 10px; }
.sg-label-year { fill: var(--text-muted); }
.sg-label--now { fill: var(--text-primary); font-weight: 600; }

/* ── The milestone being read ── */
.sg-detail {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 4px 16px;
  min-height: 84px; margin-top: 10px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-card);
}
.sg-detail-hint {
  grid-column: 1 / -1;
  font-family: 'Crimson Pro', serif; font-size: 16px; font-style: italic;
  color: var(--text-secondary);
}
.sg-detail-meta {
  grid-column: 1;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--text-secondary);
}
.sg-detail-tag {
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.8px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 3px;
}
.sg-detail-impact { font-size: 9px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--sg-tick); }
.sg-detail-title {
  grid-column: 1;
  font-family: 'Space Grotesk', 'JetBrains Mono', sans-serif;
  font-size: 16px; font-weight: 600; line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sg-detail-open {
  grid-column: 2; grid-row: 1 / span 2;
  min-height: 36px; padding: 0 14px;
  border: 1px solid #a85060; border-radius: 5px;
  background: #57243433; color: #ff9da8;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  cursor: pointer; white-space: nowrap;
}
.sg-detail-open:hover { background: #57243466; }

/* ── Size key and the note on what the line is ── */
.sg-foot {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: 8px 24px; margin-top: 12px;
}
.sg-sizes {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--text-secondary);
}
.sg-sizes-label { color: var(--sg-tick); }
.sg-size { display: inline-flex; align-items: center; gap: 6px; }
.sg-size-dot { display: inline-block; border-radius: 50%; background: var(--sg-dot); }
.sg-size-dot--1 { width: 8px; height: 8px; }
.sg-size-dot--2 { width: 11px; height: 11px; }
.sg-size-dot--3 { width: 17px; height: 17px; }
.sg-note {
  max-width: 520px;
  font-family: 'Crimson Pro', serif; font-size: 14px; font-style: italic; line-height: 1.45;
  color: var(--sg-tick);
}

.sg-live {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 600px) {
  .sg { padding: 14px 12px 12px; }
  .sg-title { font-size: 17px; }
  .sg-lede { font-size: 16px; }
  .sg-ranges { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .sg-ranges::-webkit-scrollbar { display: none; }
  .sg-range { min-height: 44px; flex: 0 0 auto; }
  .sg-detail { grid-template-columns: 1fr; min-height: 138px; align-content: start; }
  .sg-detail-open { grid-column: 1; grid-row: auto; min-height: 44px; margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .sg-pulse { animation: none; opacity: 0; }
}

@media (forced-colors: active) {
  .sg-dot, .sg-size-dot { fill: CanvasText; background: CanvasText; stroke: Canvas; }
  .sg-dot--off { fill: GrayText; }
  .sg-dot--now, .sg-ring, .sg-pulse { fill: Highlight; stroke: Highlight; }
  .sg-ring, .sg-pulse { fill: none; }
  .sg-line, .sg-axis, .sg-grid, .sg-era-line, .sg-leader { stroke: CanvasText; }
  .sg-tick, .sg-era, .sg-label, .sg-label-year, .sg-empty { fill: CanvasText; stroke: none; }
}
