/* Twist: a puzzle cube on a table, and the paper leaflet that came with it. */
:root {
  --paper: #f3efe4;
  --paper-2: #ebe5d6;
  --ink: #161514;
  --ink-2: #57524a;
  --red: #c4161c;
  --table-1: #d8d1c3;
  --table-2: #b9b1a1;
  --table-3: #8f8778;
  --leaflet-w: 452px;
  --sheet-w: min(640px, 52vw);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: radial-gradient(120% 90% at 42% 38%, var(--table-1) 0%, var(--table-2) 58%, var(--table-3) 100%);
  color: var(--ink);
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* the tabletop's grain, under everything */
  content: ""; position: fixed; inset: 0; background-image: var(--grain); opacity: .55; pointer-events: none;
}
button { font: inherit; color: inherit; }

.desk { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#stage.grabbing { cursor: grabbing; }
#stage.over-piece { cursor: pointer; }

/* the paper label that follows the pointer over a piece */
.tag {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; opacity: 0;
  transform: translate(-50%, calc(-100% - 18px)); transition: opacity .12s;
  background: var(--paper); background-image: var(--grain); color: var(--ink);
  padding: 7px 11px 8px; border-radius: 2px; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 6px 18px rgba(40,30,10,.28);
}
.tag.on { opacity: 1; }
.tag b { display: block; font-weight: 800; font-stretch: 80%; font-size: 15px; letter-spacing: .01em; line-height: 1.1; }
.tag small { display: block; font-size: 10px; font-weight: 600; letter-spacing: .14em; color: var(--red); margin-top: 2px; }

/* ---------------- the leaflet ---------------- */
.leaflet {
  position: fixed; z-index: 3; right: 28px; top: 24px;
  width: var(--leaflet-w); max-height: calc(100vh - 48px); max-height: calc(100svh - 48px);
  display: flex; flex-direction: column;
  transform: rotate(.5deg); transform-origin: 100% 0;
  background: var(--paper); background-image: var(--grain), linear-gradient(90deg, rgba(0,0,0,0) 49.6%, rgba(90,70,40,.13) 50%, rgba(255,255,255,.5) 50.4%, rgba(0,0,0,0) 51.5%);
  box-shadow: 0 1px 1px rgba(0,0,0,.12), 0 14px 34px rgba(50,38,18,.32), inset 0 0 0 1px rgba(120,100,60,.12);
  border-radius: 2px;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s;
}
.leaflet.away { transform: translateX(120%) rotate(4deg); opacity: 0; pointer-events: none; }
.leaflet-head {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 3px solid var(--red); margin: 0 14px;
}
.leaflet-head:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.brand { font-weight: 900; font-stretch: 72%; font-size: 30px; letter-spacing: .015em; line-height: 1; color: var(--ink); }
.fold-mark { width: 18px; height: 18px; color: var(--ink-2); transition: transform .3s; }
.leaflet.folded .fold-mark { transform: rotate(180deg); }
.leaflet-body { overflow: auto; overscroll-behavior: contain; padding: 10px 14px 6px; -webkit-overflow-scrolling: touch; }
.leaflet.folded .leaflet-body { display: none; }

.parts { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 22px; }
.parts li { break-inside: avoid; }
.part {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 9px;
  padding: 3px 6px; border-radius: 3px;
}
.part:hover, .part.lit { background: rgba(196,22,28,.09); }
.part:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.part .sw {
  width: 40px; height: 40px; border-radius: 5px; background: #0b0b0c; padding: 3px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.35);
}
.part .sw img { width: 100%; height: 100%; display: block; border-radius: 3px; object-fit: cover; }
.part .nm { min-width: 0; }
.part b { display: block; font-weight: 800; font-stretch: 80%; font-size: 14px; line-height: 1.12; letter-spacing: .005em; }
.part small:empty { display: none; }
.part small { display: block; margin-top: 2px; font-weight: 600; font-size: 9px; letter-spacing: .13em; color: var(--ink-2); }

.leaflet-foot { display: flex; gap: 18px; justify-content: flex-end; padding: 10px 6px 8px; margin-top: 6px; border-top: 1px solid rgba(22,21,20,.18); }
.foot-btn {
  all: unset; cursor: pointer; font-weight: 800; font-stretch: 80%; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink);
  padding: 4px 2px; border-bottom: 2px solid transparent;
}
.foot-btn:hover { border-bottom-color: var(--red); }
.foot-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.foot-btn[disabled] { opacity: .35; pointer-events: none; }

/* ---------------- a piece, opened ---------------- */
.sheet {
  position: fixed; z-index: 6; top: 0; right: 0; bottom: 0; width: var(--sheet-w);
  background: var(--paper); background-image: var(--grain);
  box-shadow: -18px 0 40px rgba(50,38,18,.28), -1px 0 0 rgba(120,100,60,.2);
  transform: translateX(104%); transition: transform .5s cubic-bezier(.2,.8,.2,1); visibility: hidden;
}
.sheet.open { transform: none; visibility: visible; }
.sheet-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 14px; align-items: center;
  padding: 22px 28px 14px; background: var(--paper); background-image: var(--grain);
  border-bottom: 3px solid var(--red);
}
.sheet-names { min-width: 0; }
.sheet h1 { margin: 0; font-weight: 900; font-stretch: 72%; font-size: clamp(26px, 3.2vw, 40px); line-height: 1; letter-spacing: .005em; }
.sheet-head p { margin: 5px 0 0; font-weight: 700; font-size: 11px; letter-spacing: .16em; color: var(--red); }
.sheet-close {
  all: unset; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; line-height: 1; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink);
}
.sheet-close:hover { background: var(--ink); color: var(--paper); }
.sheet-close:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.sheet-body { padding: 20px 28px 48px; }
.sheet-body.ab-media { --ab-fg: var(--ink); --ab-muted: var(--ink-2); --ab-accent: var(--red); --ab-gap: 16px; --ab-chrome: 130px; font-size: 16px; line-height: 1.5; }
.sheet-body .ab-lede { font-size: 19px; line-height: 1.4; font-weight: 500; }
.sheet-body .ab-heading { font-weight: 800; font-stretch: 78%; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; padding-top: 10px; border-top: 1px solid rgba(22,21,20,.2); }
.sheet-body .ab-credits { font-size: 12.5px; line-height: 1.55; padding-top: 12px; border-top: 1px solid rgba(22,21,20,.2); }
.sheet-body .ab-frame { border-radius: 2px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.sheet-body .ab-image img { box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.sheet-body figcaption { font-weight: 600; font-size: 12px; letter-spacing: .04em; }
.sheet-body audio { filter: sepia(.25); }

.about p { margin: 0 0 14px; }
.about .role { font-weight: 800; font-stretch: 80%; font-size: 20px; }
.about a { color: var(--red); font-weight: 700; text-decoration: none; border-bottom: 1px solid currentColor; }

/* ---------------- loading: the stickers go on ---------------- */
.loader {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 42% 38%, var(--table-1) 0%, var(--table-2) 58%, var(--table-3) 100%);
  transition: opacity .5s;
}
.loader.done { opacity: 0; pointer-events: none; }
.loader-cube {
  width: 84px; height: 84px; padding: 5px; border-radius: 9px; background: #0c0c0d; display: grid; gap: 4px; grid-template-columns: repeat(3, 1fr);
  box-shadow: 0 10px 24px rgba(40,30,10,.35); transform: rotate(-8deg);
}
.loader-cube i { border-radius: 3px; background: #26262a; transition: background .25s; }
.loader-cube i.on:nth-child(6n+1) { background: #f3efe2; }
.loader-cube i.on:nth-child(6n+2) { background: #b8141c; }
.loader-cube i.on:nth-child(6n+3) { background: #0d8c45; }
.loader-cube i.on:nth-child(6n+4) { background: #f5c814; }
.loader-cube i.on:nth-child(6n+5) { background: #0b45b0; }
.loader-cube i.on:nth-child(6n) { background: #f2650f; }

/* ---------------- small laptops and tablets on their side ---------------- */
@media (min-width: 820px) and (max-width: 1180px) {
  :root { --leaflet-w: 384px; }
  .leaflet { right: 18px; }
  .brand { font-size: 25px; }
  .parts { column-gap: 12px; }
  .part { grid-template-columns: 34px minmax(0, 1fr); gap: 7px; padding: 3px 3px; }
  .part .sw { width: 34px; height: 34px; }
  .part b { font-size: 12.5px; }
}

/* ---------------- phones ---------------- */
@media (max-width: 819px) {
  :root { --sheet-top: min(34svh, calc(100svh - 120px - 98vw)); }
  .leaflet {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; transform: none;
    height: 45vh; height: 45svh; max-height: none; border-radius: 12px 12px 0 0;
    background-image: var(--grain);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .leaflet.folded { height: auto; }
  .leaflet.away { transform: translateY(110%); }
  .leaflet-head { padding: 12px 6px 9px; margin: 0 14px; }
  .brand { font-size: 24px; }
  .leaflet-body { flex: 1; min-height: 0; padding: 8px 10px 4px; }
  .parts { column-gap: 8px; }
  .part { grid-template-columns: 38px minmax(0, 1fr); gap: 8px; padding: 5px 4px; }
  .part .sw { width: 38px; height: 38px; }
  .part b { font-size: 13.5px; }
  .sheet { top: var(--sheet-top); left: 0; width: auto; border-radius: 12px 12px 0 0; transform: translateY(104%); box-shadow: 0 -12px 34px rgba(50,38,18,.3); }
  .sheet-head { padding: 14px 16px 11px; grid-template-columns: minmax(0, 1fr) 44px; gap: 11px; border-radius: 12px 12px 0 0; }
  .sheet h1 { font-size: 27px; }
  .sheet-body { padding: 16px 16px 40px; }
  .sheet-body.ab-media { --ab-chrome: calc(var(--sheet-top) + 96px); font-size: 15.5px; }
  .sheet-body .ab-lede { font-size: 17px; }
  .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .leaflet, .sheet, .loader { transition: none; }
}
