/* ============================================================
   ZONES.CSS — Quiet Phosphor zone differentiation
   Each data-zone overrides :root CSS variables from style.css
   Default (no data-zone) = green phosphor palette
   ============================================================ */

/* Collection — cool cyan (strengthened for perceptibility) */
[data-zone="collection"] {
  --text-primary:    #00dde0;
  --text-secondary:  #009499;
  --text-muted:      #5a9a9c;
  --text-value:      #33e0e5;
  --accent:          #00dde0;
  --accent-dim:      #005a5c;
  --border:          #1a3838;
  --bg-surface:      #030a0a;
  --bg-card:         #081212;
}

/* Qualification — warm amber (strengthened for perceptibility) */
[data-zone="qual"] {
  --text-primary:    #e0aa00;
  --text-secondary:  #997300;
  --text-muted:      #9a8a5a;
  --text-value:      #e5c533;
  --accent:          #e0aa00;
  --accent-dim:      #5c4a00;
  --border:          #38301a;
  --bg-surface:      #0a0803;
  --bg-card:         #121008;
}

/* Hub — neutral gray (strengthened for perceptibility) */
[data-zone="hub"] {
  --text-primary:    #b0b0b0;
  --text-secondary:  #909090;
  --text-muted:      #6a6a6a;
  --text-value:      #d0d0d0;
  --accent:          #b0b0b0;
  --accent-dim:      #484848;
  --border:          #333333;
  --bg-surface:      #080808;
  --bg-card:         #111111;
}

/* ============================================================
   REGION COLORS — Shared tokens for PAL/NTSC badges
   ============================================================ */
:root {
  --region-pal:        rgba(120, 220, 170, 0.9);
  --region-pal-dim:    rgba(80, 200, 150, 0.4);
  --region-ntsc-u:     rgba(120, 170, 255, 0.9);
  --region-ntsc-u-dim: rgba(80, 140, 255, 0.4);
  --region-ntsc-j:     rgba(255, 140, 120, 0.9);
  --region-ntsc-j-dim: rgba(255, 80, 80, 0.4);
  --region-ntsc-b:     rgba(255, 210, 100, 0.9);
  --region-ntsc-b-dim: rgba(220, 170, 50, 0.4);
  --region-multi:      rgba(200, 160, 255, 0.9);
  --region-multi-dim:  rgba(160, 100, 220, 0.4);

  --z-dropdown: 10;
  --z-modal:    100;
  --z-overlay:  900;
  --z-fixed:    1000;
  --z-top:      9999;
}

/* ============================================================
   HOVER — Quiet Phosphor micro-interactions
   Subtle border transitions. No glow, no scale, no shadow.
   ============================================================ */

/* Index game rows */
.result-row {
  transition: border-color 150ms ease;
}
.result-row:hover {
  border-color: var(--accent);
}

/* Collection rows */
.collection-row-main {
  transition: border-left-color 100ms ease;
  border-left: 2px solid transparent;
}
.collection-row-main:hover {
  border-left-color: var(--accent);
}

/* Cockpit signal cards */
.cockpit-signal-card {
  transition: border-color 150ms ease;
}
.cockpit-signal-card:hover {
  border-color: var(--accent);
}

/* Hub cards */
.hub-proof-card,
.hub-rich-card,
.hub-intent-card,
.hub-encyclo-card {
  transition: border-color 150ms ease;
}
.hub-proof-card:hover,
.hub-rich-card:hover,
.hub-intent-card:hover,
.hub-encyclo-card:hover {
  border-color: var(--accent);
}

/* ============================================================
   COMPLETION BAR — Collection progress
   ============================================================ */
.completion {
  margin-top: 8px;
  padding: 0 4px;
}
.completion-text {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-ui);
}
.completion-bar {
  height: 2px;
  background: var(--border);
  margin-top: 4px;
}
.completion-fill {
  height: 100%;
  background: var(--accent);
  transition: width 600ms ease-out;
  width: 0;
}

/* ============================================================
   CHROMA-01 — Reinforce dim text contrast (WCAG AA ~4.5:1)
   Override the too-dim defaults for readability
   ============================================================ */
:root {
  --text-muted:      #5a9a64;
  --text-secondary:  #33b050;
  --accent-dim:      #1a7a3a;
}
[data-zone="collection"] {
  --text-muted:      #5a9a9c;
  --text-secondary:  #33b0b5;
}
[data-zone="qual"] {
  --text-muted:      #9a8a5a;
  --text-secondary:  #b09333;
}
[data-zone="hub"] {
  --text-muted:      #6a6a6a;
  --text-secondary:  #909090;
}

/* ============================================================
   NAV-01 — Active tab indicator
   Strong bottom border on active nav link
   ============================================================ */
.global-product-link.is-active {
  border-bottom: 2px solid var(--accent) !important;
}
.global-product-nav.global-product-nav-unified .global-product-link.is-active {
  border-bottom: 2px solid var(--accent) !important;
}

/* Nav hover feedback */
.global-product-link {
  transition: background 100ms ease;
}
.global-product-link:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ============================================================
   TYPO-01 — Collection table column widths
   Prevent truncation of column labels
   ============================================================ */
.collection-row-main {
  min-width: 0;
}
.collection-row-main .surface-chip,
.collection-row-main .surface-signal-label {
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

/* ============================================================
   LAYOUT-02 — Uniform vertical rhythm
   Consistent section spacing across all pages
   ============================================================ */
.page-wrapper > section,
.page-wrapper > div,
.page-wrapper > .terminal-context,
.page-shell > section,
.detail-shell > section,
.detail-shell > .detail-accordion,
.secondary-page-shell > section {
  margin-bottom: var(--space-section, 24px);
}
.page-wrapper > section:empty,
.page-wrapper > div:empty,
.page-shell > section:empty,
.detail-shell > section:empty,
.detail-shell > [hidden],
.secondary-page-shell > section:empty {
  margin-bottom: 0;
}

/* ============================================================
   FEED-01 — Accordion transitions
   Smooth open/close with indicator rotation
   ============================================================ */
.detail-accordion-content {
  overflow: hidden;
  transition: max-height 200ms ease-out, opacity 150ms ease;
}
.detail-accordion-indicator {
  display: inline-block;
  transition: transform 200ms ease;
}
.detail-accordion[aria-expanded="true"] .detail-accordion-indicator,
.detail-accordion-toggle[aria-expanded="true"] .detail-accordion-indicator {
  transform: rotate(90deg);
}

/* ============================================================
   LAYOUT-01 — Collapse empty dynamic sections
   Sections waiting for content should not create black holes
   ============================================================ */
section[hidden],
div[hidden] {
  display: none !important;
}

/* Empty grid/list containers: collapse until populated */
.hub-rich-card:empty,
.hub-proof-grid:empty,
.terminal-empty-state {
  min-height: 0;
}

/* Prevent massive min-height on dynamic panels before content loads */
.detail-accordion-content[hidden] {
  display: none !important;
  min-height: 0;
  padding: 0;
  margin: 0;
}

/* Collapsed sections: no residual spacing */
.pass1-surface-banner[hidden],
.product-universe-overlap[hidden] {
  display: none !important;
  margin: 0;
  padding: 0;
}

/* ============================================================
   COHER-01 — Unify navigation
   Hide legacy site-nav, let global-product-nav handle all pages
   ============================================================ */
.site-nav-links {
  display: none !important;
}

/* ============================================================
   LOADING — Placeholder pulse for unhydrated values
   ============================================================ */
.hub-stat .val {
  transition: opacity 300ms ease;
}
@keyframes rdx-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}
.hub-stat .val:not(:empty) {
  animation: none;
}
/* "--" values pulse until JS replaces them */
.hub-stats .val {
  animation: rdx-pulse 2s ease-in-out infinite;
}
.hub-stats .val.is-loaded {
  animation: none;
  opacity: 1;
}

/* ============================================================
   COLLECTION EVOLUTION CHART
   ============================================================ */
.collection-evolution-shell {
  margin: 12px 0 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}
.collection-evolution-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}
.collection-evolution-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.collection-evolution-summary {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
}
.collection-evolution-chart {
  height: 120px;
  width: 100%;
}
.collection-evolution-chart svg {
  display: block;
}

/* ============================================================
   GAME-DETAIL — Decision grid: readable layout in aside panel
   ============================================================ */
.detail-decision-grid.surface-signal-grid.is-five {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.detail-decision-grid .surface-signal-label {
  font-size: 0.6rem;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.detail-decision-grid .surface-signal-card {
  padding: 6px 8px;
  min-height: 40px;
}

/* ============================================================
   BAZ ANECDOTE — Fun facts block on game-detail
   ============================================================ */
.baz-anecdote-card {
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  background: var(--bg-surface);
}
.baz-anecdote-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.baz-anecdote-sprite {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.baz-anecdote-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  font-weight: bold;
}
.baz-anecdote-intro {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.baz-anecdote-text {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0 0 8px;
}
.baz-anecdote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.baz-anecdote-next {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
  transition: border-color 150ms ease;
}
.baz-anecdote-next:hover {
  border-color: var(--accent);
}
.baz-anecdote-source {
  font-family: var(--font-ui);
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Game evolution mini-chart */
.game-evolution-shell {
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}
.game-evolution-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.game-evolution-shell svg {
  display: block;
  width: 100%;
}
.game-evolution-summary {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Glossary tooltip */
.rdx-gloss-tip {
  position: absolute;
  z-index: 900;
  max-width: 280px;
  padding: 6px 10px;
  background: var(--bg-card, #0a0f0a);
  border: 1px solid var(--accent, #00ff66);
  color: var(--text-primary, #00ff66);
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
  white-space: normal;
}
[data-rdx-term] {
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 2px;
  cursor: help;
}

/* ============================================================
   UX AUDIT FIXES — 2026-04-11
   ============================================================ */

/* FIX: Hub zone contrast — #6a6a6a → #7a7a7a for WCAG AA */
[data-zone="hub"] {
  --text-muted: #7a7a7a;
}

/* FIX: Cockpit grid — canonical override (7 conflicting defs in style.css) */
.collection-cockpit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.95fr);
  gap: 16px;
}
@media (max-width: 1100px) {
  .collection-cockpit-grid {
    grid-template-columns: 1fr;
  }
}

/* FIX: Collection table grid — moved from inline to CSS */
.collection-table-header {
  grid-template-columns: 12px 1fr 90px 60px 70px 70px 70px 70px 70px;
}
.collection-row-main {
  grid-template-columns: 12px 1fr 90px 60px 70px 70px 70px 70px 70px;
}

/* FIX: Touch targets minimum 44px on mobile */
@media (max-width: 768px) {
  .terminal-filter-btn {
    min-height: 44px;
    padding: 10px 12px;
  }
  .collection-action-group .btn,
  .btn {
    min-height: 44px;
    padding: 12px 16px;
  }
  .collection-toolbar-group {
    flex-wrap: wrap;
    gap: 6px;
  }
  .collection-toolbar-group > * {
    flex: 1 1 calc(50% - 6px);
    min-width: 120px;
  }
  /* FIX: Hide keyboard hints on mobile */
  .terminal-footer {
    display: none;
  }
  /* FIX: Collection table responsive — hide secondary columns */
  .collection-table-header,
  .collection-row-main {
    grid-template-columns: 12px 1fr 60px 70px 70px;
  }
  /* Hide CIB, MINT, SUPPORT columns on mobile */
  .collection-table-header [role="columnheader"]:nth-child(3),
  .collection-table-header [role="columnheader"]:nth-child(6),
  .collection-table-header [role="columnheader"]:nth-child(7) {
    display: none;
  }
  .collection-cell-console,
  .collection-cell-price:nth-of-type(2),
  .collection-cell-price:nth-of-type(3) {
    display: none;
  }
}

/* FIX: Disabled button styling */
.btn:disabled, .btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* FIX: Accordion cursor + active state */
.detail-accordion-toggle {
  cursor: pointer;
}
.detail-accordion-toggle:active {
  background: var(--bg-card);
}

/* FIX: Nav active link — prevent reload on click */
.global-product-link.is-active {
  pointer-events: none;
}

/* FIX: .baz-anecdote-source — remove double opacity stacking */
.baz-anecdote-source {
  opacity: 1;
}

/* FIX: Border-radius normalization — terminal aesthetic = sharp corners */
.btn, .card, .hero-card, .stats-card, .mini-card,
.stat-cell, .price-panel, .loading-card, .pill {
  border-radius: var(--radius, 0px);
}

/* FIX: prefers-reduced-motion for zones.css animations */
@media (prefers-reduced-motion: reduce) {
  .completion-fill { transition: none; }
  .detail-accordion-content { transition: none; }
  .detail-accordion-indicator { transition: none; }
  .hub-stats .val { animation: none; }
  .collection-row-main { transition: none; }
  .result-row { transition: none; }
}

/* Pixel-perfect sprite rendering */
.baz-anecdote-sprite,
.codec-avatar img,
.codec-avatar svg {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}

/* ============================================================
   UTILITY CLASSES — Extracted from inline styles
   ============================================================ */
.u-ml-auto { margin-left: auto; }
.u-text-right { text-align: right; }

/* Collection import button (was inline style on #import-csv-btn) */
.collection-import-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font: inherit;
  padding: 0;
  margin-left: 16px;
}

/* Collection import status (was inline style on #import-csv-status) */
.collection-import-status {
  margin-left: 8px;
  font-size: 11px;
}

/* Collection mode bar flush top (was style="margin-top:0") */
.collection-mode-bar-flush {
  margin-top: 0;
}

/* Collection table row (was style="display:contents") */
.collection-table-row {
  display: contents;
}

/* ============================================================
   ACCORDION INDICATOR — CSS-only triangle (replaces &gt; character)
   ============================================================ */
.detail-accordion-indicator::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--accent);
  vertical-align: middle;
}

/* ============================================================
   GLOBAL SEARCH LINK — Anchor styled as search input
   Replaces readonly input with onclick hack in games-list.html
   ============================================================ */
.global-search-link {
  display: block;
  width: 100%;
  height: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}
.global-search-link:hover {
  border-color: var(--accent);
  color: var(--text-secondary);
}

/* ============================================================
   MOBILE FILTER SIDEBAR — Collapse filters behind toggle
   ============================================================ */
@media (max-width: 768px) {
  .filters-sidebar-content { display: none; }
  .filters-sidebar-content.is-open { display: block; }
}
