/* Kind Notes — "Say it nicely." Keepsake red ground, paper notes, a wax seal.
   Signature motions: the note folds into an envelope and gets a wax seal;
   the jar fills with envelopes; on opening night you crack each seal. */
:root {
  --red: #d70913;
  --red-deep: #8f0c14;
  --red-bright: #e3141d;
  --ink: #071013;
  --ink-soft: #2a1416;
  --cream: #f3ede4;
  --gold: #c9a84c;
  --muted: #7a6f68;
  --p-cream: #fff6ea;
  --p-blush: #ffd9d6;
  --p-butter: #fff0b8;
  --p-sky: #d7e9ff;
  --p-sage: #dcebd5;
  --sans: "Cabin", system-ui, sans-serif;
  --serif: "Mynerve", cursive;
  --mono: "Ubuntu", system-ui, sans-serif;
  --hand: "Mynerve", "Segoe Print", cursive;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* Phones pan sideways if anything pokes out (rotated notes, flying envelopes).
   clip on both html and body stops that without breaking position: sticky. */
html, body { overflow-x: hidden; max-width: 100%; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
body {
  min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(90% 45% at 50% 0%, rgba(215,9,19,.2), transparent 70%) fixed, var(--ink); color: #f0ece6;
  font-family: var(--sans); font-size: 17px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.mono { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; opacity: .8; }
.serif { font-family: var(--serif); font-style: normal; font-weight: 400; }
.hand { font-family: var(--hand); }

/* Paper colours */
[data-paper="cream"]  { --paper: var(--p-cream); }
[data-paper="blush"]  { --paper: var(--p-blush); }
[data-paper="butter"] { --paper: var(--p-butter); }
[data-paper="sky"]    { --paper: var(--p-sky); }
[data-paper="sage"]   { --paper: var(--p-sage); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 26px; border: 0; border-radius: 16px;
  background: var(--red); color: #fff;
  font-weight: 800; font-size: 18px; text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--red-deep);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), opacity .2s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-deep); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--ink { background: var(--ink); color: #fff7f2; box-shadow: 0 4px 0 #000; }
.btn--wide { width: 100%; }
.btn:focus-visible, .chip:focus-visible, .swatch:focus-visible, .linkbtn:focus-visible, .seal-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.linkbtn { min-height: 44px; padding: 0 8px; border: 0; background: none; color: inherit; opacity: .85; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

/* ── Screens ── */
.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; width: 100%; max-width: 560px; margin: 0 auto; position: relative;
  padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.screen--center { justify-content: center; text-align: center; align-items: center; gap: 16px; }
.top { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: -.02em; text-decoration: none; }
.big { margin: 0; font-weight: 800; font-size: clamp(40px, 12.5vw, 64px); line-height: .92; letter-spacing: -.035em; }
.big .serif { letter-spacing: 0; }
.sub { margin: 0; font-size: 18px; opacity: .9; }

/* ── Compose ── */
.compose__head { margin: 18px 0 14px; }
.compose__head .big { font-size: clamp(36px, 11vw, 52px); }
.compose__count { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.18); font-size: 14px; font-weight: 600; }
.compose__count i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: blink 1.8s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }

.note {
  position: relative; background: var(--paper, var(--p-cream)); color: var(--ink-soft);
  border-radius: 6px; padding: 30px 22px 20px;
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 24px 40px -22px rgba(0,0,0,.55);
  transform: rotate(-1.2deg);
  transition: background .35s var(--ease), transform .35s var(--spring);
}
.note.is-flutter { animation: flutter .5s var(--spring); }
@keyframes flutter { 0% { transform: rotate(-1.2deg) scale(1); } 40% { transform: rotate(1.6deg) scale(1.02); } 100% { transform: rotate(-1.2deg) scale(1); } }
.note::before { /* washi tape */
  content: ""; position: absolute; top: -12px; left: 50%; width: 92px; height: 24px; margin-left: -46px;
  background: rgba(201,168,76,.78); transform: rotate(-3deg); clip-path: polygon(3% 0, 97% 4%, 100% 100%, 0 96%);
}
.note__to { margin: 0 0 4px; font-family: var(--mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.note textarea {
  display: block; width: 100%; min-height: 204px; resize: none; border: 0; outline: 0; background: transparent;
  font-family: var(--hand); font-size: 23px; line-height: 34px; color: var(--ink-soft); padding: 0;
  /* ruled lines under each line of handwriting */
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(42,20,22,.12) 31px 32px, transparent 32px 34px);
  background-attachment: local;
}
.note textarea::placeholder { color: rgba(42,20,22,.38); }
.note__foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; font-size: 14px; color: var(--muted); }
.note__sign { font-family: var(--hand); font-size: 20px; color: var(--ink-soft); }
.note__left { font-family: var(--mono); font-size: 11px; }
.note__left.is-low { color: var(--red); }

.tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 22px 0 0; }
.tools > div { min-width: 0; }
.tools__label { margin: 0 0 8px; font-weight: 700; font-size: 15px; }
.swatches { display: flex; gap: 10px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; background: var(--paper); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: transform .2s var(--spring); }
.swatch[aria-checked="true"] { border-color: #fff7f2; transform: scale(1.1); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 2px 20px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border: 1.5px solid rgba(255,247,242,.5); border-radius: 999px; background: transparent; font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip[aria-checked="true"], .chip:active { background: #fff7f2; color: var(--red-deep); border-color: #fff7f2; }
.sign-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sign-row input { flex: 1 1 0; width: 0; min-width: 150px; min-height: 44px; padding: 0 14px; border: 1.5px solid rgba(255,247,242,.5); border-radius: 12px; background: rgba(0,0,0,.14); font-size: 16px; }
.sign-row input::placeholder { color: rgba(255,247,242,.6); }

.actionbar { position: sticky; bottom: 0; z-index: 4; margin: 22px -20px 0; padding: 14px 20px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(7,16,19,0), var(--ink) 30%); }
.err { min-height: 1.3em; margin: 0 0 8px; font-weight: 700; color: #fff; text-align: center; }
.fine { margin: 10px 0 0; text-align: center; font-size: 13px; opacity: .8; }

/* ── Envelope ── */
.stage { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: none; perspective: 1200px; }
.env { position: relative; width: min(300px, 80vw); aspect-ratio: 1.5; }
.env__back, .env__front, .env__flap { position: absolute; inset: 0; border-radius: 10px; }
.env__back { background: color-mix(in srgb, var(--paper) 78%, #8a6a5a); }
.env__letter { position: absolute; left: 7%; right: 7%; top: 8%; height: 84%; background: var(--paper); border-radius: 4px; padding: 14px; overflow: hidden; font-family: var(--hand); font-size: 13px; line-height: 1.3; color: var(--ink-soft); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.env__front { background: var(--paper); clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%); box-shadow: inset 0 -30px 40px -30px rgba(0,0,0,.18); }
.env__front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(0,0,0,.06), transparent 40%, transparent 60%, rgba(0,0,0,.06)); clip-path: inherit; }
.env__flap { height: 60%; background: color-mix(in srgb, var(--paper) 90%, #8a6a5a); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top center; transform: rotateX(180deg); backface-visibility: visible; z-index: 2; filter: drop-shadow(0 2px 2px rgba(0,0,0,.12)); }
.env.is-closed .env__flap { transform: rotateX(0deg); }

/* Wax seal: an uneven red blob with a pressed K */
.seal {
  position: absolute; z-index: 3; left: 50%; top: 60%; width: 74px; height: 74px; margin: -37px 0 0 -37px;
  border-radius: 47% 53% 49% 51% / 52% 46% 54% 48%;
  background: radial-gradient(circle at 35% 30%, #ef4a4f 0, var(--red) 38%, var(--red-deep) 80%);
  box-shadow: 0 3px 0 #6d0910, 0 10px 18px -6px rgba(0,0,0,.5), inset 0 -4px 8px rgba(0,0,0,.25), inset 0 3px 6px rgba(255,255,255,.18);
  display: grid; place-items: center;
}
.seal::before { /* the pressed ring */
  content: ""; position: absolute; inset: 11px; border-radius: 50%;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.18);
}
.seal b { position: relative; font-family: var(--serif); font-style: normal; font-weight: 400; font-size: 34px; line-height: 1; color: var(--red-deep); text-shadow: 0 1px 0 rgba(255,255,255,.22), 0 -1px 0 rgba(0,0,0,.35); }
/* the two halves after cracking: full seals, each clipped to one side */
.seal__half--l { clip-path: polygon(0 0, 54% 0, 44% 38%, 58% 62%, 46% 100%, 0 100%); }
.seal__half--r { clip-path: polygon(54% 0, 100% 0, 100% 100%, 46% 100%, 58% 62%, 44% 38%); }

/* little hearts left behind as the envelope flies */
.puff { position: fixed; z-index: 21; pointer-events: none; font-size: 22px; color: #fff7f2; }

/* ── Sent ── */
.sent__env { position: relative; width: 120px; aspect-ratio: 1.5; margin: 0 auto 8px; animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(2deg); } }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 360px; }
.countdown div { padding: 12px 4px; border-radius: 14px; background: rgba(0,0,0,.18); text-align: center; }
.countdown b { display: block; font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.countdown small { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.stack { display: grid; gap: 10px; width: 100%; max-width: 380px; }

/* ── Jar (owner, sealed) ── */
.jar-wrap { position: relative; width: min(280px, 72vw); margin: 14px auto 0; }
.jar { position: relative; height: clamp(170px, 30dvh, 330px); border-radius: 34px 34px 46px 46px; background: linear-gradient(100deg, rgba(255,255,255,.22), rgba(255,255,255,.06) 30%, rgba(255,255,255,.03) 70%, rgba(255,255,255,.16)); box-shadow: inset 0 0 0 3px rgba(255,247,242,.42), inset 0 -18px 30px rgba(0,0,0,.12); overflow: hidden; }
.jar::after { /* glass glint */ content: ""; position: absolute; top: 16px; left: 18px; width: 14px; height: 46%; border-radius: 10px; background: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0)); }
.jar__lid { position: relative; z-index: 2; height: 34px; margin: 0 14px -8px; border-radius: 10px 10px 6px 6px; background: var(--ink); box-shadow: inset 0 -6px 0 rgba(255,255,255,.08); display: grid; place-items: center; font-family: var(--mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.jar__env { position: absolute; width: 27%; aspect-ratio: 1.5; border-radius: 4px; background: var(--paper); box-shadow: 0 2px 3px rgba(0,0,0,.18); }
.jar__env::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: color-mix(in srgb, var(--paper) 85%, #8a6a5a); clip-path: polygon(0 0, 100% 0, 50% 58%); }
.jar__env::after { content: ""; position: absolute; left: 50%; top: 58%; width: 26%; aspect-ratio: 1; margin: -13% 0 0 -13%; border-radius: 50%; background: var(--red); box-shadow: inset 0 -1px 2px rgba(0,0,0,.3); }
.jar__more { position: absolute; z-index: 3; right: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; background: var(--ink); font-family: var(--mono); font-size: 11px; }
.jar__empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; font-family: var(--serif); font-style: normal; font-size: 22px; opacity: .8; }
.jar-count { margin: 10px 0 0; text-align: center; }
.jar-count b { font-size: 48px; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.share { display: grid; gap: 10px; margin-top: 16px; }
.countdown--sm div { padding: 8px 4px; border-radius: 12px; }
.countdown--sm b { font-size: 22px; }
.owner-foot summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; list-style: none; }
.owner-foot summary::-webkit-details-marker { display: none; }
.owner-foot summary::after { content: "+"; margin-left: auto; font-size: 22px; }
.owner-foot details[open] summary::after { content: "–"; }
.owner-foot details > div { display: grid; gap: 10px; padding-bottom: 6px; }
.share__link { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 14px; background: rgba(0,0,0,.18); }
.share__link input { flex: 1; min-width: 0; border: 0; background: transparent; font-family: var(--mono); font-size: 14px; outline: 0; }
.share__link button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: #fff7f2; color: var(--red-deep); font-weight: 800; cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .btn { padding: 0 12px; font-size: 16px; }
.owner-foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid rgba(255,247,242,.25); display: grid; gap: 10px; }
.owner-foot label { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
.owner-foot input { min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1.5px solid rgba(255,247,242,.5); background: rgba(0,0,0,.14); font-size: 16px; color-scheme: dark; }

/* ── Opening night ── */
.open { position: fixed; inset: 0; z-index: 10; background: radial-gradient(120% 80% at 50% 30%, #d41a24, var(--red-deep)); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); overflow: hidden; touch-action: pan-y; }
.open__top { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: center; z-index: 5; }
.open__env { position: relative; perspective: 1200px; }
.seal-btn { position: absolute; z-index: 4; left: 50%; top: 60%; width: 96px; height: 96px; margin: -48px 0 0 -48px; border: 0; padding: 0; background: transparent; border-radius: 50%; cursor: pointer; }
.seal-btn .seal { left: 50%; top: 50%; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.hint { margin: 26px 0 0; font-family: var(--serif); font-style: normal; font-size: 22px; opacity: .9; text-align: center; }
.reveal { position: relative; width: min(360px, 88vw); }
.reveal .note { transform: rotate(-1.5deg); padding: 34px 24px 22px; }
.reveal__text { margin: 0; font-family: var(--hand); font-size: clamp(22px, 6.6vw, 28px); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.reveal__from { margin: 18px 0 0; text-align: right; font-family: var(--hand); font-size: 20px; color: var(--muted); }
.reveal__actions { display: flex; justify-content: center; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: rgba(0,0,0,.22); color: #fff7f2; font-weight: 700; font-size: 14px; cursor: pointer; }

/* Petals */
.petal { position: absolute; top: -30px; z-index: 1; width: 14px; height: 18px; border-radius: 80% 10% 80% 10%; background: linear-gradient(135deg, #ff6b74, #b80f19); opacity: .9; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx, 40px), 110vh) rotate(var(--rot, 540deg)); } }

/* ── All notes ── */
.wall { columns: 2 150px; column-gap: 12px; margin-top: 18px; }
.wall .note { break-inside: avoid; margin: 0 0 14px; padding: 22px 14px 12px; transform: rotate(var(--r, -1deg)); }
.wall .note::before { width: 54px; height: 16px; margin-left: -27px; top: -8px; }
.wall p { margin: 0; font-family: var(--hand); font-size: 18px; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.wall .from { margin-top: 8px; font-size: 15px; color: var(--muted); text-align: right; }
.wall .tools-row { display: flex; justify-content: space-between; margin-top: 8px; }
.wall .tools-row button { min-height: 36px; padding: 0 8px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Off-screen card for "Save" images (9:16) */
.shot { position: fixed; left: -10000px; top: 0; width: 450px; height: 800px; overflow: hidden; background: radial-gradient(80% 50% at 50% 0%, #3a0609, #071013 70%); color: #fff7f2; display: flex; flex-direction: column; padding: 56px 34px 40px; }
.shot .note { margin-top: auto; margin-bottom: auto; transform: rotate(-2deg); padding: 40px 28px 26px; }
.shot .note p { margin: 0; font-family: var(--hand); font-size: 28px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-soft); }
.shot .shot__from { margin-top: 18px !important; text-align: right; font-size: 22px !important; color: var(--muted) !important; }
.shot__foot { display: flex; justify-content: space-between; align-items: flex-end; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.shot__foot b { font-family: var(--sans); font-size: 18px; letter-spacing: 0; text-transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .petal { display: none; }
}
