:root {
  --bg-a: #0a0e1a;
  --bg-b: #131a30;
  --accent: #6ea8fe;
  --accent-soft: #a9c6ff;
  --text: #eef2ff;
  --muted: #8994b3;
  --card: rgba(255, 255, 255, 0.04);
  --border: rgba(169, 198, 255, 0.18);
}

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

html,
body {
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(
      1200px 600px at 50% -10%,
      rgba(110, 168, 254, 0.18),
      transparent 60%
    ),
    linear-gradient(160deg, var(--bg-a), var(--bg-b));
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- Header + nav ---------- */
.site-header {
  position: relative;
  z-index: 50; /* keep the header (and its mobile dropdown) above main content */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  animation: fade-in 0.9s ease both;
}

.nav-toggle {
  display: none; /* shown only on mobile */
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle svg {
  width: 30px;
  height: 30px;
  display: block;
}

.logo {
  height: clamp(72px, 12vw, 132px);
  width: auto;
  cursor: pointer;
  /* logo art is black; invert so it reads white on the dark background */
  filter: invert(1) brightness(1.6);
}

.site-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nav-link {
  font: inherit;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--card);
}

.nav-link.active {
  color: var(--accent);
}

/* ---------- Sections ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1.5rem;
}

.section {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
  animation: fade-in 0.6s ease both;
}

.section[hidden] {
  display: none;
}

.section.content {
  text-align: left;
  padding: 1rem 0 3rem;
}

/* ---------- Hero / welcome ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.typewriter {
  font-size: clamp(1.4rem, 4.4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  /* reserve ~2 lines so switching between short and wrapping lines doesn't
     shift the layout up or down; bottom-align so text always sits just above
     the tagline and the height variation is absorbed above the text */
  min-height: 2.7em;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.type-line {
  text-align: center; /* center each wrapped line; keeps the cursor inline after the text */
}

.type-text {
  white-space: pre-line; /* honor the \n so "and it never really ends." is its own line */
}

.type-text {
  background: linear-gradient(90deg, var(--text), var(--accent-soft));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.type-text.aside {
  background: none;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  font-weight: 500;
  font-size: 0.82em;
}

/* Plain back/forward arrows for the welcome sequence */
.nav-arrows {
  display: flex;
  gap: 1.4rem;
  justify-content: center;
  margin-top: 2.2rem;
  animation: fade-in 0.5s ease both;
}

.arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease;
}

.arrow-btn svg {
  width: 30px;
  height: 30px;
}

.arrow-btn:hover {
  color: var(--accent-soft);
}

#next-btn:hover {
  transform: translateX(3px);
}

#back-btn:hover {
  transform: translateX(-3px);
}

.cursor {
  display: inline-block;
  width: 0.06em;
  min-width: 2px;
  height: 1.05em;
  margin-left: 0.08em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.05s step-end infinite;
}

.tagline {
  margin-top: 0.9rem;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  margin-top: 2rem;
  padding: 0.85rem 2rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--bg-a);
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(110, 168, 254, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(110, 168, 254, 0.4);
}

.btn:active {
  transform: translateY(0);
}

/* Begin-onboarding button: space always reserved; revealed + pulsing on the last line */
#begin-btn {
  visibility: hidden;
}

#begin-btn.is-visible {
  visibility: visible;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 8px 24px rgba(110, 168, 254, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 14px 36px rgba(110, 168, 254, 0.55);
  }
}

/* ---------- Content typography ---------- */
.section-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  margin-bottom: 1.2rem;
}

.section-body {
  font-size: clamp(1rem, 2.2vw, 1.12rem);
  line-height: 1.7;
  color: #cdd6f4;
  margin-bottom: 1.2rem;
}

.fill {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Mission video placeholder ---------- */
.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  margin: 0 0 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.02) 0 12px,
      transparent 12px 24px
    ),
    rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.video-label {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.85;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  color: var(--bg-a);
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(110, 168, 254, 0.3);
  transition: transform 0.15s ease;
}

.play-btn svg {
  width: 30px;
  height: 30px;
  margin-left: 3px; /* optically center the triangle */
}

.play-btn:hover {
  transform: scale(1.06);
}

.video-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- About value cards ---------- */
.value-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.card {
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.card h3 {
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------- Team / org chart ---------- */
#team {
  max-width: 1320px;
}

.team-heading {
  text-align: left;
  margin: 2.25rem 0 1.1rem;
  font-size: 1.4rem;
  color: var(--text);
}

.team-subheading {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.75rem 1rem; /* extra row-gap so board rows aren't cramped */
  margin-bottom: 0.5rem;
}

.team-card {
  position: relative;
  margin: 0;
  padding: 0;
  text-align: center;
  cursor: pointer;
}

.team-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border-radius: 12px;
  background: var(--bg-a);
}

.team-card figcaption {
  padding-top: 0.7rem;
}

.team-name {
  color: var(--text);
  font-size: 1.05rem;
}

.team-title {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

/* Bio overlays the photo on hover (team-directory style) */
.team-bio {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1.1rem;
  background: rgba(10, 14, 26, 0.94);
  border-radius: 12px;
  color: #cdd6f4;
  font-size: 1.05rem;
  line-height: 1.6;
  text-align: left;
  opacity: 0;
  transition: opacity 0.25s ease;
  overflow-y: auto;
}

.team-card:hover .team-bio,
.team-card:focus-within .team-bio,
.team-card.open .team-bio {
  opacity: 1;
}

/* ---------- How We Work flowchart images ---------- */
/* Widen this section so the horizontal flowchart renders large on desktop */
#how-we-work {
  max-width: 1200px;
}

.flow-img {
  display: block;
  width: 100%;
  height: auto;
  margin: 1.75rem 0 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.flow-mobile {
  display: none; /* desktop shows the horizontal image */
}

/* On desktop, make the How We Work section fill the available height and fit the
   horizontal flowchart inside it (object-fit) so the page never scrolls */
@media (min-width: 601px) {
  #how-we-work {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
  }
  #how-we-work .section-title,
  #how-we-work .section-body {
    text-align: center;
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
  }
  #how-we-work .btn {
    flex: 0 0 auto;
    margin-top: 0.8rem;
  }
  .flow-desktop {
    flex: 1 1 auto;
    min-height: 0; /* allow the image to shrink below its natural size */
    width: 100%;
    height: 100%;
    max-height: calc(100dvh - 260px); /* hard cap so it always fits the screen */
    object-fit: contain;
    margin: 0.5rem auto;
  }
}

/* ---------- Onboarding checklist ---------- */
.checklist {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}

.checklist li {
  position: relative;
  padding: 0.55rem 0 0.55rem 2rem;
  color: #cdd6f4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
}

.checklist li.done {
  color: var(--muted);
  text-decoration: line-through;
}

.checklist li.done::before {
  content: "✓";
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--bg-a);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Form ---------- */
.onboarding-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  text-align: left;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: none;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.optional {
  color: var(--muted);
  font-weight: 400;
}

.onboarding-form input[type="text"],
.onboarding-form input[type="email"],
.onboarding-form input[type="number"],
.onboarding-form select,
.onboarding-form textarea {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.85rem;
  width: 100%;
}

.onboarding-form textarea {
  resize: vertical;
}

.onboarding-form input:focus,
.onboarding-form select:focus,
.onboarding-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.18);
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1.2rem;
  color: #cdd6f4;
  cursor: pointer;
}

.radio input {
  accent-color: var(--accent);
}

.form-error {
  color: #ff9a9a;
  font-size: 0.9rem;
}

.form-success {
  text-align: center;
  padding: 2rem 1rem;
  animation: fade-in 0.5s ease both;
}

.form-success h3 {
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
}

.form-success p {
  color: #cdd6f4;
  line-height: 1.6;
}

.party-intel {
  margin-top: 1rem;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

/* ---------- Animations ---------- */
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

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

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .site-header {
    padding: 0.85rem 1rem;
    gap: 0.6rem;
  }
  .logo {
    height: clamp(48px, 13vw, 68px);
  }
  .nav-toggle {
    display: inline-flex;
  }
  .site-nav {
    display: none;
    position: absolute;
    top: calc(100% - 0.25rem);
    right: 1rem;
    z-index: 30;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 190px;
    padding: 0.5rem;
    background: var(--bg-b);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  }
  .site-nav.open {
    display: flex;
  }
  .nav-link {
    width: 100%;
    text-align: left;
    font-size: 1rem;
    padding: 0.65rem 0.8rem;
  }
  main {
    padding: 1rem;
  }
  .typewriter {
    font-size: clamp(1.2rem, 6.2vw, 1.7rem);
  }
  .tagline {
    margin-top: 0.7rem;
  }
  .nav-arrows {
    margin-top: 1.8rem;
  }
  .section.content {
    padding: 0.5rem 0 2.5rem;
  }
  .value-cards {
    grid-template-columns: 1fr;
  }
  .team-grid,
  .team-grid.leadership {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .team-card {
    text-align: left;
  }
  .team-subheading {
    display: block; /* "— The Silicon Valley Kennel" drops to its own line */
  }
  .team-bio {
    font-size: 0.95rem;
    line-height: 1.5;
  }
  .flow-desktop {
    display: none; /* mobile shows the vertical image instead */
  }
  .flow-mobile {
    display: block;
  }
  .video-label {
    font-size: 0.6rem;
    left: 0.7rem;
    top: 0.7rem;
  }
  .play-btn {
    width: 60px;
    height: 60px;
  }
  .btn {
    width: 100%; /* full-width tap targets on phones */
  }
  .radio {
    display: flex;
    margin: 0 0 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .section,
  .form-success {
    animation: none;
  }
  .cursor {
    animation: none;
  }
  .btn:hover,
  .play-btn:hover {
    transform: none;
  }
  #begin-btn.is-visible {
    animation: none;
  }
  .game-view {
    animation: none;
  }
}

/* ---------- Training minigame (Squirrel Patrol) ---------- */
#training {
  max-width: 1180px;
}

.game {
  position: relative;
  margin: 1.5rem 0 2rem;
}

.game-view {
  animation: fade-in 0.4s ease both;
}

/* Start screen */
.game-loadscreen {
  position: relative;
  aspect-ratio: 16 / 9;
  /* big, but height-capped so the whole section still fits the screen */
  width: min(100%, calc(70vh * 16 / 9));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  /* forest art, dimmed so the overlay text stays readable */
  background: linear-gradient(rgba(10, 14, 26, 0.35), rgba(10, 14, 26, 0.55)),
    url("background_desktop.png") center / cover no-repeat;
  image-rendering: pixelated; /* keep the pixel art crisp */
}

.game-loadimg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-start-overlay {
  position: relative;
  z-index: 1;
  max-width: 30rem;
  margin: 1rem;
  padding: 1.5rem 1.75rem;
  text-align: center;
  background: rgba(10, 14, 26, 0.62);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(3px);
}

.game-title {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.game-brief {
  color: #cdd6f4;
  line-height: 1.5;
  margin-bottom: 0.7rem;
}

.game-topscore {
  color: var(--accent-soft);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

/* Play screen — score/timer/combo are drawn onto the canvas itself */
.game-stage {
  position: relative;
  width: min(100%, calc(70vh * 16 / 9));
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #17331f url("background_desktop.png") center / cover no-repeat;
  image-rendering: pixelated; /* keep the pixel-art forest crisp */
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair; /* fallback if the custom cursor is unsupported */
  /* paw-print reticle (Bark Blaster), hotspot centered on the 44px image */
  cursor: url("training/paw-cursor.png") 22 22, crosshair;
  touch-action: none; /* taps shoot; don't scroll/zoom the page */
}

/* Game over screen */
.game-over {
  text-align: center;
}
.game-over-title {
  font-size: clamp(1.4rem, 4vw, 2rem);
  margin-bottom: 0.3rem;
}
.game-final {
  color: #cdd6f4;
  font-size: 1.15rem;
  margin-bottom: 1.2rem;
}
.game-final span {
  color: var(--accent);
  font-weight: 700;
}

.score-form {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto 1.5rem;
}
.score-form .field {
  flex: 1;
  text-align: left;
}
.score-form input {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.85rem;
  width: 100%;
  text-transform: uppercase;
}
.score-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.18);
}
.score-form .btn {
  margin-top: 0;
  white-space: nowrap;
}

.leaderboard {
  max-width: 420px;
  margin: 0 auto 1.5rem;
  text-align: left;
}
.leaderboard-title {
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rank;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.lb-row {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.lb-row:last-child {
  border-bottom: none;
}
.lb-row::before {
  content: counter(rank);
  min-width: 1.4rem;
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lb-row:first-child::before {
  color: #ffd479; /* gold for #1 */
}
.lb-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}
.lb-score {
  color: var(--accent-soft);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lb-row.me {
  background: rgba(110, 168, 254, 0.16);
}
.lb-row.me .lb-name {
  color: var(--accent);
}
.lb-empty {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
}
.leaderboard-note {
  margin-top: 0.6rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-secondary:hover {
  background: var(--card);
  box-shadow: none;
}

@media (max-width: 600px) {
  /* Portrait game on phones — swap to the vertical art and make it big. Sized
     by height (capped by width) so it fills the screen without distorting. */
  #training {
    max-width: none;
  }
  .game-stage,
  .game-loadscreen {
    aspect-ratio: 9 / 16;
    width: min(100%, 46vh);
    margin-inline: auto;
  }
  .game-stage {
    background-image: url("background_mobile.png");
  }
  .game-loadscreen {
    background: linear-gradient(rgba(10, 14, 26, 0.35), rgba(10, 14, 26, 0.55)),
      url("background_mobile.png") center / cover no-repeat;
  }
  .score-form {
    flex-direction: column;
    align-items: stretch;
  }
  .score-form .btn {
    width: 100%;
  }
}
