/* Phones and upright tablets: the site as a spiral notepad (built by js/notepad.js). Each chapter is a sheet that scrolls;
   the tabs under the pad, and the links at the foot of each sheet, flip to another.
   Larger screens never get body.notepad, so none of this applies to the book. */

body.notepad { height: 100dvh; overflow: hidden; -webkit-tap-highlight-color: transparent; }
body.notepad #stage, body.notepad .sun-back, body.notepad .sun-front { display: none; }
body:not(.notepad) .np-pad { display: none; }

.np-pad { position: relative; height: 100dvh; padding: 22px 12px 0; display: flex; flex-direction: column; }
.np-stack { position: relative; flex: 1; }
.np-stack::before, .np-stack::after {   /* sheets underneath, peeking at the bottom */
  content: ""; position: absolute; left: 3px; right: 3px; bottom: -4px; height: 40px;
  background: #ebe3d2; border-radius: 0 0 6px 6px; box-shadow: 0 2px 3px rgba(45, 42, 38, .12);
}
.np-stack::after { left: 7px; right: 7px; bottom: -8px; background: #e2d9c5; z-index: -1; }

/* flipping: a later sheet lifts the current one up over the spiral; an earlier one swings back down over it.
   The 3D is switched on only while a sheet turns (.flipping): iPhones won't finger-scroll a page inside a 3D scene. */
.np-stack.flipping { perspective: 1400px; }
.np-sheet { position: absolute; inset: 0; z-index: 1; transform-origin: 50% 0; transition: transform .65s cubic-bezier(.45, .05, .35, 1); }
.np-stack.flipping .np-sheet { transform-style: preserve-3d; }
.np-sheet.is-top { z-index: 3; }
.np-sheet.is-next { z-index: 2; }
.np-sheet[hidden] { display: none; }
.np-sheet.over { transform: rotateX(178deg); }
.np-face { position: absolute; inset: 0; border-radius: 4px 4px 6px 6px; overflow: hidden; }
.np-stack.flipping .np-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.np-front { background: var(--page); container-type: size; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(45, 42, 38, .15), 0 8px 18px -10px rgba(45, 42, 38, .35); }
.np-back { background: #ece4d3; transform: rotateX(180deg); }
.np-stack:not(.flipping) .np-back { display: none; }   /* a sheet's underside only shows as it turns */

/* punched holes along the top of every sheet, and the wire through them */
.np-holes { position: absolute; top: 0; left: 0; right: 0; height: 22px; z-index: 8; pointer-events: none;
  background: radial-gradient(circle at 50% 11px, var(--backdrop) 4px, rgba(45, 42, 38, .3) 4.6px, transparent 5.4px) 9px 0 / 18px 22px repeat-x; }
.np-spiral { position: absolute; top: -14px; left: 0; right: 0; height: 30px; z-index: 10; pointer-events: none; }
.np-spiral svg { width: 100%; height: 100%; display: block; }

/* a sheet's page scrolls, in one piece, instead of being split into numbered pages */
.np-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; position: relative; }
/* no scrollbar: a short pencil mark down the sheet's edge shows where you are, while you scroll (see .np-thumb) */
.np-scroll, .np-front > .face.np-scrolls { scrollbar-width: none; }
.np-scroll::-webkit-scrollbar, .np-front > .face.np-scrolls::-webkit-scrollbar { display: none; }
.np-scroll.np-still, .np-front > .face.np-scrolls.np-still { overflow-y: hidden; }   /* see update() in notepad.js */
.np-thumb { position: absolute; top: 0; right: 5px; z-index: 8; width: 3px; height: 40px; border-radius: 2px; background: rgba(45, 42, 38, .38);
  opacity: 0; transition: opacity .5s; pointer-events: none; }
.np-thumb.on { opacity: 1; transition-duration: .15s; }
.np-scroll > .chapter { position: relative; height: auto; min-height: 100%; }
.np-scroll > .chapter .page-pad { flex: none; overflow: visible; padding-top: 24px !important; padding-bottom: 48px; }
.np-scroll .side { display: block !important; position: static; margin-bottom: 12px; }
.np-scroll .cv { padding-top: 0 !important; margin-top: 0 !important; }
.np-scroll .ruled-note { cursor: pointer; }
.np-scroll .pasted { scroll-margin-top: 20px; }   /* a pile spread out (see spreadPile) scrolls to its first drawing, tape and all */   /* a whole note card opens what its link opens */
/* the cover, Contents and the back cover are whole faces in the book; here they sit flat in the sheet */
.np-front > .face { position: absolute; inset: 0; transform: none; }
.np-front > .face.np-scrolls { overflow-y: auto; overscroll-behavior: contain; }
/* Contents' page sits pinned to the book page; here it grows with what's on it, so its foot keeps room below */
.np-front > .face.np-scrolls > .page-pad { position: relative; inset: auto; height: auto; min-height: 100%; padding-bottom: 48px; }
.np-front .hinge, .np-front .shade, .np-front .corner { display: none; }   /* no page corners: the tabs do the turning */
/* the strip with the punched holes stays paper; the page scrolls below it */
.np-front:not(.np-cover) { padding-top: 22px; }
.np-front:not(.np-cover) > .face { top: 22px; }

/* a short band: the title on the colour, the drawing half on it and half on the page (see clearArt) */
.np-scroll .chapter .band { height: 78px; overflow: visible; z-index: 3; }
.np-scroll .chapter .band .title { top: 17px; left: 8cqw; width: auto; font-size: 46px; }
.np-scroll .chapter.convertlens .band .title, .np-scroll .chapter.builds .band .title, .np-scroll .chapter[data-chapter="fun"] .band .title,
.np-scroll .chapter[data-chapter="work"] .band .title, .np-scroll .chapter[data-chapter="about"] .band .title { font-size: 38px; top: 21px; }   /* long titles: clear of the drawing and the bookmark */
.np-scroll .chapter.builds .band .title { font-size: 34px; line-height: .95; top: 9px; width: 42cqw; white-space: normal; }   /* two lines, clear of the drawing */
.np-scroll .chapter[data-chapter="work"] .band .title { font-size: 34px; line-height: .95; top: 9px; width: 32cqw; white-space: normal; }   /* two lines too: "Work I’ve done" would run under the drawing */
.np-scroll .chapter .band .art-group { right: 13cqw; bottom: auto; top: 40px; width: clamp(80px, min(34cqw, 30cqh), 210px); }   /* smaller on a short (sideways) screen */
.np-scroll .notes-page > .ruled-note:first-child { margin-top: 22px; }
/* Kitchen, under Zed draws on one sheet: its band is a divider, without the drawing again, and its cards follow on */
.np-scroll .chapter + .chapter .band .art-group { display: none; }
.np-scroll .kitchen-page > .recipe-card:first-of-type { margin-top: 0; }
.np-scroll .chapter.resume .cv-download { top: 96px; left: 8cqw; }
.np-scroll > .chapter.resume .page-pad { padding-top: 60px !important; }   /* the contact line starts just under the Download button */
.np-scroll .chapter.resume .cv-contact { margin: 0 0 14px; font-size: 15px; line-height: 1.5; }

/* the back cover */
.np-front .backcover { position: absolute; inset: 0; width: auto; height: auto; padding: 56px 9cqw 72px; opacity: 1; pointer-events: auto; transform: none; overflow-y: auto; }
.np-front .backcover .bc-plane { top: 34px; }
.np-front .backcover .bc-foot { display: none; }
.np-front .backcover .bc-colophon { max-width: 84cqw; padding: 14px 5cqw; }

/* "there's more below": a fade and a cue at the foot of a sheet, until you reach the end */
.np-more { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; height: 64px; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
  background: linear-gradient(to bottom, transparent, var(--page) 70%);
  font-family: "Nunito Sans", system-ui, sans-serif; font-weight: 600; font-size: 14px; color: #4f6a85; transition: opacity .3s; }
.np-more span { animation: np-nudge 1.6s ease-in-out infinite; }
.np-more.off { opacity: 0; }
@keyframes np-nudge { 50% { transform: translateY(3px); } }

/* the foot of every sheet: turn back, or on. Its dashed line closes Work's case list, so the list's own last line goes */
.np-scroll .cases li:last-child > a { border-bottom: 0; }
.np-turn { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 14px; border-top: 1.5px dashed rgba(45, 42, 38, .3); clear: both; }
.np-turn a { font-family: "Nunito Sans", system-ui, sans-serif; font-weight: 600; font-size: 14px; line-height: 1.4; color: #4f6a85; text-decoration: none; border-radius: 3px; }
.np-turn a small { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); opacity: .6; }
.np-turn a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.np-turn .next { margin-left: auto; text-align: right; }

/* "What I'm looking for": a yellow note, in How I got here's colour, so it stands out on the cream sheet (in the book it sits on that chapter's yellow page) */
body.notepad .looking { background: #f6e5b0; box-shadow: 2px 3px 0 rgba(190, 140, 60, .3); }

/* a case study opens as the next sheet of the pad: in the top sheet's place (see place() in notepad.js), under the wire,
   with the tabs still below. A copy of the top sheet turns over it (notepad.turnOver), with the wire it hangs from */
body.notepad .foldout { inset: auto; top: calc(var(--np-top) + 22px); left: var(--np-left); width: var(--np-width); height: calc(var(--np-height) - 22px);
  border-radius: 0 0 6px 6px; }
body.notepad .foldout.shown { background: transparent; }
body.notepad .fold-sheet { width: 100%; margin: 0; min-height: 100%; border-radius: 0; background-image: none; box-shadow: none; }   /* one sheet: no fold creases */
.np-stack.np-turnover { position: fixed; z-index: 600; flex: none; pointer-events: none; perspective: 4200px; perspective-origin: 50% 0; }   /* deep, so the lifting sheet doesn't balloon at the screen */
.np-turnover::before, .np-turnover::after { display: none; }
.np-shade { position: absolute; inset: 22px 0 0; border-radius: 0 0 6px 6px; background: linear-gradient(to bottom, rgba(45, 42, 38, .2), rgba(45, 42, 38, .06));
  transition: opacity .6s ease-out; }
.np-shade.off { opacity: 0; }
.np-turnover.down .np-shade { transition-timing-function: ease-in; }

/* sub-pages (Case studies, Projects, Zed draws, Kitchen) carry a way back to their chapter */
.np-crumb { position: absolute; z-index: 9; top: 26px; right: 14px; padding: 4px 12px; border-radius: 99px; background: rgba(255, 255, 255, .75);
  font-family: "Caveat", cursive; font-size: 21px; line-height: 1.1; color: var(--ink); text-decoration: none; box-shadow: 0 1px 2px rgba(45, 42, 38, .2); }
.np-crumb:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* the red bookmark, back to Contents: it hangs over the band, left of the title, and scrolls away with the band.
   Not on the cover, Contents or the back cover (they have no .np-scroll) */
.np-ribbon { position: absolute; z-index: 5; top: 0; left: 14px; width: 34px; height: 86px; padding-top: 8px;
  display: flex; justify-content: center; align-items: flex-start; background: #b8473a; color: #fbf3e6; text-decoration: none;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 88%, 0 100%); box-shadow: inset -3px 0 0 rgba(0, 0, 0, .12);
  font-family: "Caveat", cursive; font-size: 17px; line-height: 1; writing-mode: vertical-rl; outline: none; }
.np-ribbon::after { content: ""; position: absolute; inset: 0 -8px; }   /* a finger-sized tap area */
.np-ribbon:focus-visible { box-shadow: 0 0 0 3px var(--ink); clip-path: none; }
.np-scroll .chapter .band .title { left: 62px; }   /* clear of the bookmark */

/* the tabs: sticky-note tabs under the pad, in thumb reach */
.np-tabs { display: flex; gap: 5px; padding: 12px 2px calc(10px + env(safe-area-inset-bottom)); transition: opacity .3s; }
.np-tabs.off { opacity: 0; pointer-events: none; }
.np-tab {
  flex: 1; text-align: center; text-decoration: none;
  background: var(--bg); color: var(--ink);
  font-family: "Nunito Sans", system-ui, sans-serif; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: 12px 2px 10px; border-radius: 3px 3px 9px 9px; outline: none;
  box-shadow: 0 2px 0 rgba(45, 42, 38, .12), inset 0 0 0 1px rgba(45, 42, 38, .12);
  opacity: .78; transition: transform .25s, opacity .25s, box-shadow .25s;
}
.np-tab[aria-current="page"] { opacity: 1; font-weight: 700; transform: translateY(-7px); box-shadow: 0 7px 0 -1px rgba(45, 42, 38, .16), inset 0 0 0 1px rgba(45, 42, 38, .18); }
.np-tab[aria-current="page"]::after { content: ""; display: block; width: 18px; height: 2px; margin: 4px auto 0; border-radius: 2px; background: currentColor; opacity: .55; }
.np-tab:focus-visible { box-shadow: 0 0 0 3px #fbf6ec, 0 0 0 5px rgba(45, 42, 38, .55); }
.np-tab.work { --bg: var(--blue); } .np-tab.ai { --bg: #ee9a87; } .np-tab.fun { --bg: var(--green); }
.np-tab.about { --bg: var(--yellow); } .np-tab.resume { --bg: #fbf8f1; }
.np-hint { position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); margin: 0; text-align: center; font-size: 15px; opacity: .75; transition: opacity .3s; pointer-events: none; }
.np-hint.off { opacity: 0; }

/* a phone on its side: shorter tabs, so the sheet keeps its room */
@media (max-height: 500px) {
  .np-pad { padding-top: 18px; }
  .np-tabs { padding-top: 8px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .np-tab { padding: 7px 2px 6px; }
  .np-tab[aria-current="page"] { transform: translateY(-4px); }
  .np-tab[aria-current="page"]::after { display: none; }
}

/* an upright tablet: the pad fills the screen, as on a phone, with slimmer page margins and a taller band */
@media (min-width: 701px) and (min-height: 501px) {
  .np-pad { padding: 32px 16px 0; }
  .np-scroll > .chapter .page-pad, .np-front > .face.np-scrolls > .page-pad { padding-left: 7cqw !important; padding-right: 7cqw !important; }
  .np-scroll .chapter.resume .cv-download { left: 7cqw; }
  .np-scroll .chapter .band .title { left: max(7cqw, 62px); }
  .np-scroll .chapter .band { height: 104px; }
  .np-scroll .chapter .band .title { top: 22px; font-size: 60px; }
  .np-scroll .chapter.convertlens .band .title, .np-scroll .chapter.builds .band .title, .np-scroll .chapter[data-chapter="fun"] .band .title,
  .np-scroll .chapter[data-chapter="work"] .band .title, .np-scroll .chapter[data-chapter="about"] .band .title { font-size: 50px; top: 28px; width: auto; white-space: nowrap; line-height: inherit; }   /* room for one line here */
  .np-scroll .chapter.builds .band .title { font-size: 44px; top: 12px; width: 40cqw; }
  .np-scroll .chapter .band .art-group { width: clamp(80px, min(28cqw, 26cqh), 180px); }
  .np-scroll .chapter.resume .cv-download { top: 122px; }
  .np-scroll > .chapter.resume .page-pad { padding-top: 64px !important; }
  .np-tab { font-size: 13px; padding: 14px 2px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .np-sheet, .np-tabs, .np-tab, .np-more, .np-thumb, .np-shade { transition: none; }
  .np-more span { animation: none; }
}
