/* EuclideanKids website: a galactic home with the name huge and comic
   buttons into the app (served at /app). */

:root {
  --space-deep: #0b0626;
  --space-mid: #1d1052;
  --ink: #15112e;
  --cyan: #5ee7ff;
  --violet: #9b7bff;
  --pink: #ff6fb5;
  --peach: #ffc48a;
  --sun: #ffd84a;
  --mint: #6ff7c8;
  --white: #fdfbff;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 50% 120%, #3a1a7a 0%, transparent 55%),
    radial-gradient(ellipse at 50% -20%, #1b2a6b 0%, transparent 50%),
    linear-gradient(180deg, var(--space-deep) 0%, var(--space-mid) 60%, #2a1060 100%);
  color: var(--white);
  font-family: 'Fredoka', system-ui, sans-serif;
  overflow-x: hidden;
}

/* ---------------------------------------------------------- the galaxy */

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.nebula {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(closest-side at 22% 30%, rgba(155, 123, 255, 0.35), transparent),
    radial-gradient(closest-side at 80% 25%, rgba(94, 231, 255, 0.22), transparent),
    radial-gradient(closest-side at 70% 80%, rgba(255, 111, 181, 0.25), transparent),
    radial-gradient(closest-side at 15% 85%, rgba(255, 196, 138, 0.15), transparent);
  filter: blur(30px);
  animation: drift 40s ease-in-out infinite alternate;
}

.planet {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
}

.planet-a {
  width: clamp(110px, 14vw, 210px);
  aspect-ratio: 1;
  top: 1%;
  right: -6%;
  background: radial-gradient(circle at 30% 30%, #ffb3d9, #c2459a 60%, #5a1450);
  box-shadow: 0 0 60px rgba(255, 111, 181, 0.45), inset -18px -18px 40px rgba(0, 0, 0, 0.35);
  animation: float 9s ease-in-out infinite;
}

/* Its ring. */
.planet-a::after {
  content: '';
  position: absolute;
  inset: 38% -30%;
  border-radius: 50%;
  border: 4px solid rgba(255, 216, 74, 0.7);
  transform: rotate(-18deg);
}

.planet-b {
  width: clamp(70px, 9vw, 130px);
  aspect-ratio: 1;
  bottom: 12%;
  left: 4%;
  background: radial-gradient(circle at 30% 30%, #b8fff0, #2fb7c9 60%, #134a6b);
  box-shadow: 0 0 40px rgba(94, 231, 255, 0.4), inset -10px -10px 24px rgba(0, 0, 0, 0.35);
  animation: float 12s ease-in-out infinite reverse;
}

@keyframes drift {
  from { transform: translate(-2%, -1%) scale(1); }
  to { transform: translate(2%, 1%) scale(1.06); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

/* ------------------------------------------------------------- the hero */

.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 48px;
  text-align: center;
}

.title {
  margin: 0;
  font-family: 'Audiowide', 'Fredoka', sans-serif;
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: float 7s ease-in-out infinite;
}

.title span {
  display: block;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  /* The glow sits on a copy behind the gradient text. */
  filter: drop-shadow(0 0 18px rgba(155, 123, 255, 0.55)) drop-shadow(0 6px 0 rgba(21, 17, 46, 0.9));
}

.title-top {
  font-size: clamp(3.2rem, 13.5vw, 12.5rem);
  background-image: linear-gradient(100deg, var(--cyan) 0%, var(--violet) 45%, var(--pink) 100%);
}

.title-bottom {
  font-size: clamp(4.8rem, 24vw, 22rem);
  background-image: linear-gradient(100deg, var(--sun) 0%, var(--peach) 40%, var(--pink) 100%);
  margin-top: -0.04em;
}

.tagline {
  margin: 12px 0 0;
  font-size: clamp(1.05rem, 2.4vw, 1.6rem);
  font-weight: 600;
  color: rgba(253, 251, 255, 0.85);
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------- comic buttons */

.actions {
  margin-top: clamp(28px, 5vh, 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
}

/* The link holds a comic starburst and, over it, the button's face. */
.comic-btn {
  --face: var(--sun);
  --shadow: var(--ink);
  --burst: var(--white);
  --tilt: -1.2deg;
  position: relative;
  display: inline-block;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.comic-btn:nth-child(2n) { --tilt: 1.2deg; }

.comic-btn .face {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 260px;
  padding: 16px 30px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  background-color: var(--face);
  /* Halftone dots, comic style. */
  background-image: radial-gradient(rgba(21, 17, 46, 0.14) 1.5px, transparent 1.6px);
  background-size: 9px 9px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--shadow);
  transform: rotate(var(--tilt));
  transition: transform 0.18s cubic-bezier(0.34, 1.8, 0.64, 1), box-shadow 0.18s ease, filter 0.18s ease;
}

/* The "activation": a starburst popping out behind the button. */
.comic-btn .burst {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: calc(100% + 70px);
  height: calc(100% + 64px);
  background: var(--burst);
  border-radius: 0;
  clip-path: polygon(50% 0%, 56% 22%, 68% 4%, 70% 26%, 86% 10%, 82% 32%, 100% 26%, 88% 44%, 100% 56%,
    86% 64%, 96% 84%, 76% 76%, 74% 98%, 62% 80%, 50% 100%, 40% 80%, 26% 98%, 24% 76%, 4% 84%, 14% 64%,
    0% 56%, 12% 44%, 0% 26%, 18% 32%, 14% 10%, 30% 26%, 32% 4%, 44% 22%);
  transform: translate(-50%, -50%) scale(0.2) rotate(-12deg);
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.34, 1.9, 0.64, 1), opacity 0.12s ease;
  pointer-events: none;
}

.comic-btn:hover .face,
.comic-btn:focus-visible .face {
  transform: translate(-4px, -4px) rotate(calc(var(--tilt) * 2.5)) scale(1.06);
  box-shadow: 11px 11px 0 var(--shadow);
  filter: saturate(1.2) brightness(1.05);
}

.comic-btn:hover .burst,
.comic-btn:focus-visible .burst {
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
  opacity: 1;
  animation: pulse 0.9s ease-in-out infinite 0.26s;
}

.comic-btn:hover .label,
.comic-btn:focus-visible .label {
  display: inline-block;
  animation: zap 0.35s ease;
}

.comic-btn:active .face {
  transform: translate(3px, 3px) rotate(0deg) scale(0.98);
  box-shadow: 2px 2px 0 var(--shadow);
  transition-duration: 0.06s;
}

.comic-btn:focus-visible .face { outline: 3px dashed var(--white); outline-offset: 6px; }

.comic-btn--student { --face: var(--sun); --burst: var(--cyan); }
.comic-btn--tutor { --face: var(--cyan); --burst: var(--sun); }

.comic-btn--join { --face: var(--pink); --burst: var(--sun); --tilt: -2deg; }

.comic-btn--join .face {
  min-width: 300px;
  padding: 20px 40px;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  color: var(--white);
  text-shadow: 2px 2px 0 var(--ink);
  animation: wobble 2.6s ease-in-out infinite;
}

.comic-btn--join:hover .face,
.comic-btn--join:focus-visible .face {
  animation: none;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  50% { transform: translate(-50%, -50%) scale(1.07) rotate(2deg); }
}

@keyframes zap {
  0% { transform: scale(1); }
  40% { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(1); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(-2deg) scale(1); }
  50% { transform: rotate(1deg) scale(1.04); }
}

@media (max-width: 600px) {
  .actions-row { flex-direction: column; align-items: center; gap: 18px; }
  .comic-btn .face { min-width: min(300px, 82vw); }
  .comic-btn--join .face { min-width: min(320px, 86vw); }
}

@media (prefers-reduced-motion: reduce) {
  .title, .planet, .nebula, .comic-btn--join .face { animation: none; }
  .comic-btn:hover .burst, .comic-btn:focus-visible .burst { animation: none; }
}

/* ------------------------------------------------------- language switch */

.lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  padding: 4px;
  gap: 4px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: rgba(253, 251, 255, 0.12);
  backdrop-filter: blur(6px);
  box-shadow: 3px 3px 0 var(--ink);
}

.lang-switch button {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--white);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.lang-switch button:hover { transform: scale(1.08); }

.lang-switch button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--sun);
}

.lang-switch button:focus-visible { outline: 2px dashed var(--white); outline-offset: 2px; }

/* ------------------------------------------------------- the warp, into the app */

body.warping .hero {
  transform: scale(2.4);
  opacity: 0;
  filter: blur(6px);
  transition: transform 1.1s cubic-bezier(0.6, 0, 0.9, 0.4), opacity 0.8s ease-in 0.2s, filter 1s ease-in;
}

body.warping .planet,
body.warping .title,
body.warping .nebula {
  animation: none;
}

body.warping .planet-a {
  transform: translate(40vw, -45vh) scale(3);
  opacity: 0;
  transition: transform 1.1s cubic-bezier(0.6, 0, 0.9, 0.4), opacity 0.9s ease-in;
}

body.warping .planet-b {
  transform: translate(-45vw, 45vh) scale(3);
  opacity: 0;
  transition: transform 1.1s cubic-bezier(0.6, 0, 0.9, 0.4), opacity 0.9s ease-in;
}

body.warping .nebula {
  transform: scale(1.5);
  opacity: 0.4;
  transition: transform 1.3s ease-in, opacity 1.3s ease-in;
}

body.warping .lang-switch {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* The white the app starts on. */
#warp-flash {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-in;
}

#warp-flash.on {
  opacity: 1;
  pointer-events: auto;
}
