/* TomeWorm — brand/BRAND.md in code. Dark-first: the art wants it. */

:root {
  color-scheme: dark;
  --space: #0B1F3B;       /* Deep Space */
  --space-deep: #071630;
  --coral: #FF7A66;       /* Cosmic Coral — dark-background colour only */
  --stardust: #FFF7E6;    /* the text colour on Deep Space */
  --sage: #7DA78B;
  --nebula: #A78BFA;
  --asteroid: #2E3A4B;
  --ink-dim: rgba(255, 247, 230, .78);
  --ink-faint: rgba(255, 247, 230, .6);
  --line: rgba(255, 247, 230, .16);
  --card: rgba(255, 247, 230, .06);
  --card-hi: rgba(255, 247, 230, .1);
  --display: "Fredoka", "Trebuchet MS", "Segoe UI", sans-serif;
  --body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --wrap: 1080px;
  --gutter: clamp(18px, 5vw, 56px);
  --radius: 18px;
  --nav-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 18px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: hidden;
  background: var(--space); color: var(--stardust);
  font-family: var(--body); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--stardust); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 4px; border-radius: 6px; }
.wrap { width: min(var(--wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }
code { white-space: nowrap; font: 500 .95em/1 ui-monospace, "SF Mono", Menlo, monospace; background: var(--card-hi); padding: 2px 6px; border-radius: 6px; }

.skip {
  position: absolute; left: 12px; top: -100px; z-index: 100;
  background: var(--coral); color: var(--space); padding: 10px 14px;
  font-size: 13px; font-weight: 600; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* Type */
.kicker {
  margin: 0 0 14px;
  color: var(--coral); font: 600 12px/1.4 var(--body);
  letter-spacing: .16em; text-transform: uppercase;
}
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; line-height: 1.08; text-wrap: balance; }
h1 { font-size: clamp(36px, 7.2vw, 66px); letter-spacing: -.01em; }
h1 > span, .sub > span, .tile p > span, .card p > span { display: block; }
h2 { margin-bottom: clamp(22px, 3.5vw, 36px); font-size: clamp(30px, 5vw, 48px); }
h3 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 500; }
.sub { margin: 18px 0 0; color: var(--ink-dim); font-size: clamp(17px, 2vw, 20px); }

/* Buttons — a coral button always takes Deep Space text. Never white. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 50px; padding: 13px 24px;
  border: 1.5px solid var(--stardust); border-radius: 999px;
  background: transparent; color: var(--stardust);
  font: 600 16px/1 var(--body); text-decoration: none; cursor: pointer;
  transition: background-color .16s var(--ease), color .16s var(--ease), transform .08s var(--ease), border-color .16s var(--ease);
}
.btn:hover, .btn:focus-visible { background: var(--card-hi); }
.btn.primary { background: var(--coral); border-color: var(--coral); color: var(--space); }
.btn.primary:hover, .btn.primary:focus-visible { background: #FF937F; border-color: #FF937F; color: var(--space); }
.btn:active { transform: scale(.97); }
.btn[disabled] { cursor: progress; opacity: .85; }
.text-link { display: inline-flex; align-items: center; gap: .5em; min-height: 48px; color: var(--stardust); font-weight: 600; text-decoration: underline; text-decoration-color: var(--coral); text-decoration-thickness: 2px; }
.text-link:hover { color: var(--coral); }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 31, 59, .88); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding-top: env(safe-area-inset-top, 0px);
}
.nav-inner {
  width: min(1200px, 100% - 2 * var(--gutter)); min-height: var(--nav-h);
  margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.wordmark { position: relative; display: inline-block; padding: 6px 14px 6px 0; color: var(--stardust); text-decoration: none; flex: 0 1 auto; min-width: 0; }
.wordmark-text { font: 600 clamp(24px, 3vw, 30px)/1 var(--display); letter-spacing: -.01em; }
.wordmark .swoosh { position: absolute; left: -4px; bottom: -6px; width: 100%; height: 14px; color: var(--coral); pointer-events: none; }
.wordmark .spark { position: absolute; right: -2px; top: -4px; color: var(--coral); font-size: 12px; line-height: 1; }
.sign-in {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px;
  border: 1.5px solid var(--coral); border-radius: 999px;
  color: var(--coral); font: 600 14px/1 var(--body); text-decoration: none;
  transition: background-color .16s var(--ease), color .16s var(--ease), transform .08s var(--ease);
}
.sign-in:hover, .sign-in:focus-visible { background: var(--coral); color: var(--space); }
.sign-in:active { transform: scale(.97); }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(44px, 8vw, 96px) 0 0;
  background: radial-gradient(120% 70% at 80% 0%, rgba(167, 139, 250, .18), transparent 60%), var(--space);
}
.hero-copy { position: relative; z-index: 1; max-width: 760px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 28px; }
.hero-art { position: relative; margin-top: clamp(8px, 3vw, 24px); width: min(980px, 100%); margin-inline: auto; }
.hero-art img {
  width: 100%;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%), linear-gradient(to right, transparent 0, #000 8%, #000 92%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent 0, #000 22%), linear-gradient(to right, transparent 0, #000 8%, #000 92%, transparent 100%);
  mask-composite: intersect;
}
.stars { position: absolute; inset: 0; pointer-events: none; }
.stars i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--stardust); opacity: .5; animation: twinkle 3.2s infinite var(--ease); }
.stars i:nth-child(1) { left: 8%; top: 18%; }
.stars i:nth-child(2) { left: 22%; top: 8%; animation-delay: .6s; width: 3px; height: 3px; }
.stars i:nth-child(3) { left: 61%; top: 12%; animation-delay: 1.1s; }
.stars i:nth-child(4) { left: 78%; top: 30%; animation-delay: 1.7s; width: 5px; height: 5px; background: var(--coral); }
.stars i:nth-child(5) { left: 91%; top: 10%; animation-delay: .3s; }
.stars i:nth-child(6) { left: 45%; top: 40%; animation-delay: 2.1s; width: 3px; height: 3px; background: var(--nebula); }
.stars i:nth-child(7) { left: 84%; top: 55%; animation-delay: 1.4s; }
.stars i:nth-child(8) { left: 33%; top: 26%; animation-delay: 2.6s; width: 3px; height: 3px; }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: .9; transform: scale(1.2); } }

/* Sections */
.section { padding: clamp(56px, 8vw, 104px) 0; }
.section.alt { background: var(--space-deep); }

/* What it is */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: 1fr; }
.tile { position: relative; padding: 26px 24px 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.tile-art { width: clamp(120px, 30vw, 160px); margin: -6px 0 14px; }
.tile p { margin: 10px 0 0; color: var(--ink-dim); }
.chips { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.chips li { padding: 10px 16px; border-radius: 999px; background: var(--stardust); color: var(--space); font: 600 14px/1.2 var(--display); }
.chips li:nth-child(2) { background: var(--sage); }
.chips li:nth-child(3) { background: var(--nebula); }
.chips li:nth-child(4) { background: var(--coral); }
.float { animation: bob 4.5s infinite ease-in-out; }
.float.delay { animation-delay: 1.6s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* Examples */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: 1fr; }
.card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 26px 24px 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  transition: transform .18s var(--ease), background-color .18s var(--ease);
}
.card:hover { transform: translateY(-3px); background: var(--card-hi); }
.card-kicker { margin: 0; color: var(--sage); font: 600 12px/1.4 var(--body); letter-spacing: .14em; text-transform: uppercase; }
.card p { margin: 0; color: var(--ink-dim); }
.card .btn { align-self: flex-start; margin-top: 12px; }

/* Ask form */
.ask { display: grid; gap: 22px; max-width: 620px; margin-top: 34px; }
.field { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field legend { padding: 0; color: var(--stardust); font: 500 15px/1.4 var(--body); }
.field input, .field textarea {
  width: 100%; min-height: 50px; margin: 0; padding: 13px 15px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--stardust); font: 16px/1.5 var(--body);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.field textarea { min-height: 120px; resize: vertical; }
.field input:hover, .field textarea:hover { border-color: rgba(255, 247, 230, .4); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 3px rgba(255, 122, 102, .22); }
.field input.is-bad, .field textarea.is-bad, .choices.is-bad .choice { border-color: var(--coral); }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; }
.choice {
  position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 10px 16px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--stardust); font: 500 15px/1.3 var(--body); cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .08s var(--ease);
}
.choice:active { transform: scale(.97); }
.field .choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; }
.choice:has(input:checked) { background: var(--coral); border-color: var(--coral); color: var(--space); font-weight: 600; }
.choice:has(input:focus-visible) { outline: 3px solid var(--coral); outline-offset: 3px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.send { min-width: 160px; }
.send-dots { display: none; gap: 5px; align-items: center; }
.send-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: pulse 1s infinite var(--ease); }
.send-dots i:nth-child(2) { animation-delay: .16s; }
.send-dots i:nth-child(3) { animation-delay: .32s; }
.send.is-sending .send-dots { display: inline-flex; }
@keyframes pulse { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.form-note { min-height: 1.4em; margin: 0; font-size: 15px; color: var(--ink-dim); }
.form-note.good { color: var(--sage); font-weight: 600; }
.form-note.bad { color: var(--coral); }

/* Free recipe */
.needs { list-style: none; margin: 0 0 28px; padding: 0; display: grid; gap: 12px; max-width: 620px; }
.needs li { display: flex; align-items: flex-start; gap: 14px; font-size: clamp(16px, 1.9vw, 18px); color: var(--ink-dim); }
.needs .num {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--nebula); color: var(--space); font: 600 15px/1 var(--display);
}
.needs li:nth-child(2) .num { background: var(--sage); }
.needs li:nth-child(3) .num { background: var(--coral); }
.needs li > span:last-child { padding-top: 5px; }

/* Footer */
.footer { padding: 36px 0 calc(44px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 13px; }
.footer .wrap { text-align: center; }
.footer p { margin: 0; }
.footer p > span { display: block; }
.footer .dot { display: none; }
.footer a { color: var(--stardust); }

/* Back to top — phones, once the reader is down the page */
.to-top {
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 60;
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%;
  background: var(--coral); color: var(--space); box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  display: grid; place-items: center; cursor: pointer;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.to-top svg { width: 22px; height: 22px; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:active { transform: scale(.94); }

/* Wider screens */
@media (min-width: 720px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile-wide { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; }
  .tile-wide .chips { margin: 0; }
  .cards { grid-template-columns: 1fr 1fr; }
  .to-top { display: none; }
  .footer p > span { display: inline; }
  .footer .dot { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .float, .stars i, .send-dots i { animation: none; }
  .card, .btn, .sign-in, .choice, .to-top { transition: none; }
}
