/* ==========================================================================
   INTERAKTIV AUDIO LIMITED — Landing Page
   ========================================================================== */

/* --- Design Tokens --- */

:root {
  /* Dark theme (default) */
  --bg:           hsl(220, 15%, 6%);
  --bg-surface:   hsl(220, 15%, 10%);
  --bg-elevated:  hsl(220, 15%, 14%);
  --text:         hsl(220, 10%, 88%);
  --text-muted:   hsl(220, 8%, 50%);
  --accent:       hsl(180, 70%, 55%);
  --accent-dim:   hsla(180, 70%, 55%, 0.15);
  --accent-glow:  hsla(180, 70%, 55%, 0.25);
  --border:       hsl(220, 15%, 16%);

  /* Layout */
  --max-width: 1120px;
  --px: clamp(1.25rem, 4vw, 3rem);
  --radius: 4px;

  /* Type scale */
  --font-display: 'Syne', sans-serif;
  --font-body:    'Outfit', sans-serif;
  --fs-hero:   clamp(1.75rem, 6vw, 5.5rem);
  --fs-h2:     clamp(1.75rem, 4vw, 2.75rem);
  --fs-h3:     1.05rem;
  --fs-body:   1.05rem;
  --fs-small:  0.85rem;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.5s;
}

[data-theme="light"] {
  --bg:           hsl(220, 12%, 90%);
  --bg-surface:   hsl(220, 10%, 85%);
  --bg-elevated:  hsl(220, 10%, 93%);
  --text:         hsl(220, 20%, 12%);
  --text-muted:   hsl(220, 8%, 40%);
  --accent:       hsl(180, 75%, 30%);
  --accent-dim:   hsla(180, 75%, 30%, 0.12);
  --accent-glow:  hsla(180, 75%, 30%, 0.18);
  --border:       hsl(220, 10%, 78%);
}

/* --- Reset & Base --- */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  overflow-x: hidden;
  padding: 0 !important;
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.75;
}

/* --- Grain Overlay --- */

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* --- Header --- */

.site-header {
  position: -webkit-sticky;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 100;
  padding: 0 var(--px);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  height: 60px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  transition: color var(--dur) var(--ease);
}

.logo:hover {
  opacity: 1;
  color: var(--accent);
}

/* --- Safe Area Cover (iOS status bar) --- */

.safe-area-cover {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--bg);
  z-index: 101;
  pointer-events: none;
  transition: background var(--dur) var(--ease);
}

/* --- Nav Actions --- */

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Accessibility Toggle --- */

.a11y-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color 0.2s;
}

.a11y-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

[data-contrast="high"] .a11y-toggle {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- Theme Toggle --- */

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color 0.2s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.theme-icon--moon { display: none; }
[data-theme="light"] .theme-icon--sun  { display: none; }
[data-theme="light"] .theme-icon--moon { display: block; }

/* --- Hero --- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px var(--px) 60px;
  overflow: hidden;
}

.hero-waveform {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.25;
  transition: opacity var(--dur) var(--ease);
}

[data-theme="light"] .hero-waveform {
  opacity: 0.2;
}

.hero-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
  filter: blur(80px);
  transition: background var(--dur) var(--ease);
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  width: 100%;
  max-width: var(--max-width);
  padding: 0 var(--px);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-hero);
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--text);
  text-transform: uppercase;
  transition: color var(--dur) var(--ease);
  width: 100%;
  white-space: nowrap;
}

.hero-tagline {
  margin-top: 1.5rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.15rem, 2.5vw, 1.6rem);
  letter-spacing: 0.04em;
  color: var(--accent);
  transition: color var(--dur) var(--ease);
}

.hero-description {
  margin-top: 1.25rem;
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  font-weight: 400;
  line-height: 1.7;
  color: hsl(220, 10%, 70%);
  transition: color var(--dur) var(--ease);
}

[data-theme="light"] .hero-description {
  color: hsl(220, 10%, 38%);
}


/* --- Scroll Cue --- */

.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  color: var(--text-muted);
  animation: scroll-bounce 2s var(--ease) infinite;
  transition: color var(--dur) var(--ease);
}

@keyframes scroll-bounce {
  0%, 100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
  50%      { opacity: 0.8; transform: translateX(-50%) translateY(8px); }
}

/* --- About --- */

.about {
  padding: clamp(5rem, 12vw, 10rem) var(--px);
  border-top: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}

.about-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-label {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-small);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  transition: color var(--dur) var(--ease);
}

.about-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h2);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 600px;
  transition: color var(--dur) var(--ease);
}

.about-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  margin-top: 3rem;
}

.about-text p {
  color: var(--text-muted);
  transition: color var(--dur) var(--ease);
}

.about-text p + p {
  margin-top: 1.25rem;
}


/* --- Pillars --- */

.about-pillars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 600px) {
  .about-pillars {
    grid-template-columns: 1fr 1fr;
  }
}

.pillar {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.4s var(--ease);
  box-shadow: 0 0 0 0 transparent;
}

.pillar:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 1px var(--accent-dim);
  background: var(--bg-elevated);
}

.pillar-marker {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  transition: all 0.4s var(--ease);
}

.pillar:hover .pillar-marker {
  box-shadow: 0 0 14px var(--accent-glow), 0 0 4px var(--accent);
}

.pillar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h3);
  letter-spacing: 0.01em;
  color: var(--text);
  margin-bottom: 0.25rem;
  transition: color var(--dur) var(--ease);
}

.pillar-text {
  font-size: var(--fs-small);
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-muted);
  transition: color var(--dur) var(--ease);
}

/* --- Products --- */

.products {
  padding: clamp(5rem, 12vw, 10rem) var(--px);
  border-top: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}

.products-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.products-header {
  margin-bottom: 2.5rem;
}

.products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .products-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

.product-card {
  padding: 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.4s var(--ease);
  box-shadow: 0 0 0 0 transparent;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 4px 24px var(--accent-glow), 0 0 0 1px var(--accent-dim);
  background: var(--bg-elevated);
}

.product-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -0.01em;
  color: var(--text);
  transition: color var(--dur) var(--ease);
}

.product-text {
  font-size: var(--fs-body);
  line-height: 1.65;
  color: var(--text-muted);
  transition: color var(--dur) var(--ease);
}

.product-status {
  margin-top: auto;
  padding-top: 0.5rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-small);
  letter-spacing: 0.05em;
  color: var(--accent);
  transition: color var(--dur) var(--ease);
}

/* --- Player --- */

.player {
  padding: clamp(5rem, 12vw, 10rem) var(--px);
  border-top: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}

.player-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.player-header {
  margin-bottom: 2.5rem;
}

.player-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h2);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  transition: color var(--dur) var(--ease);
}

.player-description {
  margin-top: 0.75rem;
  font-size: var(--fs-body);
  color: var(--text-muted);
  transition: color var(--dur) var(--ease);
}

/* Deck Grid */
.deck {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 48px;
  gap: 8px;
}

.deck-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deck-col-header {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  padding: 0.5rem 0;
  transition: color var(--dur) var(--ease);
}

.deck-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  min-height: 56px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  box-shadow: 0 0 0 0 transparent;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.deck-cell:hover {
  border-color: var(--accent-dim);
  color: var(--text);
  background: var(--bg-elevated);
}

.deck-cell.is-active:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: 0 4px 24px var(--accent-glow), inset 0 0 0 1px var(--accent);
}

.deck-cell.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.cell-waveform {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.25;
  transition: opacity 0.3s var(--ease);
}

.deck-cell:hover .cell-waveform {
  opacity: 0.4;
}

.deck-cell.is-active .cell-waveform {
  opacity: 0.5;
}

.cell-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.15s;
}

.deck-cell.is-active .cell-playhead,
.deck-cell.is-queued .cell-playhead {
  opacity: 0.8;
}

.deck-cell .cell-name {
  position: relative;
  z-index: 1;
}

.cell-key,
.btn-key {
  position: absolute;
  top: 4px;
  right: 4px;
  font-family: var(--font-body);
  font-size: 0.55rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 5px;
  border-radius: 2px;
  opacity: 0.6;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.2s;
}

.deck-cell:hover .cell-key,
.deck-random:hover .btn-key {
  opacity: 0.8;
}

.deck-row-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-cell.is-queued {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-surface);
  animation: cell-queue 0.3s ease-in-out infinite alternate;
}

@keyframes cell-queue {
  0%   { opacity: 0.5; }
  100% { opacity: 1; }
}

.deck-cell.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: hsla(180, 70%, 55%, 0.08);
  box-shadow: 0 2px 20px var(--accent-glow), inset 0 0 0 1px var(--accent-dim);
}

[data-theme="light"] .deck-cell.is-active {
  background: hsla(180, 75%, 32%, 0.08);
}

.deck-cell.is-active::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  animation: cell-pulse 1.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes cell-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0; }
}

/* XY Pad */
.xy-pad {
  position: relative;
  width: 100%;
  height: 220px;
  margin-bottom: 1.25rem;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--dur) var(--ease);
}

.xy-well {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: crosshair;
  touch-action: none;
  overflow: hidden;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}


.xy-cursor {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: translate(-50%, -50%);
  left: 50%;
  top: calc(100% - 8px);
  pointer-events: none;
  transition: box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  z-index: 1;
}

.xy-well.is-touching .xy-cursor,
.xy-pad.is-touching .xy-cursor {
  box-shadow: 0 0 20px var(--accent-glow), 0 0 6px var(--accent);
  width: 20px;
  height: 20px;
}

.xy-label {
  position: absolute;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.5;
  pointer-events: none;
  transition: color var(--dur) var(--ease);
}

.xy-label--left   { left: 0;    top: 50%;  transform: translateY(-50%); }
.xy-label--right  { right: 0;   top: 50%;  transform: translateY(-50%); }
.xy-label--top    { top: 2px;   left: 50%; transform: translateX(-50%); }
.xy-label--bottom { bottom: 2px; left: 50%; transform: translateX(-50%); }

/* Deck Controls */
.deck-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
}

.deck-stop,
.deck-random,
.deck-help {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}



.deck-help {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0;
  width: 48px;
  max-width: 48px;
}

.deck-stop:hover,
.deck-random:hover,
.deck-help:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

/* Responsive — Tablet */
@media (max-width: 768px) {
  .xy-pad {
    height: 160px;
    padding: 20px 28px;
  }

  .deck {
    gap: 6px;
  }

  .deck-cell {
    min-height: 48px;
    padding: 0.75rem 0.35rem;
    font-size: 0.75rem;
  }

  .deck-col-header {
    font-size: 0.7rem;
    padding: 0.35rem 0;
  }
}

/* Responsive — Mobile */
@media (max-width: 480px) {
  .xy-pad {
    height: 200px;
    padding: 22px 28px;
  }

  .deck {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .deck-col--rows {
    display: none;
  }

  .deck-cell {
    min-height: 44px;
    padding: 0.6rem 0.25rem;
    font-size: 0.7rem;
  }

  .deck-col-header {
    font-size: 0.65rem;
    padding: 0.3rem 0;
    letter-spacing: 0.05em;
  }

  .deck-controls {
    grid-template-columns: 1fr 1fr;
  }

  .deck-help {
    display: none;
  }

  .deck-stop {
    grid-column: span 1;
  }

  .cell-key,
  .btn-key {
    display: none;
  }

  .deck-stop,
  .deck-random {
    padding: 0.5rem;
  }

  .xy-label {
    font-size: 0.6rem;
  }
}

.help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 0.25rem;
  transition: all 0.2s var(--ease);
}

.help-trigger:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* --- Help Overlay --- */

.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: hsla(220, 15%, 6%, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: var(--px);
}

[data-theme="light"] .help-overlay {
  background: hsla(220, 15%, 96%, 0.85);
}

.help-overlay.is-open {
  display: flex;
}

.help-sheet {
  position: relative;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.help-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.2s;
}

.help-close:hover {
  color: var(--text);
}

.help-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  transition: color var(--dur) var(--ease);
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 480px) {
  .help-grid {
    grid-template-columns: 1fr;
  }
}

.help-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
  transition: color var(--dur) var(--ease);
}

.help-keys {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.help-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-small);
  color: var(--text-muted);
  transition: color var(--dur) var(--ease);
}

.help-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.help-row span {
  margin-left: 0.25rem;
}

.help-note {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
  transition: color var(--dur) var(--ease);
}

.help-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: var(--fs-small);
  color: var(--text-muted);
  text-align: center;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.help-footer kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text);
}

/* --- Footer --- */

.site-footer {
  padding: 3rem var(--px);
  border-top: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  transition: color var(--dur) var(--ease);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  font-size: var(--fs-small);
  color: var(--text-muted);
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent);
  opacity: 1;
}

.footer-copy {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.6;
  transition: color var(--dur) var(--ease);
}

@media (min-width: 768px) {
  .footer-copy {
    width: auto;
    margin-top: 0;
  }
}

/* --- Entrance Animations --- */

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

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Hero elements: animate on page load via CSS */
.hero [data-animate="fade-up"] {
  animation: fade-up 0.8s var(--ease) both;
}

.hero [data-animate="fade"] {
  animation: fade-in 0.8s var(--ease) both;
}

.hero [data-delay="1"] { animation-delay: 0.15s; }
.hero [data-delay="2"] { animation-delay: 0.3s; }
.hero [data-delay="3"] { animation-delay: 0.45s; }
.hero [data-delay="4"] { animation-delay: 0.6s; }

/* Non-hero elements: transition on scroll */
[data-animate]:not(.hero [data-animate]) {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

[data-animate]:not(.hero [data-animate])[data-animate="fade"] {
  transform: none;
}

[data-animate]:not(.hero [data-animate]).is-visible {
  opacity: 1;
  transform: none;
}

:not(.hero) > [data-delay="1"] { transition-delay: 0.12s; }
:not(.hero) > [data-delay="2"] { transition-delay: 0.24s; }
:not(.hero) > [data-delay="3"] { transition-delay: 0.36s; }
:not(.hero) > [data-delay="4"] { transition-delay: 0.5s; }

/* --- High Contrast Mode --- */

/* Auto-detect OS preference */
@media (prefers-contrast: more) {
  :root {
    --text: hsl(0, 0%, 100%);
    --text-muted: hsl(220, 8%, 75%);
    --accent: hsl(180, 90%, 60%);
    --border: hsl(220, 15%, 30%);
  }
  [data-theme="light"] {
    --text: hsl(0, 0%, 0%);
    --text-muted: hsl(220, 15%, 25%);
    --accent: hsl(180, 90%, 28%);
    --border: hsl(220, 15%, 50%);
  }
}

/* Manual toggle via data-contrast="high" */
[data-contrast="high"] {
  --fs-hero:   clamp(2rem, 7vw, 6rem);
  --fs-h2:     clamp(2rem, 4.5vw, 3.25rem);
  --fs-h3:     1.25rem;
  --fs-body:   1.2rem;
  --fs-small:  1rem;
}

[data-contrast="high"]:not([data-theme="light"]) {
  --text: hsl(0, 0%, 100%);
  --text-muted: hsl(220, 8%, 75%);
  --accent: hsl(180, 90%, 60%);
  --accent-dim: hsla(180, 90%, 60%, 0.2);
  --accent-glow: hsla(180, 90%, 60%, 0.35);
  --border: hsl(220, 15%, 28%);
  --bg-surface: hsl(220, 15%, 12%);
  --bg-elevated: hsl(220, 15%, 16%);
}

[data-contrast="high"][data-theme="light"] {
  --text: hsl(0, 0%, 0%);
  --text-muted: hsl(220, 15%, 22%);
  --accent: hsl(180, 90%, 25%);
  --accent-dim: hsla(180, 90%, 25%, 0.15);
  --accent-glow: hsla(180, 90%, 25%, 0.2);
  --border: hsl(220, 15%, 55%);
  --bg-surface: hsl(220, 12%, 88%);
  --bg-elevated: hsl(220, 12%, 100%);
}

/* Thicker borders and larger touch targets in high contrast */
[data-contrast="high"] .deck-cell,
[data-contrast="high"] .pillar,
[data-contrast="high"] .product-card,
[data-contrast="high"] .xy-well,
[data-contrast="high"] .theme-toggle,
[data-contrast="high"] .a11y-toggle,
[data-contrast="high"] .deck-stop,
[data-contrast="high"] .deck-random,
[data-contrast="high"] .deck-help {
  border-width: 2px;
}

[data-contrast="high"] .deck-cell {
  min-height: 64px;
}

[data-contrast="high"] .hero-description {
  color: var(--text-muted);
}

[data-contrast="high"] .cell-key,
[data-contrast="high"] .btn-key {
  font-size: 0.75rem;
  opacity: 0.8;
}

[data-contrast="high"] .xy-label {
  font-size: 0.85rem;
  opacity: 0.8;
}

[data-contrast="high"] .deck-col-header {
  font-size: 1rem;
}

/* --- Responsive --- */

@media (max-width: 480px) {
  .hero-title {
    letter-spacing: 0.03em;
  }

  .pillar {
    padding: 1rem 1.15rem;
  }

  .footer-container {
    flex-direction: column;
    align-items: flex-start;
  }
}
