/* Julias Adventskalender, mobile first */
:root {
  --table: #1d140d;
  --ui: rgba(255, 246, 232, .82);
  --ui-bg: rgba(255, 246, 232, .09);
  --ui-line: rgba(255, 246, 232, .14);
  --sheet: #201710;
}
body.day {
  --table: #e7e1d6;
  --ui: rgba(40, 36, 30, .78);
  --ui-bg: rgba(40, 36, 30, .07);
  --ui-line: rgba(40, 36, 30, .12);
  --sheet: #f6f2ea;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--table);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body {
  font: 15px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif;
  color: var(--ui);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
#stage {
  position: fixed; inset: 0;
  touch-action: none;
  opacity: 0;
  transition: opacity .9s ease;
}
#stage.ready { opacity: 1; }

/* ---------- Licht: Abend (Kerze) ---------- */
.scene.evening { background: #3a2a1d; }
.scene.evening::before {
  background:
    repeating-linear-gradient(91deg, rgba(255, 214, 170, .045) 0 2px, transparent 2px 9px, rgba(0, 0, 0, .09) 9px 11px, transparent 11px 23px),
    url(../assets/noise/paper-grain.webp);
  background-size: auto, 300px;
  opacity: .7; mix-blend-mode: multiply;
}
.scene.evening::after { background: radial-gradient(130% 110% at 30% 78%, transparent 38%, rgba(8, 4, 2, .58) 100%); }
.candle-warm { position: absolute; inset: 0; z-index: 48; pointer-events: none; background: rgb(255, 200, 146); mix-blend-mode: multiply; opacity: .5; }
.candle {
  position: absolute; inset: -10%; z-index: 49; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(60% 50% at 14% 88%, rgba(255, 160, 70, .12), rgba(255, 140, 60, .04) 45%, transparent 72%);
  will-change: opacity, transform;
}

/* ---------- Pappe in den Umschlag ---------- */
.board-clip { position: absolute; left: 0; top: 0; }
.board-clip .board { transform-origin: 0 0; }
.board-clip.in .board { transition: transform 1.3s cubic-bezier(.3, .7, .2, 1); }

/* ---------- Umschlag ---------- */
.env-part { position: absolute; transition: transform 1.1s cubic-bezier(.5, 0, .3, 1), opacity 1s; }
.env-back { z-index: 1; background: #a98457; border-radius: .9em; box-shadow: 0 1.4em 3.2em rgba(20, 12, 5, .45); }
.env-front {
  z-index: 4; background: #b48c5b; border-radius: .9em;
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 -1em 2em rgba(0, 0, 0, .08);
}
.env-back, .env-front, .env-flap { background-image: url(../assets/noise/paper-grain-light.webp); background-size: 60em; background-blend-mode: multiply; }
.env-front::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(32deg, transparent 49.6%, rgba(0,0,0,.10) 50%, transparent 56%), linear-gradient(-32deg, transparent 49.6%, rgba(0,0,0,.10) 50%, transparent 56%);
}
.airmail {
  position: absolute; inset: 0; padding: 3.4em; border-radius: inherit;
  background: repeating-linear-gradient(135deg, #b5473d 0 6em, transparent 6em 9em, #2e4d78 9em 15em, transparent 15em 18em);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: .85;
}
.env-addr { position: absolute; left: 57%; top: 80%; transform: translate(-50%, -50%) rotate(-3deg); z-index: 2; color: #1f2124; text-align: center; opacity: .88; white-space: nowrap; font-family: "oskar", cursive; line-height: .95; }
.env-addr b { font-weight: 400; font-size: 20em; display: block; }
.env-addr i { font-style: normal; font-size: 6.4em; display: block; margin-top: .7em; }
.airlabel { position: absolute; left: 7%; top: 69%; z-index: 2; background: #2e4d78; color: #f3efe6; padding: .4em .8em; font: 600 4.6em/1 -apple-system, system-ui, sans-serif; letter-spacing: .08em; transform: rotate(-4deg); }
.airlabel small { display: block; font-weight: 400; font-size: .7em; letter-spacing: .1em; margin-top: .3em; }
.env-flap {
  z-index: 6; background-color: #b99260; border-radius: .9em .9em 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0;
  transform: perspective(500em) rotateX(0deg);
  transition: transform .75s cubic-bezier(.5, 0, .3, 1), z-index 0s .37s, opacity 1s;
}
.env-flap.open { transform: perspective(500em) rotateX(180deg); z-index: 2; }
.env-seal { z-index: 7; }
.env-away { transform: translateY(260em) rotate(4deg) !important; opacity: 0; }

/* ---------- UI ---------- */
.hint {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font: 25px/1 "oskar", cursive; font-feature-settings: "calt" 1;
  color: var(--ui); white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .5s;
  z-index: 20;
}
.hint.on { opacity: 1; }
.iconbtn {
  position: fixed; z-index: 30;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--ui-line); background: var(--ui-bg); color: var(--ui);
  display: grid; place-items: center; padding: 0; cursor: pointer;
}
.snd { top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); }
.snd .cross { display: none; }
.snd[aria-pressed="false"] .wave { display: none; }
.snd[aria-pressed="false"] .cross { display: inline; }
.iconbtn:focus-visible, .pill:focus-visible, .seg button:focus-visible { outline: 2px solid var(--ui); outline-offset: 2px; }
.pill {
  font: 500 13px/1 -apple-system, system-ui, sans-serif;
  border-radius: 99px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--ui-line); background: var(--ui-bg); color: var(--ui);
}
.testbtn { position: fixed; z-index: 30; left: calc(10px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); }
.sheet {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
  background: var(--sheet); color: var(--ui);
  border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .35);
  max-width: 560px; margin: 0 auto;
}
.sheet[hidden] { display: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.row { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--ui-line); }
.row > span { font-size: 13px; opacity: .75; }
.row.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--ui-line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 38px; border: 0; background: transparent; color: var(--ui); font: 500 13px/1.1 -apple-system, system-ui, sans-serif; padding: 6px 4px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--ui-line); }
.seg button.on { background: var(--ui); color: var(--sheet); }
.fine { font-size: 12px; opacity: .55; margin: 10px 0 0; }
.fine code { font-size: 11px; }

/* Zahl auf Kraftpapier-Zettel */
.kraft-tag { position: absolute; left: -13em; top: 9em; width: 14.5em; height: 10em; z-index: 4;
  background: var(--kraft-back); transform: rotate(-9deg);
  box-shadow: .06em .1em .15em rgba(0, 0, 0, .35);
  display: flex; align-items: center; padding-left: 1.6em;
  clip-path: polygon(0 3%, 97% 0, 100% 96%, 2% 100%); }
.kraft-tag span { font-family: "oskar", cursive; font-size: 6.6em; line-height: 1; color: #1f2124; transform: rotate(3deg); opacity: .9; }

/* Vertippt? wieder zukleben */
.undo {
  position: fixed; z-index: 30; left: 50%;
  bottom: calc(62px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); opacity: 0;
  transition: opacity .35s, transform .35s;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 16px; font-size: 14px;
  background: rgba(255, 246, 232, .14); border-color: rgba(255, 246, 232, .22);
}
body.day .undo { background: rgba(40, 36, 30, .08); }
.undo.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- PIN-Karte ---------- */
.lock {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(130% 100% at 30% 80%, transparent 40%, rgba(8, 4, 2, .55)),
    repeating-linear-gradient(91deg, rgba(255, 214, 170, .04) 0 2px, transparent 2px 9px, rgba(0, 0, 0, .08) 9px 11px, transparent 11px 23px),
    #33251a;
  opacity: 0; transition: opacity .6s;
}
body.day .lock { background: #e7e1d6; }
.lock.on { opacity: 1; }
.lock.done { opacity: 0; }
.lock-card {
  width: min(320px, 86vw); padding: 26px 24px 22px; text-align: center;
  background: #c19a67 url(../assets/noise/paper-grain-light.webp) 0 0 / 220px;
  background-blend-mode: multiply;
  color: #1f2124;
  transform: rotate(-2.2deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .45);
  clip-path: polygon(0 1%, 99% 0, 100% 98%, 1% 100%);
  transition: transform .6s cubic-bezier(.4, 0, .2, 1);
}
.lock.done .lock-card { transform: translateY(-30px) rotate(-6deg) scale(.96); }
.lock-card.nope { animation: nope .45s ease; }
@keyframes nope { 0%, 100% { transform: rotate(-2.2deg) } 25% { transform: translateX(-8px) rotate(-3deg) } 50% { transform: translateX(7px) rotate(-1.4deg) } 75% { transform: translateX(-3px) rotate(-2.4deg) } }
.lock-title { font: 46px/1 "oskar", cursive; margin-bottom: 14px; opacity: .9; }
.lock-label { display: block; font: 21px/1.2 "oskar", cursive; opacity: .7; margin-bottom: 6px; }
#pin {
  width: 100%; border: 0; border-bottom: 2px solid rgba(31, 33, 36, .55); border-radius: 0;
  background: transparent; color: #1f2124; text-align: center;
  font: 38px/1.2 "oskar", cursive; letter-spacing: .04em; padding: 4px 0 6px;
  outline: none; -webkit-appearance: none; appearance: none; caret-color: #1f2124;
}
#pin::placeholder { color: rgba(31, 33, 36, .28); }
#pin:focus { border-bottom-color: #1f2124; }
.lock-msg { min-height: 26px; margin-top: 10px; font: 21px/1.2 "oskar", cursive; color: #5b1f1f; }

/* ---------- Zahlen wie mit Kugelschreiber ----------
   duenner als der Filzstift-Font (Kontur in Tape-Farbe "radiert" den Rand weg) und mit
   ungleichmaessiger Tintendichte. Wird einmal gerastert, kostet danach nichts. */
body[data-ink="blau"] .tape .t-num span, body[data-ink="schwarz"] .tape .t-num span {
  color: transparent;
  background-image: url(../assets/noise/paper-grain.webp), linear-gradient(var(--ink-c), var(--ink-c));
  background-size: 6em, 100% 100%;
  background-blend-mode: soft-light, normal;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-stroke: .009em rgba(84, 104, 106, .8);
  text-shadow: none;
}
body[data-ink="blau"] { --ink-c: #2340a6; }
body[data-ink="schwarz"] { --ink-c: #121416; }

/* hidden muss immer gewinnen (sonst liegen unsichtbare Ebenen ueber dem Kalender) */
[hidden] { display: none !important; }
