/* Tie-In: handhelds on a bedroom carpet */
:root { --carpet: #b5a48a; --ink: #1b1b1b; --paper: #f7f4ec; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--carpet); }
body {
  font-family: "Helvetica Neue", Arial, sans-serif; color: var(--ink); overflow-x: hidden;
  background-color: var(--carpet);
  background-image:
    radial-gradient(120% 90% at 18% 0%, rgba(255, 236, 200, .28), rgba(255, 236, 200, 0) 60%),
    radial-gradient(140% 120% at 50% 40%, rgba(0, 0, 0, 0) 55%, rgba(30, 18, 6, .28) 100%),
    url(art/carpet.webp);
  background-size: auto, auto, 520px 520px;
  background-attachment: fixed, fixed, scroll;
  -webkit-tap-highlight-color: transparent;
}
body.holding, body.sheet-open { overflow: hidden; }

/* ------------------------------------------------ the pile */
#carpet { position: relative; width: 100%; }
#pile { position: relative; width: 100%; min-height: 100vh; }
.toy {
  all: unset; position: absolute; display: block; cursor: pointer; transform-origin: 50% 50%;
  transform: rotate(var(--rot, 0deg)); transition: translate .18s ease, filter .18s ease;
  filter: drop-shadow(0 1.5px 1px rgba(30, 18, 6, .45)) drop-shadow(5px 9px 9px rgba(30, 18, 6, .32));
  -webkit-tap-highlight-color: transparent;
}
.toy > svg { display: block; width: 100%; height: 100%; overflow: visible; }
@media (hover: hover) {
  .toy:hover { translate: 0 -5px; filter: drop-shadow(0 2px 2px rgba(30, 18, 6, .35)) drop-shadow(8px 16px 14px rgba(30, 18, 6, .3)); }
}
.toy:focus-visible { outline: 3px solid #ffd23f; outline-offset: 4px; border-radius: 18px; }
.toy.lifted { visibility: hidden; }
.toy.leaf { filter: drop-shadow(0 1px 1px rgba(30, 18, 6, .35)) drop-shadow(3px 5px 5px rgba(30, 18, 6, .25)); }

/* the LCD: unlit figures stay faintly visible, as on the real glass */
.seg .fg { opacity: .085; fill: #0c0e12; transition: none; }
.seg .sh { opacity: 0; }
.seg.on .fg { opacity: .9; }
.seg.on .sh { opacity: .2; }
.lcd text.fg { fill: #0c0e12; }
/* switched on, the polariser lifts the printed picture a little so the black figures read */
.case .lift { opacity: 0; mix-blend-mode: screen; transition: opacity .35s; pointer-events: none; }
.case.powered .lift { opacity: var(--lift, .3); }

/* ------------------------------------------------ in the hand */
.hand {
  position: fixed; inset: 0; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: rgba(24, 16, 8, .66);
}
.hand[hidden], .hand.stacked[hidden] { display: none; }
.hand-front { position: relative; display: grid; place-items: center; min-height: 0; padding: 24px 12px; }
.device { position: relative; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35)) drop-shadow(10px 26px 26px rgba(0, 0, 0, .38)); }
.device > svg { display: block; width: 100%; height: 100%; }
.device .pressable { cursor: pointer; transition: transform .05s; transform-box: fill-box; transform-origin: center; outline: none; }
.device .pressable.down { transform: translateY(1.4px) scale(.97); filter: brightness(.86); }
.device .pressable:focus-visible { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 3px #ffd23f); }
.device .acl-hit { cursor: pointer; }
.peek { display: none; }

.put-down {
  position: fixed; z-index: 30; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left));
  width: 44px; height: 44px; border: 0; border-radius: 22px; cursor: pointer;
  background: rgba(255, 255, 255, .88); color: #1b1b1b; font: 30px/44px Arial, sans-serif; box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.put-down:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }

/* the back of the box: the case study */
.boxback {
  position: relative; height: 100vh; height: 100dvh; overflow: auto; overscroll-behavior: contain;
  background: #fbfaf6; color: #1b1b1b; box-shadow: -10px 0 30px rgba(0, 0, 0, .3);
  --ab-fg: #1b1b1b; --ab-muted: #5b574f; --ab-accent: var(--btn, #ffd23f);
}
.bb-head { position: relative; padding: 26px 26px 18px; background: var(--case, #c00); color: #fff; overflow: hidden; }
.bb-band { position: absolute; inset: auto 0 0 0; height: 10px; background: repeating-linear-gradient(90deg, var(--btn) 0 18px, rgba(0, 0, 0, .25) 18px 22px); }
.bb-title { margin: 0; font-size: clamp(26px, 3.4vw, 42px); line-height: 1.04; font-weight: 400; text-transform: uppercase;
  -webkit-text-stroke: 1.2px rgba(0, 0, 0, .55); paint-order: stroke; text-shadow: 2px 3px 0 rgba(0, 0, 0, .35); }
.bb-client { margin: 6px 0 4px; font: 700 12px/1.2 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; opacity: .92; }
.bb-media { padding: 22px 26px 36px; font-size: 15px; line-height: 1.5; }
.bb-media.ab-media { --ab-chrome: 150px; }
.bb-media .ab-lede { font-size: 16px; line-height: 1.5; font-weight: 600; }
.bb-media .ab-heading { font: 700 13px/1.2 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; padding-top: 10px; border-top: 3px solid #1b1b1b; }
.bb-media .ab-frame, .bb-media .ab-zoom img { box-shadow: 0 0 0 4px #fff, 0 0 0 5px rgba(0, 0, 0, .18), 3px 5px 10px rgba(0, 0, 0, .18); }
.bb-media figcaption { font: 700 11px/1.3 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .08em; text-transform: uppercase; margin-top: 10px; }
.bb-media .ab-credits { font-size: 12px; border-top: 1px solid rgba(0, 0, 0, .15); padding-top: 12px; }
.bb-media audio { filter: sepia(.2); }

/* the bottom of every box: the other titles in the line */
.bb-more { padding: 18px 26px 60px; border-top: 6px solid var(--case, #c00); background: #f1eee6; }
.bb-more-head { margin: 0 0 12px; font: 400 22px/1 Bungee, Impact, sans-serif; color: var(--case, #c00); -webkit-text-stroke: 1px #1b1b1b; paint-order: stroke; text-transform: uppercase; }
.bb-minis { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 12px 10px; }
.bb-mini { all: unset; box-sizing: border-box; display: grid; justify-items: center; gap: 4px; width: 100%; cursor: pointer; text-align: center; }
.bb-mini .scr { display: block; width: 70px; padding: 5px 5px 12px; border-radius: 7px; background: var(--c); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .2); position: relative; }
.bb-mini .scr img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #111; border-radius: 2px; }
.bb-mini .dots { position: relative; margin-top: -14px; display: flex; gap: 14px; height: 8px; }
.bb-mini .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--b); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .3); }
.bb-mini .nm { font: 700 10px/1.15 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .04em; text-transform: uppercase; color: #3b3830; }
.bb-mini.here { cursor: default; opacity: .45; }
.bb-down { margin-top: 22px; border: 0; border-radius: 22px; padding: 12px 20px; cursor: pointer; background: #1b1b1b; color: #fff; font: 700 13px/1 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.bb-down:focus-visible { outline: 3px solid var(--btn, #ffd23f); outline-offset: 2px; }
.bb-mini:not(.here):hover .scr, .bb-mini:focus-visible .scr { transform: translateY(-2px); }
.bb-mini:focus-visible { outline: 3px solid #1b1b1b; outline-offset: 3px; border-radius: 6px; }

/* phones and tall screens: the handheld fills the screen; the box is underneath */
.hand.stacked { display: block; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.hand.stacked .put-down { position: absolute; }   /* scrolls away with the handheld, so it never sits on the work */
.hand.stacked .hand-front { min-height: 100vh; min-height: 100svh; padding: 62px 10px 50px; place-items: end center; }
.hand.stacked .boxback { height: auto; overflow: visible; box-shadow: 0 -10px 24px rgba(0, 0, 0, .3); border-radius: 6px 6px 0 0; }
.hand.stacked .peek {
  display: flex; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, calc(100% - 20px));
  height: 38px; border: 0; border-radius: 6px 6px 0 0; cursor: pointer; align-items: center; justify-content: center; gap: 10px;
  background: var(--case, #c00); color: #fff; font: 700 12px/1 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, .25);
}
.peek-edge { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; text-shadow: 1px 1px 0 rgba(0, 0, 0, .4); }
.peek-arrow { width: 10px; height: 10px; border-right: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(45deg) translateY(-3px); }
.hand.stacked .bb-media { padding: 18px 16px 56px; }
.hand.stacked .bb-media.ab-media { --ab-chrome: 90px; }
.hand.stacked .bb-head { padding: 22px 16px 18px; }
.hand.stacked .bb-more { padding: 16px 16px 48px; }

/* ------------------------------------------------ the lid's checklist, the leaflet */
.sheet { position: fixed; inset: 0; z-index: 25; overflow: auto; overscroll-behavior: contain; background: rgba(24, 16, 8, .6); padding: 64px 16px 40px; }
.sheet[hidden] { display: none; }
.lid-inner {
  max-width: 980px; margin: 0 auto; padding: 26px clamp(16px, 4vw, 40px) 30px; border-radius: 8px;
  background: linear-gradient(135deg, #ffe35a, #ffb21f); box-shadow: 0 0 0 6px #c9a77a, 0 20px 40px rgba(0, 0, 0, .4);
}
.lid-head { margin: 0 0 18px; text-align: center; font: 400 clamp(30px, 6vw, 56px)/1 Bungee, Impact, sans-serif; color: #e2231a;
  -webkit-text-stroke: 2px #1b1b1b; paint-order: stroke; text-shadow: 3px 4px 0 #1b1b1b; text-transform: uppercase; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 8px 18px; }
.check { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 18px 64px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; align-items: center; cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.check:hover, .check:focus-visible { background: rgba(255, 255, 255, .45); }
.check:focus-visible { outline: 3px solid #1b1b1b; }
.check .box { grid-row: 1 / 3; width: 16px; height: 16px; border: 2.5px solid #1b1b1b; background: #fff; border-radius: 2px; position: relative; }
.check.got .box::after { content: ""; position: absolute; left: 3px; top: -5px; width: 6px; height: 13px; border-right: 3.5px solid #e2231a; border-bottom: 3.5px solid #e2231a; transform: rotate(40deg); }
.check .mini { grid-row: 1 / 3; width: 64px; height: 44px; border-radius: 6px; background: var(--c); padding: 4px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); display: block; }
.check .mini img { display: block; width: 100%; height: 100%; object-fit: contain; background: #111; border-radius: 2px; }
.check .nm { font: 400 17px/1.1 "Titan One", Impact, sans-serif; color: #1b1b1b; }
.check .cl { font: 700 10px/1.2 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .12em; color: rgba(0, 0, 0, .62); }

.leaflet-paper {
  max-width: 560px; margin: 0 auto; padding: 30px clamp(18px, 5vw, 40px) 34px; background: var(--paper);
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 49.6%, rgba(0, 0, 0, .06) 50%, rgba(0, 0, 0, 0) 50.4%), linear-gradient(rgba(0, 0, 0, 0) 49.7%, rgba(0, 0, 0, .05) 50%, rgba(0, 0, 0, 0) 50.3%);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .4); font: 15px/1.5 "Helvetica Neue", Arial, sans-serif;
}
.lf-name { margin: 0; font: 700 clamp(28px, 6vw, 40px)/1 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .02em; text-transform: uppercase; border-bottom: 4px solid #1b1b1b; padding-bottom: 8px; }
.lf-title { margin: 12px 0 4px; font-weight: 700; }
.lf-bio { margin: 0 0 12px; }
.lf-contact { list-style: none; margin: 0 0 22px; padding: 0; }
.lf-contact a { color: #1b1b1b; }
.lf-head { margin: 0 0 8px; font: 700 13px/1.2 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; border-top: 2px solid #1b1b1b; padding-top: 10px; }
.lf-steps { margin: 0; padding-left: 22px; }

/* ------------------------------------------------ loading */
#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #2a2622; transition: opacity .4s; cursor: pointer; }
#loader.gone { opacity: 0; pointer-events: none; }
.ld-panel { width: min(320px, 76vw); padding: 14px; border-radius: 14px; background: #121314; box-shadow: inset 0 0 0 2px #2c2d30, 0 10px 30px rgba(0, 0, 0, .5); }
.ld-panel svg { display: block; width: 100%; height: auto; }
#ld-lcd .seg .fg { fill: #1b1d1f; opacity: .08; }
#ld-lcd .seg.on .fg { opacity: .88; }

@media (prefers-reduced-motion: reduce) { .toy { transition: none; } }
