/* Landing page (/) — Telluna Guide Program.
   Two themes: "Night" (default, deep navy + gold moon) and "Paper" (light,
   near-white + gold), switched via html[data-theme="light"]. */

:root {
  color-scheme: dark;
  --bg: #0f1524;
  --ink: #f3efe6;
  --ink-2: #a7adbd;
  --ink-3: #666e82;
  --glow-1: #1f2b4a;
  --glow-2: #3a2c25;
  --ring: rgba(240, 220, 170, 0.14);
  --moon: #f0c96a;
  --moon-halo: rgba(240, 201, 106, 0.22);
  --chip-bg: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.12);
  --card: rgba(255, 255, 255, 0.05);
  --btn: #f0c96a;
  --btn-hover: #f5d685;
  --btn-text: #141824;
  --kicker: var(--moon);
  --focus: var(--moon);
  --hover-bg: rgba(255, 255, 255, 0.09);
  --hover-line: rgba(255, 255, 255, 0.24);
  --card-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  --grain-opacity: 0.18;
  --grain-blend: screen;
  --logo-filter: invert(1);
  --logo-opacity: 0.94;
  --orbit: 780px;
}

/* Light theme — "Periwinkle": cool paper white + periwinkle accent. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fa;
  --ink: #141a33;
  --ink-2: #5a6077;
  --ink-3: #9a9fb0;
  --glow-1: #dfe5fb;
  --glow-2: #ece6f8;
  --ring: rgba(40, 55, 120, 0.12);
  --moon: #5b6ee1;
  --moon-halo: rgba(91, 110, 225, 0.2);
  /* Slightly deeper than the moon so white button text meets WCAG AA (~4.9:1). */
  --btn: #5266d9;
  --btn-hover: #4658c8;
  --btn-text: #ffffff;
  --chip-bg: #ffffff;
  --line: rgba(20, 26, 51, 0.1);
  --card: #ffffff;
  --kicker: var(--ink);
  --focus: var(--ink);
  --hover-bg: #ffffff;
  --hover-line: rgba(20, 26, 51, 0.22);
  --card-shadow: 0 14px 40px rgba(20, 26, 51, 0.07);
  --grain-opacity: 0.3;
  --grain-blend: multiply;
  --logo-filter: none;
  --logo-opacity: 1;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- Background ---------- */

.bg {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, var(--glow-1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 100% 100%, var(--glow-2) 0%, transparent 60%),
    var(--bg);
}

/* Film grain. */
.bg::before {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  content: "";
}

.ring {
  position: absolute;
  top: 48%;
  left: 50%;
  border: 1px solid var(--ring);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.ring--1 { width: var(--orbit); height: var(--orbit); }
.ring--2 { width: calc(var(--orbit) * 1.385); height: calc(var(--orbit) * 1.385); opacity: 0.65; }
.ring--3 { width: calc(var(--orbit) * 1.795); height: calc(var(--orbit) * 1.795); opacity: 0.4; }

/* The moon travels slowly along the inner ring. */
.orbit {
  position: absolute;
  top: 48%;
  left: 50%;
  width: var(--orbit);
  height: var(--orbit);
  margin: calc(var(--orbit) / -2) 0 0 calc(var(--orbit) / -2);
  transform: rotate(45deg);
  animation: orbit 180s linear infinite;
}

.moon {
  position: absolute;
  top: -6px;
  left: calc(50% - 6px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--moon);
  box-shadow: 0 0 0 7px var(--moon-halo), 0 0 30px var(--moon-halo);
}

@keyframes orbit {
  from { transform: rotate(45deg); }
  to { transform: rotate(405deg); }
}

/* ---------- Layout ---------- */

.page {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 48px;
}

.brand img {
  display: block;
  width: 84px;
  height: auto;
  filter: var(--logo-filter);
  opacity: var(--logo-opacity);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.signin,
.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--chip-bg);
  transition: border-color 160ms ease, background 160ms ease;
}

.signin {
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 500;
}

.signin:hover,
.theme-toggle:hover {
  border-color: var(--hover-line);
  background: var(--hover-bg);
}

/* Theme switch: shows the sun in dark mode, the moon in light mode. */
.theme-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 48px 60px;
  text-align: center;
}

.kicker {
  margin: 0 0 28px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--kicker);
  background: var(--chip-bg);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* Light theme: dark kicker text with a small gold dot. */
html[data-theme="light"] .kicker::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--moon);
  vertical-align: 1px;
  content: "";
}

h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.6rem, 6.4vw, 4.625rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.rotating-word {
  color: var(--moon);
  display: inline-block;
}

.rotating-word.fade-out {
  opacity: 0;
  transition: opacity 200ms ease;
}

.rotating-word.fade-in {
  opacity: 1;
  transition: opacity 200ms ease;
}

.lede {
  max-width: 560px;
  margin: 24px 0 40px;
  color: var(--ink-2);
  font-size: clamp(1.02rem, 1.6vw, 1.1875rem);
  line-height: 1.55;
}

.cta {
  width: min(100%, 480px);
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.cta p {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 0.875rem;
}

.cta-form {
  display: grid;
  gap: 12px;
}

.cta-field {
  display: grid;
  gap: 12px;
}

.cta-field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--chip-bg);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.cta-field input::placeholder {
  color: var(--ink-3);
}

.cta-field input:focus {
  border-color: var(--moon);
  outline: none;
  box-shadow: 0 0 0 3px var(--moon-halo);
}

.cta-field .button {
  width: 100%;
}

.cta-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  color: #f5a5a5;
  background: rgba(220, 80, 80, 0.12);
  font-size: 0.8125rem;
}

html[data-theme="light"] .cta-error {
  color: #a02525;
  background: #fdf0f0;
}

.cta-note {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.75rem;
  text-align: center;
}

.cta-success {
  text-align: center;
}

.cta-success p {
  margin: 0;
  color: var(--moon);
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px;
  border: 0;
  border-radius: 12px;
  color: var(--btn-text);
  background: var(--btn);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.button:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}

.button__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(20, 24, 36, 0.3);
  border-top-color: var(--btn-text);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.footer {
  padding: 0 0 24px;
  color: var(--ink-3);
  font-size: 0.75rem;
  text-align: center;
}

.footer p {
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  :root {
    --orbit: 520px;
  }

  .header {
    padding: 18px 20px;
  }

  .brand img {
    width: 74px;
  }

  .main {
    padding: 24px 20px 48px;
  }

  .kicker {
    margin-bottom: 22px;
  }

  h1 {
    letter-spacing: -0.04em;
  }

  .lede {
    margin: 20px 0 32px;
  }

  .cta {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orbit {
    animation: none;
  }

  .button,
  .signin,
  .theme-toggle {
    transition: none;
  }

  .button:hover {
    transform: none;
  }
}
