/* ============================================================
   Inner Lantern — editorial spiritual journal
   Warm cream paper, lantern glow, expressive Fraunces display,
   asymmetric masthead, hairline rules, sectioned reflection.
   ============================================================ */

:root {
  /* Warm cream paper palette */
  --paper:        #f5ecdc;
  --paper-deep:   #ece0ca;
  --ink:          #38301f;   /* warm near-black for text */
  --ink-soft:     #6c604c;   /* muted body text */
  --ink-faint:    #a3937a;   /* captions, counters, rules */

  /* Lantern light — amber / candle gold */
  --flame:        #df9f4d;
  --flame-deep:   #c07d2c;
  --flame-glow:   rgba(223, 159, 77, 0.40);

  /* Mystical Mauve — brand accent (used sparingly) */
  --mauve:        #7c4c9e;
  --mauve-deep:   #5e3680;
  --mauve-glow:   rgba(124, 76, 158, 0.22);

  --card:         #fbf6ea;
  --card-edge:    rgba(120, 96, 60, 0.16);
  --hairline:     rgba(120, 96, 60, 0.30);
  --shadow:       rgba(70, 50, 22, 0.12);

  --field-focus:  #fffdf7;
  --error:        #b4533b;
  --top-glow:     rgba(255, 248, 232, 0.9);
  --grain:        rgba(120, 96, 60, 0.05);

  --radius:       18px;
  --radius-lg:    26px;
  --ease:         cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- Twilight (dusk-mauve) theme ---------- */
[data-theme="twilight"] {
  --paper:        #1e1729;
  --paper-deep:   #17111f;
  --ink:          #ede4f4;
  --ink-soft:     #c4b4d4;
  --ink-faint:    #8f7fa0;

  --flame:        #ecb775;
  --flame-deep:   #e0a259;
  --flame-glow:   rgba(236, 183, 117, 0.30);

  --mauve:        #bd96da;
  --mauve-deep:   #c8a6e0;
  --mauve-glow:   rgba(150, 104, 188, 0.32);

  --card:         #271d36;
  --card-edge:    rgba(196, 168, 226, 0.14);
  --hairline:     rgba(196, 168, 226, 0.22);
  --shadow:       rgba(0, 0, 0, 0.55);

  --field-focus:  #2c2140;
  --error:        #e79279;
  --top-glow:     rgba(170, 132, 206, 0.18);
  --grain:        rgba(196, 168, 226, 0.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Spectral", Georgia, "Times New Roman", serif;
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}

/* Warm vignette + faint paper grain for depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% -10%, var(--top-glow), transparent 55%),
    radial-gradient(ellipse at 50% 120%, var(--mauve-glow), transparent 62%);
}
body::after {  /* subtle grain via repeating noise-ish gradient */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(var(--grain) 0.5px, transparent 0.5px),
    radial-gradient(var(--grain) 0.5px, transparent 0.5px);
  background-size: 3px 3px, 4px 4px;
  background-position: 0 0, 1px 2px;
}

/* Lantern glow that breathes behind the masthead, pulled to one side */
.ambient {
  position: fixed;
  top: -180px;
  left: 62%;
  width: 540px;
  height: 540px;
  transform: translateX(-50%);
  /* amber lantern core fading into a mystical-mauve halo */
  background:
    radial-gradient(circle at 50% 42%, var(--flame-glow), transparent 52%),
    radial-gradient(circle at 50% 58%, var(--mauve-glow), transparent 72%);
  filter: blur(22px);
  z-index: 0;
  animation: breathe 7s var(--ease) infinite;
  pointer-events: none;
}
@keyframes breathe {
  0%, 100% { opacity: 0.5;  transform: translateX(-50%) scale(1);    }
  50%      { opacity: 0.85; transform: translateX(-50%) scale(1.07); }
}

/* ---------- Layout ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 660px;
  margin: 0 auto;
  padding: clamp(2.6rem, 7vw, 5rem) 1.4rem 3rem;
  display: flex;
  flex-direction: column;
  gap: clamp(1.8rem, 4vw, 2.6rem);
}

/* ---------- Masthead (asymmetric, editorial) ---------- */
.masthead {
  animation: rise 1s var(--ease) both;
}

.folio {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: clamp(1.4rem, 4vw, 2.2rem);
  font-family: "Fraunces", Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.folio-mark { color: var(--flame-deep); font-weight: 600; white-space: nowrap; }
.folio-home { text-decoration: none; transition: color 0.3s var(--ease); }
.folio-home:hover { color: var(--mauve-deep); }
.folio-rule { flex: 1; height: 1px; background: var(--hairline); }

/* Day / Twilight toggle, styled like part of the running head */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.32rem 0.7rem 0.32rem 0.55rem;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease);
}
.theme-toggle:hover { border-color: var(--mauve); color: var(--mauve-deep); }

/* Icon: a small moon that fills in on twilight */
.theme-toggle-icon {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--flame);
  box-shadow: inset -4px -4px 0 0 var(--card);  /* crescent cut */
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
[data-theme="twilight"] .theme-toggle-icon {
  background: var(--mauve);
  box-shadow: inset -3px -3px 0 0 var(--mauve), 0 0 10px var(--mauve-glow);
}
.theme-toggle-text::after { content: ""; }

.hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.title {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(3.4rem, 16vw, 6.2rem);
  line-height: 0.92;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ink);
}

/* Lantern glyph, offset to overlap the headline's upper-right */
.lantern {
  flex: none;
  width: 52px;
  height: 68px;
  margin-top: 0.4rem;
  border: 1.5px solid var(--flame-deep);
  border-radius: 11px 11px 16px 16px;
  position: relative;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(223,159,77,0.12), rgba(223,159,77,0.02));
  box-shadow: 0 0 42px var(--flame-glow);
}
.lantern::before {  /* top ring */
  content: "";
  position: absolute;
  top: -9px;
  width: 16px;
  height: 9px;
  border: 1.5px solid var(--flame-deep);
  border-bottom: none;
  border-radius: 9px 9px 0 0;
}
.lantern-flame {
  width: 10px;
  height: 16px;
  background: radial-gradient(circle at 50% 65%, #fff6e2, var(--flame) 60%, var(--flame-deep));
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 0 16px var(--flame);
  animation: flicker 3.2s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: scale(1) translateY(0);     opacity: 1;    }
  40%      { transform: scale(0.93) translateY(1px);  opacity: 0.85; }
  70%      { transform: scale(1.06) translateY(-1px); opacity: 1;    }
}

.tagline {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.1rem, 3.6vw, 1.45rem);
  color: var(--flame-deep);
  margin: 1.2rem 0 0;
  max-width: 28rem;
}

.lede {
  max-width: 32rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0.7rem 0 0;
}

/* ---------- Kicker label (small-caps section marker) ---------- */
.kicker {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--flame-deep);
  margin-bottom: 1.1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--hairline);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-lg);
  padding: clamp(1.6rem, 5vw, 2.4rem);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 22px 48px -28px var(--shadow);
}
.card--form { animation: rise 1s var(--ease) 0.12s both; }

/* ---------- Form ---------- */
.field-label {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
  color: var(--ink);
  margin-bottom: 0.7rem;
}
.field {
  width: 100%;
  resize: vertical;
  min-height: 150px;
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-family: "Spectral", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.65;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}
.field::placeholder { color: var(--ink-faint); font-style: italic; }
.field:focus {
  outline: none;
  background: var(--field-focus);
  border-color: var(--flame);
  box-shadow: 0 0 0 4px var(--flame-glow);
}

.field-foot {
  display: flex;
  justify-content: flex-end;
  margin: 0.55rem 0 1.3rem;
}
.counter { font-size: 0.8rem; letter-spacing: 0.02em; color: var(--ink-faint); }
.counter.is-warn { color: var(--flame-deep); }

/* ---------- Button ---------- */
.btn {
  position: relative;
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--flame), var(--flame-deep));
  color: #fff8ec;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 12px 28px -12px var(--flame-deep);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), filter 0.25s var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 34px -14px var(--flame-deep); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { cursor: progress; filter: saturate(0.7) brightness(0.97); }

.btn-spinner {
  display: none;
  width: 17px; height: 17px;
  margin-left: 0.6rem;
  vertical-align: -3px;
  border: 2px solid rgba(255, 248, 236, 0.45);
  border-top-color: #fff8ec;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Response ---------- */
.card--response { animation: rise 0.7s var(--ease) both; }

.response-state {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  color: var(--ink-faint);
}
.response-state.is-error { color: var(--error); font-style: normal; }

/* Plain-prose fallback with an editorial drop cap */
.response-body { color: var(--ink); }
.response-prose { font-size: 1.1rem; white-space: pre-wrap; word-wrap: break-word; }
.response-prose::first-letter {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 3.1rem;
  line-height: 0.8;
  float: left;
  padding: 0.1rem 0.6rem 0 0;
  color: var(--flame-deep);
}

/* Structured 4-part reflection */
.reflection { display: flex; flex-direction: column; gap: 1.6rem; }
.movement {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 1.1rem;
  align-items: baseline;
  opacity: 0;
  animation: rise 0.6s var(--ease) forwards;
}
.movement-num {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.1rem;
  color: var(--flame-deep);
  grid-row: span 2;
}
.movement-label {
  font-family: "Fraunces", Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--ink-faint);
}
.movement-text {
  grid-column: 2;
  font-size: 1.08rem;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.movement:not(:last-child) .movement-text { padding-bottom: 1.4rem; border-bottom: 1px solid var(--hairline); }

/* ---------- Brand badge (Mystical Mauve) ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  margin-bottom: 1.6rem;
  padding: 0.4rem 0.9rem 0.4rem 0.45rem;
  border-radius: 999px;
  transition: background 0.3s var(--ease);
}
.brand:hover { background: rgba(124, 76, 158, 0.07); }

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow:
    0 0 0 1px rgba(124, 76, 158, 0.35),
    0 0 22px var(--mauve-glow);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.brand:hover .brand-mark {
  transform: scale(1.05) rotate(-3deg);
  box-shadow: 0 0 0 1px var(--mauve), 0 0 28px rgba(124, 76, 158, 0.4);
}

.brand-text { text-align: left; line-height: 1.25; }
.brand-by {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.6rem;
  color: var(--ink-faint);
}
.brand-name {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--mauve-deep);
}

/* ---------- Disclaimer ---------- */
.disclaimer {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.85rem;
  line-height: 1.6;
  max-width: 34rem;
  margin: 0.6rem auto 0;
}
.disclaimer-rule {
  display: block;
  width: 44px;
  height: 1px;
  background: var(--hairline);
  margin: 0 auto 1.2rem;
}
.disclaimer p { margin: 0; }

/* ---------- Shared entrance ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 460px) {
  .lantern { width: 42px; height: 56px; }
}

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