/* ---------- Foundations ---------- */
:root {
  --ink: #f4f1ea;
  --ink-soft: #c8c2d8;
  --ink-faint: #8f89a6;

  --bg-top: #1b1b2f;
  --bg-mid: #26243f;
  --bg-low: #33304f;

  --glass: rgba(255, 255, 255, 0.045);
  --glass-line: rgba(255, 255, 255, 0.10);

  --wish: #d9c48f;      /* warm moonlight gold */
  --thought: #a9b8d6;   /* soft periwinkle */
  --gratitude: #a8cbbf; /* gentle sage water */

  --radius: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --maxw: 620px;
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute always wins over display rules below. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg-top);
  line-height: 1.6;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0;
}

/* ---------- Ambient sky ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 90% at 50% -10%, #3a3560 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-low) 100%);
}

.glow {
  position: absolute;
  top: -12vh;
  left: 50%;
  width: 60vh;
  height: 60vh;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(230, 220, 180, 0.16) 0%, transparent 62%);
  filter: blur(6px);
  pointer-events: none;
}

.moon {
  position: absolute;
  top: 6vh;
  left: 50%;
  width: 78px;
  height: 78px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fbf6e6 0%, #ece0bd 55%, #cdbf95 100%);
  box-shadow: 0 0 42px 10px rgba(240, 230, 195, 0.28), inset -8px -8px 18px rgba(140, 128, 96, 0.35);
  animation: float 9s var(--ease) infinite;
}

.stars { position: absolute; inset: 0; overflow: hidden; }
.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0.7;
  animation: twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes twinkle { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.85; } }
@keyframes float { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(9px); } }

/* ---------- Layout ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.4rem, 5vw, 2.6rem) clamp(1.1rem, 5vw, 1.6rem) 4rem;
  animation: rise 1s var(--ease) both;
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Masthead ---------- */
.masthead { text-align: center; margin: 8.5rem 0 2.4rem; }
.crest { font-size: 1.5rem; color: var(--wish); opacity: 0.85; }
.masthead h1 { font-size: clamp(2.5rem, 9vw, 3.4rem); margin-top: 0.2rem; }
.greeting { color: var(--ink-soft); font-size: 0.98rem; margin-top: 0.5rem; font-weight: 300; }

/* ---------- Cards ---------- */
.cards { display: flex; flex-direction: column; gap: 1.15rem; }

.card {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.5s var(--ease), transform 0.5s var(--ease);
}
.card:focus-within { border-color: var(--accent, var(--glass-line)); transform: translateY(-2px); }

.card[data-accent="wish"] { --accent: var(--wish); }
.card[data-accent="thought"] { --accent: var(--thought); }
.card[data-accent="gratitude"] { --accent: var(--gratitude); }

.card-head { display: flex; align-items: flex-start; gap: 0.85rem; margin-bottom: 0.9rem; }
.card-icon {
  font-size: 1.05rem;
  color: var(--accent);
  line-height: 1.9;
  width: 1.7rem; height: 1.7rem;
  display: grid; place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0.85;
  flex-shrink: 0;
}
.card h2 { font-size: 1.35rem; line-height: 1.2; }
.card-prompt { color: var(--ink-faint); font-size: 0.85rem; margin: 0.15rem 0 0; }

textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.7;
  resize: none;
  outline: none;
  padding: 0;
  overflow: hidden;
}
textarea::placeholder { color: var(--ink-faint); opacity: 0.6; }

/* ---------- Release button ---------- */
.release {
  margin: 0.6rem auto 0;
  display: block;
  padding: 0.85rem 2.4rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(217, 196, 143, 0.10);
  color: var(--ink);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.4s var(--ease), transform 0.2s var(--ease), border-color 0.4s var(--ease);
}
.release:hover { background: rgba(217, 196, 143, 0.18); border-color: var(--wish); }
.release:active { transform: scale(0.98); }
.release:disabled { opacity: 0.55; cursor: default; }

.form-note { text-align: center; color: var(--ink-faint); font-size: 0.85rem; margin-top: 0.4rem; }

/* ---------- Confirmation ---------- */
.confirm { text-align: center; padding: 2.5rem 1rem; animation: rise 0.7s var(--ease) both; }
.confirm p { color: var(--ink-soft); font-family: "Cormorant Garamond", serif; font-size: 1.5rem; margin-top: 1rem; }
.ripple { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.ripple span {
  position: absolute; inset: 0; margin: auto;
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid var(--wish);
  animation: ring 2.6s var(--ease) infinite;
}
.ripple span:nth-child(2) { animation-delay: 0.7s; }
.ripple span:nth-child(3) { animation-delay: 1.4s; }
@keyframes ring {
  from { width: 12px; height: 12px; opacity: 0.9; }
  to { width: 120px; height: 120px; opacity: 0; }
}

/* ---------- Today ---------- */
.today { margin-top: 2.4rem; padding-top: 1.6rem; border-top: 1px solid var(--glass-line); }
.today h3 { font-size: 1.2rem; color: var(--ink-soft); margin-bottom: 0.8rem; }
.today ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.today li { display: flex; gap: 0.7rem; align-items: baseline; font-size: 0.95rem; color: var(--ink-soft); }
.today .tag { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); flex-shrink: 0; width: 5.2rem; }
.today li[data-accent="wish"] { --accent: var(--wish); }
.today li[data-accent="thought"] { --accent: var(--thought); }
.today li[data-accent="gratitude"] { --accent: var(--gratitude); }

/* ---------- Recent ---------- */
.recent { margin-top: 2.4rem; }
.recent-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-soft); font-family: "Cormorant Garamond", serif; font-size: 1.25rem;
  padding: 0.6rem 0; border-top: 1px solid var(--glass-line);
}
.chevron { transition: transform 0.4s var(--ease); font-size: 1.1rem; }
.recent-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.recent-body { padding: 0.4rem 0 0; }
.recent-day { margin-bottom: 1.4rem; }
.recent-date { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.5rem; }
.recent-entry { display: flex; gap: 0.7rem; align-items: baseline; margin-bottom: 0.4rem; font-size: 0.94rem; color: var(--ink-soft); }
.recent-entry .tag { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; width: 5.2rem; flex-shrink: 0; }
.recent-entry[data-accent="wish"] .tag { color: var(--wish); }
.recent-entry[data-accent="thought"] .tag { color: var(--thought); }
.recent-entry[data-accent="gratitude"] .tag { color: var(--gratitude); }
.recent-empty { color: var(--ink-faint); font-size: 0.9rem; }

/* ---------- Footer ---------- */
.footer { text-align: center; margin-top: 3rem; }
.lock { background: none; border: none; color: var(--ink-faint); font-size: 0.8rem; letter-spacing: 0.05em; cursor: pointer; opacity: 0.6; transition: opacity 0.3s; }
.lock:hover { opacity: 1; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  padding: 1.5rem;
  background: rgba(15, 15, 28, 0.55);
  backdrop-filter: blur(4px);
  animation: rise 0.6s var(--ease) both;
}
.gate-card {
  background: var(--glass); border: 1px solid var(--glass-line);
  border-radius: var(--radius); padding: 2.4rem 2rem; text-align: center;
  max-width: 340px; width: 100%;
  backdrop-filter: blur(14px);
}
.gate-moon { font-size: 2rem; }
.gate-card h2 { font-size: 1.8rem; margin: 0.6rem 0 0.2rem; }
.gate-card p { color: var(--ink-soft); font-size: 0.92rem; margin: 0 0 1.3rem; }
#gate-form { display: flex; flex-direction: column; gap: 0.7rem; }
#gate-input {
  text-align: center; letter-spacing: 0.3em; font-size: 1.1rem;
  padding: 0.75rem; border-radius: 14px;
  border: 1px solid var(--glass-line); background: rgba(0,0,0,0.15); color: var(--ink);
  outline: none;
}
#gate-input:focus { border-color: var(--wish); }
#gate-form button {
  padding: 0.75rem; border-radius: 14px; border: 1px solid var(--glass-line);
  background: rgba(217, 196, 143, 0.14); color: var(--ink);
  font-family: "Cormorant Garamond", serif; font-size: 1.15rem; cursor: pointer;
  transition: background 0.3s;
}
.gate-error { color: #e0a3a3 !important; margin-top: 0.8rem !important; font-size: 0.85rem !important; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
