/* =============================================================================
   ALLY'S BARN — design system
   A warm twilight barn (not the heavy adult midnight). The boldness is spent in
   one place: the knot that loosens and the star that lights when a child spots
   a knot. Everything else stays quiet and disciplined.
   ============================================================================= */

:root {
  /* palette */
  --barn-night:    #1f2b4d;   /* twilight barn blue (background) */
  --barn-night-2:  #28365e;   /* raised panels */
  --lantern:       #f4b740;   /* lantern gold (primary) */
  --lantern-deep:  #e09a2b;   /* gold pressed/hover */
  --parchment:     #fbf3e0;   /* warm cream (text on dark, cards on light) */
  --meadow:        #5f9b6b;   /* the "good fruit" green */
  --meadow-deep:   #4a7d55;
  --barnwood:      #7a4a2b;   /* warm wood accent */
  --rose:          #e9a7a0;   /* gentle warmth */
  --ink:           #2a2438;   /* text on parchment */
  --muted:         #b9c2dd;   /* muted text on night */

  --radius:        18px;
  --radius-lg:     28px;
  --shadow:        0 10px 30px rgba(0,0,0,.28);
  --maxw:          720px;

  --font-display:  "Fredoka", system-ui, sans-serif;
  --font-body:     "Nunito", system-ui, sans-serif;
  --font-scripture:"Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--parchment);
  background:
    radial-gradient(1200px 600px at 50% -10%, #2c3a64 0%, transparent 60%),
    linear-gradient(180deg, #1b2543 0%, var(--barn-night) 55%, #18203c 100%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ambient starfield */
.starfield {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(251,243,224,.9), transparent),
    radial-gradient(1.5px 1.5px at 70% 20%, rgba(251,243,224,.7), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(251,243,224,.8), transparent),
    radial-gradient(1px 1px at 85% 60%, rgba(251,243,224,.6), transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, rgba(244,183,64,.8), transparent),
    radial-gradient(1px 1px at 15% 80%, rgba(251,243,224,.6), transparent);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: .9; } }

.app {
  position: relative; z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px) clamp(16px, 5vw, 28px) 64px;
  min-height: 100dvh;
}

/* ---- typography ---- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.12; margin: 0 0 .4em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 4.5vw, 1.9rem); }
.eyebrow {
  font-family: var(--font-display); font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; font-size: .72rem; color: var(--lantern);
}
p { line-height: 1.6; }
.muted { color: var(--muted); }

/* Scripture is always set apart — illuminated serif. */
.scripture {
  font-family: var(--font-scripture); font-style: italic;
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  color: var(--parchment);
  border-left: 3px solid var(--lantern);
  padding: .2em 0 .2em 1em; margin: 1.1em 0;
}
.scripture .ref { display: block; font-style: normal; font-family: var(--font-display);
  font-size: .8rem; letter-spacing: .08em; color: var(--lantern); margin-top: .5em; }

/* ---- buttons ---- */
.btn {
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem;
  border: 0; border-radius: 999px; padding: .85em 1.5em; cursor: pointer;
  background: var(--lantern); color: #3a2a07; box-shadow: var(--shadow);
  transition: transform .12s ease, background .2s ease;
}
.btn:hover { background: var(--lantern-deep); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.secondary { background: transparent; color: var(--parchment); box-shadow: none;
  border: 1.5px solid rgba(251,243,224,.35); }
.btn.secondary:hover { border-color: var(--lantern); color: var(--lantern); }
.btn.meadow { background: var(--meadow); color: #fff; }
.btn.meadow:hover { background: var(--meadow-deep); }
.btn.block { display: block; width: 100%; }
.btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--lantern); outline-offset: 2px;
}

/* ---- cards & layout ---- */
.card {
  background: var(--barn-night-2); border: 1px solid rgba(251,243,224,.08);
  border-radius: var(--radius-lg); padding: clamp(20px, 5vw, 32px);
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.card.parchment { background: var(--parchment); color: var(--ink); }
.card.parchment .muted { color: #6a6275; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.center { text-align: center; }

label { display: block; font-weight: 700; margin: 0 0 .35em; font-size: .95rem; }
input[type=email], input[type=password], input[type=text], select {
  width: 100%; padding: .8em 1em; border-radius: var(--radius);
  border: 1.5px solid rgba(251,243,224,.25); background: rgba(255,255,255,.06);
  color: var(--parchment); font-family: var(--font-body); font-size: 1rem;
}
.card.parchment input, .card.parchment select { background: #fff; color: var(--ink); border-color: #dccfae; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.consent input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; }
.error { color: #ffd0c8; background: rgba(160,40,40,.25); border: 1px solid rgba(233,167,160,.4);
  padding: .7em 1em; border-radius: var(--radius); font-weight: 600; }
.tiny { font-size: .82rem; }

/* ---- Ally avatar (placeholder emblem — NOT a depiction of Ally's likeness) ---- */
.ally {
  --d: 96px; width: var(--d); height: var(--d); border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; margin: 0 auto;
  background: radial-gradient(circle at 50% 35%, #34406b, #222d51);
  border: 2px solid var(--lantern); box-shadow: 0 0 0 6px rgba(244,183,64,.12), var(--shadow);
  position: relative;
}
.ally .lantern-emblem { font-size: calc(var(--d) * .5); line-height: 1; }
.ally .tag {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-display); font-size: .62rem; letter-spacing: .1em;
  background: var(--lantern); color: #3a2a07; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.ally-speech {
  background: rgba(251,243,224,.06); border: 1px solid rgba(251,243,224,.12);
  border-radius: var(--radius-lg); padding: 18px 20px; margin: 18px 0 8px;
  font-size: 1.08rem; line-height: 1.55;
}

/* ---- knot chooser grid ---- */
.knot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.knot-tile {
  background: var(--barn-night-2); border: 1.5px solid rgba(251,243,224,.12);
  border-radius: var(--radius); padding: 16px 12px; text-align: center; cursor: pointer;
  font-family: var(--font-display); font-weight: 500; color: var(--parchment);
  transition: transform .12s ease, border-color .2s ease; min-height: 116px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.knot-tile:hover { border-color: var(--lantern); transform: translateY(-2px); }
.knot-tile .em { font-size: 2rem; }
.knot-tile.spotted { border-color: var(--meadow); }
.knot-tile.spotted::after { content: "✓ spotted"; font-family: var(--font-body);
  font-size: .68rem; color: var(--meadow); font-weight: 700; }

/* ---- the signature: the knot that loosens ---- */
.untie-stage { display: grid; place-items: center; padding: 8px 0 4px; }
.untie-star {
  font-size: 3.4rem; transform: scale(.2); opacity: 0;
  animation: starPop .7s .35s cubic-bezier(.2,1.3,.4,1) forwards;
}
.rope { width: 220px; height: 60px; }
.rope path { stroke: var(--barnwood); stroke-width: 9; fill: none; stroke-linecap: round; }
.rope .knot-loop {
  stroke: var(--lantern);
  stroke-dasharray: 120; stroke-dashoffset: 0;
  animation: loosen 1.1s ease forwards;
}
@keyframes loosen { to { stroke-dashoffset: 120; opacity: .15; } }
@keyframes starPop { to { transform: scale(1); opacity: 1; } }

.fruit-chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px;
  background: rgba(95,155,107,.18); border: 1px solid var(--meadow);
  color: #d6f0d9; border-radius: 999px; padding: .5em 1em; font-weight: 700;
}

/* ---- progress / parent guide ---- */
.progress-row { display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px dashed rgba(251,243,224,.14); }
.progress-row .em { font-size: 1.5rem; }
details.guide { background: var(--barn-night-2); border-radius: var(--radius);
  padding: 4px 18px; margin-bottom: 10px; border: 1px solid rgba(251,243,224,.08); }
details.guide summary { cursor: pointer; font-family: var(--font-display); font-weight: 600;
  padding: 12px 0; }
details.guide .spirit { font-size: .9rem; color: var(--muted); padding: 0 0 14px; }
details.guide .spirit b { color: var(--lantern); }

.brandbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brandbar .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--lantern);
  display: grid; place-items: center; font-size: 1.3rem; }
.brandbar .name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.footer-note { color: var(--muted); font-size: .8rem; margin-top: 28px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .starfield, .untie-star, .rope .knot-loop { animation: none !important; }
  .rope .knot-loop { opacity: .15; }
  .untie-star { transform: none; opacity: 1; }
  .btn:active { transform: none; }
}
