/* ===== Design tokens (from MainSiteImage.png: sky-blue gradient, white ribbon,
   hand-lettered script logo, warm red scarf accent) ===== */
:root {
  --blue-deep: #0b3d6b;
  --blue-mid: #1f6fb2;
  --blue-light: #5fa8dc;
  --blue-pale: #cfe8fb;
  --white: #ffffff;
  --ink: #0d2233;
  --accent-red: #e0454f;
  --accent-red-dark: #c13039;
  --placeholder-border: #ffb020;
  --placeholder-bg: rgba(255, 176, 32, 0.12);
  --placeholder-text: #8a5a00;
  --max-width: 1160px;

  --font-display: 'Gaegu', cursive;
  --font-body: 'Nunito', system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--white);
  line-height: 1.6;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 0.4em;
  color: var(--blue-deep);
}

h2 { font-size: clamp(2rem, 4vw, 2.8rem); text-align: center;  }
h3 { font-size: clamp(1.5rem, 3vw, 1.9rem); color: var(--blue-mid); }

p { margin: 0 0 1em; }

a { color: var(--blue-mid); }

/* ===== Placeholder styling (shared) ===== */
.placeholder-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--placeholder-text);
  background: var(--placeholder-bg);
  border: 1px dashed var(--placeholder-border);
  border-radius: 4px;
  padding: 0.05em 0.4em;
  vertical-align: middle;
}

.placeholder-link { color: var(--placeholder-text); cursor: default; text-decoration: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.85em 1.6em;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-red);
  color: var(--white);
  box-shadow: 0 6px 18px rgba(224, 69, 79, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary:hover {
  background: var(--accent-red-dark);
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(224, 69, 79, 0.4);
}

.btn-secondary {
  background: transparent;
  color: var(--white);
  border: 2px solid var(--white);
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-reserved {
  background: transparent;
  border: 1px dashed rgba(13, 34, 51, 0.25);
  color: rgba(13, 34, 51, 0.45);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: normal;
  max-width: 100%;
}

.cta-row { display: flex; flex-wrap: wrap; gap: 1em; align-items: center; margin: 1.4em 0 0.8em; min-width: 0; }
.cta-row-reserved { opacity: 0.7; margin-top: 0.6em; }
.cta-row > * { min-width: 0; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(180deg, var(--blue-deep) 0%, var(--blue-mid) 45%, var(--blue-light) 100%);
  color: var(--white);
}

.hero-banner-wrap {
  position: relative;
}

.hero-banner {
  width: 100%;
  height: auto;
  display: block;
}

.top-nav {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  display: flex;
  gap: 2rem;
  white-space: nowrap;
}

.top-nav a {
  font-family: var(--font-display);
  color: #adcde4;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.top-nav a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .top-nav {
    top: 0.75rem;
    gap: 1.25rem;
    font-size: 1rem;
  }
}

.hero-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0rem 1.5rem 4rem;
  text-align: center;
  min-width: 0;
}

.hero-video {
  position: relative;
  width: min(250%, 100vw - 2rem);
  left: 50%;
  transform: translateX(-50%);
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  margin-top: clamp(-6rem, -4.5vw, -1.5rem);
  margin-bottom: 1.8em;
}
.hero-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (min-width: 641px) {
  .hero-video {
    /* .hero-banner has no max-width above it, so it renders at ~100vw;
       tying the video to vw keeps it a fixed proportion of the hero image
       at any desktop width instead of the container-relative mobile sizing.
       Floored at the mobile breakpoint's width (640px - 2rem) so it meets
       the mobile formula exactly at 641px instead of snapping smaller. */
    width: max(75vw, calc(640px - 2rem));
  }
}

.cta-row { justify-content: center; }

/* ===== Wave section dividers =====
   Each divider's own background is the color of the section ABOVE it; the SVG
   path inside is filled with the color of the section BELOW it, so the curve
   reads as that lower section bleeding up into a wave. preserveAspectRatio="none"
   lets the wave stretch to any width without distorting proportions. */
.wave-divider {
  width: 100%;
  height: 70px;
  background: var(--divider-top);
  overflow: hidden;
  line-height: 0;
}
.wave-divider svg {
  display: block;
  width: 100%;
  height: 100%;
}
.wave-divider path {
  fill: var(--divider-bottom);
}
.wave-divider--flip svg {
  transform: scaleX(-1);
}

/* ===== Generic section ===== */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

#about {
  max-width: 75ch;
}

#about h2 {
  margin-bottom: 1.5rem;
}

/* ===== Legal/content pages (privacy policy, etc.) ===== */
.legal-content {
  max-width: 75ch;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}
.legal-content h2 { text-align: left; margin-top: 2.5rem; }
.legal-content h3 { margin-top: 1.5rem; }
.legal-content ul { margin: 0 0 1em; padding-left: 1.4em; }
.legal-content li { margin-bottom: 0.4em; }

.section-eyebrow {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent-red);
  margin-bottom: 0.2em;
}

/* ===== Three ways to play ===== */
.section-modes { background: var(--blue-pale); max-width: none; }
.section-modes > h2 { text-align: center; max-width: var(--max-width); margin: 0 auto 1.5em; }

.modes-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.mode-card {
  --mode-color: var(--blue-deep);
  background: var(--mode-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 32px rgba(11, 61, 107, 0.35);
}
.mode-card--sandbox { --mode-color: #f0ffff; }
.mode-card--challenge { --mode-color: #27485a; }
.mode-card--yolo { --mode-color: #6e0001; }

.mode-card--sandbox .mode-card-body h3,
.mode-card--sandbox .mode-card-body p {
  color: #3f4853;
}

.mode-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: -1px;
}

.mode-clip {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mode-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: calc(10% + 1px);
  background: linear-gradient(to bottom, transparent 0%, var(--mode-color) 100%);
  pointer-events: none;
}

.mode-card-body {
  padding: 1.5rem;
}
.mode-card-body h3 { color: var(--white); }
.mode-card-body p { color: var(--blue-pale); }
.mode-card--challenge .mode-card-body h3,
.mode-card--challenge .mode-card-body p { color: #c4d9eb; }
.mode-card--yolo .mode-card-body h3,
.mode-card--yolo .mode-card-body p { color: #ffd6b2; }
.yolo-ps { color: rgba(255, 214, 178, 0.55); }

/* ===== Sandbox deep-dive ===== */
.section-sandbox {
  background: linear-gradient(180deg, var(--white) 0%, var(--blue-pale) 100%);
  max-width: none;
}
.section-sandbox > h2, .section-sandbox > .feature-highlights, .section-sandbox > .tools-grid {
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
}

.feature-highlights {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 3rem;
}

.feature-card {
  display: flex;
  justify-content: center;
  padding-bottom: 140px;
padding-top: 50px;
}

/* Positioning root for the overlapping text box — deliberately has no
   overflow:hidden of its own (unlike .feature-media below it), so the text
   box can hang below and poke out past the image without being clipped. */
.feature-visual {
  position: relative;
  width: min(400px, 100%);
  flex-shrink: 0;
}

.feature-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 32px rgba(11, 61, 107, 0.35);
}

/* Poster frame layered over a clip while it downloads, faded out via JS
   (adding .clip-poster-hidden) once the video actually starts playing —
   gives a smooth blend instead of an abrupt poster-to-video switch. */
.clip-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.clip-poster.clip-poster-hidden {
  opacity: 0;
}

.feature-clip {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feature-card-body {
  position: absolute;
  z-index: 2;
  left: 8%;
  width: 65%;
  top: 87.5%;
  background: var(--white);
  border-radius: 14px;
  padding: 1rem 1.3rem;
  box-shadow: 0 18px 38px rgba(11, 61, 107, 0.45);
}
.feature-card-body h3 {
  color: var(--blue-deep);
  font-size: 1.3rem;
  margin-bottom: 0.2em;
}
.feature-card-body p {
  color: var(--blue-mid);
  font-size: 0.85rem;
  margin: 0;
}

.toolbox-title {
  text-align: center;
  font-size: 1.5rem;
  margin: 0rem 0 0;
  color: var(--blue-deep);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2.5rem 1rem;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.tool-icon {
  width: 128px;
  height: 128px;
  object-fit: contain;
  filter: drop-shadow(0 20px 20px rgba(11, 61, 107, 0.4));
  transition: transform 0.15s ease;
}
.tool-card:hover .tool-icon,
.tool-card:focus .tool-icon,
.tool-card:focus-within .tool-icon {
  transform: translateY(-4px) scale(1.05);
}

.tool-name {
  font-family: var(--font-display);
  font-weight: 300;
  color: var(--blue-deep);
  font-size: 1.5rem;
}

.tool-tooltip {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  --tt-tx: -50%;
  --tt-ty: 6px;
  --tt-arrow: 50%;
  transform: translateX(var(--tt-tx)) translateY(var(--tt-ty));
  width: 300px;
  max-width: 70vw;
  background: var(--blue-deep);
  color: var(--blue-pale);
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 400;
  text-align: left;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(11, 61, 107, 0.3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}
.tool-tooltip-media {
  position: relative;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
}

.tool-tooltip-gif {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.tool-tooltip-text {
  margin: 0;
  padding: 0.9rem 1rem;
}
.tool-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--tt-arrow);
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--blue-deep);
}
/* Tooltip visibility is JS-controlled (script.js) via .tt-open, not :hover,
   so only one tool's bubble can ever be open at a time — plain CSS :hover
   can't guarantee that, especially on touch where taps can leave hover
   state "stuck" on more than one card. */
.tool-card.tt-open .tool-tooltip {
  opacity: 1;
  visibility: visible;
  --tt-ty: 0px;
}


/* Narrow screens: 2-column grid puts icons close to the viewport edges, so a
   centered tooltip can overflow off-screen. Anchor left-column tooltips to
   their icon's left edge (grow rightward) and right-column ones to the right
   edge (grow leftward) — both grow toward the center instead of off-screen.
   --tt-arrow repositions the arrow to stay under the icon (which sits at a
   fixed spot) instead of at the bubble's own center, since the bubble no
   longer straddles the icon symmetrically once shifted to an edge. */
@media (max-width: 640px) {
  .tool-tooltip { width: min(78vw, 300px); }

  .tool-card:nth-child(odd) .tool-tooltip {
    left: 0;
    --tt-tx: 0%;
    --tt-arrow: 105px;
  }
  .tool-card:nth-child(even) .tool-tooltip {
    left: auto;
    right: 0;
    --tt-tx: 0%;
    --tt-arrow: calc(100% - 95px);
  }
}


/* ===== About ===== */
.about-original { color: var(--blue-mid); }

/* ===== Community closing CTA ===== */
.section-community {
  text-align: center;
  background: var(--blue-deep);
  max-width: none;
  padding: 4.5rem 1.5rem;
  color: var(--white);
}
.section-community h2 { color: var(--white); }
.section-community p {
  max-width: 560px;
  margin: 0 auto 1.6em;
  color: var(--blue-pale);
}

/* ===== Support page / Contact ticket ===== */
.support-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

.support-intro { color: var(--ink); }

.support-form { display: flex; flex-direction: column; gap: 1.4rem; margin-top: 2rem; }

.support-field { display: flex; flex-direction: column; gap: 0.4em; }
.support-field label { font-weight: 700; color: var(--blue-deep); }
.support-optional { font-weight: 400; color: var(--ink); opacity: 0.6; font-size: 0.85em; }

.support-form input[type="text"],
.support-form textarea,
.support-form select {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--blue-pale);
  border-radius: 10px;
  padding: 0.7em 0.9em;
}
.support-form input[type="text"]:focus,
.support-form textarea:focus,
.support-form select:focus {
  outline: none;
  border-color: var(--blue-mid);
}
.support-form textarea { resize: vertical; }
.support-form select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%231f6fb2'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%231f6fb2' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8em center;
  padding-right: 2.4em;
}

.ticket-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.8em; text-align: center; }

.ticket-card {
  position: relative;
  width: 320px;
  aspect-ratio: 600 / 400;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 14px 32px rgba(11, 61, 107, 0.35);
}
#ticket-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

.ticket-reset-btn {
  background: transparent;
  border: none;
  color: var(--blue-mid);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.3em;
}

.support-code-hint { min-height: 1.2em; margin: 0; font-size: 0.9rem; }
.support-code-hint.is-error { color: var(--accent-red-dark); }
.support-code-hint.is-success { color: #2f8f4e; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--ink);
  color: var(--blue-pale);
  padding: 2.5rem 1.5rem 0;
}

.footer-main {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
  padding-bottom: 2rem;
}

.footer-dev { font-weight: 800; color: var(--white); margin-bottom: 0.2em; }
.footer-copyright { font-size: 0.85rem; opacity: 0.75; }

.footer-links { margin-top: 0.8em; font-size: 0.9rem; }
.footer-links a { color: var(--blue-pale); }
.footer-links .sep { margin: 0 0.6em; opacity: 0.5; }

/* ===== Funding compliance section =====
   White background is required here (not cosmetic): the official logo files
   render black/dark with no fill color set. */
.funding-section {
  text-align: center;
}

.funding-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
}

.funding-logo {
  height: 32px;
  width: auto;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .modes-grid { grid-template-columns: 1fr; }
  .funding-logos { gap: 1.5rem; }
}

@media (max-width: 640px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-highlights { grid-template-columns: 1fr; }
  .ticket-card { width: 260px; }
}

@media (max-width: 480px) {
  .hero-inner { padding: 2.5rem 1rem 3rem; }
  .section { padding: 3rem 1rem; }
  .btn { font-size: 0.95rem; padding: 0.75em 1.3em; }
  .support-content { padding: 3rem 1rem; }
  .ticket-card { width: 220px; }
}
