/* ============================================================
   Papier-Engine: Pappe, gefaltete Quadrate, Washi, Leporello
   1em = 1mm innerhalb von .board / .scene (per JS skaliert)
   ============================================================ */
@font-face {
  font-family: "oskar";
  src: url(../assets/fonts/oskar.woff2) format("woff2");
  font-display: block;
}

:root {
  --board: #56655f;
  --board-deep: #3f4c48;
  --paper-back: #f1ece1;
  --kraft-back: #b48c5b;
  --ink: #1f2124;
  --light-x: -0.55;
  --light-y: -0.75;
}

/* ---------- Szene / Tisch ---------- */
.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #e9e4da;
  isolation: isolate;
}
.scene::before {            /* Tischkorn */
  content: "";
  position: absolute; inset: 0;
  background: url(../assets/noise/paper-grain.webp);
  background-size: 300px;
  mix-blend-mode: multiply;
  opacity: .18;
  pointer-events: none;
}
.scene::after {             /* Tageslicht von oben links */
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 18% 8%, rgba(255, 252, 240, .26), transparent 55%),
    radial-gradient(130% 120% at 85% 100%, rgba(60, 45, 30, .16), transparent 60%);
  pointer-events: none;
  z-index: 50;
}
.cam {                      /* "Kamera": wird fuer Zoom/Fit transformiert */
  position: absolute;
  left: 50%; top: 50%;
  transform-origin: 0 0;
}

/* ---------- Pappe ---------- */
.board {
  position: absolute;
  background: var(--board);
  border-radius: .35em;
  box-shadow:
    inset .25em .25em .2em -.1em rgba(255, 255, 255, .03),
    inset -.3em -.3em .3em -.1em rgba(0, 0, 0, .16),
    0 0 0 .08em rgba(20, 30, 28, .35),
    .25em .45em .5em rgba(30, 25, 15, .30),
    1.2em 2.4em 4.5em rgba(40, 30, 18, .28);
}
.board > .grain {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: url(../assets/noise/board-grain.webp);
  background-size: 90em;
  mix-blend-mode: overlay;
  opacity: .26;
  pointer-events: none;
}
.board > .tone {
  position: absolute; inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(90% 70% at 20% 12%, rgba(255, 255, 245, .03), transparent 70%),
    linear-gradient(165deg, rgba(255, 255, 255, 0), rgba(0, 0, 0, .12));
  pointer-events: none;
}
.board.clean { box-shadow: 0 .3em 1em rgba(30, 25, 15, .18); border-radius: 0; }
.board.clean > .grain { opacity: .18; }
.items { position: absolute; inset: 0; }
.board-light {               /* (matt: aus) */
  display: none;
  position: absolute; inset: 0;
  border-radius: .35em;
  pointer-events: none;
  background: radial-gradient(80% 60% at 22% 10%, rgba(255, 250, 235, .10), transparent 70%);
  mix-blend-mode: soft-light;
  z-index: 40;
}

/* ---------- Gefaltetes Quadrat (Leporello-Stapel) ---------- */
.sq {
  position: absolute;
  transform-origin: 50% 50%;
}
.sq .contact {               /* Schatten des Stapels auf der Pappe */
  position: absolute; inset: 0;
  border-radius: .3em;
  box-shadow:
    .12em .18em .15em rgba(0, 0, 0, .45),
    .7em 1.1em 1.6em rgba(0, 0, 0, .30);
  transition: box-shadow .5s;
}
.sq .ly {
  position: absolute; inset: 0;
  background-color: var(--paper-back);
  background-repeat: no-repeat;
  box-shadow: .05em .09em .12em rgba(0, 0, 0, .28), inset 0 0 0 .04em rgba(255, 255, 255, .1);
  transition: transform .6s cubic-bezier(.3, 1.4, .5, 1);
}

.sq .ly.f-l::before, .sq .ly.f-r::before {   /* Falzkante */
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
}
.sq .ly.f-l::before { background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(0,0,0,.18) 3%, rgba(0,0,0,.06) 9%, transparent 18%); border-radius: .5em 0 0 .5em / 50% 0 0 50%; }
.sq .ly.f-r::before { background: linear-gradient(270deg, rgba(0,0,0,.30), rgba(0,0,0,.12) 5%, transparent 16%); border-radius: 0 .5em .5em 0 / 0 50% 50% 0; }
.sq .ly.f-l { border-radius: .55em 0 0 .55em / 30% 0 0 30%; }
.sq .ly.f-r { border-radius: 0 .55em .55em 0 / 0 30% 30% 0; }
.sq .ly.top { box-shadow: .04em .08em .1em rgba(0, 0, 0, .32), inset 0 0 0 .05em rgba(255, 255, 255, .08); }
.sq.open-loose .ly.top { transform: var(--loose) !important; }

/* Goldglanz */
.foil {
  position: absolute; inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: screen;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  background: linear-gradient(var(--glint-a, 115deg),
     transparent calc(var(--glint, 50%) - 22%),
     rgba(255, 236, 180, .0) calc(var(--glint, 50%) - 14%),
     rgba(255, 240, 200, .85) var(--glint, 50%),
     rgba(255, 236, 180, .0) calc(var(--glint, 50%) + 14%),
     transparent calc(var(--glint, 50%) + 22%));
  opacity: var(--glint-o, .55);
}

/* ---------- Washi-Tape ---------- */
.tape {
  position: absolute;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  z-index: 5;
}
.tape .t-shadow {
  position: absolute; inset: 0;
  transform: translate(.09em, .15em);
  opacity: .32;
}
.tape .t-shadow > div { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.tape .t-face {
  position: absolute; top: 0; bottom: 0; left: 0;
  background-image: linear-gradient(180deg, rgba(255,255,255,.015), transparent 18%, transparent 82%, rgba(0,0,0,.08)), url(../assets/tape/washi.webp);
  background-repeat: no-repeat, repeat-x;
}
.tape .bump {
  position: absolute; top: 0; bottom: 0;
  width: 3.2em;
  margin-left: -1.6em;
  z-index: 2;
}
.tape .t-liftshadow {
  position: absolute; top: 0; bottom: 0;
  z-index: 3;
  background: linear-gradient(270deg, rgba(0,0,0,.38), rgba(0,0,0,.14) 35%, transparent);
  opacity: 0;
}
.tape .t-cast {
  position: absolute; top: 0; bottom: 0;
  background: rgba(0, 0, 0, .5);
  border-radius: .2em;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}
.tape .t-lift::before {       /* Biegung faengt Licht */
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 2.2em; z-index: 3;
  background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.02) 40%, transparent);
  pointer-events: none;
}
.tape .t-lift {
  position: absolute; top: 0; bottom: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  display: none;
  z-index: 6;
}
.tape .t-lift .t-face { width: 100%; }
.tape .t-lift .t-white {      /* Klebeseite wird sichtbar */
  position: absolute; inset: 0;
  background: url(../assets/tape/washi-back.webp);
  background-repeat: repeat-x;
  opacity: 0;
}
.tape .t-lift .t-shade { position: absolute; inset: 0; background: #000; opacity: 0; }
.tape .t-tab {
  position: absolute; top: 0; bottom: 0;
  background-image: url(../assets/tape/washi-back.webp);
  background-repeat: repeat-x;
  z-index: 4;
}
.tape .t-tab::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 60%, rgba(0,0,0,.18));
}
.tape .t-num {
  position: absolute;
  z-index: 7;
  font-family: "oskar", cursive;
  color: rgba(250, 248, 240, .93);
  line-height: 1;
  text-shadow: 0 0 .05em rgba(255,255,255,.4);
  pointer-events: none;
  font-feature-settings: "calt" 1;
}
.tape.flying { transition: transform .9s cubic-bezier(.3, .8, .2, 1); }
.tape.grab { cursor: grab; }
.tape.grab:active { cursor: grabbing; }

/* ---------- Leporello-Streifen ---------- */
.strip {
  position: absolute;
  transform-style: preserve-3d;
  transform-origin: 0 50%;
  z-index: 30;
}
.strip .pn {
  position: absolute;
  top: 0;
  transform-style: preserve-3d;
  transform-origin: 0 50%;
}
.strip > .pn { left: 0; }
.strip .pn .pn { left: 100%; }
.strip .face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.strip .face.back { transform: rotateY(180deg); background-repeat: no-repeat; }
.strip .face.front { background-color: var(--paper-back); }
.strip .face .crease {
  position: absolute; inset: 0;
  box-shadow: inset .1em 0 0 rgba(0,0,0,.11), inset -.08em 0 0 rgba(255,255,255,.12);
  background: linear-gradient(90deg, rgba(60,40,20,.10), rgba(60,40,20,.02) 9%, transparent 16%, transparent 86%, rgba(255,255,255,.02) 95%, rgba(60,40,20,.08));
  z-index: 3;
}
.strip .face .shade { position: absolute; inset: 0; background: #1b140c; opacity: 0; z-index: 4; }
.strip .txtwrap { position: absolute; top: 0; height: 100%; display: flex; align-items: center; white-space: nowrap; z-index: 2; }
.strip .txt {
  display: block; white-space: pre; text-align: center; line-height: 1.12 !important;
  font-family: "oskar", cursive;
  color: var(--ink);
  opacity: .88;
  line-height: 1;
  font-feature-settings: "calt" 1, "liga" 1;
  transform: translateY(.06em);
}
.strip-shadow {
  position: absolute;
  background: rgba(0, 0, 0, .5);
  border-radius: 1em;
  filter: blur(2.2em);
  opacity: 0;
  z-index: 29;
  pointer-events: none;
}
.dim {
  position: absolute; inset: 0; border-radius: inherit;
  background: rgba(20, 22, 20, .45);
  opacity: 0;
  transition: opacity .8s;
  pointer-events: none;
  z-index: 25;
}
.dim.on { opacity: 1; }

/* Hand-Notiz mit weissem Gelstift auf der Pappe */
.pen {
  position: absolute;
  font-family: "oskar", cursive;
  color: rgba(248, 246, 238, .9);
  line-height: 1.05;
  white-space: nowrap;
  pointer-events: none;
  font-feature-settings: "calt" 1;
  z-index: 35;
}

@keyframes wiggle {
  0%, 100% { transform: var(--base) }
  20% { transform: var(--base) rotate(-2.5deg) }
  45% { transform: var(--base) rotate(2deg) }
  70% { transform: var(--base) rotate(-1deg) }
}
.sq.wiggle { animation: wiggle .45s ease; }
