/* ═══════════════════════════════════════════════════════════════════════════
   THE HAPPINESS JAR · base — tokens, reset, typography, opening screen
   Mobile-first. Reference device: iPhone 13 (390 × 844).
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --ivory: #fff8ef;
  --ivory-deep: #fbf0e2;
  --blush: #f8e3e1;
  --blush-deep: #f0c9c6;
  --rose: #c07b81;
  --rose-deep: #a05e66;
  --plum: #462e33;
  --plum-soft: #6c4c51;
  --ink: #3d2b2f;
  --ink-soft: #7a6166;
  --gold: #c19a52;
  --gold-soft: #e6cfa5;
  --sage: #94a785;
  --paper: #fffdf8;
  --espresso: #3c261f;
  --espresso-soft: #6b5044;
  --journ-ivory: #fbf5e6;

  --radius: 18px;
  --radius-lg: 26px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --hand: "Snell Roundhand", "Segoe Script", "Bradley Hand", "Brush Script MT", cursive;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --shadow-soft: 0 10px 30px -18px rgba(70, 46, 51, 0.45);
  --shadow-card: 0 18px 45px -26px rgba(70, 46, 51, 0.55);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--ivory);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 70% at 88% 4%, #fff3dc 0%, rgba(255, 243, 220, 0) 58%),
    radial-gradient(100% 60% at 8% 96%, #fde3e0 0%, rgba(253, 227, 224, 0) 62%),
    linear-gradient(172deg, #fffaf3 0%, #fdf1e7 46%, #fbe6e3 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

body.is-locked {
  overflow: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

p,
h1,
h2,
h3 {
  margin: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

:focus-visible {
  outline: 2.5px solid var(--rose-deep);
  outline-offset: 3px;
  border-radius: 6px;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sf {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── ambience: sunlight + paper grain ─────────────────────────────────────── */
.ambience {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sunbeam {
  position: absolute;
  top: -28vh;
  right: -18vw;
  width: 92vw;
  height: 92vw;
  max-width: 720px;
  max-height: 720px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 226, 170, 0.6) 0%, rgba(255, 226, 170, 0) 68%);
  filter: blur(6px);
  animation: beam 18s ease-in-out infinite alternate;
}

.grain {
  position: absolute;
  inset: -10%;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes beam {
  from { transform: translate3d(0, 0, 0) scale(1); opacity: 0.85; }
  to   { transform: translate3d(-4%, 3%, 0) scale(1.08); opacity: 1; }
}

/* ── screens ──────────────────────────────────────────────────────────────── */
.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}

.screen[hidden] {
  display: none;
}

.screen.is-entering {
  animation: screen-in 0.7s var(--ease-out) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.994); }
  to   { opacity: 1; transform: none; }
}

/* ── shared type + buttons ───────────────────────────────────────────────── */
.eyebrow,
.eyerow {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rose);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 52px;
  min-width: 44px;
  padding: 0 1.5rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  transition: transform 0.18s var(--ease-out), box-shadow 0.25s var(--ease-out),
    background-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
  will-change: transform;
}

.btn:active {
  transform: scale(0.968);
}

.btn--primary {
  color: #fff9f4;
  background: linear-gradient(135deg, #b9707a 0%, #93525e 100%);
  box-shadow: 0 16px 30px -18px rgba(122, 63, 74, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn--soft {
  color: var(--rose-deep);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(192, 123, 129, 0.32);
  box-shadow: 0 10px 22px -20px rgba(70, 46, 51, 0.7);
}

.btn--ghost {
  color: var(--plum-soft);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(122, 97, 102, 0.22);
}

.btn--wide {
  width: 100%;
}

/* ── waveform (player) ───────────────────────────────────────────────────── */
.wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
}

.wave i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--rose) 0%, var(--blush-deep) 100%);
  transform: scaleY(0.45);
  transform-origin: bottom;
  opacity: 0.6;
  transition: transform 0.4s var(--ease-out), opacity 0.4s ease;
}

.wave--player {
  height: 15px;
  gap: 2.5px;
  opacity: 0.85;
}

.wave--player i {
  width: 2.5px;
}

.player.is-playing .wave i {
  opacity: 1;
  animation: wave 1.15s ease-in-out infinite;
}

.player.is-playing .wave i:nth-child(2) { animation-delay: 0.14s; }
.player.is-playing .wave i:nth-child(3) { animation-delay: 0.28s; }
.player.is-playing .wave i:nth-child(4) { animation-delay: 0.42s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.24); }
  50%      { transform: scaleY(1); }
}

@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;
  }
}
