/* Kindling: paper, ink, moss and ember. One voice, one place, one minute. */

:root {
  --paper: #f4eee3;
  --paper-2: #fbf7f0;
  --paper-3: #e9e1d2;
  --ink: #27231f;
  --ink-2: #5a534a;
  --ink-3: #857b6e;
  --moss: #566b4a;
  --ember: #c4602f;
  --ember-soft: rgba(196, 96, 47, 0.14);
  --fill: #a44d28;
  --fill-hover: #8a3f20;
  --on-accent: #fff;
  --line: rgba(39, 35, 31, 0.14);
  --line-strong: rgba(39, 35, 31, 0.32);
  --grain-opacity: 0.07;
  --grain-blend: multiply;
  --shadow: 0 14px 34px rgba(39, 35, 31, 0.09);
  --radius: 14px;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* default tone, overridden per track */
  --tint: #dfe4d3;
  --tint-ink: #4a5c3c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1916;
    --paper-2: #24211c;
    --paper-3: #2d2822;
    --ink: #ede5d7;
    --ink-2: #b8ad9b;
    --ink-3: #877d6e;
    --moss: #8ea07a;
    --ember: #e07a4c;
    --ember-soft: rgba(224, 122, 76, 0.16);
    --fill: #e07a4c;
    --fill-hover: #f09066;
    --on-accent: #1b1916;
    --line: rgba(237, 229, 215, 0.14);
    --line-strong: rgba(237, 229, 215, 0.34);
    --grain-opacity: 0.09;
    --grain-blend: screen;
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
    --tint: #2a3324;
    --tint-ink: #b9c7a8;
  }
}

/* Each track carries a tone: the band on its card and the wash on its postcard page. */
.tone-moss { --tint: #dfe4d3; --tint-ink: #4a5c3c; }
.tone-rain { --tint: #d9dfe3; --tint-ink: #4d5c68; }
.tone-flame { --tint: #ecd7c6; --tint-ink: #8f4526; }
.tone-wave { --tint: #d5e2df; --tint-ink: #3f6a66; }
.tone-hill { --tint: #e3dad8; --tint-ink: #66505f; }
@media (prefers-color-scheme: dark) {
  .tone-moss { --tint: #2a3324; --tint-ink: #b9c7a8; }
  .tone-rain { --tint: #262d33; --tint-ink: #aebcc7; }
  .tone-flame { --tint: #3a2418; --tint-ink: #e9a07e; }
  .tone-wave { --tint: #22302e; --tint-ink: #a6cbc5; }
  .tone-hill { --tint: #2f272d; --tint-ink: #cbb7c6; }
}

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

body {
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.5;
  font-variation-settings: 'opsz' 14;
  min-height: 100dvh;
  position: relative;
}

/* paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

a { color: var(--ember); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }

.wrap {
  position: relative;
  z-index: 1;
  overflow-wrap: anywhere;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 18px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- type ---------- */
h1 {
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 26px 0 14px;
  font-variation-settings: 'opsz' 120;
}
h1 em { font-style: italic; color: var(--ember); }
.h2 {
  font-size: clamp(28px, 7.5vw, 34px);
  font-weight: 400;
  line-height: 1.12;
  margin: 10px 0 8px;
  font-variation-settings: 'opsz' 96;
}
.h3 { font-size: 21px; font-weight: 500; margin: 0 0 10px; }
.lede { font-size: 18px; color: var(--ink-2); margin: 0 0 14px; }
.whisper { font-style: italic; color: var(--ember); margin: 0; font-size: 21px; font-variation-settings: 'opsz' 40; }
.eyebrow {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 12px 0 10px;
  font-weight: 500;
}
.meta { font-family: var(--font-ui); font-size: 13px; color: var(--ink-2); margin: 2px 0 0; }
.fine { font-family: var(--font-ui); font-size: 14px; color: var(--ink-2); margin: 12px 0 0; text-align: center; }
.fine-left { text-align: left; margin: 16px 0 0; }
.quiet { font-style: italic; color: var(--ink-2); }

/* ---------- header ---------- */
.hero { padding: 26px 0 8px; }
.hero-row, .top { display: flex; align-items: center; justify-content: space-between; }
.top { padding: 22px 0 10px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark-flame { width: 22px; height: 22px; color: var(--ember); display: inline-block; }
.wordmark-flame .motif { width: 100%; height: 100%; display: block; stroke-width: 2.6; }
.wordmark-flame .motif path:nth-child(2) { fill: currentColor; }
.back { font-family: var(--font-ui); font-size: 14px; color: var(--ink-2); text-decoration: none; }
.back::before { content: '← '; }
.navlink {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 13px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

/* the drawing under the headline */
.horizon {
  display: block;
  width: 100%;
  height: auto;
  margin: 8px 0 6px;
  color: var(--ink-3);
}
.horizon-flame { fill: var(--ember); stroke: none; }
.horizon-flame-inner { fill: var(--paper); stroke: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--fill); color: var(--on-accent); }
.btn-primary:hover { background: var(--fill-hover); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-wide { width: 100%; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 14px; }
.chip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.is-active { background: var(--moss); border-color: var(--moss); color: var(--on-accent); }

/* ---------- postcards (the track cards) ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.track[hidden] { display: none; }
.postcard { padding: 0; overflow: hidden; }
.scene {
  position: relative;
  height: 120px;
  background: var(--tint);
  color: var(--tint-ink);
  border-bottom: 1px solid var(--line);
}
.scene-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stamp {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 46px;
  height: 46px;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--paper-2);
  color: var(--tint-ink);
  border: 1.5px dashed var(--tint-ink);
  border-radius: 4px;
  transform: rotate(5deg);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}
.stamp small { display: block; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 500; margin-top: 3px; }
.card-body { padding: 16px 18px 18px; }
.card h3 { margin: 0; font-size: 24px; font-weight: 500; line-height: 1.15; font-variation-settings: 'opsz' 40; }
.line { margin: 10px 0 14px; color: var(--ink-2); font-style: italic; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty { margin: 8px 0; }

/* ---------- player ---------- */
.player { display: flex; align-items: center; gap: 12px; }
.player-large { flex-direction: column; gap: 14px; }
.play {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  background: var(--fill);
  color: var(--on-accent);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease;
}
.play:active { transform: scale(0.96); }
.player-large .play { width: 116px; height: 116px; box-shadow: 0 16px 38px rgba(164, 77, 40, 0.32); }
.player-small .play { width: 48px; height: 48px; }
/* idle, the big button breathes: a cue, not decoration */
.player-large:not(.is-playing) .play { animation: breathe 8s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.ring {
  position: absolute;
  inset: -9px;
  width: calc(100% + 18px);
  height: calc(100% + 18px);
  transform: rotate(-90deg);
  fill: none;
  pointer-events: none;
}
.ring-bg { stroke: var(--line); stroke-width: 2; }
.ring-fg { stroke: var(--ember); stroke-width: 2.5; stroke-linecap: round; transition: stroke-dashoffset 0.25s linear; }
.player-small .ring { display: none; }
.icon { width: 42%; height: 42%; fill: currentColor; }
.icon-play { transform: translateX(6%); }
.icon-pause { display: none; }
.is-playing .icon-play { display: none; }
.is-playing .icon-pause { display: block; }
.is-error .play { background: var(--ink-3); }
.time {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
}

/* ---------- forms ---------- */
.form { margin-top: 6px; }
.field { display: block; margin: 0 0 16px; position: relative; }
.field > span {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field input, .field textarea, .linkbox input, .email input {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .email input:focus { outline: 2px solid var(--ember); outline-offset: 2px; }
.count { display: block; text-align: right; font-family: var(--font-ui); font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.error, .notice {
  background: var(--ember-soft);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: var(--font-ui);
  font-size: 15px;
  margin: 0 0 14px;
}
.notice { margin: 12px 0 0; }
.stack .field { margin-bottom: 12px; }
.stack .btn { margin-top: 4px; }
.signout { margin-top: 18px; }

/* the live preview on the compose page is a postcard too */
.postcard-preview { transform: rotate(-1.2deg); margin: 22px 6px 26px; }
.pc-body { padding: 16px 18px 18px; }
.pc-to { margin: 0; color: var(--ink-2); }
.pc-note {
  margin: 6px 0 10px;
  font-size: 22px;
  font-style: italic;
  font-weight: 300;
  line-height: 1.35;
  font-variation-settings: 'opsz' 40;
}
.pc-from { margin: 0; text-align: right; color: var(--ink-2); }

/* ---------- checkout (dormant while sends are free) ---------- */
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.summary dt {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 4px;
}
.summary dd { margin: 0; }
.price { font-size: 30px; margin: 14px 0 0; }
.providers { display: grid; gap: 10px; margin: 18px 0 10px; }

/* ---------- share ---------- */
.linkbox { display: flex; gap: 8px; margin: 14px 0; }
.linkbox input { flex: 1; min-width: 0; font-size: 16px; }
.share { display: grid; gap: 10px; margin: 0 0 18px; }
.email { margin: 8px 0 16px; }
.email form { display: flex; gap: 8px; }
.email input { flex: 1; min-width: 0; }
.plays a { font-family: var(--font-ui); }

/* ---------- the postcard page ---------- */
.stage-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--tint) 0%, var(--paper) 70%);
}
.stage {
  position: relative;
  z-index: 1;
  overflow-wrap: anywhere;
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  padding: 44px 22px calc(32px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.stage-scene {
  position: fixed;
  left: 50%;
  top: 0;
  width: min(140vw, 900px);
  height: 42vh;
  transform: translateX(-50%);
  color: var(--tint-ink);
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
}
.stage-scene .scene-art { width: 100%; height: 100%; }
.pc-to-big { font-size: 26px; margin: 0; }
.note-big {
  font-size: clamp(24px, 6vw, 30px);
  font-style: italic;
  font-weight: 300;
  line-height: 1.35;
  margin: 0;
  font-variation-settings: 'opsz' 72;
}
.track-name {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.instruction { color: var(--ink-2); font-style: italic; margin: 0; max-width: 26ch; }
.after { margin-top: 10px; animation: rise 0.6s ease both; }
.after[hidden] { display: none; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- footer ---------- */
.foot {
  margin-top: 44px;
  padding: 20px 0 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.foot p { margin: 0; }
.foot-stage { margin-top: 28px; border-top: 0; align-items: center; }

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

/* ---------- the reveal ---------- */
.gift { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.gift h1 { margin: 0; font-size: clamp(28px, 7.5vw, 34px); font-variation-settings: 'opsz' 96; }
.envelope { width: min(78vw, 300px); height: auto; display: block; cursor: pointer; overflow: visible; filter: drop-shadow(0 14px 24px rgba(39, 35, 31, 0.16)); }
.env-body { fill: var(--paper-2); stroke: var(--line-strong); stroke-width: 1.5; }
.env-fold { fill: none; stroke: var(--line); stroke-width: 1.5; }
.env-flap { fill: var(--paper-3); stroke: var(--line-strong); stroke-width: 1.5; transform-box: fill-box; transform-origin: 50% 0; transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1); }
.env-address { fill: none; stroke: var(--line-strong); stroke-width: 1.5; stroke-linecap: round; }
.seal { transform-box: fill-box; transform-origin: center; transition: transform 0.45s ease, opacity 0.45s ease; }
.seal circle { fill: var(--ember); }
.seal path { fill: var(--paper); }
.gift.is-open .env-flap { transform: scaleY(-1); }
.gift.is-open .seal { transform: scale(0.2) rotate(30deg); opacity: 0; }
.gift.is-open .envelope { animation: settle 0.9s ease both; }
@keyframes settle {
  0% { transform: none; opacity: 1; }
  60% { transform: translateY(6px); opacity: 1; }
  100% { transform: translateY(24px); opacity: 0; }
}
.opened { display: contents; }
.opened.is-shown > * { animation: rise 0.7s ease both; }
.opened.is-shown > :nth-child(2) { animation-delay: 0.08s; }
.opened.is-shown > :nth-child(3) { animation-delay: 0.16s; }
.opened.is-shown > :nth-child(4) { animation-delay: 0.24s; }
.opened.is-shown > :nth-child(5) { animation-delay: 0.32s; }

/* embers */
.ember {
  position: fixed;
  z-index: 5;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 8px 2px var(--ember-soft), 0 0 2px var(--ember);
  pointer-events: none;
  opacity: 0;
  animation: ember-rise 1.8s ease-out forwards;
}
@keyframes ember-rise {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--sway, 0), calc(-1 * var(--rise, 140px))) scale(0.4); }
}

/* ---------- library ---------- */
[hidden] { display: none !important; }
.library-empty { text-align: center; }
.library-empty .h3 { margin-bottom: 6px; }

/* header pills never break mid-word; the row wraps instead on narrow screens */
.top, .hero-row { flex-wrap: wrap; gap: 8px 12px; }
.wordmark, .navlink, .back { white-space: nowrap; }
.top-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
