@font-face {
  font-family: Fraunces;
  src: url("./fonts/fraunces-500.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  src: url("./fonts/fraunces-700.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  src: url("./fonts/fraunces-500i.woff2") format("woff2");
  font-style: italic;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: Literata;
  src: url("./fonts/literata-400.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: Literata;
  src: url("./fonts/literata-650.woff2") format("woff2");
  font-style: normal;
  font-weight: 650;
  font-display: swap;
}

@font-face {
  font-family: Literata;
  src: url("./fonts/literata-400i.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #07080e;
  --ink: rgba(8, 10, 16, .78);
  --text: #f3ead8;
  --muted: #c4bba9;
  --gold: #e7d7a8;
  --gold-deep: #c6a15a;
  --copper: #c4845a;
  --line: rgba(198, 161, 90, .5);
  --serif: Fraunces, Georgia, serif;
  --body: Literata, Georgia, serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
  background: var(--night);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(ellipse at 12% 18%, rgba(35, 44, 71, .35), transparent 38rem),
    radial-gradient(ellipse at 77% 55%, rgba(77, 52, 33, .13), transparent 42rem),
    var(--night);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.72;
}

body, button, input, textarea { font-family: var(--body); }
a { color: inherit; }
button, input, textarea { font-size: inherit; }
button { color: inherit; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}

.sky, .nebula, .branches {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky { z-index: 0; width: 100%; height: 100%; }

.nebula {
  z-index: 0;
  background:
    radial-gradient(ellipse 32rem 16rem at 19% 46%, rgba(67, 59, 43, .2), transparent 75%),
    radial-gradient(ellipse 28rem 16rem at 73% 12%, rgba(150, 106, 62, .14), transparent 76%);
  animation: nebula-drift 20s ease-in-out infinite;
}

.branches {
  z-index: 1;
  inset: auto 0 0;
  width: 100%;
  height: 40vh;
  min-height: 210px;
  color: var(--copper);
  opacity: .34;
  stroke-width: 1.15;
  mask-image: linear-gradient(to top, #000 0%, #000 35%, transparent 100%);
  transform-origin: 50% 100%;
  animation: branch-sway 8s ease-in-out infinite;
}

.gate {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(7, 8, 14, .28);
}

.gate[hidden] { display: none; }

.gate-panel {
  width: min(100%, 430px);
  padding: clamp(2rem, 6vw, 3.5rem);
  border: 1px solid var(--gold-deep);
  background:
    radial-gradient(ellipse at 50% 0, rgba(198, 161, 90, .11), transparent 70%),
    rgba(8, 10, 16, .86);
  box-shadow: 0 0 70px rgba(0, 0, 0, .35), inset 0 0 22px rgba(198, 161, 90, .035);
  text-align: center;
}

.gate-panel.is-shaking { animation: shake .32s ease-in-out; }
.gate-panel h1 { margin: .2rem 0 .4rem; font: 500 clamp(2.4rem, 7vw, 3.5rem)/1.1 var(--serif); }
.gate-intro { margin: 0 0 2rem; color: var(--muted); }
.gate form { display: grid; gap: .75rem; text-align: left; }
.gate label, .name-form label { color: var(--gold); font-size: .88rem; }
.gate input, .name-form input, textarea {
  width: 100%;
  border: 1px solid rgba(231, 215, 168, .4);
  border-radius: 0;
  padding: .8rem .9rem;
  color: var(--text);
  background: rgba(7, 8, 14, .78);
}
.gate input:focus, .name-form input:focus, textarea:focus { border-color: var(--gold); }
.gate-error { min-height: 1.5em; margin: 0; color: #f2b9a2; font-size: .88rem; }

.site {
  position: relative;
  z-index: 2;
  overflow-x: clip;
  display: grid;
  grid-template-columns: minmax(340px, 46vw) minmax(0, 1fr);
  max-width: 1800px;
  min-height: 100vh;
  margin-inline: auto;
}

.site[inert] { visibility: hidden; }

.visual-column {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  min-height: 600px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2vw, 2rem);
  border-right: 1px solid var(--line);
}

.astrolabe { display: block; width: min(100%, 600px); max-height: 78vh; overflow: visible; }
.card-crop { display: contents; }
.card-frame { fill: rgba(8, 10, 16, .45); stroke: var(--gold-deep); stroke-width: 1.15; }
.orbit { fill: none; stroke: rgba(231, 215, 168, .47); stroke-width: 1; }
.orbit-inner { stroke: rgba(198, 161, 90, .32); stroke-dasharray: 1 4; }
.phase-node { color: rgba(231, 215, 168, .62); transform-box: fill-box; transform-origin: center; }
.phase-node circle { fill: var(--night); stroke: currentColor; stroke-width: 1.1; }
.phase-node .moon-shadow { fill: currentColor; stroke: none; }
.phase-node text { fill: var(--gold); font: 400 11px var(--body); }
.phase-node.is-active { color: var(--gold); filter: url(#moon-glow); }
.phase-node.is-active circle { fill: var(--gold); }
.phase-node.is-active .moon-shadow { fill: var(--night); }
.phase-node.is-active { animation: moon-breathe 3s ease-in-out infinite; }
.phase-node.is-related { color: var(--gold-deep); opacity: .8; }
.phase-node.is-life { color: var(--gold-deep); opacity: .48; }
.phase-ring { transform-box: view-box; transform-origin: 300px 370px; animation: ring-turn 48s linear infinite; }
.phase-ring.is-fixed { animation: none; }
.seed-rotor { transform-box: view-box; transform-origin: 300px 370px; animation: seed-turn 70s linear infinite; }
.seed { stroke: var(--gold); stroke-width: 1; opacity: .76; }
.card-center { fill: rgba(7, 8, 14, .76); stroke: rgba(231, 215, 168, .78); stroke-width: 1; }
.center-number { fill: var(--text); font: 500 42px var(--serif); }
.card-signature { fill: var(--gold); font: 500 13px var(--serif); letter-spacing: .05em; }
.card-rule { stroke: var(--gold-deep); stroke-width: .8; }
.card-caption { fill: var(--muted); font: 400 8px var(--body); letter-spacing: .17em; }
.visual-caption { margin: 1rem 0 0; color: var(--muted); font: italic 500 1rem var(--serif); }

.content { min-width: 0; padding: 0 clamp(1.5rem, 5vw, 6rem) 4rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 76px; border-bottom: 1px solid rgba(198, 161, 90, .22); }
.wordmark { font: 500 1.16rem var(--serif); text-decoration: none; }
.top-link, .text-link { color: var(--gold); text-decoration-color: rgba(231, 215, 168, .5); text-underline-offset: .35em; }
.top-link:hover, .text-link:hover { text-decoration-color: var(--gold); }
.hero { display: flex; min-height: min(76vh, 760px); flex-direction: column; align-items: flex-start; justify-content: center; padding: 5rem 0 6rem; }
.eyebrow { margin: 0 0 .8rem; color: var(--gold-deep); font-size: .8rem; letter-spacing: .08em; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; }
.hero h1 { max-width: 760px; margin: .2rem 0 1.3rem; font-size: clamp(3rem, 6vw, 6.4rem); line-height: .99; letter-spacing: -.035em; }
.hero-lead { max-width: 37rem; margin: 0 0 1.6rem; color: var(--muted); font-size: clamp(1.05rem, 1.55vw, 1.35rem); }
.text-link { font-size: .98rem; }

.story { display: grid; grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr); align-items: start; border-top: 1px solid var(--line); }
.story-reading { position: sticky; top: 0; display: flex; min-height: 100vh; align-items: center; padding: 3rem 2rem 3rem 0; }
.story-reading-inner { max-width: 25rem; transition: opacity .25s ease, transform .25s ease; }
.story-reading-inner.is-changing { opacity: .2; transform: translateY(8px); }
.story-phase { margin: 0 0 .45rem; color: var(--gold-deep); font: 500 .85rem/1 var(--serif); opacity: .72; }
.story-reading h2, .mobile-story-copy h2 { margin: .15rem 0 1rem; font-size: clamp(2rem, 3.5vw, 3.55rem); line-height: 1.08; }
.story-reading p:last-child, .mobile-story-copy p:last-child { color: var(--muted); }
.story-steps { min-width: 0; }
.story-step { display: flex; min-height: 100vh; align-items: center; border-left: 1px solid rgba(198, 161, 90, .2); padding: 2rem 0 2rem clamp(1.5rem, 3vw, 3rem); }
.mobile-story-copy { display: none; }

.template { padding: clamp(4rem, 8vw, 8rem) 0 5rem; border-top: 1px solid var(--line); }
.section-heading { max-width: 39rem; margin-bottom: 2.4rem; }
.section-heading h2 { margin: 0 0 .7rem; font-size: clamp(2.4rem, 4vw, 4rem); line-height: 1.05; }
.section-heading > p:last-child { color: var(--muted); }
.name-form { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1rem; max-width: 650px; }
.name-form label { grid-column: span 2; margin-top: .45rem; }
.name-form input { grid-column: span 2; }
.name-form input[type="date"] { font-size: 16px; }
.button { min-height: 48px; border: 1px solid var(--gold-deep); border-radius: 0; padding: .72rem 1.25rem; cursor: pointer; transition: background .2s ease, color .2s ease, border-color .2s ease; }
.button-gold { width: fit-content; margin-top: .65rem; color: #17130b; background: var(--gold); font-weight: 650; }
.button-gold:hover { background: #f2e4bd; }
.button-outline { color: var(--gold); background: transparent; }
.button-outline:hover { color: var(--night); background: var(--gold); }
.form-message { min-height: 1.5rem; color: #f2b9a2; font-size: .9rem; }
.saved-area { margin: 2.5rem 0 1rem; }
.saved-list { display: flex; flex-wrap: wrap; gap: .55rem; }
.saved-name { border: 1px solid var(--line); border-radius: 0; padding: .45rem .8rem; color: var(--text); background: rgba(8, 10, 16, .55); cursor: pointer; }
.saved-name:hover, .saved-name[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.privacy-note { color: var(--muted); font-size: .84rem; }
.portrait { margin-top: 2rem; }
.portrait-heading { margin: 3rem 0; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.portrait-heading h3 { margin: .3rem 0 2rem; font-size: clamp(1.7rem, 3vw, 2.5rem); }
.portrait-total { display: grid; justify-items: center; gap: .2rem; color: var(--muted); }
.portrait-total strong { color: var(--gold); font: 500 clamp(4rem, 9vw, 7rem)/1 var(--serif); }
.portrait-total span:last-child { font-size: .9rem; }
.portrait-sections { display: grid; gap: 1rem; }
.result-section, .portrait-note-section { position: relative; border: 1px solid var(--line); padding: clamp(1.25rem, 3vw, 2rem); background: var(--ink); }
.result-topline { display: flex; align-items: center; gap: .8rem; }
.result-topline h4, .portrait-note-section h4 { margin: 0; font-size: 1.35rem; }
.mini-moon { width: 26px; height: 26px; flex: 0 0 auto; border: 1px solid var(--gold); border-radius: 50%; background: var(--gold); box-shadow: inset -8px 0 0 var(--night); }
.result-number { display: block; margin: .3rem 0 .1rem; color: var(--gold); font: 500 clamp(2.7rem, 6vw, 4.5rem)/1.05 var(--serif); }
.result-path { margin: .25rem 0 1rem; color: var(--muted); font-size: .88rem; }
.letter-breakdown { display: flex; flex-wrap: wrap; gap: .35rem; margin: 1rem 0 1.4rem; }
.letter-chip { display: inline-flex; min-width: 2.45rem; flex-direction: column; align-items: center; border-bottom: 1px solid rgba(198, 161, 90, .35); padding: .2rem .35rem; color: var(--text); }
.letter-chip strong { color: var(--gold); font: 500 1.15rem var(--serif); }
.letter-chip span { color: var(--muted); font-size: .7rem; }
textarea { display: block; min-height: 112px; resize: vertical; line-height: 1.6; }
.portrait-note-section textarea { margin-top: .9rem; }
.portrait-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.2rem; margin-top: 1.5rem; }
.quiet-button { border: 0; padding: .6rem 0; color: var(--muted); background: transparent; text-decoration: underline; text-decoration-color: rgba(196, 187, 169, .4); text-underline-offset: .3em; cursor: pointer; }
.quiet-button:hover { color: var(--text); }
.footer { max-width: 54rem; padding: 2rem 0 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.footer p + p { color: var(--gold); }

@keyframes ring-turn { to { transform: rotate(360deg); } }
@keyframes seed-turn { to { transform: rotate(-360deg); } }
@keyframes moon-breathe { 0%, 100% { opacity: .72; } 50% { opacity: 1; } }
@keyframes nebula-drift {
  0%, 100% { transform: translate3d(-2.5%, -1.5%, 0) scale(1); }
  50% { transform: translate3d(2.5%, 1.5%, 0) scale(1.08); }
}
@keyframes branch-sway {
  0%, 100% { transform: rotate(-1.2deg) translateX(-1.2%); }
  50% { transform: rotate(1.2deg) translateX(1.2%); }
}
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

@media (max-width: 1100px) and (min-width: 901px) {
  .site { grid-template-columns: minmax(310px, 46vw) minmax(0, 1fr); }
  .content { padding-inline: clamp(1.25rem, 3.5vw, 3rem); }
  .story { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
}

@media (max-width: 900px) {
  .site { display: flex; flex-direction: column; }
  .branches { opacity: .42; }
  .visual-column { position: relative; top: auto; height: auto; min-height: 0; justify-content: flex-start; padding: calc(48px + env(safe-area-inset-top)) 1rem .5rem; border-right: 0; }
  .card-crop { display: block; width: min(78vw, 310px); aspect-ratio: 1; overflow: hidden; }
  .astrolabe { width: 120%; height: auto; max-height: none; margin-top: -24%; margin-left: -10%; }
  .visual-caption { display: none; }
  .content { padding: 0 clamp(1.25rem, 6vw, 3rem) 2rem; }
  .topbar { position: fixed; z-index: 8; inset: 0 0 auto; width: 100%; min-height: calc(48px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) clamp(1.25rem, 6vw, 3rem) 0; border-bottom: 1px solid rgba(198, 161, 90, .22); background: rgba(7, 8, 14, .72); }
  .wordmark { font-size: 1rem; }
  html { scroll-padding-top: calc(4rem + env(safe-area-inset-top)); }
  .hero { min-height: 0; align-items: center; padding: .4rem 0 1.1rem; text-align: center; }
  .hero h1 { max-width: 100%; margin: .2rem 0 .75rem; font-size: 2.15rem; line-height: 1.08; }
  .hero-lead { margin-bottom: .85rem; }
  .story { display: block; }
  .story-reading { display: none; }
  .story-steps { display: block; padding: 0; }
  .mobile-story-copy { display: block; width: min(100%, 20rem); text-align: center; }
  .mobile-story-copy h2 { margin: .15rem 0 1rem; font-size: 2.15rem; line-height: 1.08; }
  .mobile-story-copy p:last-child { margin-bottom: 0; font-size: 1.05rem; line-height: 1.55; }
  .story-step { display: flex; min-height: 100svh; flex-direction: column; align-items: center; justify-content: center; border: 0; padding: calc(64px + env(safe-area-inset-top)) 0 2rem; background: transparent; text-align: center; }
  .story-step::before { color: var(--gold); content: attr(data-step); font: 500 2.2rem/1 var(--serif); margin-bottom: .65rem; }
  .template { padding: 2rem 0 3rem; }
  .section-heading { margin-bottom: 1.25rem; }
  .section-heading h2 { margin-bottom: .45rem; font-size: 2rem; }
  .name-form { display: flex; width: 100%; min-width: 0; max-width: none; flex-direction: column; }
  .name-form input { width: 100%; max-width: 100%; min-width: 0; }
  .name-form input[type="date"] { width: 100%; max-width: 100%; min-width: 0; }
  .name-form input[type="date"]::-webkit-datetime-edit,
  .name-form input[type="date"]::-webkit-datetime-edit-fields-wrapper { max-width: 100%; min-width: 0; }
  .name-form label { margin-top: .35rem; }
  .button-gold { width: 100%; }
  .portrait { margin-top: 1.5rem; }
  .portrait-heading { margin: 1.5rem 0; padding: 1rem 0; }
  .portrait-heading h3 { margin: .3rem 0 1rem; font-size: 1.5rem; }
  .portrait-total strong { font-size: clamp(3rem, 14vw, 4.2rem); }
  .result-section, .portrait-note-section { padding: 1rem; }
  textarea { min-height: 88px; }
}

@media (max-width: 480px) {
  .gate-panel { padding: 2rem 1.4rem; }
  .content { padding-inline: 1.1rem; }
  .portrait-actions { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .branches { height: 30vh; min-height: 170px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; }
}

@media print {
  :root { color-scheme: light; }
  body { min-width: 0; color: #111; background: #fff !important; font-family: Georgia, serif; }
  .sky, .nebula, .branches, .gate, .visual-column, .topbar, .hero, .story, .section-heading, .name-form, .form-message, .saved-area, .privacy-note, .footer, .portrait-actions { display: none !important; }
  .site, .content { display: block; max-width: none; min-height: 0; padding: 0; }
  .template { padding: 0; border: 0; }
  .portrait { display: block !important; margin: 0; }
  #portrait[hidden] { display: none !important; }
  .portrait-heading { margin: 0 0 1rem; padding: 0 0 1rem; border-color: #888; }
  .portrait-heading h3 { margin: 0 0 .5rem; }
  .portrait-total, .result-path { color: #333; }
  .portrait-total strong, .result-number { color: #111; }
  .portrait-sections { display: block; }
  .result-section, .portrait-note-section { display: none !important; border: 1px solid #999; margin: 0 0 .7rem; padding: .8rem; color: #111; background: #fff; break-inside: avoid; }
  .result-section.print-filled, .portrait-note-section.print-filled { display: block !important; }
  .result-topline h4, .portrait-note-section h4 { color: #111; }
  .mini-moon { border-color: #555; background: #ddd; box-shadow: inset -8px 0 0 #fff; }
  textarea { min-height: 0; height: auto; overflow: visible; border: 0; padding: .2rem 0; color: #111; background: #fff; }
  .letter-chip, .letter-chip span { color: #333; }
  .letter-chip strong { color: #111; }
}
