/* ============================================================
   InsanityCraft — happy, friendly, colourful title screen.
   Structure mirrors the Willowbrook homepage (breathing logo,
   tagline, action row, hover-reveal footer, floating top-right
   controls) skinned bright and playful over the ic_bg artwork:
   blue sky, castle, waterfalls, cherry trees.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --sky:        #6db9f7;
  --ink:        #23324a;
  --ink-soft:   #52617a;

  /* brand accents (from the logo) */
  --green:      #57bd39;
  --green-deep: #3a9e22;
  --gold:       #ffc12e;
  --gold-deep:  #f2960d;
  --cyan:       #33c6e6;
  --cyan-deep:  #14a6c9;
  --blurple:    #5865f2;
  --blurple-deep:#4854e0;
  --pink:       #ec52ac;
  --pink-deep:  #d5348f;

  --font-display: 'Fredoka', 'Trebuchet MS', sans-serif;
  --font-body:    'Nunito', 'Segoe UI', system-ui, sans-serif;

  --radius:   16px;
  --shadow:   0 14px 30px -14px rgba(29, 46, 79, .5);
}

/* ---------- Reset-ish ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--sky); }
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--sky);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--cyan-deep); }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-deep); outline-offset: 2px; border-radius: 6px; }

/* ============================================================
   NAV — floating controls, top-right
   ============================================================ */
.nav { position: absolute; top: 0; left: 0; right: 0; z-index: 50; }
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-spacer { margin-right: auto; }
.nav-links { display: flex; align-items: center; gap: 10px; list-style: none; }

/* frosted pill shared by Menu + Login */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .98rem;
  color: var(--ink);
  background: rgba(255, 255, 255, .82);
  border: 1.5px solid rgba(255, 255, 255, .95);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(23, 48, 91, .28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform .15s ease, background .18s ease, box-shadow .15s ease;
}
.chip:hover, .chip:focus-visible {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 8px 20px rgba(23, 48, 91, .34);
}
.chip svg { width: 16px; height: 16px; }

/* Store — the loud, gilded one */
.nav-store {
  color: #5a3a00;
  background: linear-gradient(180deg, #ffe08a 0%, #ffc12e 52%, #f2960d 100%);
  border: 1.5px solid #e08a06;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 5px 16px rgba(122, 76, 6, .45);
}
.nav-store:hover, .nav-store:focus-visible {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 9px 22px rgba(122, 76, 6, .5);
}

/* Menu dropdown */
.dropdown { position: relative; }
.dropdown-toggle svg { transition: transform .18s ease; }
.dropdown.open .dropdown-toggle svg { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 214px;
  padding: 8px;
  list-style: none;
  background: rgba(255, 255, 255, .97);
  border: 1.5px solid #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px) scale(.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dropdown-menu a, .dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 10px;
  transition: background .15s ease, transform .12s ease;
}
.dropdown-menu a svg, .dropdown-menu button svg { width: 18px; height: 18px; color: var(--cyan-deep); flex: none; }
.dropdown-menu a:hover, .dropdown-menu a:focus-visible,
.dropdown-menu button:hover, .dropdown-menu button:focus-visible {
  background: rgba(51, 198, 230, .14);
  transform: translateX(2px);
}

/* Burger */
.burger { display: none; padding: 9px; border: 0; background: rgba(255,255,255,.82); border-radius: 12px; box-shadow: 0 4px 14px rgba(23,48,91,.28); }
.burger svg { width: 26px; height: 26px; stroke: var(--ink); }

/* ============================================================
   HERO — the title screen over the artwork
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  background-color: var(--sky);
  background-image: url("../assets/bg-hero.webp?v=1");
  background-size: cover;
  background-position: center 38%;
}
@media (max-width: 700px) {
  .hero { background-image: url("../assets/bg-hero-sm.webp?v=1"); }
}
/* white wash veil (Willowbrook-style): softens the artwork so the
   content sits comfortably on top, stronger at the edges */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, .60) 0%,
    rgba(255, 255, 255, .42) 30%,
    rgba(255, 255, 255, .42) 70%,
    rgba(255, 255, 255, .64) 100%);
}

/* twinkly sparkles in the sky */
.spark {
  position: absolute;
  z-index: 2;
  width: var(--ss, 10px);
  height: var(--ss, 10px);
  pointer-events: none;
  color: var(--sc, #fff);
  opacity: 0;
  animation: spark-tw var(--sd, 3.2s) ease-in-out var(--sdl, 0s) infinite;
}
.spark::before {
  content: ""; position: absolute; inset: 0;
  background: currentColor;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}
@keyframes spark-tw {
  0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); }
  50%      { opacity: .95; transform: scale(1) rotate(45deg); }
}

.hero-inner {
  position: relative;
  z-index: 3;
  max-width: 1060px;
  width: 100%;
  margin: 0 auto;
  padding: 58px 20px 108px; /* bottom-heavy: floats the content above centre */
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* breathing logo — scale DOWN from natural size only (never past
   100%: upscaling a rasterised layer mid-animation goes blurry) */
.hero-logo-wrap {
  display: block;
  width: min(560px, 88%); /* logo served at exactly 2x this (1120px) so the
                             animated layer downscales clean, never shimmery */
  margin: 0 auto;
  will-change: transform;
  animation: logo-breathe 5.5s ease-in-out infinite;
}
@keyframes logo-breathe {
  0%, 100% { transform: scale(.95); }
  50%      { transform: scale(1); }
}
.hero-logo {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 12px 22px rgba(16, 34, 66, .45));
}

/* catchphrase — small, quiet, one line; ink with a soft white halo
   over the washed artwork (Willowbrook treatment) */
.tagline {
  margin: 8px auto 28px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(.98rem, 2vw, 1.18rem);
  letter-spacing: .2px;
  color: var(--ink);
  text-shadow: 0 0 6px rgba(255,255,255,.95), 0 0 14px rgba(255,255,255,.85), 0 2px 3px rgba(255,255,255,.9);
}

/* ---------- Action row: 4 in a line ---------- */
.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 215px));
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.action-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 20px 14px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, .93);
  border: 2px solid #fff;
  border-radius: var(--radius);
  box-shadow: 0 10px 26px -10px rgba(16, 34, 66, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  cursor: pointer;
}
.action-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent2, var(--accent)));
}
.action-card:hover, .action-card:focus-visible {
  transform: translateY(-4px);
  background: #fff;
  box-shadow: 0 18px 34px -12px color-mix(in srgb, var(--accent) 45%, rgba(16,34,66,.6));
}
.action-card:active { transform: translateY(-1px); }
.action-icon {
  width: 50px;
  height: 50px;
  margin-bottom: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--accent2, var(--accent)));
  border-radius: 15px;
  box-shadow: 0 7px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .2s ease;
}
.action-card:hover .action-icon { transform: rotate(-6deg) scale(1.08); }
.action-icon svg { width: 27px; height: 27px; }
.action-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.06rem;
  line-height: 1.25;
}
.action-sub {
  font-weight: 700;
  font-size: .84rem;
  color: var(--ink-soft);
  word-break: break-word;
}

/* ============================================================
   Footer — hover-reveal on desktop home
   ============================================================ */
.footer {
  background: linear-gradient(180deg, #2b3b57, #23324a);
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.footer-copy { color: #a9b6cc; font-size: .95rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; list-style: none; }
.footer-links a, .footer-links button {
  color: #dbe6f7; text-decoration: none; font-size: .97rem; background: none; border: 0;
  font-family: inherit; transition: color .15s ease;
}
.footer-links a:hover, .footer-links button:hover { color: var(--gold); }

/* ============================================================
   Modal + toast
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 20px;
  background: rgba(16, 34, 66, .5);
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }
.modal {
  max-width: 420px; width: 100%;
  padding: 30px 26px;
  text-align: center;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.modal-emoji { font-size: 2.6rem; line-height: 1; }
.modal h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; margin-top: 10px; }
.modal p { margin: 10px 0 20px; color: var(--ink-soft); }
.btn-solid {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 24px;
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem;
  color: #fff; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, var(--cyan), var(--cyan-deep));
  box-shadow: 0 8px 18px -6px rgba(20, 166, 201, .6);
  transition: transform .15s ease, filter .15s ease;
}
.btn-solid:hover { transform: translateY(-1px); filter: brightness(1.05); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 95;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 20px;
  font-family: var(--font-display); font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #3a4a68, #23324a);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(16, 34, 66, .5);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: var(--green); }

/* ============================================================
   Responsive
   ============================================================ */
/* squeeze the row before wrapping it */
@media (max-width: 900px) {
  .actions { grid-template-columns: repeat(2, minmax(150px, 230px)); }
}
@media (max-width: 380px) {
  .actions { grid-template-columns: minmax(0, 260px); }
}

/* short viewports: shrink the logo so everything stays on screen */
@media (max-height: 760px) {
  .hero-logo-wrap { width: min(470px, 80%); }
  .tagline { margin-bottom: 22px; }
  .hero-inner { padding-bottom: 84px; }
}
@media (max-height: 640px) {
  .hero-logo-wrap { width: min(380px, 68%); }
}

/* mobile: collapse the right-hand controls into a burger sheet */
@media (max-width: 780px) {
  .burger { display: inline-flex; }
  .nav-links {
    position: absolute;
    top: calc(100% + 10px);
    right: max(14px, env(safe-area-inset-right));
    left: max(14px, env(safe-area-inset-left));
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    background: rgba(255,255,255,.97);
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
  }
  .nav-links.open { display: flex; }
  .chip, .nav-store { justify-content: center; width: 100%; }
  .dropdown-menu {
    position: static; opacity: 1; transform: none; pointer-events: auto;
    display: none; box-shadow: none; margin-top: 6px; background: rgba(51,198,230,.08);
    border-color: rgba(51,198,230,.2);
  }
  .dropdown.open .dropdown-menu { display: block; }
}

/* desktop home: no scroll, footer is a hover-reveal strip */
@media (min-width: 781px) {
  body.home { height: 100vh; height: 100dvh; overflow: hidden; }
  body.home .hero { height: 100vh; height: 100dvh; min-height: 0; }
  body.home .footer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    transform: translateY(calc(100% - 14px));
    transition: transform .35s ease;
  }
  body.home .footer::before {
    content: "";
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 54px; height: 4px; margin-top: 5px; border-radius: 3px;
    background: rgba(255,255,255,.5);
  }
  body.home .footer:hover, body.home .footer:focus-within { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .spark { display: none !important; }
}
