@font-face {
  font-family: "MadInk";
  src: url("/fonts/MadInk.woff2") format("woff2"),
       url("/fonts/MadInk.woff") format("woff");
  font-display: swap;
}

/* ---------- Theme tokens: warm pink light, cool green dark ---------- */

:root {
  color-scheme: light;
  --bg: #fbeef2;
  --text: #2b0a1d;
  --muted: #4a3540;
  --blob-1: #ffb6d5;   /* bubblegum */
  --blob-2: #ffc9d4;   /* candy */
  --blob-3: #f9a6cf;   /* fuchsia haze */
  --blob-4: #ffd6e2;   /* blush */
  --blob-5: #f6bde8;   /* orchid */
  --glass: #fff6f9c4;
  --glass-border: #2b1c201a;
  --field: #ffffffb3;
  --accent: #ff3d9a;          /* hot pink */
  --accent-hover: #ff5aab;
  --accent-text: #2b0a1d;     /* deep plum */
  --req: #c4175f;             /* asterisk: darker pink, readable on light */
  --error: #b3403a;
  --success: #c4175f;          /* confirmation text: deeper pink, readable on light */
  --grain-opacity: .16;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1411;
  --text: #e3eee9;
  --muted: #b8ccc4;
  --blob-1: #143229;   /* pine */
  --blob-2: #183b33;   /* deep teal-green */
  --blob-3: #1e3b29;   /* moss */
  --blob-4: #11302e;   /* sea */
  --blob-5: #1d3d35;   /* fern */
  --glass: #101b18c7;
  --glass-border: #e3eee91f;
  --field: #e3eee90d;
  --accent: #8cd2b2;          /* mint */
  --accent-hover: #a6dfc5;
  --accent-text: #0b1411;
  --req: #8cd2b2;
  --error: #f0a39b;
  --success: #a9dcc3;
  --grain-opacity: .12;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1411;
    --text: #e3eee9;
    --muted: #b8ccc4;
    --blob-1: #143229;
    --blob-2: #183b33;
    --blob-3: #1e3b29;
    --blob-4: #11302e;
    --blob-5: #1d3d35;
    --glass: #101b18c7;
    --glass-border: #e3eee91f;
    --field: #e3eee90d;
    --accent: #8cd2b2;
    --accent-hover: #a6dfc5;
    --accent-text: #0b1411;
    --req: #8cd2b2;
    --error: #f0a39b;
    --success: #a9dcc3;
    --grain-opacity: .12;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Roboto Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color .6s ease, color .6s ease;
}

/* ---------- Hazy background: soft shapes drifting very slowly ---------- */

.haze {
  position: fixed;
  inset: -10%;
  overflow: hidden;
  z-index: -2;
}

/* Soft edges are built into the gradient (no blur filter), so the shapes
   animate with cheap transforms only. That keeps phones smooth. */
.blob {
  position: absolute;
  width: 60vmax;
  height: 48vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    var(--c) 0%,
    color-mix(in srgb, var(--c) 72%, transparent) 25%,
    color-mix(in srgb, var(--c) 38%, transparent) 50%,
    color-mix(in srgb, var(--c) 12%, transparent) 75%,
    transparent 100%);
  will-change: transform;
}

.b1 { --c: var(--blob-1); top: -10%; left: -10%; animation: drift1 30s ease-in-out infinite alternate; }
.b2 { --c: var(--blob-2); top: 40%;  left: 50%;  animation: drift2 36s ease-in-out infinite alternate; }
.b3 { --c: var(--blob-3); top: -5%;  left: 45%;  animation: drift3 27s ease-in-out infinite alternate; }
.b4 { --c: var(--blob-4); top: 50%;  left: -15%; animation: drift4 40s ease-in-out infinite alternate; }
.b5 { --c: var(--blob-5); top: 20%;  left: 20%;  width: 45vmax; height: 38vmax; animation: drift5 33s ease-in-out infinite alternate; }

@keyframes drift1 {
  50%  { transform: translate(14vw, 4vh) rotate(18deg) scale(1.12); }
  100% { transform: translate(22vw, 16vh) rotate(30deg) scale(.95); }
}
@keyframes drift2 {
  50%  { transform: translate(-12vw, -12vh) rotate(-16deg) scale(.88); }
  100% { transform: translate(-24vw, -4vh) rotate(-28deg) scale(1.08); }
}
@keyframes drift3 {
  50%  { transform: translate(-16vw, 10vh) rotate(24deg) scale(1.15); }
  100% { transform: translate(-6vw, 24vh) rotate(40deg) scale(.92); }
}
@keyframes drift4 {
  50%  { transform: translate(16vw, -8vh) rotate(-20deg) scale(1.1); }
  100% { transform: translate(26vw, -18vh) rotate(-32deg) scale(.96); }
}
@keyframes drift5 {
  50%  { transform: translate(12vw, 14vh) rotate(30deg) scale(.86); }
  100% { transform: translate(-10vw, 20vh) rotate(55deg) scale(1.1); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  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='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Touch screens: blending a full-screen layer over a moving background is
   expensive, so use a plain, fainter grain instead */
@media (hover: none), (pointer: coarse) {
  .grain { mix-blend-mode: normal; opacity: .06; }
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 0;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}

.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity .3s ease, transform .4s ease;
}

/* moon in light mode (click → dark), sun in dark mode */
.theme-toggle .sun { opacity: 0; transform: rotate(-90deg) scale(.6); }
:root[data-theme="dark"] .theme-toggle .sun { opacity: 1; transform: none; }
:root[data-theme="dark"] .theme-toggle .moon { opacity: 0; transform: rotate(90deg) scale(.6); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { opacity: 1; transform: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { opacity: 0; transform: rotate(90deg) scale(.6); }
}

/* ---------- Hero ---------- */

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 72px 16px 24px;
}

h1 {
  width: 100%;
  margin: 0 0 28px;
  font-family: "MadInk", cursive;
  font-weight: 400;
  /* fallback before script sizes it to fit */
  font-size: var(--title-size, clamp(2.6rem, 10vw, 8rem));
  line-height: 1.2;
  color: var(--text);
  transition: opacity .6s ease;
}

.js h1:not(.ready) { opacity: 0; }

/* Built by script.js: lines → letter containers */
.line { display: block; height: 1.2em; white-space: nowrap; }
.sp { display: inline-block; }

.ch {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  align-items: baseline;
  /* zero height: every font shares the baseline without stretching the line */
  height: 0;
}

.g {
  grid-area: 1 / 1;
  line-height: 0;
  white-space: nowrap;
}

.lede {
  margin: 0 0 40px;
  max-width: 560px;
  font-size: .95rem;
  line-height: 1.75;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  text-wrap: pretty;
}

@media (min-width: 1100px) {
  .lede { max-width: 720px; }
}

@media (max-width: 560px) {
  .hero { padding-left: 8px; padding-right: 8px; }
  .lede { padding: 0 8px; font-size: .78rem; line-height: 1.7; letter-spacing: .03em; }
  .btn { font-size: .82rem; padding: 13px 26px; }
  .footer { font-size: 11px; }
}

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 30px;
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background-color .2s ease, transform .25s ease;
}

/* Organic shadow: a soft, blurred glow in the button's color that breathes */
.btn::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 35% 4% -22% 8%;
  background: var(--accent);
  border-radius: 46% 54% 60% 40% / 55% 45% 55% 45%;
  filter: blur(14px);
  opacity: .55;
  animation: breathe 7s ease-in-out infinite alternate;
  transition: opacity .3s ease, inset .3s ease;
}

@keyframes breathe {
  0%   { transform: translateX(-3%) scale(.96, .9) rotate(-2deg); }
  50%  { transform: translateX(2%) scale(1.04, 1.02) rotate(1deg); }
  100% { transform: translateX(4%) scale(.98, .94) rotate(3deg); }
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.btn:hover::before { opacity: .75; inset: 40% 2% -34% 6%; }

.btn:active { transform: translateY(0); }
.btn:active::before { opacity: .4; inset: 30% 8% -12% 10%; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }
.btn:disabled::before { animation: none; opacity: .25; }

.btn-full { width: 100%; margin-top: 6px; }

.footer {
  padding: 24px 16px 28px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Dialog ---------- */

dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 0;
  box-shadow: 0 40px 100px -30px #00000073;
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

dialog::backdrop {
  background: #00000033;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog[open] { animation: rise .3s cubic-bezier(.2, .8, .2, 1); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
}

form { display: flex; flex-direction: column; gap: 16px; padding: 24px 26px; }

.dialog-head { display: flex; align-items: center; justify-content: space-between; }

.dialog-head h2 {
  margin: 0;
  font-family: "MadInk", cursive;
  font-weight: 400;
  font-size: 2rem;
  text-transform: lowercase;
}

.close {
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.close:hover { color: var(--text); background: var(--glass-border); }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

input, textarea {
  font: inherit;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--glass-border);
  border-radius: 0;
  padding: 11px 13px;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.legend {
  margin: -6px 0 0;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.req { color: var(--req); font-weight: 500; }

/* After a failed submit, flag the fields that still need attention */
.was-validated input:invalid,
.was-validated textarea:invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 18%, transparent);
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.status { margin: 0; min-height: 1.3em; font-size: 12px; line-height: 1.5; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.status.error { color: var(--error); }
.status.success { color: var(--success); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
