/* =================================================================
   HOME.CSS — Unified scrollable home page
   Sections 1-6 stacked full-viewport, responsive for all devices
   ================================================================= */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: auto;
  -webkit-text-size-adjust: 100%;
  scroll-snap-type: y proximity;
  background: #000;
}

body {
  margin: 0;
  font-family: 'Courier New', 'Segoe UI', Arial, sans-serif;
  color: #fff;
  background: #000;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}


.home-top-nav {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  width: min(96vw, 1200px);
  max-width: calc(100vw - 1rem);
}

.home-top-nav-inner {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: center;
  background: rgba(10, 15, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.home-top-nav-inner::-webkit-scrollbar {
  display: none;
}

.home-top-nav-inner a {
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}

.home-top-nav-inner a:hover {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
}



/* ── Compact Soundtrack Mute Button ─────────────────────────── */
.soundtrack-mute-btn {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 1300;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), rgba(147, 197, 253, 0.2) 35%, rgba(17, 24, 39, 0.88) 75%);
  color: #f8fafc;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 8, 23, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.soundtrack-mute-btn:hover,
.soundtrack-mute-btn:focus-visible {
  border-color: rgba(147, 197, 253, 0.8);
  transform: translateY(-1px);
  outline: none;
}

.soundtrack-mute-btn .sound-icon {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.soundtrack-mute-btn .sound-icon-off {
  display: none;
}

.soundtrack-mute-btn.is-muted {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.6);
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.3), rgba(248, 113, 113, 0.2) 35%, rgba(17, 24, 39, 0.9) 75%);
}

.soundtrack-mute-btn.is-muted .sound-icon-on {
  display: none;
}

.soundtrack-mute-btn.is-muted .sound-icon-off {
  display: block;
}

@media (max-width: 900px) {
  .soundtrack-mute-btn {
    top: auto;
    bottom: 0.8rem;
    right: 0.8rem;
  }
}

/* ── Scroll Container ─────────────────────────────────────────── */
.scroll-container {
  width: 100%;
  isolation: isolate;
  background: #000;
}

/* ── Each Section — Full Viewport ─────────────────────────────── */
.page-section {
  width: 100%;
  height: 100dvh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.section-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100%;
}

/* ── Scroll Progress Bar ──────────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #D2181F, #ff6b35, #93c5fd);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* ── Section Dots Navigation ──────────────────────────────────── */
.section-dots {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 999;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.dot:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.3);
}

.dot.active {
  background: #fff;
  border-color: #fff;
  transform: scale(1.3);
}

/* =================================================================
   SECTION 1 — License Plate (Ferrari)
   ================================================================= */
@font-face {
  font-family: 'Dealerplate';
  src: url('https://assets.codepen.io/163175/DealerplateCalifornia-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}

.section-1 {
  background: #D2181F;
}

.plate-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
}

.plate-svg-container {
  width: min(90vw, 700px);
  max-width: 100%;
}

.plate-svg-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.plate-input-wrapper {
  width: min(90vw, 400px);
}

#plate-text-input {
  font-size: clamp(1.2rem, 4vw, 2.25rem);
  width: 100%;
  border-radius: 8px;
  appearance: none;
  border: 2px solid #333;
  font-family: 'Dealerplate', monospace;
  background-color: #ddd;
  color: #1D185B;
  text-align: center;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#plate-text-input:focus {
  border-color: #1D185B;
  box-shadow: 0 0 0 3px rgba(29, 24, 91, 0.3);
}

/* =================================================================
   SECTION 2 — F1 ASCII Art + Bio (iframe)
   ================================================================= */
.section-2 {
  background: #fff;
  color: #333;
}

.section-2 .section-inner {
  padding: 0;
}

.page2-frame,
.page-frame {
  width: 100%;
  height: 100dvh;
  border: 0;
  display: block;
  vertical-align: top;
}

/* =================================================================
   SECTION 3 — Lights Out Game
   ================================================================= */
.section-3 {
  background: #2a2520;
  font-family: 'Courier New', monospace;
  color: #1a1512;
}

.lights-out-container {
  text-align: center;
  padding: 1rem;
  width: 100%;
}

.lights-out-header {
  margin-bottom: 1.5rem;
}

.lights-out-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  margin-bottom: 0.75rem;
  color: #e8dcc8;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.lights-out-instructions {
  font-size: clamp(0.8rem, 2vw, 1.25rem);
  color: #c8b8a0;
  margin-bottom: 1.25rem;
  line-height: 1.6;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  font-weight: 600;
}

.lights-out-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}

.lights-out-moves {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: #1a1512;
  color: #ff6b35;
  padding: 0.4rem 1.2rem;
  border-radius: 2px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.lights-out-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.lights-out-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  border: 2px solid #3a3028;
  background: linear-gradient(180deg, #e8dcc8 0%, #d4c5b0 100%);
  color: #2a2520;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.1s ease;
  text-transform: uppercase;
  box-shadow: 0 3px 0 #3a3028, 0 4px 8px rgba(0, 0, 0, 0.3);
  font-family: 'Courier New', monospace;
}

.lights-out-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a3028, 0 2px 4px rgba(0, 0, 0, 0.3);
}

.control-panel {
  background: linear-gradient(135deg, #d4c5b0 0%, #c8b8a0 100%);
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 8px 0 #3a3028, 0 12px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border: 3px solid #4a3f35;
  position: relative;
  max-width: 580px;
  margin: 0 auto;
}

.control-panel::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  pointer-events: none;
}

.rivet {
  position: absolute;
  width: 12px;
  height: 12px;
  background: radial-gradient(circle at 30% 30%, #6a5f55, #3a3028);
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.rivet:nth-child(1) { top: 15px; left: 15px; }
.rivet:nth-child(2) { top: 15px; right: 15px; }
.rivet:nth-child(3) { bottom: 15px; left: 15px; }
.rivet:nth-child(4) { bottom: 15px; right: 15px; }

.grid-wrapper {
  position: relative;
  display: inline-block;
}

.grid-labels {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 700;
  color: #3a3028;
  letter-spacing: 0.05em;
}

.grid-labels.top {
  top: -25px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 0 35px;
}

.grid-labels.left {
  left: -25px;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 35px 0;
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: clamp(4px, 1.5vw, 10px);
  width: clamp(250px, 60vw, 450px);
  height: clamp(250px, 60vw, 450px);
  padding: clamp(15px, 4vw, 30px);
  background: #2a2520;
  border-radius: 4px;
  border: 2px solid #1a1512;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.6);
}

.puzzle-grid.solved {
  animation: solveFlash 0.6s ease;
}

@keyframes solveFlash {
  0%, 100% { box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.6); }
  50% { box-shadow: inset 0 4px 12px rgba(255, 107, 53, 0.4); }
}

.light {
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  border: 3px solid #1a1512;
  box-shadow: 0 3px 0 #1a1512, inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

.light::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 1px;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 100%);
  pointer-events: none;
}

.light.off {
  background: linear-gradient(135deg, #3a3028 0%, #2a2520 100%);
}

.light.on {
  background: radial-gradient(circle at 40% 40%, #fff5e6, #ffb366 30%, #ff8833 60%, #ff6b35);
  box-shadow: 0 3px 0 #1a1512, 0 0 20px rgba(255, 107, 53, 0.8), 0 0 40px rgba(255, 107, 53, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.light:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #1a1512, inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.victory-message {
  margin-top: 2rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #ff6b35;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 107, 53, 0.5);
}

.victory-message.show {
  opacity: 1;
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* =================================================================
   SECTION 4 — Handwriting Typography
   ================================================================= */
.section-4 {
  background: #FFFDF3;
  color: red;
}

.handwriting-container {
  padding: 0 2rem;
  max-width: 900px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.handwriting-container p {
  font-size: clamp(2rem, 5vw, 4rem);
  color: red;
  line-height: 1.15;
}

/* Font classes for handwriting effect */
.caveat { font-family: 'Caveat', cursive; }
.shadows-into-light { font-family: 'Shadows Into Light', cursive; }
.indie-flower { font-family: 'Indie Flower', cursive; }
.nothing-you-could-do { font-family: 'Nothing You Could Do', cursive; }
.oooh-baby { font-family: 'Oooh Baby', cursive; }
.reenie-beanie { font-family: 'Reenie Beanie', cursive; }
.cedarville-cursive { font-family: 'Cedarville Cursive', cursive; }

/* =================================================================
   SECTION 5, 6 & 7 — Reserved Placeholders
   ================================================================= */
.section-5 {
  background: linear-gradient(160deg, #0f172a, #1e293b 55%, #0f172a);
}

.section-6 {
  background: linear-gradient(160deg, #111827, #1f2937 55%, #0f172a);
}

.section-7 {
  background: linear-gradient(160deg, #111827, #1f2937 55%, #0f172a);
}

.section-5,
.section-6,
.section-7 {
  width: 100%;
}

.section-5 .section-inner,
.section-6 .section-inner,
.section-7 .section-inner {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  padding: 0;
}

.section-5 .page-frame,
.section-6 .page-frame,
.section-7 .page-frame {
  width: 100%;
  height: 100vh;
  height: 100dvh;
}


.reserved-content {
  text-align: center;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 3rem 2rem;
  width: min(90vw, 560px);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.reserved-content h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: #e2e8f0;
  margin-bottom: 1rem;
}

.reserved-content p {
  color: #94a3b8;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
}

/* =================================================================
   RESPONSIVE — Mobile (< 640px)
   ================================================================= */
@media (max-width: 640px) {
  html {
    scroll-snap-type: y mandatory;
  }
  .section-inner {
    padding: 1.5rem 1rem;
  }

  /* Section dots — smaller on mobile */
  .section-dots {
    display: none;
  }

  .home-top-nav {
    top: max(0.4rem, env(safe-area-inset-top));
    width: calc(100vw - 0.5rem);
  }

  .home-top-nav-inner {
    gap: 0.25rem;
    padding: 0.35rem 0.55rem;
  }

  .home-top-nav-inner a {
    font-size: 0.68rem;
    padding: 0.25rem 0.45rem;
  }

  .dot {
    width: 8px;
    height: 8px;
  }

  /* Section 1 — Plate */
  .plate-svg-container {
    width: 95vw;
  }

  #plate-text-input {
    font-size: 1.2rem;
  }

  /* Section 3 — Lights Out */
  .control-panel {
    padding: 1.5rem;
  }

  .puzzle-grid {
    width: 75vw;
    height: 75vw;
    max-width: 320px;
    max-height: 320px;
    gap: 4px;
    padding: 12px;
  }

  .grid-labels.top {
    padding: 0 12px;
    top: -20px;
    font-size: 0.6rem;
  }

  .grid-labels.left {
    left: -18px;
    padding: 12px 0;
    font-size: 0.6rem;
  }

  .lights-out-controls {
    flex-wrap: wrap;
  }

  /* Section 4 — Handwriting */
  .handwriting-container {
    padding: 0 1rem;
  }

  .handwriting-container p {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    line-height: 1.2;
  }

  /* Section 5/6/7 — keep iframe and section heights aligned on mobile */
  .page-section {
    height: 100dvh;
    min-height: 100svh;
  }

  .section-inner {
    height: 100%;
    min-height: 100%;
  }

  .section-5,
  .section-6,
  .section-7,
  .section-5 .section-inner,
  .section-6 .section-inner,
  .section-7 .section-inner {
    min-height: 100%;
  }

  .section-5 .page-frame,
  .section-6 .page-frame,
  .section-7 .page-frame {
    height: 100%;
    min-height: 100%;
  }
}

/* =================================================================
   RESPONSIVE — Tablet (641px - 1024px)
   ================================================================= */
@media (min-width: 641px) and (max-width: 1024px) {
  .puzzle-grid {
    width: clamp(300px, 50vw, 400px);
    height: clamp(300px, 50vw, 400px);
  }
}

/* =================================================================
   RESPONSIVE — Large screens / TV (> 1400px)
   ================================================================= */
@media (min-width: 1400px) {
  .section-inner {
    max-width: 1400px;
  }

  .plate-svg-container {
    width: 800px;
  }

  .puzzle-grid {
    width: 500px;
    height: 500px;
  }

  .handwriting-container p {
    font-size: 4.5rem;
  }

  .reserved-content {
    width: 700px;
    padding: 4rem 3rem;
  }
}

/* =================================================================
   RESPONSIVE — Ultra-wide / TV (> 2000px)
   ================================================================= */
@media (min-width: 2000px) {
  .section-inner {
    max-width: 1800px;
  }

  .lights-out-title {
    font-size: 4rem;
  }

  .puzzle-grid {
    width: 600px;
    height: 600px;
    gap: 14px;
  }

  .dot {
    width: 16px;
    height: 16px;
  }

  .section-dots {
    gap: 1.5rem;
    right: 2.5rem;
  }
}

/* =================================================================
   RESPONSIVE — Portrait mode (height > width)
   ================================================================= */
@media (orientation: portrait) and (max-width: 640px) {
  .page-section {
    min-height: 100svh; /* Use small viewport height for mobile browsers */
  }
}

/* =================================================================
   Accessibility — Reduced motion
   ================================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; scroll-snap-type: none; }
  .scroll-progress { transition: none; }
  .dot { transition: none; }
  .light { transition: none; }
  .victory-message { transition: none; }
  .puzzle-grid.solved { animation: none; }
  .victory-message.show { animation: none; }
}
