/* Steam-inspired dark theme.
   Palette references: #1b2838 main bg, #171a21 deep bg (header/footer),
   #2a3f5a elevated surfaces, #66c0f4 iconic accent blue, #c7d5e0 default
   text, #8f98a0 muted text. */

:root {
  --bg: #1b2838;
  --bg-elevated: #2a3f5a;
  --bg-deep: #171a21;
  --bg-input: #316282;

  --fg: #c7d5e0;
  --fg-bright: #ffffff;
  --muted: #8f98a0;
  --muted-strong: #c7d5e0;

  --accent: #66c0f4;
  --accent-bright: #1a9fff;

  --border: #3d4a5e;
  --border-strong: #4b6479;

  --max-width: 1200px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  /* Motiva Sans is Steam's house font (hot-linked in index.html); Source Sans 3
     is the closest open-source match and serves as the reliable fallback when
     Steam's font CSS doesn't resolve cross-origin. System sans rounds it out. */
  font-family: "Motiva Sans", "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); text-decoration: underline; }

em { color: var(--fg-bright); font-style: italic; }
strong { color: var(--fg-bright); }

/* ---------- Hero ---------- */

.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 5rem 1.5rem 3rem;
  animation: hero-fade-in 900ms ease-out 100ms backwards;
}

@keyframes hero-fade-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero h1 {
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
  color: var(--fg-bright);
  text-align: center;
}

.hero__intro {
  font-size: 1.125rem;
  color: var(--fg);
  margin: 0 auto;
  max-width: 720px;
  line-height: 1.65;
}

/* ---------- Scene scaffold ---------- */

.scene {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

/* Scrollama-driven scene entrance.
   When body.has-scrollama is set (main.js verified scrollama loaded), each
   scene starts hidden and slid down 32px, then fades and slides into place
   when the scrollama trigger fires (.scene--in-view class).
   Without body.has-scrollama (graceful fallback), scenes are always visible. */
body.has-scrollama .scene {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 750ms ease-out, transform 750ms ease-out;
  will-change: opacity, transform;
}

body.has-scrollama .scene.scene--in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Children stagger inside the scene for a small cascade — title first,
   then viz, then footnote — once the scene is in view. */
body.has-scrollama .scene .scene__intro,
body.has-scrollama .scene .scene__viz,
body.has-scrollama .scene .scene__footnote {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms ease-out, transform 600ms ease-out;
}

body.has-scrollama .scene--in-view .scene__intro {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 80ms;
}

body.has-scrollama .scene--in-view .scene__viz {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 220ms;
}

body.has-scrollama .scene--in-view .scene__footnote {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 360ms;
}

.scene__intro {
  max-width: 720px;
  margin: 0 auto 2rem;
}

.scene__title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.75rem;
  color: var(--fg-bright);
}

.scene__lead {
  font-size: 1.1rem;
  color: var(--fg);
  margin: 0;
}

.scene__viz {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1.5rem 1rem;
  margin: 0 auto;
  position: relative;
}

.scene__footnote {
  max-width: 720px;
  margin: 1.5rem auto 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* ---------- Scene 1: The Flood ---------- */

.flood-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.flood-controls__group {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.flood-controls__label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

.flood-controls__btn {
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--fg);
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.flood-controls__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.flood-controls__btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-deep);
}

.flood-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.flood-chart .axis text {
  font-size: 11px;
  fill: var(--muted-strong);
  font-family: inherit;
}

.flood-chart .axis-label {
  font-size: 12px;
  fill: var(--muted);
}

.flood-chart .annotation-label {
  font-size: 11px;
  fill: var(--muted-strong);
  font-weight: 500;
}

.flood-legend {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.flood-legend__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-strong);
  margin-bottom: 0.5rem;
}

.flood-legend__items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.4rem 1rem;
}

.flood-legend__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg);
}

.flood-legend__swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.flood-legend__label {
  font-weight: 600;
}

.flood-legend__def {
  color: var(--muted);
  font-size: 0.8rem;
}

.flood-tooltip {
  position: absolute;
  z-index: 10;
  max-width: 360px;
  padding: 0.6rem 0.8rem;
  background: var(--bg-deep);
  color: var(--fg-bright);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 0.82rem;
  line-height: 1.4;
  pointer-events: none;
}

.flood-tooltip[hidden] { display: none; }

.flood-tooltip__title {
  font-weight: 700;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-bright);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.flood-tooltip__body {
  color: var(--fg);
}

.flood-tooltip__rows {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 0.25rem 0.7rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.flood-tooltip__swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.flood-tooltip__row-label {
  font-weight: 500;
  color: var(--fg-bright);
}

.flood-tooltip__row-count,
.flood-tooltip__row-pct {
  text-align: right;
  color: var(--fg);
}

.flood-tooltip__row-pct {
  min-width: 3em;
}

/* ---------- Scene 2: The Indie Wave ---------- */

.indie-wave-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.indie-wave-chart .axis text {
  font-size: 11px;
  fill: var(--muted-strong);
  font-family: inherit;
}

.indie-wave-chart .axis-label {
  font-size: 12px;
  fill: var(--muted);
}

.indie-wave-chart .indie-line {
  transition: stroke 200ms ease, stroke-width 200ms ease;
}

.indie-wave-chart .line-label {
  font-family: inherit;
  transition: fill 200ms ease, font-weight 200ms ease;
}

.indie-wave-chart .line-label:hover {
  fill: var(--accent) !important;
}

.indie-wave-tooltip {
  position: absolute;
  z-index: 10;
  padding: 0.6rem 0.8rem;
  background: var(--bg-deep);
  color: var(--fg-bright);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 0.82rem;
  line-height: 1.4;
  pointer-events: none;
  min-width: 200px;
}

.indie-wave-tooltip[hidden] { display: none; }

.indie-wave-tooltip__title {
  font-weight: 700;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-bright);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.indie-wave-tooltip__rows {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.2rem 0.7rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.indie-wave-tooltip__row-name {
  color: var(--fg);
}

.indie-wave-tooltip__row-value {
  text-align: right;
  color: var(--fg);
}

.indie-wave-tooltip__row-name.is-selected,
.indie-wave-tooltip__row-value.is-selected {
  color: var(--fg-bright);
  font-weight: 700;
}

/* ---------- Scene 4: Find Your Game ---------- */

.find-your-game {
  position: relative;
}

.fyg-search {
  position: relative;
  margin-bottom: 0.5rem;
}

.fyg-search__input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--fg-bright);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.fyg-search__input::placeholder {
  color: rgba(199, 213, 224, 0.55);
}

.fyg-search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 192, 244, 0.2);
}

.fyg-results {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: calc(0.5rem + 3.1rem);
  left: 1.5rem;
  right: 1.5rem;
  z-index: 5;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.fyg-results[hidden] { display: none; }

.fyg-result {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--fg);
}

.fyg-result:last-child { border-bottom: none; }
.fyg-result:hover { background: var(--bg-elevated); color: var(--fg-bright); }

.fyg-result__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fyg-result__year {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.fyg-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.fyg-suggestions__label {
  color: var(--muted);
  margin-right: 0.25rem;
}

.fyg-suggestion {
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--fg);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.fyg-suggestion:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-deep);
}

.fyg-suggestions__divider {
  color: var(--muted);
  margin: 0 0.25rem;
  font-size: 0.85rem;
}

.fyg-suggestion--random {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.fyg-suggestion--random:hover {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}

.fyg-detail__empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-style: italic;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.fyg-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.fyg-card__image {
  display: block;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 460 / 215;
  object-fit: cover;
  border-radius: 6px;
  margin: 0 auto 1rem;
  background: var(--bg-elevated);
}

.fyg-card__image.is-hidden { display: none; }

.fyg-card__header {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.fyg-card__name {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg-bright);
}

.fyg-card__meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.fyg-card__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.fyg-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.fyg-stat__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.fyg-stat__value {
  font-size: 0.95rem;
  color: var(--fg-bright);
}

.fyg-cohort { margin-top: 1rem; }

.fyg-cohort__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-strong);
  margin-bottom: 0.5rem;
}

.fyg-cohort__bar svg {
  display: block;
  width: 100%;
}

.fyg-cohort__legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.4rem 1rem;
  margin-top: 0.75rem;
}

.fyg-cohort__legend-item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg);
}

.fyg-cohort__legend-item.is-selected {
  font-weight: 700;
  color: var(--fg-bright);
}

.fyg-cohort__legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.fyg-cohort__legend-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- Scene placeholders (3, 5) ---------- */

.scene-placeholder {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  font-style: italic;
}

.scene-placeholder strong {
  display: block;
  font-style: normal;
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* ---------- Footer ---------- */

.footer {
  max-width: var(--max-width);
  margin: 4rem auto 0;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.footer p { margin: 0.25rem 0; }
