/* Bedtime stories app — website theme.
   Mirrors the iOS app's two worlds:
   the night sky (indigo gradient, starfield, candy buttons)
   and the paper world (cream book pages, sepia ink, serif type).
   System fonts only — no webfont downloads. */

:root {
  color-scheme: dark;
  --sky-top: #363b78;
  --sky-bottom: #1c1f4a;
  --periwinkle: #6663cc;
  --periwinkle-bright: #b3a4e6;
  --periwinkle-deep: #6b5ba6;
  --paper: #f7edd9;
  --paper-deep: #f0e4cc;
  --ink: #33261c;
  --ink-muted: rgba(51, 38, 28, 0.72);
  --night-ink: rgba(255, 255, 255, 0.96);
  --night-ink-muted: rgba(255, 255, 255, 0.72);
  --card-fill: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.15);
  --button-border: rgba(255, 255, 255, 0.22);
  --font-serif: Georgia, "Times New Roman", serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
    "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font-serif);
  line-height: 1.65;
  color: var(--night-ink-muted);
  background: var(--sky-bottom);
}

body {
  margin: 0;
  min-height: 100vh;
}

/* The night sky lives on a fixed pseudo-element so the gradient always
   spans the viewport, even on very long legal pages. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

::selection {
  background: rgba(102, 99, 204, 0.55);
  color: #fff;
}

a {
  color: var(--night-ink);
  text-underline-offset: 0.18em;
  text-decoration-color: rgba(255, 255, 255, 0.4);
}

a:hover {
  color: #fff;
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--periwinkle-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 10;
  padding: 0.7rem 1rem;
  color: var(--ink);
  background: var(--paper);
  border-radius: 0.75rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  font-family: var(--font-round);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
  color: var(--ink);
}

/* ---------- Header & footer (night-sky chrome) ---------- */

.header-inner,
.footer-inner,
.page-shell {
  width: min(100% - 2rem, 70rem);
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding-block: 1.1rem;
}

.brand {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-decoration: none;
}

.primary-nav > ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav a {
  display: inline-block;
  padding: 0.4rem 0.95rem;
  color: var(--night-ink-muted);
  font-family: var(--font-round);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid transparent;
}

.primary-nav a:hover {
  color: #fff;
  background: var(--card-fill);
  border-color: var(--card-border);
}

/* Dropdown for the legal pages (native <details>, no JS needed) */

.nav-dropdown {
  position: relative;
}

.nav-dropdown summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.95rem;
  color: var(--night-ink-muted);
  font-family: var(--font-round);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-dropdown summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown summary::after {
  content: "";
  width: 0.42em;
  height: 0.42em;
  margin-top: -0.2em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.nav-dropdown[open] summary::after {
  margin-top: 0.2em;
  transform: rotate(-135deg);
}

.nav-dropdown summary:hover,
.nav-dropdown[open] summary {
  color: #fff;
  background: var(--card-fill);
  border-color: var(--card-border);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 20;
  min-width: 13.5rem;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: #262a5e;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}

.primary-nav .dropdown-menu a {
  display: block;
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 500;
  border: none;
  white-space: nowrap;
}

.site-footer {
  margin-top: 4.5rem;
  border-top: 1px solid var(--card-border);
}

.footer-inner {
  padding-block: 2rem 2.4rem;
}

.footer-inner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-round);
  font-size: 0.85rem;
}

.footer-inner .copying-notice {
  margin-top: 0.4rem;
  font-size: 0.78rem;
}

/* ---------- Shared type ---------- */

.page-shell {
  padding-block: clamp(2.5rem, 7vw, 5rem);
}

h1,
h2,
h3 {
  line-height: 1.25;
  color: var(--night-ink);
}

p,
li {
  max-width: 72ch;
}

.eyebrow {
  margin: 0;
  color: var(--night-ink-muted);
  font-family: var(--font-round);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lead {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(1.1rem, 2.4vw, 1.32rem);
}

/* ---------- Candy button (KidButtonStyle) ---------- */

.candy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1.4rem;
  color: #fff;
  font-family: var(--font-round);
  font-size: 0.98rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid var(--button-border);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 28%),
    linear-gradient(to bottom, #726fd0, #524fa3);
  box-shadow: 0 5px 20px rgba(92, 89, 184, 0.5);
}

.candy-button:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 7px 24px rgba(92, 89, 184, 0.65);
}

.candy-button:active {
  transform: scale(0.94);
}

.candy-button:focus-visible {
  border-radius: 999px;
}

/* ---------- Coming soon (index) ---------- */

.coming-soon-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: min(44rem, calc(100vh - 16rem));
  place-items: center;
}

.coming-soon-card {
  position: relative;
  width: min(100%, 52rem);
  margin-top: 3rem;
  padding: clamp(2.25rem, 6vw, 4.25rem);
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: 24px;
}

.coming-soon-card h1 {
  margin: 0.4rem 0 1.2rem;
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 7vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;
}

.coming-soon-card p {
  color: var(--night-ink-muted);
}

.coming-soon-card .lead {
  max-width: 44rem;
  color: rgba(255, 255, 255, 0.9);
}

.coming-soon-support {
  margin: 2.2rem 0 0;
}

.moon {
  position: absolute;
  top: -4.25rem;
  right: 6%;
  width: clamp(96px, 15vw, 150px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 0 26px rgba(194, 193, 235, 0.4));
}

/* ---------- Hero (404) ---------- */

.hero {
  max-width: 52rem;
  padding-block: clamp(1rem, 4vw, 3rem);
}

.hero h1 {
  margin: 0.4rem 0 1rem;
  font-family: var(--font-serif);
  font-size: clamp(2.3rem, 6vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;
}

.hero p {
  color: var(--night-ink-muted);
}

.hero .candy-button {
  margin-top: 0.75rem;
}

.constellation {
  display: block;
  width: clamp(190px, 32vw, 270px);
  height: auto;
  margin-bottom: 1.25rem;
}

/* ---------- Legal documents (paper world) ---------- */

.legal-document {
  position: relative;
  max-width: 50rem;
  margin-inline: auto;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  color: var(--ink);
  background: radial-gradient(120% 110% at 50% 0%, #faf2e2 0%, var(--paper) 55%, var(--paper-deep) 100%);
  border-radius: 8px 20px 20px 8px;
  /* Two cream "pages" peeking out under the cover, then the drop to the sky. */
  box-shadow:
    5px 6px 0 -2px #e8dabc,
    10px 12px 0 -4px #d9c8a4,
    0 26px 60px rgba(0, 0, 0, 0.45);
}

/* Soft spine shadow along the bound edge, like an open hardcover. */
.legal-document::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(to right, rgba(51, 38, 28, 0.12), rgba(51, 38, 28, 0.03) 6%, transparent 12%);
  pointer-events: none;
}

.legal-document h1,
.legal-document h2,
.legal-document h3 {
  color: var(--ink);
}

.legal-document h1 {
  margin: 0.35rem 0 1.1rem;
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.legal-document h1::after {
  content: "";
  display: block;
  width: 76px;
  height: 3px;
  margin-top: 0.9rem;
  border-radius: 999px;
  background: linear-gradient(to right, rgba(102, 99, 204, 0.55), rgba(102, 99, 204, 0.1));
}

.legal-document h2 {
  margin-top: 2.4rem;
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  font-weight: 600;
}

.legal-document h3 {
  margin-top: 1.6rem;
  font-size: 1.12rem;
  font-weight: 600;
}

.legal-document a {
  color: var(--periwinkle-deep);
  text-decoration-color: rgba(107, 91, 166, 0.45);
}

.legal-document a:hover {
  color: #5b58bd;
  text-decoration-color: currentColor;
}

.legal-document a:focus-visible {
  outline-color: var(--periwinkle-deep);
}

.legal-document ::selection {
  background: rgba(102, 99, 204, 0.25);
  color: var(--ink);
}

.document-meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legal-document section + section {
  padding-top: 0.15rem;
}

.notice {
  margin-block: 1.5rem;
  padding: 1rem 1.15rem;
  background: rgba(102, 99, 204, 0.1);
  border-left: 4px solid var(--periwinkle);
  border-radius: 6px 14px 14px 6px;
}

.contact-block {
  font-style: normal;
}

.license-text {
  overflow-x: auto;
  padding: 1rem 1.1rem;
  white-space: pre-wrap;
  color: #453527;
  background: #f1e6ce;
  border: 1px solid rgba(51, 38, 28, 0.14);
  border-radius: 14px;
  font: 0.82rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Motion (gentle, and only when welcome) ---------- */

@media (prefers-reduced-motion: no-preference) {
  a,
  .primary-nav a,
  .nav-dropdown summary {
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
  }

  .candy-button {
    transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 160ms ease;
  }

  .moon {
    animation: moon-drift 7s ease-in-out infinite alternate;
  }

  @keyframes moon-drift {
    from {
      transform: translateY(0);
    }

    to {
      transform: translateY(9px);
    }
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 43rem) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.4rem;
  }

  .primary-nav a {
    padding-inline: 0.75rem;
  }

  .dropdown-menu {
    right: auto;
    left: 0;
  }

  .moon {
    top: -3rem;
    right: 4%;
  }

  .legal-document {
    box-shadow:
      4px 4px 0 -2px #e8dabc,
      8px 8px 0 -4px #d9c8a4,
      0 18px 44px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- Print (legal pages should print cleanly) ---------- */

@media print {
  body::before,
  #starfield,
  .skip-link,
  .site-header,
  .site-footer {
    display: none;
  }

  html,
  body {
    color: #000;
    background: #fff;
  }

  .legal-document {
    max-width: none;
    padding: 0;
    color: #000;
    background: #fff;
    border-radius: 0;
    box-shadow: none;
  }

  .legal-document::before {
    display: none;
  }

  .legal-document h1,
  .legal-document h2,
  .legal-document h3 {
    color: #000;
  }

  .legal-document a {
    color: #000;
  }

  .moon,
  .constellation {
    display: none;
  }

  .coming-soon-card,
  .hero {
    background: none;
    border: none;
    padding: 0;
  }

  .coming-soon-card h1,
  .hero h1,
  .coming-soon-card p,
  .hero p,
  .lead,
  .eyebrow {
    color: #000;
    text-shadow: none;
  }

  .candy-button {
    color: #000;
    background: none;
    border: 1px solid #000;
    box-shadow: none;
  }
}
