/* =============================================================================
   Dream Meaning Decoder — Styles
   -----------------------------------------------------------------------------
   Theme: a soft, starry "nursery for grown-ups". Deep royal-blue gradients,
   moonlight silver, muted lavender, soft gold. Glass panels with backdrop
   blur, inline-SVG moons and twinkling stars, and gentle CSS-first motion.

   Conventions: kebab-case class names, CSS custom properties for the palette,
   all animation gated behind prefers-reduced-motion where heavy.
   ============================================================================= */

/* ----------------------------- design tokens ---------------------------- */
:root {
  --bg-1: #1a1a4e;
  --bg-2: #2d2d8f;
  --bg-3: #4a4aa0;

  --silver: #e8e8f5;
  --silver-bright: #f5f5ff;
  --lavender: #b8a9d9;
  --gold: #f0d878;
  --gold-soft: #f0d878cc;

  --text: #f0f0fa;
  --text-dim: #c8c8e8;
  --text-faint: #9a9ac8;

  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-bg-strong: rgba(255, 255, 255, 0.12);
  --panel-border: rgba(232, 232, 245, 0.18);
  --panel-blur: 14px;

  --radius: 22px;
  --radius-sm: 14px;
  --radius-pill: 999px;

  --shadow-soft: 0 18px 50px rgba(10, 10, 40, 0.45);
  --shadow-glow: 0 0 28px rgba(184, 169, 217, 0.35);

  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

  --focus: var(--gold);
}

/* -------------------------------- reset --------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

/* Ensure the hidden attribute always wins over any display declaration so
   overlays toggled via [hidden] never bleed through. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-1);
  line-height: 1.6;
  font-size: 17px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; }
p { margin: 0; }
button { font-family: inherit; }
a { color: var(--silver-bright); }

/* Visible, dreamy focus ring for keyboard users. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

kbd {
  font-family: var(--font-body);
  font-size: 0.78em;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--silver-bright);
}

/* ------------------------- background night-scape ----------------------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 15% -10%, #5a5ab0 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #3a3a9a 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
}

/* Twinkling pinprick stars (generated as spans by JS). */
.stars { position: absolute; inset: 0; }
.star {
  position: absolute;
  border-radius: 50%;
  background: var(--silver-bright);
  box-shadow: 0 0 6px rgba(245, 245, 255, 0.8);
  opacity: 0.5;
  animation-name: twinkle;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 0.9; transform: scale(1); }
}

/* Soft drifting motes rising like dream dust (generated by JS). */
.particles { position: absolute; inset: 0; }
.particle {
  position: absolute;
  bottom: -80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(232, 232, 245, 0.6), rgba(184, 169, 217, 0.05));
  filter: blur(1px);
  animation-name: drift;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

@keyframes drift {
  0% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-55vh) translateX(18px); }
  100% { transform: translateY(-115vh) translateX(-12px); }
}

/* Decorative inline-SVG moons / constellations scattered around. */
.deco { position: absolute; }
.deco-crescent-1 { top: 7%; right: 6%; animation: floaty 9s ease-in-out infinite; }
.deco-face-moon { top: 62%; left: 4%; width: 96px; height: 96px; animation: floaty 11s ease-in-out infinite; }
.deco-crescent-2 { top: 30%; left: 8%; animation: floaty 8s ease-in-out infinite reverse; }
.deco-constellation { top: 12%; left: 52%; width: 320px; height: 220px; opacity: 0.9; animation: floaty 13s ease-in-out infinite; }
.deco-sparkle { top: 22%; right: 22%; animation: floaty 7s ease-in-out infinite; }
.deco-sparkle-2 { top: 70%; right: 12%; animation: floaty 10s ease-in-out infinite reverse; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

/* ============================== App shell ============================== */
.app {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 54px) clamp(16px, 4vw, 40px) 64px;
}

.app-header { text-align: center; margin-bottom: clamp(22px, 4vw, 44px); }

.app-title {
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  color: var(--gold);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 24px rgba(240, 216, 120, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.title-icon { display: inline-flex; filter: drop-shadow(0 0 10px rgba(240, 216, 120, 0.5)); }
.title-icon svg { animation: floaty 6s ease-in-out infinite; }

.subtitle {
  margin-top: 10px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  color: var(--lavender);
}

/* ------------------------------- layout -------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 3vw, 34px);
  align-items: start;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  }
}

/* ------------------------------- panels ------------------------------- */
.panel {
  position: relative;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(var(--panel-blur));
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 30px);
  box-shadow: var(--shadow-soft);
}

.panel::before {
  /* faint top sheen like moonlight on glass */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 40%);
  pointer-events: none;
}

/* ----------------------------- input panel ----------------------------- */
.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold);
  margin-bottom: 10px;
}

.dream-textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(232, 232, 245, 0.25);
  background: rgba(26, 26, 78, 0.45);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  box-shadow: inset 0 0 18px rgba(184, 169, 217, 0.18);
  transition: border-color 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
  animation: textareaGlow 5s ease-in-out infinite;
}
.dream-textarea::placeholder { color: var(--text-faint); font-style: italic; }
.dream-textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(26, 26, 78, 0.6);
  box-shadow: inset 0 0 22px rgba(240, 216, 120, 0.18), 0 0 0 3px rgba(240, 216, 120, 0.15);
  animation: none;
}

@keyframes textareaGlow {
  0%, 100% { box-shadow: inset 0 0 16px rgba(184, 169, 217, 0.18), 0 0 0 1px rgba(184, 169, 217, 0.12); border-color: rgba(232, 232, 245, 0.22); }
  50% { box-shadow: inset 0 0 24px rgba(184, 169, 217, 0.3), 0 0 0 1px rgba(232, 232, 245, 0.4); border-color: rgba(232, 232, 245, 0.45); }
}

.hint {
  margin: 10px 2px 0;
  font-size: 0.88rem;
  color: var(--text-faint);
  min-height: 1.2em;
  transition: color 0.3s ease;
}
.hint.show { color: var(--lavender); }
.hint.ok { color: var(--gold); }

/* optional structured fields */
.optional-fields { margin-top: 16px; }
.optional-summary {
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--lavender);
  list-style: none;
  user-select: none;
  padding: 6px 0;
}
.optional-summary::-webkit-details-marker { display: none; }
.optional-summary::before {
  content: "✦";
  margin-right: 8px;
  color: var(--gold);
  display: inline-block;
  transition: transform 0.3s ease;
}
.optional-fields[open] .optional-summary::before { transform: rotate(90deg); }
.optional-fields[open] .optional-summary { margin-bottom: 12px; }

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 560px) { .fields-grid { grid-template-columns: 1fr; } }

.opt-field { display: flex; flex-direction: column; gap: 5px; }
.opt-label { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.opt-field input {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(232, 232, 245, 0.2);
  background: rgba(26, 26, 78, 0.4);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.opt-field input::placeholder { color: var(--text-faint); }
.opt-field input:focus {
  outline: none;
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(184, 169, 217, 0.18);
}

/* ------------------------------- buttons ------------------------------- */
.input-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: transform 0.25s ease, box-shadow 0.3s ease, background 0.3s ease, color 0.3s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--panel-border);
  color: var(--silver-bright);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); box-shadow: var(--shadow-glow); }

.btn-primary {
  position: relative;
  background: linear-gradient(135deg, #5a5ab0, #6a6ac0);
  color: var(--silver-bright);
  border-color: rgba(240, 216, 120, 0.5);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(74, 74, 160, 0.5), 0 0 0 0 rgba(240, 216, 120, 0.4);
  animation: btnPulse 2.6s ease-in-out infinite;
}
.btn-primary::after {
  /* moonlit shimmer sweep on hover */
  content: "";
  position: absolute;
  top: 0; left: -120%;
  width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(245, 245, 255, 0.45), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
}
.btn-primary:hover::after { left: 130%; }
.btn-primary:hover {
  box-shadow: 0 14px 36px rgba(74, 74, 160, 0.6), 0 0 22px rgba(240, 216, 120, 0.35);
  transform: translateY(-1px);
}
.btn-primary .btn-moon { display: inline-flex; }
.btn-primary:disabled { animation: none; }

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(74, 74, 160, 0.5), 0 0 0 0 rgba(240, 216, 120, 0.35); }
  50% { box-shadow: 0 10px 34px rgba(74, 74, 160, 0.55), 0 0 0 8px rgba(240, 216, 120, 0.05); }
}

.kbd-hint { margin: 12px 2px 0; font-size: 0.8rem; color: var(--text-faint); }

/* speak button listening state */
.speak-btn.listening {
  background: rgba(240, 216, 120, 0.18);
  border-color: var(--gold);
  color: var(--gold);
  animation: listenPulse 1.4s ease-in-out infinite;
}
@keyframes listenPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 216, 120, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(240, 216, 120, 0); }
}

/* ----------------------------- output area ----------------------------- */
.output-area { min-height: 320px; }

.output-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
  padding: 30px;
}
.placeholder-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 340px; }
.placeholder-moon svg { filter: drop-shadow(0 0 14px rgba(184, 169, 217, 0.5)); animation: floaty 7s ease-in-out infinite; }
.placeholder-text { color: var(--text-dim); font-family: var(--font-display); font-style: italic; font-size: 1.15rem; }

/* --------------------------- parchment scroll -------------------------- */
.scroll-card {
  position: relative;
  border-radius: var(--radius);
  padding: clamp(22px, 3vw, 34px);
  background:
    linear-gradient(180deg, rgba(255, 251, 235, 0.97), rgba(244, 236, 214, 0.95));
  color: #2a2a52;
  border: 1px solid rgba(240, 216, 120, 0.55);
  box-shadow: 0 20px 50px rgba(10, 10, 40, 0.45), inset 0 0 40px rgba(240, 216, 120, 0.12);
  overflow: hidden;
  /* unfurl initial state (animated in by .output-area.unfurl .scroll-card) */
  opacity: 0;
  transform: translateY(20px);
  clip-path: inset(0 0 100% 0);
}
.scroll-card::before {
  /* subtle paper texture via layered gradients */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 255, 255, 0.6), transparent 60%),
    repeating-linear-gradient(45deg, rgba(240, 216, 120, 0.04) 0 2px, transparent 2px 9px);
  pointer-events: none;
}
.output-area.unfurl .scroll-card {
  opacity: 1;
  transform: none;
  clip-path: inset(0 0 0 0);
  transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), clip-path 0.9s ease;
}

.scroll-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(58, 58, 110, 0.18);
  position: relative;
}
.scroll-head svg { filter: drop-shadow(0 0 6px rgba(240, 216, 120, 0.6)); flex-shrink: 0; }
.scroll-title { font-size: 1.6rem; color: #3a3a6e; }

.scroll-ref {
  font-style: italic;
  color: #5a5a82;
  font-size: 0.95rem;
  margin-bottom: 18px;
  padding-left: 14px;
  border-left: 3px solid rgba(240, 216, 120, 0.7);
  position: relative;
}

.scroll-section { margin-bottom: 18px; position: relative; }
.scroll-section:last-of-type { margin-bottom: 0; }
.section-heading {
  font-size: 1.18rem;
  color: #4a4a8a;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
.section-heading::before { content: "☾ "; color: var(--gold); opacity: 0.85; }
.scroll-section p {
  color: #34345e;
  font-size: 1.02rem;
  line-height: 1.7;
  margin-bottom: 8px;
}
.scroll-section p:last-child { margin-bottom: 0; }

.scroll-whisper p {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: italic;
  color: #3a3a6e;
  line-height: 1.5;
}

.scroll-lantern p {
  color: #3a3a6e;
  font-size: 1.05rem;
  padding: 14px 16px;
  background: rgba(240, 216, 120, 0.16);
  border-radius: 12px;
  border: 1px dashed rgba(240, 216, 120, 0.6);
}

.scroll-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(58, 58, 110, 0.18);
  position: relative;
}
.tags-label { font-size: 0.8rem; color: #5a5a82; text-transform: uppercase; letter-spacing: 0.6px; margin-right: 4px; }
.tag {
  font-size: 0.82rem;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(74, 74, 138, 0.12);
  color: #3a3a6e;
  border: 1px solid rgba(74, 74, 138, 0.2);
}

/* ============================ decode overlay ============================ */
.decode-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(45, 45, 143, 0.55), rgba(26, 26, 78, 0.82));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.decode-overlay.visible { opacity: 1; }

.decode-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  width: min(420px, 80vw);
  height: 320px;
  justify-content: center;
}

/* cycling moon phase built from a lit disc + an animated shadow */
.moon-phase {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(232, 232, 245, 0.45), 0 0 80px rgba(184, 169, 217, 0.3);
}
.moon-phase-light {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #fbfbff, #cfcfee 70%, #a9a9d8);
}
.moon-phase-shadow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #1a1a4e;
  animation: phaseCycle 2.6s linear infinite;
}
@keyframes phaseCycle {
  0%   { clip-path: inset(0 0 0 0); }      /* new moon — fully shadowed */
  25%  { clip-path: inset(0 50% 0 0); }    /* first quarter */
  50%  { clip-path: inset(0 100% 0 0); }   /* full moon — no shadow */
  75%  { clip-path: inset(0 0 0 50%); }    /* last quarter */
  100% { clip-path: inset(0 0 0 0); }      /* new moon again */
}

.float-symbols { position: absolute; inset: 0; pointer-events: none; }
.float-symbol {
  position: absolute;
  bottom: -50px;
  opacity: 0;
  animation-name: floatUp;
  animation-timing-function: ease-in;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 0 6px rgba(232, 232, 245, 0.5));
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { opacity: 0.9; }
  100% { transform: translateY(-340px) scale(1); opacity: 0; }
}

.decode-text {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--silver-bright);
  background: linear-gradient(90deg, var(--lavender), var(--silver-bright), var(--gold), var(--silver-bright), var(--lavender));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 2.4s linear infinite;
  text-align: center;
}
@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ============================== journal ============================== */
.journal-section {
  margin-top: clamp(28px, 5vw, 48px);
}
.journal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--gold);
}
.journal-count {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(240, 216, 120, 0.18);
  color: var(--gold);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(240, 216, 120, 0.4);
}

.journal-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
}
.journal-list.open { max-height: none; }

.journal-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 1.1rem;
  padding: 30px;
}

.journal-card {
  background: var(--panel-bg-strong);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  -webkit-backdrop-filter: blur(var(--panel-blur));
  backdrop-filter: blur(var(--panel-blur));
  transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}
.journal-card:hover { border-color: rgba(240, 216, 120, 0.4); transform: translateY(-2px); box-shadow: var(--shadow-glow); }

.journal-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.journal-date { font-size: 0.78rem; color: var(--lavender); text-transform: uppercase; letter-spacing: 0.5px; }

.journal-snippet { font-size: 0.92rem; color: var(--text-dim); font-style: italic; margin-bottom: 8px; }
.journal-essence {
  font-family: var(--font-display);
  font-size: 1.12rem;
  color: var(--gold);
  line-height: 1.4;
}

.journal-actions { display: flex; gap: 8px; margin-top: 12px; }
.journal-btn {
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--silver-bright);
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.journal-btn:hover { background: rgba(255, 255, 255, 0.14); }
.reveal-btn:hover { border-color: var(--lavender); }
.delete-btn:hover { border-color: #e88; color: #ffcaca; }
.delete-btn.confirming { background: rgba(232, 100, 100, 0.25); border-color: #e88; color: #ffd0d0; animation: listenPulse 1s ease-in-out infinite; }

/* expandable full reading inside a journal card */
.journal-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
  margin-top: 0;
}
.journal-body .scroll-section { margin-top: 14px; }
.journal-body .section-heading { color: var(--gold); font-size: 1.05rem; }
.journal-body .section-heading::before { content: "☾ "; }
.journal-body .scroll-section p { color: var(--text-dim); font-size: 0.95rem; }
.journal-body .scroll-whisper p { color: var(--silver-bright); font-family: var(--font-display); font-style: italic; font-size: 1.1rem; }
.journal-body .scroll-lantern p { color: var(--text); background: rgba(240, 216, 120, 0.12); border-radius: 10px; padding: 10px 12px; border: 1px dashed rgba(240, 216, 120, 0.4); }
.journal-card.expanded .journal-body { max-height: 1200px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--panel-border); }

/* ------------------------------- footer -------------------------------- */
.app-footer {
  margin-top: 48px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.app-footer p { max-width: 560px; margin: 0 auto; }

/* -------------------------------- toast -------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26, 26, 78, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(240, 216, 120, 0.45);
  color: var(--silver-bright);
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== prefers-reduced-motion ===================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .star { opacity: 0.5; }
  .particle { display: none; }
  .moon-phase-shadow { animation: none; clip-path: inset(0 100% 0 0); } /* show a calm full moon */
  .decode-text { animation: none; -webkit-text-fill-color: var(--silver-bright); color: var(--silver-bright); }
  .float-symbols { display: none; }
  .dream-textarea { animation: none; }
  .btn-primary { animation: none; }
  .deco { animation: none; }
  .scroll-card {
    opacity: 1;
    transform: none;
    clip-path: none;
  }
}

/* Explicit class mirror for JS-triggered reduced motion (covers the case where
   the media query itself is not the source, e.g. toggled at runtime). */
.reduced-motion .star { opacity: 0.5; }
.reduced-motion .particle { display: none; }
.reduced-motion .float-symbols,
.reduced-motion .moon-phase-shadow { animation: none; }
.reduced-motion .decode-text {
  animation: none;
  -webkit-text-fill-color: var(--silver-bright);
  color: var(--silver-bright);
}
.reduced-motion .dream-textarea,
.reduced-motion .btn-primary,
.reduced-motion .deco { animation: none; }
.reduced-motion .scroll-card { opacity: 1; transform: none; clip-path: none; }

/* --------------------------- small screens ---------------------------- */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .input-actions { flex-direction: column-reverse; align-items: stretch; }
  .btn { justify-content: center; }
  .deco-constellation { width: 220px; height: 160px; }
  .deco-face-moon { width: 70px; height: 70px; }
}

/* Honor users who prefer less data / no backdrop blur support. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel, .journal-card, .toast {
    background: rgba(30, 30, 80, 0.92);
  }
}
