/* Scroll film. Static by default (no JS / reduced motion): illustration, title, sheet in reading order.
   With JS, .is-live pins one stage. Layers come from assets/stories/<id>/scene.json. */

.film { --paper: #f4efe2; --navy: #192d54; --ink: #243c66; --blue: #2f6aa8; position: relative; background: var(--paper); color: var(--navy); }
.film-pin { position: relative; }
.film-art { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: #e8dcc4; }
.film-camera { position: absolute; inset: 0; }
.plate { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.film-title { padding: 1.5rem clamp(1.25rem, 5vw, 4rem) 0; }
.film-kicker { margin: 0; font: 600 0.875rem/1.4 var(--body); letter-spacing: .14em; color: var(--blue); }
.film .film-name { margin: 0; font-family: var(--face); font-weight: var(--weight); font-size: clamp(4.5rem, 17vw, 13rem); line-height: .95; letter-spacing: 0; color: var(--navy); }
.film-name .ch { display: inline-block; }
.film-line { max-width: 34rem; margin: .75rem 0 0; font: 400 1.125rem/1.55 var(--body); color: var(--ink); }
.film-sheet { position: relative; padding: 2.5rem clamp(1.25rem, 5vw, 4rem) 3rem; background: var(--paper); overflow: hidden; }
.sheet-grid { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(52, 86, 132, .2) 1px, transparent 1px), linear-gradient(90deg, rgba(52, 86, 132, .2) 1px, transparent 1px);
  background-size: 2rem 2rem; }
.sheet-sample { position: relative; display: grid; justify-items: center; font-family: var(--face); font-weight: var(--weight); font-size: clamp(3rem, min(22vw, 34svh, calc(150vw / var(--len, 4))), 20rem); line-height: 1.1; }
.sheet-sample > span { grid-area: 1 / 1; white-space: nowrap; }
.s-line { color: transparent; -webkit-text-stroke: 1.5px var(--blue); }
.s-fill { color: var(--navy); }
.sheet-copy { position: relative; max-width: 36rem; margin: 1.25rem auto 0; font: 400 clamp(1.125rem, 1.6vw, 1.375rem)/1.55 var(--body); color: var(--ink); text-wrap: balance; }
.film.can-type .s-line { outline: none; caret-color: var(--navy); cursor: text; min-width: .5em; }
.film.can-type .s-fill { pointer-events: none; }
.film.can-type .s-fill { position: relative; }
.film.can-type .sheet-sample:not(:focus-within) .s-fill::after { content: ""; position: absolute; inset-inline-end: -.12em; top: .18em; width: .05em; height: .72em; background: var(--blue); animation: caret-blink 1.1s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
.film-actions { position: relative; display: flex; justify-content: center; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.film-skip, .film-progress { display: none; }

/* ---------- live film ---------- */
.film.is-live { height: 280svh; }
.film.is-live .film-pin { position: sticky; top: var(--header, 0px); height: calc(100svh - var(--header, 0px)); overflow: hidden; }
.film.is-live .film-art { position: absolute; inset: 0; aspect-ratio: auto; }

/* camera: slow push in while scrolling */
.film.is-live .film-camera { transform: scale(calc(1 + var(--a, 0) * .16)); transform-origin: 62% 55%; will-change: transform; }

/* each plate drifts out along its own direction, by its depth */
.film.is-live .plate {
  translate: calc(var(--ox) * var(--depth) * var(--a, 0) * 30% - var(--mx, 0) * (var(--depth) + .15) * 2.4%) calc(var(--oy) * var(--depth) * var(--a, 0) * 30% - var(--my, 0) * (var(--depth) + .15) * 2.4%);
  scale: calc(1 + var(--depth) * var(--a, 0) * .3);
  opacity: 0;
  transition: opacity .9s ease, transform 1.4s cubic-bezier(.2, .8, .2, 1);
  transition-delay: calc(var(--n) * .14s);
  will-change: translate, scale;
}

/* pop-up-book entrance once the first plate has loaded */
.film.is-live .plate[data-enter="rise"] { transform: translateY(14%); }
.film.is-live .plate[data-enter="from-top"] { transform: translate(-8%, -12%) rotate(-3deg); }
.film.is-live .plate[data-enter="from-bottom"] { transform: translate(-6%, 18%) rotate(4deg); }
.film.is-live .plate[data-enter="fade"] { transform: scale(1.06); }
.film.is-live.is-in .plate { opacity: 1; transform: none; }

/* ambient life after the entrance (rotate/translate properties, so they don't fight the entrance transform) */
.film.is-live.is-in .plate[data-ambient="sway"] { animation: plate-sway 7s ease-in-out 1.6s infinite; }
.film.is-live.is-in .plate[data-ambient="sway-slow"] { animation: plate-sway 9s ease-in-out 2s infinite reverse; }
.film.is-live.is-in .plate[data-ambient="drift"] { animation: plate-drift 14s ease-in-out infinite alternate; }
@keyframes plate-sway { 0%, 100% { rotate: 0deg; } 50% { rotate: -1.4deg; } }
@keyframes plate-drift { from { transform: translateX(0); } to { transform: translateX(-2.5%); } }

/* title sits in a paper band at the bottom of the picture */
.film.is-live .film-title {
  position: absolute; inset: auto 0 0 0; z-index: 1; padding: 7rem clamp(1.25rem, 5vw, 4rem) clamp(1.5rem, 5svh, 3rem);
  background: linear-gradient(to top, var(--paper) 45%, rgba(247, 247, 242, 0));
  opacity: calc(1 - var(--b, 0) * 1.6);
  translate: 0 calc(var(--b, 0) * -6rem);
}
.film.is-live .film-name { font-size: clamp(4.5rem, 15vw, 12rem); }
.film.is-live .film-name .ch { opacity: 0; transform: translateY(.35em); }
.film.is-live.is-in .film-name .ch { animation: letter-rise .9s cubic-bezier(.2, .8, .2, 1) forwards; animation-delay: calc(.5s + var(--i) * .08s); }
@keyframes letter-rise { to { opacity: 1; transform: none; } }
.film.is-live .film-kicker, .film.is-live .film-line { opacity: 0; transition: opacity .8s ease 1.1s; }
.film.is-live.is-in .film-kicker, .film.is-live.is-in .film-line { opacity: 1; }

/* drawing sheet rises over the picture, then the outline fills with ink from right to left */
.film.is-live .film-sheet {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  translate: 0 calc((1 - var(--b, 0)) * 101%);
  box-shadow: 0 -1.5rem 3rem rgba(25, 45, 84, .18);
}
.film.is-live .s-fill { clip-path: inset(0 0 0 calc((1 - clamp(0, var(--b, 0) * 1.6 - .45, 1)) * 100%)); }
.film.is-live .s-line { opacity: clamp(0, var(--b, 0) * 3 - .6, 1); }
.film.is-live .sheet-copy, .film.is-live .film-actions { opacity: clamp(0, var(--b, 0) * 3 - 1.8, 1); }
.film.is-live:not(.is-sheet) .film-actions { visibility: hidden; }

.film.is-live .film-skip {
  display: block; position: absolute; top: 1rem; inset-inline-start: 1rem; z-index: 3;
  padding: .4rem .8rem; border-radius: 999px; background: rgba(247, 247, 242, .9);
  font: 600 0.875rem/1.4 var(--body); color: var(--navy); text-decoration: none;
}
.film.is-live .film-progress { display: block; position: absolute; inset: auto 0 0 0; height: 3px; z-index: 3; background: rgba(25, 45, 84, .12); }
.film.is-live .film-progress i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: #4a86c5; margin-inline-start: auto; }

@media (max-width: 56rem) {
  .film.is-live { height: 240svh; }
  .film.is-live .film-title { padding-top: 5rem; }
  .film-line, .sheet-copy { font-size: 1rem; }
}

.film .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Real-use lines under the type tester */
/* Everyday-use bento */
.bento { --unit: clamp(6.4rem, 9.4vw, 10.5rem); display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--unit); grid-auto-flow: dense; gap: clamp(.6rem, 1vw, 1rem); }
.bento-tile { position: relative; grid-column: span 4; grid-row: span 2; display: flex; flex-direction: column; min-width: 0; padding: clamp(1rem, 1.8vw, 1.8rem); border-radius: 14px; overflow: hidden; background: var(--white, #faf7ef); color: var(--navy, #192d54); border: 1px solid var(--rule, #97a8bd); }
.bento-s1 { grid-column: span 5; grid-row: span 4; }
.bento-s2 { grid-column: span 7; }
.bento-letter { grid-column: span 3; }
.bento-para { grid-column: span 8; }
.bento-wide { grid-column: span 12; grid-row: span 1; }
.bento-stage { flex: 1; min-height: 0; display: grid; align-items: center; padding-inline: 3%; }
.bento-text { white-space: pre-line; margin: 0; min-width: 0; line-height: 1.12; text-wrap: balance; outline: none; cursor: text; font-family: var(--face); font-weight: var(--weight); }
.bento-text[data-tight] { line-height: .95; text-align: center; }
.bento-text:focus-visible, .bento-para p:focus-visible { box-shadow: inset 0 -3px var(--tekhelet, #4a86c5); }
.bento-cap { flex: none; margin-block-start: .7rem; font: 500 .875rem/1.3 var(--body); opacity: .78; }
[data-family="lital"] .bento-text, [data-family="mifras"] .bento-text, [data-family="shoresh"] .bento-text, [data-family="eretz-canaan"] .bento-text, [data-family="achziv"] .bento-text { line-height: 1.35; }
/* Materials */
.bento-sign { background: var(--navy, #192d54); color: var(--paper, #f4efe2); border-color: var(--navy, #192d54); box-shadow: inset 0 0 0 .5rem var(--navy, #192d54), inset 0 0 0 calc(.5rem + 2px) rgba(244, 239, 226, .55); }
.bento-poster { background: var(--tekhelet, #4a86c5); color: var(--white, #faf7ef); border-color: var(--tekhelet, #4a86c5); }
.bento-poster .bento-cap { opacity: 1; }
.bento-label .bento-stage { border: 2px solid currentColor; border-radius: 999px / 46%; padding: 0 9%; text-align: center; outline: 1px solid currentColor; outline-offset: 5px; margin: 6px; }
.bento-screen { background: var(--paper, #f4efe2); }
.bento-screen .bento-stage { background: var(--white, #faf7ef); border: 1px solid var(--rule, #97a8bd); border-radius: 18px 18px 0 0; border-block-end: 0; padding: 0 7%; }
.bento-button { flex: none; display: block; padding: .7rem 1.2rem; background: var(--navy, #192d54); color: var(--white, #faf7ef); border-radius: 0 0 18px 18px; font-size: 1.05rem; text-align: center; }
.bento-headline .bento-stage { border-block: 4px solid currentColor; box-shadow: inset 0 5px 0 -4px currentColor; padding-block: .4rem; }
.bento-book { background: var(--blue, #2f6aa8); color: var(--white, #faf7ef); border-color: var(--blue, #2f6aa8); box-shadow: inset -1.1rem 0 0 rgba(25, 45, 84, .28); padding-inline-start: 2.2rem; }
.bento-book .bento-cap { opacity: 1; }
.bento-ticket { background: var(--paper, #f4efe2); border-style: dashed; border-width: 2px; border-color: var(--navy, #192d54); }
.bento-ticket .bento-stage { border-inline-start: 2px dashed currentColor; padding-inline-start: 6%; }
.bento-note { background: var(--white, #faf7ef); background-image: repeating-linear-gradient(to bottom, transparent 0 2.1rem, rgba(74, 134, 197, .28) 2.1rem calc(2.1rem + 1px)); }
.bento-letter { background: var(--navy, #192d54); color: var(--paper, #f4efe2); border-color: var(--navy, #192d54); }
.bento-digits { background: var(--paper, #f4efe2); }
.bento-digits .bento-text { text-align: center; }
.bento-rows { flex: 1; display: grid; align-content: space-between; min-height: 0; }
.bento-rows p { margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-family: var(--face); font-weight: var(--weight); font-size: clamp(1.9rem, 3.3vw, 3.5rem); line-height: 1.1; border-block-end: 1px solid var(--rule, #97a8bd); padding-block-end: .25rem; white-space: nowrap; overflow: hidden; }
.bento-rows p:last-child { border: 0; }
.bento-rows small { font: 500 .875rem/1 var(--body); opacity: .78; }
.bento-abc .bento-text { text-align: center; }
.bento-para p { flex: 1; margin: 0; font-family: var(--face); font-weight: var(--weight); font-size: clamp(1.2rem, 1.75vw, 1.85rem); line-height: 1.5; columns: 2; column-gap: 2rem; outline: none; overflow: hidden; }
.bento-wait .bento-tile { opacity: 0; transform: translateY(26px); transition: opacity .6s ease var(--delay, 0ms), transform .7s cubic-bezier(.2, .7, .2, 1) var(--delay, 0ms); }
.bento-wait .bento-tile.is-in { opacity: 1; transform: none; }
.bento-section .section-heading p { max-width: 34rem; }
@media (max-width: 900px) {
  .bento { --unit: clamp(5.4rem, 24vw, 8.5rem); grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento-tile, .bento-s2, .bento-para, .bento-wide { grid-column: span 2; }
  .bento-s1 { grid-column: span 2; grid-row: span 3; }
  .bento-letter, .bento-ladder { grid-column: span 1; }
  .bento-ladder.bento-abc { grid-column: span 1; }
  .bento-para { grid-row: auto; }
  .bento-para p { columns: 1; }
  .bento-rows p { font-size: clamp(1.1rem, 5vw, 1.6rem); }
  .bento-rows small { display: none; }
}
