/* A school desk, four paper fortune tellers, and a notebook page for the work. */
:root {
  --desk: #b98d5b;
  --ink: #2b2a2e;
  --rule: rgba(84, 140, 214, .38);
  --margin: rgba(214, 74, 74, .55);
  --paper: #fdfcf6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6e5034; overscroll-behavior: none; }
body { font-family: "Patrick Hand", "Comic Sans MS", system-ui, sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sr-only:focus-within { position: fixed !important; width: auto; height: auto; clip: auto; left: 8px; top: 8px; z-index: 50; background: var(--paper); padding: 10px 14px; border-radius: 4px; box-shadow: 0 4px 18px rgba(0,0,0,.3); max-height: 80vh; overflow: auto; }
#index ul { margin: 0; padding: 0; list-style: none; }
#index button { font: inherit; font-size: 18px; background: none; border: 0; padding: 2px 0; cursor: pointer; color: var(--ink); text-align: left; }

/* ---------- loading: a fortune teller opening and shutting while a pencil line draws */
#loader { position: fixed; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 22px;
  background: radial-gradient(120% 90% at 30% 20%, #d6aa74 0%, #b98d5b 55%, #8f6a42 100%); transition: opacity .6s ease; }
#loader.done { opacity: 0; pointer-events: none; }
#loader .cc { width: 112px; height: 112px; overflow: visible; filter: drop-shadow(0 6px 6px rgba(60, 35, 10, .35)); }
#loader .cc path { fill: #fbfaf2; stroke: #8b8f99; stroke-width: 1.1; stroke-linejoin: round; }
#loader .h { transform-origin: 60px 60px; animation: snap 1.1s ease-in-out infinite; }
#loader .h1 { --dx: -1; --dy: -1; } #loader .h2 { --dx: 1; --dy: -1; } #loader .h3 { --dx: 1; --dy: 1; } #loader .h4 { --dx: -1; --dy: 1; }
@keyframes snap {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(calc(var(--dx) * 7px), 0); }
  50% { transform: translate(0, 0); }
  75% { transform: translate(0, calc(var(--dy) * 7px)); }
}
#loader .line { width: 200px; height: 12px; overflow: visible; }
#loader .line path { fill: none; stroke: #3a3a3e; stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: .8; transition: stroke-dashoffset .3s ease; }
@media (prefers-reduced-motion: reduce) { #loader .h { animation: none; } }

/* ---------- in-hand buttons: scraps of notebook paper with pencil drawings */
#ui { position: fixed; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 10; display: flex; justify-content: center; gap: 14px; pointer-events: none; }
#ui[hidden] { display: none; }
.scrap { pointer-events: auto; width: 58px; height: 54px; padding: 6px; border: 0; cursor: pointer;
  background: linear-gradient(transparent 0 46%, var(--rule) 46% 49%, transparent 49% 100%), #fdfcf4;
  clip-path: polygon(3% 6%, 30% 0, 62% 4%, 97% 1%, 100% 40%, 96% 72%, 99% 97%, 64% 100%, 35% 95%, 2% 99%, 0 60%);
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); transition: transform .15s ease; }
.scrap:nth-child(2) { transform: rotate(2.5deg); }
.scrap:nth-child(3) { transform: rotate(-2deg); }
.scrap:hover { transform: translateY(-2px) rotate(-1deg); }
.scrap:focus-visible { outline: 3px solid #2357c8; outline-offset: 2px; }
.scrap[hidden] { display: none; }
/* on a wide screen the scraps stand in a column on the desk at the right, so the paper in hand gets the full height */
@media (min-aspect-ratio: 9/10) {
  #ui { left: auto; right: max(14px, env(safe-area-inset-right)); top: 50%; bottom: auto; transform: translateY(-50%); flex-direction: column; }
}
.scrap svg { width: 100%; height: 100%; }
.scrap path { fill: none; stroke: #45464c; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the case study: a page torn from a notebook */
#case { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; background: rgba(40, 26, 12, .42); }
#case[hidden] { display: none; }
#case .page { position: relative; width: min(980px, 100%); height: min(100%, 100svh - 36px); overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background:
    radial-gradient(circle at 26px 90px, #6e5034 0 9px, transparent 10px),
    radial-gradient(circle at 26px 50%, #6e5034 0 9px, transparent 10px),
    linear-gradient(90deg, transparent 0 63px, var(--margin) 63px 65px, transparent 65px),
    linear-gradient(transparent 0 31px, var(--rule) 31px 32px) 0 6px / 100% 32px,
    var(--paper);
  background-attachment: local;
  box-shadow: 0 18px 50px rgba(0,0,0,.45); border-radius: 2px; padding: 26px 34px 48px 88px; outline: none;
  animation: pagein .38s cubic-bezier(.2, .8, .25, 1); }
@keyframes pagein { from { transform: translateY(28px) rotate(-1deg); opacity: 0; } to { transform: none; opacity: 1; } }
#case .close { position: sticky; top: 0; float: right; margin: -12px -20px 0 8px; width: 48px; height: 48px; padding: 6px; border: 0; background: none; cursor: pointer; z-index: 2; }
#case .close path { fill: none; stroke: #3b3b40; stroke-width: 2.8; stroke-linecap: round; }
#case .close:focus-visible { outline: 3px solid #2357c8; border-radius: 6px; }
#case header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px 26px; margin: 4px 0 26px; }
#case .scrap-art { display: block; max-width: min(100%, 420px); height: auto; filter: drop-shadow(0 4px 5px rgba(0,0,0,.28)); transform: rotate(-1.4deg); }
#case .who { flex: 1 1 220px; min-width: 0; }
#case h1 { margin: 0; font: 400 clamp(32px, 5vw, 46px)/1.05 "Schoolbell", "Patrick Hand", cursive; color: #26262b; }
#case .client { margin: 8px 0 0; font: 400 20px/1.2 "Patrick Hand", cursive; color: #5b5d66; letter-spacing: .04em; }
#case .work { --ab-fg: #2c2c31; --ab-muted: #5b5d66; --ab-accent: #2357c8; --ab-gap: 18px; --ab-chrome: 130px; font: 400 20px/32px "Patrick Hand", "Comic Sans MS", system-ui, sans-serif; }
#case .work .ab-lede { font-size: 22px; line-height: 32px; }
#case .work .ab-heading { font: 400 26px/32px "Schoolbell", "Patrick Hand", cursive; color: #26262b; margin-top: 10px; }
#case .work .ab-credits { font-size: 17px; line-height: 26px; }
#case .work .ab-image img, #case .work .ab-frame { box-shadow: 0 3px 10px rgba(0,0,0,.22); }
#case .work .ab-film figcaption, #case .work .ab-audio figcaption { font-size: 17px; }
@media (max-width: 640px) {
  #case { padding: 8px; }
  #case .page { height: calc(100% - 0px); height: min(100%, 100svh - 16px); padding: 16px 16px 40px 40px;
    background:
      radial-gradient(circle at 15px 70px, #6e5034 0 6px, transparent 7px),
      radial-gradient(circle at 15px 50%, #6e5034 0 6px, transparent 7px),
      linear-gradient(90deg, transparent 0 30px, var(--margin) 30px 32px, transparent 32px),
      linear-gradient(transparent 0 31px, var(--rule) 31px 32px) 0 6px / 100% 32px,
      var(--paper);
    background-attachment: local; }
  #case .close { margin: -8px -10px 0 6px; }
  #case .work { font-size: 18px; line-height: 28px; }
  #case .work .ab-lede { font-size: 20px; line-height: 28px; }
}
@media (prefers-reduced-motion: reduce) { #case .page { animation: none; } }

/* no WebGL: the work as a list on a notebook page */
body.nogl #gl { display: none; }
body.nogl #index { position: fixed !important; inset: 0; width: auto; height: auto; margin: 0; clip: auto; white-space: normal; overflow: auto; padding: 40px 24px 40px 88px;
  background: linear-gradient(90deg, transparent 0 63px, var(--margin) 63px 65px, transparent 65px), linear-gradient(transparent 0 31px, var(--rule) 31px 32px) 0 6px / 100% 32px, var(--paper); background-attachment: local; }
body.nogl #index button { font-size: 22px; line-height: 32px; padding: 0; }
