/* letter screen (source/build_letter.py): the paper, then the envelope, then the jar (owner, 6 Oct 2026) */

/* the ruled letter paper with its pink margin line; the textarea carries its own lines so they scroll with the text */
.lt-paper {
  position: absolute; top: 60px; bottom: 21px; padding: 12px 18px 10px 22px; display: flex; flex-direction: column;
  background-color: #FFFDF7; background-image: repeating-linear-gradient(to bottom, transparent 0px, transparent 23px, #EADFCB 23px, #EADFCB 24px), var(--pp, none); background-size: auto, var(--pps, auto);
  background-position: 0 44px; border: 2px solid var(--ink); border-radius: 6px; box-shadow: var(--edge);
}
.lt-margin { position: absolute; top: 0; bottom: 0; left: 12px; border-left: 1.5px solid #F2B8B5; }
.lt-dear { font-size: 17px; font-weight: 800; line-height: 24px; height: 32px; flex: none; }
.lt-paper textarea {
  flex: 1; min-height: 0; resize: none; border: none; outline: none; padding: 0; margin: 0; font-size: 14px; font-weight: 700; line-height: 24px; color: var(--ink);
  background-color: #FFFDF7; background-image: repeating-linear-gradient(to bottom, transparent 0px, transparent 23px, #EADFCB 23px, #EADFCB 24px), var(--pp, none); background-size: auto, var(--pps, auto);
  background-attachment: local; scrollbar-width: none; position: relative; z-index: 1;
}
/* (its pattern lines up with the paper's round it: the textarea starts 22px in from the paper's edge) */
.lt-paper textarea { background-position: 0 0, -22px 0; }
.lt-paper textarea::-webkit-scrollbar { display: none; }
.lt-paper textarea::placeholder { color: #9C8F80; }
.lt-paper textarea:focus-visible { box-shadow: none !important; }
.lt-love { flex: none; text-align: right; font-size: 15px; font-weight: 800; line-height: 24px; padding-right: 60px; }
.lt-flower { position: absolute; right: 12px; bottom: 34px; opacity: 0.9; z-index: 2; pointer-events: none; }

/* the side card: what each step needs, and its one button at the bottom */
.lt-side { position: absolute; left: 540px; right: 16px; top: 60px; bottom: 21px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; z-index: 4; }
/* the paper, from level 8: plain and three patterns, each swatch its own paper (screens.css [data-paper]) */
.lt-papers { margin-top: 4px; display: flex; flex-direction: column; gap: 4px; }
.lt-pps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lt-pp { height: 44px; padding: 0; border-radius: 8px; border: 1.5px solid var(--ink); }
.lt-pp.on { box-shadow: 0 0 0 3px var(--honey); border-width: 2px; }
.lt-quiet { align-items: center; justify-content: center; text-align: center; }

/* write: when each of you last wrote to the other (owner, 6 Oct 2026) */
.lt-lasts { display: flex; flex-direction: column; margin-top: 4px; }
.lt-last { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: #FFF6D9; border: 1.5px solid var(--ink); }
.lt-path + .lt-last { background: #F3EEF9; }
.lt-last .tx { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.lt-last b { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-last small { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-path { position: relative; height: 34px; display: flex; align-items: center; justify-content: center; color: var(--label); }
.lt-path::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 2px dashed #D8CDBB; }
.lt-path svg { position: relative; padding: 3px; background: var(--card); box-sizing: content-box; }

/* when it opens */
.lt-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lt-opt {
  height: 38px; padding: 0 6px; border-radius: 10px; border: 2px solid var(--ink); background: #FFFFFF; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; min-width: 0;
}
.lt-opt b { font-size: 12px; font-weight: 800; white-space: nowrap; }
.lt-opt small { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lt-opt.on { background: var(--honey); box-shadow: 0 2px 0 var(--ink); }
.lt-opt.on small { color: #4A423B; }
.lt-opt[aria-disabled="true"] { background: var(--disabled); border-color: #C9BBA6; color: #A89A88; cursor: default; }
.lt-opt[aria-disabled="true"] small { color: #A89A88; }
/* "Pick a date & time": a small chip beside the label, and the two pickers it opens */
.lt-exact { height: 30px; padding: 0 8px; border-radius: 11px; border: 1.5px solid var(--ink); background: #FFFFFF; color: var(--ink); font-size: 11px; font-weight: 800; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.lt-exact.on { background: var(--honey); box-shadow: 0 2px 0 var(--ink); }
.lt-pick { position: relative; font: inherit; color: var(--ink); height: 32px; padding: 0 8px; border-radius: 9px; border: 1.5px solid var(--ink); background: #FFFFFF; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.lt-opens { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; line-height: 1.15; }
.lt-date { font-size: 16px; font-weight: 800; }

/* the envelope: wax, stickers, a drawing (owner, 6 Oct 2026) */
.lt-waxes { gap: 6px; }
.lt-wax { width: 32px; height: 32px; padding: 0; border-radius: 17px; display: flex; align-items: center; justify-content: center; background: #FFFFFF; border: 2px solid transparent; }
.lt-wax.on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--honey); }
.lt-wax i { display: block; width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--ink); }
/* any colour: the rainbow, with a + until one is picked (owner, 8 Oct 2026) */
.lt-anywax { position: relative; }
.lt-anywax b { position: absolute; left: 50%; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; border-radius: 8px; background: #FFFFFF; border: 1.5px solid var(--ink); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.lt-anywax b[hidden] { display: none; }
.lt-tools { padding: 2px; box-shadow: none; }
.lt-tools > button { height: 26px; padding: 0 10px; font-size: 12px; color: var(--ink); }
.lt-tray { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.lt-stk { height: 40px; padding: 0; border-radius: 10px; border: 1.5px solid #D8CDBB; background: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.lt-stk[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.lt-inks { display: flex; flex-wrap: wrap; gap: 6px; }
.lt-ink { width: 34px; height: 34px; padding: 0; border-radius: 17px; border: 2px solid transparent; background: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.lt-ink.on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--honey); }
.lt-ink i { display: block; width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--ink); }
.lt-hint { font-size: 12px; font-weight: 700; line-height: 1.3; color: var(--muted); }
.lt-mini {
  height: 30px; padding: 0 10px; border-radius: 15px; border: 1.5px solid var(--ink); background: #FFFFFF; color: var(--ink);
  font-size: 12px; font-weight: 800; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px;
}
.lt-mini[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.lt-unfold { position: absolute; left: 48px; bottom: 21px; height: 34px; padding: 0 12px; font-size: 13px; box-shadow: 0 2px 0 var(--ink); }

/* the envelope itself, in the middle of the left side; a finger draws on it or moves its stickers */
.lt-env { position: absolute; left: 107px; top: 64px; width: 360px; height: 257px; z-index: 2; touch-action: none; transition: transform .45s cubic-bezier(.3, .8, .3, 1); }
.lt-env > svg { display: block; filter: drop-shadow(0 3px 0 rgba(43, 38, 34, 0.16)); }
.lt-env.tool-draw { cursor: crosshair; }
.lt-env.tool-stickers [data-st] { cursor: grab; }
/* the wax drops onto the flap, squashes, and the heart is pressed into it */
.lt-env.sealing .env-wax { transform-box: fill-box; transform-origin: center; animation: ltWax .8s cubic-bezier(.3, .7, .4, 1) both; }
.lt-env.sealing .env-heart { animation: ltPress .9s both; }
@keyframes ltWax { 0% { opacity: 0; transform: translateY(-26px) scale(.45); } 45% { opacity: 1; transform: none; } 58% { transform: scale(1.32, .72); } 74% { transform: scale(.92, 1.08); } 100% { opacity: 1; transform: none; } }
@keyframes ltPress { 0%, 62% { opacity: 0; } 80%, 100% { opacity: 1; } }
/* Edit the envelope: the wax lifts off and the envelope comes back down, while the jar drops away (owner, 7 Oct 2026) */
.lt-env.unsealing { animation: ltUnfloat .5s cubic-bezier(.3, .8, .3, 1) both; }
.lt-env.unsealing .env-wax { transform-box: fill-box; transform-origin: center; animation: ltUnwax .5s .12s ease-in both; }
@keyframes ltUnfloat { from { transform: translateY(-34px) scale(.7); } to { transform: none; } }
@keyframes ltUnwax { 0% { opacity: 1; transform: none; } 30% { opacity: 1; transform: scale(1.12, .9); } 100% { opacity: 0; transform: translateY(-24px) scale(.5); } }
.lt-jar.leaving { animation: ltJarOut .4s ease-in both; }
@keyframes ltJarOut { from { transform: translateY(64px); } to { transform: translateY(190px); } }
/* choosing the day: it floats up, over the jar waiting below; then it falls in */
.lt-env.when { transform: translateY(-34px) scale(.7); }
.lt-env.falling { animation: ltFall 1.15s both; }
@keyframes ltFall {
  0% { transform: translateY(-34px) scale(.7); }
  34% { transform: translateY(12px) scale(.24) rotate(-6deg); }
  44% { transform: translateY(16px) scale(.24) rotate(3deg); animation-timing-function: cubic-bezier(.5, 0, .95, .5); }
  82% { transform: translateY(162px) scale(.24) rotate(12deg); animation-timing-function: ease-out; }
  90% { transform: translateY(155px) scale(.24) rotate(9deg); }
  100% { transform: translateY(161px) scale(.24) rotate(10deg); }
}
.lt-jar { position: absolute; left: 212px; top: 236px; width: 150px; height: 170px; pointer-events: none; transform-origin: 50% 100%; transition: transform .4s cubic-bezier(.3, .8, .3, 1); }
.lt-jar svg { display: block; overflow: visible; }
.lt-jar.back { z-index: 1; }
.lt-jar.front { z-index: 3; }
.lt-jar.waiting { transform: translateY(64px); animation: ltJarIn .5s .15s both; }
.lt-jar.catching { transform: none; animation: ltJarBump .45s .94s forwards; }
@keyframes ltJarIn { from { transform: translateY(170px); } to { transform: translateY(64px); } }
@keyframes ltJarBump { 0% { transform: none; } 30% { transform: translateY(3px) rotate(-2deg); } 60% { transform: rotate(1.5deg); } 100% { transform: none; } }

/* folding: in half, in half again, into the envelope (2.1 s; one shared timeline, so the parts hand over exactly) */
.lt-fold { position: absolute; inset: 0; z-index: 3; pointer-events: none; perspective: 1400px; }
.lt-fold > * { position: absolute; }
.lt-fold svg { display: block; overflow: visible; }
.lf-lines { background-color: #FFFDF7; background-image: repeating-linear-gradient(to bottom, transparent 0px, transparent 23px, #EADFCB 23px, #EADFCB 24px), var(--pp, none); background-size: auto, var(--pps, auto); background-position: 0 44px; overflow: hidden; }
.lf-lines::after { content: ""; position: absolute; left: 24px; right: 22px; top: 58px; height: 190px; background: repeating-linear-gradient(to bottom, rgba(120, 105, 90, 0.3) 0px, rgba(120, 105, 90, 0.3) 3px, transparent 3px, transparent 24px); }
.lf-dear { position: absolute; left: 22px; top: 12px; font-size: 17px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.lf-a { left: 48px; top: 60px; width: 478px; height: 309px; perspective: 1400px; z-index: 5; animation: lfA 2.1s linear both; }
/* each fold turns a half over its crease: one piece for the first quarter turn (its face), another for the second (its
   back), so nothing depends on hiding the back of a turned element. A crease is outlined from the moment it starts to
   turn, and a folded-over half has its crease edge outlined too, so the paper never loses its border (owner, 7 Oct 2026) */
.lf-r, .lf-l1, .lf-l2 { position: absolute; top: 0; width: 239px; height: 309px; }
.lf-r { left: 239px; border: 2px solid var(--ink); border-radius: 0 6px 6px 0; animation: lfCrease1 2.1s linear both; }
.lf-l1, .lf-l2 { left: 0; transform-origin: 100% 50%; }
.lf-l1 { border: 2px solid var(--ink); border-right: none; border-radius: 6px 0 0 6px; animation: lfL1 2.1s both; }
.lf-l1::before { content: ""; position: absolute; top: 0; bottom: 0; left: 12px; border-left: 1.5px solid #F2B8B5; }
.lf-l2 { background: #F4EBDC; border: 2px solid var(--ink); border-radius: 6px 0 0 6px; animation: lfL2 2.1s both; }
.lf-bf { left: 287px; top: 60px; width: 239px; height: 309px; perspective: 1400px; z-index: 5; animation: lfBf 2.1s linear both; }
.lf-t, .lf-d1, .lf-d2 { position: absolute; left: 0; width: 239px; height: 154.5px; }
.lf-t { top: 0; background: #F4EBDC; border: 2px solid var(--ink); border-radius: 0 6px 0 0; animation: lfCrease2 2.1s linear both; }
.lf-d1, .lf-d2 { top: 154.5px; transform-origin: 50% 0; }
.lf-d1 { background: #F4EBDC; border: 2px solid var(--ink); border-top: none; border-radius: 0 0 6px 0; animation: lfD1 2.1s both; }
.lf-d2 { border: 2px solid var(--ink); border-radius: 0 0 6px 0; animation: lfD2 2.1s both; }
.lf-c {
  left: 191px; top: 140px; width: 192px; height: 124px; transform-origin: 0 0; border: 2px solid var(--ink); border-radius: 4px;
  background-color: #FFFDF7; background-image: repeating-linear-gradient(to bottom, transparent 0px, transparent 19px, #EADFCB 19px, #EADFCB 20px);
  animation: lfC 2.1s both;
}
.lf-bk { z-index: 1; animation: lfEnv 2.1s both; }
.lf-fr { z-index: 4; animation: lfEnv 2.1s both; }
/* the flap turns on the envelope's top edge (y 10 of 60); open (.o) and shut (.c) trade places edge-on, at 90% */
.lf-flap { z-index: 2; transform-origin: 50% 42.83px; animation: lfFlap 2.1s both; }
.lf-flap .o { animation: lfFlapO 2.1s linear both; }
.lf-flap .c { animation: lfFlapC 2.1s linear both; }
@keyframes lfFlapO { 0%, 90% { opacity: 1; } 90.1%, 100% { opacity: 0; } }
@keyframes lfFlapC { 0%, 90% { opacity: 0; } 90.1%, 100% { opacity: 1; } }
/* the closed envelope as the next step draws it (its stickers and drawing, if any), there as the flap shuts */
.lf-done { z-index: 7; animation: lfDone 2.1s linear both; }
.lf-done > svg { display: block; filter: drop-shadow(0 3px 0 rgba(43, 38, 34, 0.16)); }
@keyframes lfDone { 0%, 96.5% { opacity: 0; } 100% { opacity: 1; } }
/* the first crease is drawn as soon as the left half starts to turn; the second, as the bottom half does */
@keyframes lfCrease1 { 0% { border-left-color: transparent; } 1.5%, 100% { border-left-color: var(--ink); } }
@keyframes lfCrease2 { 0%, 28% { border-bottom: 1px dashed rgba(43, 38, 34, 0.3); } 28.5%, 100% { border-bottom: 2px solid var(--ink); } }
/* Edit the letter: the whole fold, backwards (the same timeline, so every part still hands over exactly) */
.lt-fold.back * { animation-direction: reverse !important; }
@keyframes lfA { 0%, 26% { opacity: 1; } 26.3%, 100% { opacity: 0; } }
@keyframes lfL1 { 0% { transform: rotateY(0deg); opacity: 1; animation-timing-function: ease-in; } 13% { transform: rotateY(90deg); opacity: 1; } 13.1%, 100% { transform: rotateY(90deg); opacity: 0; } }
@keyframes lfL2 { 0%, 13% { transform: rotateY(90deg); opacity: 0; } 13.1% { transform: rotateY(90deg); opacity: 1; animation-timing-function: ease-out; } 26%, 100% { transform: rotateY(180deg); opacity: 1; } }
@keyframes lfBf { 0%, 26% { opacity: 0; } 26.3%, 50% { opacity: 1; } 50.3%, 100% { opacity: 0; } }
@keyframes lfD1 { 0%, 28% { transform: rotateX(0deg); opacity: 1; animation-timing-function: ease-in; } 39% { transform: rotateX(90deg); opacity: 1; } 39.1%, 100% { transform: rotateX(90deg); opacity: 0; } }
@keyframes lfD2 { 0%, 39% { transform: rotateX(90deg); opacity: 0; } 39.1% { transform: rotateX(90deg); opacity: 1; animation-timing-function: ease-out; } 50%, 100% { transform: rotateX(180deg); opacity: 1; } }
@keyframes lfC {
  0%, 50% { opacity: 0; transform: translate(96px, -80px) scale(1.245); z-index: 5; }
  50.3% { opacity: 1; transform: translate(96px, -80px) scale(1.245); z-index: 5; }
  66.5% { opacity: 1; transform: translate(0, -110px); z-index: 5; }
  66.7% { opacity: 1; transform: translate(0, -110px); z-index: 3; }
  83%, 100% { opacity: 1; transform: none; z-index: 3; }
}
@keyframes lfEnv { 0%, 48% { opacity: 0; transform: translateY(26px); } 64%, 100% { opacity: 1; transform: none; } }
@keyframes lfFlap {
  0%, 48% { opacity: 0; transform: translateY(26px) rotateX(180deg); z-index: 2; }
  64% { opacity: 1; transform: rotateX(180deg); z-index: 2; }
  83% { opacity: 1; transform: rotateX(180deg); z-index: 6; animation-timing-function: ease-in; }
  90% { opacity: 1; transform: rotateX(90deg); z-index: 6; animation-timing-function: ease-out; }
  97%, 100% { opacity: 1; transform: rotateX(0deg); z-index: 6; }
}
@media (prefers-reduced-motion: reduce) {
  .lt-fold *, .lt-env, .lt-env *, .lt-jar { animation-duration: .01s !important; animation-delay: 0s !important; transition: none !important; }
}

/* the jar chip in the header */
.lt-jarchip {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; background: var(--card); border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink); border-radius: 18px; font-size: 13px; font-weight: 800; color: var(--ink); white-space: nowrap;
}

/* sealed */
.lt-done { position: absolute; left: 48px; right: 16px; top: 60px; bottom: 21px; display: flex; align-items: center; gap: 36px; padding: 0 44px; }
.lt-paid { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
/* before level 8: the envelope has only its wax; a quiet line says what comes later (owner, 9 Oct 2026) */
.lt-locked { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
