/* The story box (templates/_storybox.html, storybox.js): the day's film and read-along as an open picture book on
   the page, and the dialog each one opens in. Site tokens from /assets/css/site.css (ink, sheet, crayon colours,
   Fredoka and Nunito, the 3px stroke). */
.sbox { margin: 1.25rem 0 2rem; --cover: var(--blue, #3a86ff); --edge: #e7e1d4; }
.sbox__title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.35rem, 2.6vw, 1.75rem); line-height: 1.15;
  margin: 0 0 0.75rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; text-wrap: balance; }
.sbox__kicker { display: inline-block; font-family: var(--font-text); font-weight: 800; font-size: 0.8rem; letter-spacing: 0.06em;
  text-transform: uppercase; line-height: 1; padding: 0.4em 0.7em; border: 2px solid var(--ink); border-radius: 999px; background: var(--yellow); }

/* the book: a crayon-blue hardback with white pages, a spine down the middle and the page edges showing underneath */
.sbox__book { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); padding: 12px 12px 18px;
  background: var(--cover) url("/assets/img/crayon-grain.png"); border: var(--stroke, 3px) solid var(--ink); border-radius: 18px; }
.sbox__book--two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sbox__page { position: relative; background: var(--sheet, #fff); min-width: 0;
  box-shadow: 0 3px 0 var(--edge), 0 6px 0 #d8d0bf; }   /* taste-skill-ignore: the stacked page edges, not a shadow */
.sbox__page--film { border-radius: 8px 3px 3px 8px; }
.sbox__page--read { border-radius: 3px 8px 8px 3px; }
.sbox__book:not(.sbox__book--two) .sbox__page { border-radius: 8px; }
/* the spine: the pages curve into the gutter, with an ink stitch line between them */
.sbox__book--two .sbox__page--film { background-image: linear-gradient(to left, rgba(26, 26, 26, 0.13), rgba(26, 26, 26, 0) 34px); }
.sbox__book--two .sbox__page--read { background-image: linear-gradient(to right, rgba(26, 26, 26, 0.13), rgba(26, 26, 26, 0) 34px); }
.sbox__book--two::after { content: ""; position: absolute; top: 8px; bottom: 10px; left: 50%; width: 3px; margin-left: -1.5px;
  background: repeating-linear-gradient(to bottom, var(--ink) 0 9px, transparent 9px 15px); border-radius: 2px; pointer-events: none; }
/* a folded page corner at each outer bottom corner */
.sbox__page::after { content: ""; position: absolute; bottom: 0; width: 30px; height: 30px; pointer-events: none; }
.sbox__page--film::after { left: 0; border-bottom-left-radius: 8px;
  background: linear-gradient(45deg, var(--cover) 0 50%, var(--ink) 50% calc(50% + 2.5px), var(--edge) calc(50% + 2.5px)); }
.sbox__page--read::after, .sbox__book:not(.sbox__book--two) .sbox__page--film::after { left: auto; right: 0; border-radius: 0 0 8px 0;
  background: linear-gradient(-45deg, var(--cover) 0 50%, var(--ink) 50% calc(50% + 2.5px), var(--edge) calc(50% + 2.5px)); }

/* each page is one big button: the picture, then what it is and the button */
.sbox__open { all: unset; box-sizing: border-box; display: grid; grid-template-columns: minmax(6.5rem, 9.5rem) minmax(0, 1fr); gap: 1.1rem;
  align-items: center; width: 100%; height: 100%; padding: 1.1rem 1.3rem 1.3rem; cursor: pointer; border-radius: inherit; color: var(--ink); }
.sbox__open:focus-visible { outline: 3px solid var(--ink); outline-offset: -6px; box-shadow: inset 0 0 0 9px var(--yellow); }  /* taste-skill-ignore: focus ring */
.sbox__pic { position: relative; display: block; aspect-ratio: 3 / 4; border: var(--stroke, 3px) solid var(--ink); border-radius: 10px;
  overflow: hidden; background: #efe9dc; transform: rotate(-1.5deg); transition: transform var(--t-ui, 240ms) var(--ease-out, ease); }
.sbox__pic--read { transform: rotate(1.5deg); }
.sbox__pic img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.sbox__play { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; display: grid; place-items: center;
  border-radius: 50%; border: var(--stroke, 3px) solid var(--ink); background: var(--yellow); color: var(--ink); }
.sbox__play svg { width: 30px; height: 30px; margin-left: 4px; }
.sbox__play--read { background: var(--sheet, #fff); }
.sbox__play--read svg { margin-left: 0; width: 32px; }
.sbox__words { display: grid; justify-items: start; gap: 0.55rem; min-width: 0; }
.sbox__what { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; line-height: 1.1; }
.sbox__first { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; line-height: 1.35; color: #4a4a4a;
  border-left: 4px solid var(--yellow); padding-left: 0.6rem; }
.sbox__btn { pointer-events: none; }
.sbox__note { margin: 0; }
.sbox__noscript { margin-top: 0.5rem; }
@media (hover: hover) and (pointer: fine) {
  .sbox__open:hover .sbox__pic { transform: rotate(0deg) scale(1.03); }
  .sbox__open:hover .btn--crayon { background-position: 100% 0; }
}
.sbox__open:active .sbox__pic { transform: rotate(0deg) scale(0.98); }

/* phones: the pages stack, top-bound like a notepad, with the stitch across */
@media (max-width: 40rem) {
  .sbox__book--two { grid-template-columns: minmax(0, 1fr); }
  .sbox__book--two .sbox__page--film { border-radius: 8px 8px 3px 3px; background-image: linear-gradient(to top, rgba(26, 26, 26, 0.12), rgba(26, 26, 26, 0) 26px); }
  .sbox__book--two .sbox__page--read { border-radius: 3px 3px 8px 8px; background-image: linear-gradient(to bottom, rgba(26, 26, 26, 0.12), rgba(26, 26, 26, 0) 26px); margin-top: 6px; }
  .sbox__book--two .sbox__page--film { box-shadow: none; }
  .sbox__book--two .sbox__page--film::after { display: none; }
  .sbox__book--two::after { top: 50%; bottom: auto; left: 12px; right: 12px; width: auto; height: 3px; margin: 0;
    background: repeating-linear-gradient(to right, var(--ink) 0 9px, transparent 9px 15px); }
  .sbox__open { grid-template-columns: 6.25rem minmax(0, 1fr); gap: 0.9rem; padding: 0.9rem 1rem 1.1rem; }
  .sbox__what { font-size: 1.15rem; }
  .sbox__first { font-size: 0.95rem; }
  .sbox__btn.btn { min-height: 52px; font-size: 1.1rem; padding-inline: 1.1em; }
  .sbox__play { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  .sbox__play svg { width: 26px; height: 26px; }
}

/* ---------- the dialog: the same book, over the page. Phones: the whole screen. Wide screens: a page from the right */
html.sbox-is-open { overflow: hidden; }
.sbox-dlg { padding: 0; margin: 0; border: 0; background: transparent; color: var(--ink);
  width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; max-width: none; max-height: none; overflow: hidden; }
.sbox-dlg::backdrop { background: rgba(26, 26, 26, 0.62); }
.sbox-dlg__book { position: relative; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; height: 100%;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) 12px;
  background: var(--paper, #f6f5f3) url("/assets/img/paper.png") repeat; }
.sbox-dlg__bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.sbox-dlg__title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.15rem, 4.4vw, 1.5rem); line-height: 1.15;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; min-width: 0; }
.sbox-dlg__close { flex: none; width: 60px; height: 60px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: var(--stroke, 3px) solid var(--ink); border-radius: 50%; background: var(--sheet, #fff); color: var(--ink);
  transition: transform var(--t-press, 140ms) var(--ease-out, ease); }
.sbox-dlg__close svg { width: 30px; height: 30px; }
.sbox-dlg__close:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) { .sbox-dlg__close:hover { background: var(--yellow); } }
/* the stage is a white page in the ink line, with a folded corner */
.sbox-dlg__stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 10px;
  background: var(--sheet, #fff); border: var(--stroke, 3px) solid var(--ink); border-radius: 14px; }
.sbox-dlg__stage::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 34px; height: 34px; pointer-events: none;
  border-bottom-right-radius: 14px;
  background: linear-gradient(-45deg, var(--paper, #f6f5f3) 0 50%, var(--ink) 50% calc(50% + 3px), #e7e1d4 calc(50% + 3px)); }
.sbox-dlg__video { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; min-height: 0; background: var(--ink); border-radius: 10px; }
.sbox-dlg--read .sbox-dlg__stage { padding: 0; overflow: hidden; }
.sbox-dlg__frame { display: block; flex: 1 1 auto; align-self: stretch; width: 100%; height: auto; border: 0; border-radius: 11px; background: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .sbox-dlg[open] { animation: sbox-up 260ms var(--ease-out, ease) both; }
  .sbox-dlg[open]::backdrop { animation: sbox-fade 200ms ease both; }
}
@keyframes sbox-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes sbox-fade { from { opacity: 0; } }

/* wide screens: the story slides in from the right as the next page of the book, its blue spine on the left edge */
@media (min-width: 56rem) and (min-height: 30rem) {
  .sbox-dlg { margin: 0 0 0 auto; inset: 0 0 0 auto; height: 100vh; height: 100dvh;
    width: clamp(24rem, calc((100dvh - 8.5rem) * var(--ar, 9 / 16) + 4.5rem), min(46vw, 44rem)); }
  .sbox-dlg--read { width: min(40rem, 50vw); }
  .sbox-dlg__book { padding: 18px 20px 20px 40px; border-left: var(--stroke, 3px) solid var(--ink); }
  .sbox-dlg__book::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 22px;
    background: var(--blue, #3a86ff) url("/assets/img/crayon-grain.png"); border-right: var(--stroke, 3px) solid var(--ink); }
  .sbox-dlg__book::after { content: ""; position: absolute; left: 9px; top: 14px; bottom: 14px; width: 3px; pointer-events: none;
    background: repeating-linear-gradient(to bottom, var(--sheet, #fff) 0 10px, transparent 10px 18px); }
}
@media (min-width: 56rem) and (min-height: 30rem) and (prefers-reduced-motion: no-preference) {
  .sbox-dlg[open] { animation: sbox-in 380ms var(--ease-expo, ease-out) both; }
}
@keyframes sbox-in { from { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .sbox__pic, .sbox-dlg__close { transition: none; }
  .sbox-dlg[open], .sbox-dlg[open]::backdrop { animation: none; }
}

/* ---------- a page read here (infodlg.js: the terms over the book's pay step, what you get by the Club's join form):
   the same dialog, a scrolling white page */
.sbox-dlg__stage.sbox-dlg__doc { display: block; overflow: auto; overscroll-behavior: contain; padding: 1.1rem 1.25rem 2rem; }
.sbox-dlg__doc:focus { outline: none; }
.sbox-dlg__content .wrap { padding: 0; max-width: none; }
.sbox-dlg__content { display: grid; gap: 2rem; }
.sbox-dlg__content > main, .sbox-dlg__content > section { display: grid; gap: 1.25rem; }
.sbox-dlg__content .legal-top { display: block; }
.sbox-dlg__content .legal-top .head { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: 0.75rem; }
.sbox-dlg__content .draft-banner { padding: 0.75rem 1rem; font-weight: 700; margin: 0; max-width: none; }
.sbox-dlg__content .legal { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.sbox-dlg__content .legal-sub { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.sbox-dlg__content .legal-lead { margin: 0 0 1rem; }
.sbox-dlg__content .head { font-size: clamp(1.5rem, 3.4vw, 2rem); }
.sbox-dlg__content .dw-sec__head { margin-bottom: 0.75rem; }
.sbox-dlg__content .compare { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.sbox-dlg__content .compare__col { background: var(--sheet, #fff); padding: 1rem 1.1rem; }
.sbox-dlg__content .compare__col--club { background: color-mix(in srgb, var(--yellow) 26%, var(--sheet)); }
.sbox-dlg__content .compare__col h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin-bottom: 0.4rem; }
.sbox-dlg__content .compare__col li { position: relative; padding: 0.25rem 0 0.25rem 1.7rem; font-weight: 700; line-height: 1.3; }
.sbox-dlg__content .compare__col li::before { content: ""; position: absolute; left: 0.1rem; top: 0.5em; width: 0.9rem; height: 0.5rem;
  border-left: var(--stroke, 3px) solid var(--ink); border-bottom: var(--stroke, 3px) solid var(--ink); transform: rotate(-45deg); }
.sbox-dlg__content .dw-faq { display: grid; gap: 0.75rem; }
.sbox-dlg__content .dw-faq details { padding: 0.75rem 1rem; background: var(--sheet, #fff); }
.sbox-dlg__content .dw-faq summary { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; cursor: pointer; }
.sbox-dlg__content .dw-faq p { margin-top: 0.5rem; font-weight: 600; }
.sbox-dlg__more { margin-top: 1.5rem; }
.sbox-dlg__wait { padding: 1rem 0; }
@media (min-width: 56rem) and (min-height: 30rem) {
  .sbox-dlg--doc { width: min(48rem, 60vw); }
  .sbox-dlg__stage.sbox-dlg__doc { padding: 1.5rem 2rem 2.25rem; }
  .sbox-dlg__content .compare { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
