/* Registered so these can be transitioned smoothly (the wheel roll) */
@property --item-angle     { syntax: '<angle>';  inherits: false; initial-value: 0deg; }
@property --item-translate { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --item-scale     { syntax: '<number>'; inherits: false; initial-value: 1; }

/* ---------------------------------------------------------
   YOUR CUSTOM PERSONA 5 FONT
   1. Put the font file in a folder next to index.html, e.g. fonts/
   2. Change the file names in the src lines below to match yours
   3. Keep 'P5Custom' as the name; it is already used by the
      tab labels and the name in the header (the vertical watermark uses the default font).
   --------------------------------------------------------- */
@font-face {
  font-family: 'P5Custom';
  src: url('fonts/YourFont.woff2') format('woff2'),
       url('fonts/YourFont.ttf') format('truetype'),
       url('fonts/YourFont.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --p5-red: #D30000;
  --page-bg: #e9e7e2;             /* light grey / off-white page background */
  --edge: #D30000;                /* border colour where the page meets the black shapes */
  --p5-cyan: #00e5ff;
  --plate-bg: #3a3a3a;
  --plate-sel: #4d4d4d;           /* selected tab is a touch lighter */
  --sb-w: clamp(380px, 28vw, 500px);    /* main wheel width: scales with the window, never over 500px */
  --sub-w: clamp(340px, 22vw, 400px);   /* projects wheel width: scales with the window, never over 400px */
  --focus-y: 42%;                 /* fallback only; the script sets the real resting spot per wheel */
  --swap-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --p5-font: 'Dela Gothic One', 'Impact', sans-serif;
  /* Custom font first; anything it lacks (or if the file is missing) falls back to Dela Gothic One */
  --p5-custom: 'P5Custom', 'Dela Gothic One', 'Impact', sans-serif;
  --p5-label-font: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--page-bg);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: var(--p5-font);
}

/* =========================================================
   BACKGROUND ART (behind everything; content goes on top)
   ========================================================= */
.edge-stripes {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Halftone corners: three layers of the same grid, big dots near the corner shrinking outward */
.dots {
  position: absolute;
  inset: 0;
  background-size: 18px 18px;
}
.dots-l {
  background-image: radial-gradient(circle, rgba(0,0,0,0.13) 3px, transparent 3.6px);
  -webkit-mask-image: radial-gradient(circle 20vmax at 100% 100%, #000 20%, transparent 100%),
                      radial-gradient(circle 11vmax at 100% 0%, #000 20%, transparent 100%);
          mask-image: radial-gradient(circle 20vmax at 100% 100%, #000 20%, transparent 100%),
                      radial-gradient(circle 11vmax at 100% 0%, #000 20%, transparent 100%);
}
.dots-m {
  background-image: radial-gradient(circle, rgba(0,0,0,0.10) 2.2px, transparent 2.8px);
  -webkit-mask-image: radial-gradient(circle 40vmax at 100% 100%, transparent 28%, #000 52%, transparent 88%),
                      radial-gradient(circle 24vmax at 100% 0%, transparent 28%, #000 52%, transparent 88%);
          mask-image: radial-gradient(circle 40vmax at 100% 100%, transparent 28%, #000 52%, transparent 88%),
                      radial-gradient(circle 24vmax at 100% 0%, transparent 28%, #000 52%, transparent 88%);
}
.dots-s {
  background-image: radial-gradient(circle, rgba(0,0,0,0.08) 1.3px, transparent 1.8px);
  -webkit-mask-image: radial-gradient(circle 58vmax at 100% 100%, transparent 42%, #000 64%, transparent 100%),
                      radial-gradient(circle 34vmax at 100% 0%, transparent 42%, #000 64%, transparent 100%);
          mask-image: radial-gradient(circle 58vmax at 100% 100%, transparent 42%, #000 64%, transparent 100%),
                      radial-gradient(circle 34vmax at 100% 0%, transparent 42%, #000 64%, transparent 100%);
}

/* Frame strips + wall live in their own layer above the content and the wiper */
.frame-layer {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

/* Jagged black strips with a red edge along the top and bottom of the light area */
.frame {
  position: absolute;
  left: 0;
  right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 55%, 88% 100%, 72% 50%, 55% 100%, 38% 55%, 20% 100%, 0 60%);
}
.frame-black { height: 26px; background: #000; }
.frame-edge  { height: 33px; background: var(--edge); }
.frame-top { top: 0; }
.frame-bottom { bottom: 0; transform: scaleY(-1); }

/* Tilted black wall down the right edge: always touches the screen edge, but its inner side leans
   the other way now: thick at the top, skinny at the bottom (so it stays clear of the vertical text).
   --wall-bottom is the bottom width, --wall-lean is how much wider it gets by the top. */
.edge-line-r {
  --wall-bottom: 40px;
  --wall-lean: 8vh;
  --wall-border: 6px;
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: calc(var(--wall-bottom) + var(--wall-lean) + var(--wall-border));
}
.wall-border,
.wall-black { position: absolute; inset: 0; }
.wall-border {
  background: var(--edge);
  clip-path: polygon(0 0, 100% 0, 100% 100%, calc(100% - var(--wall-bottom) - var(--wall-border)) 100%);
}
.wall-black {
  background: #000;
  clip-path: polygon(var(--wall-border) 0, 100% 0, 100% 100%, calc(100% - var(--wall-bottom)) 100%);
}
.wall-black::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(211,0,0,0.9) 1.8px, transparent 2.3px);
  background-size: 11px 11px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 8%, #000 50%, transparent 92%);
          mask-image: linear-gradient(to bottom, transparent 8%, #000 50%, transparent 92%);
}

/* Big outlined section name; text updates with the selected tab */
.watermark {
  position: absolute;
  right: 50px;
  bottom: 56px;
  max-height: calc(100% - 140px);
  overflow: hidden;
  font-family: var(--p5-font);
  writing-mode: vertical-rl;
  font-size: calc(clamp(3rem, 5.5vw, 6rem) * var(--wm-scale, 1));
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 2px rgba(0, 0, 0, 0.38);
  white-space: nowrap;
  user-select: none;
  /* Align text parallel to the right wall angle (~4.6°) */
  transform: rotate(-4.6deg);
  transform-origin: bottom right;
}

/* =========================================================
   WINDSHIELD WIPER (light content area only)
   The sweep pivots on the top-left corner of the screen and swings clockwise from lying along the top edge
   down to standing along the left edge. The new stage is revealed behind the blade; the old copy of the
   stage is wiped away ahead of it. Layer order: content (1) < blade (2) < frame/wall (3) < wheels (10).
   ========================================================= */
@property --wipe-a { syntax: '<angle>'; inherits: false; initial-value: 90deg; }   /* 90deg = along the top edge, 180deg = down the left edge */

:root {
  --wipe-dur: 0.62s;
  --wipe-ease: cubic-bezier(0.25, 0.6, 0.3, 1);   /* starts moving immediately, settles gently */
}

.wiper-blade {
  position: fixed;
  left: 0;
  top: 0;
  width: 190vmax;
  height: 46px;                                   /* thick blade */
  box-sizing: border-box;
  background: #000;
  border-bottom: 8px solid var(--edge);           /* red edge on the leading (lower) side */
  transform-origin: 0 0;                          /* pivot = top-left corner of the screen */
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.wiper-blade.go { animation: wipe-blade var(--wipe-dur) var(--wipe-ease) both; }
@keyframes wipe-blade {
  from { opacity: 1; transform: rotate(0deg); }
  to   { opacity: 1; transform: rotate(90deg); }
}

/* Old copy of the stage, stacked right above the real one; visible only AHEAD of the blade */
.stage-ghost { pointer-events: none; }
.stage-ghost.wipe-old {
  animation: wipe-sweep var(--wipe-dur) var(--wipe-ease) both;
  -webkit-mask-image: conic-gradient(from 0deg at 0% 0%, transparent var(--wipe-a), #000 var(--wipe-a));
          mask-image: conic-gradient(from 0deg at 0% 0%, transparent var(--wipe-a), #000 var(--wipe-a));
}
/* Real stage; visible only BEHIND the blade */
.content-viewport.wipe-new {
  animation: wipe-sweep var(--wipe-dur) var(--wipe-ease) both;
  -webkit-mask-image: conic-gradient(from 0deg at 0% 0%, #000 var(--wipe-a), transparent var(--wipe-a));
          mask-image: conic-gradient(from 0deg at 0% 0%, #000 var(--wipe-a), transparent var(--wipe-a));
}
@keyframes wipe-sweep { from { --wipe-a: 90deg; } to { --wipe-a: 180deg; } }

/* =========================================================
   WHEELS (main + projects share the same look; only one shows at a time)
   ========================================================= */
.shell {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--w);
  z-index: 10;
  transition: transform 0.6s var(--swap-ease), visibility 0s 0s;
}
.main-shell { --w: var(--sb-w); }
.sub-shell {
  --w: var(--sub-w);
  visibility: hidden;
  transform: translateX(calc(-100% - 30px));
  transition: transform 0.6s var(--swap-ease), visibility 0s 0.6s;
}

/* Swap: the main wheel slides away, the projects wheel slides in */
.sub-open .main-shell {
  visibility: hidden;
  transform: translateX(calc(-100% - 30px));
  transition: transform 0.6s var(--swap-ease), visibility 0s 0.6s;
}
.sub-open .sub-shell {
  visibility: visible;
  transform: none;
  transition: transform 0.6s var(--swap-ease) 0.08s, visibility 0s 0s;
}

/* The red area follows whichever wheel is showing */
/* The light content area: a full-screen layer under the wheels. Padding keeps your content clear of
   whichever wheel is showing, and follows the wheel as it swaps. */
.content-viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
  box-sizing: border-box;
  padding-left: var(--sb-w);
  padding-right: 70px;
  transition: padding-left 0.6s var(--swap-ease);
}
.sub-open .content-viewport { padding-left: var(--sub-w); }

/* White border around the curved edge: a slightly wider white copy of the shape behind it */
.sidebar-outline {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--w) + 6px);
  height: 100%;
  background: var(--edge);
  pointer-events: none;
  clip-path: polygon(
    0% 0%, 82% 0%,
    88% 12%, 93% 25%,
    96% 38%, 97% 50%,
    96% 62%, 93% 75%,
    88% 88%, 82% 100%,
    0% 100%
  );
}

.persona-sidebar {
  width: var(--w);
  height: 100%;
  background-color: #000;
  position: relative;
  flex-shrink: 0;
  clip-path: polygon(
    0% 0%, 82% 0%,
    88% 12%, 93% 25%,
    96% 38%, 97% 50%,
    96% 62%, 93% 75%,
    88% 88%, 82% 100%,
    0% 100%
  );
}

/* Red halftone fading in from the lower right of each wheel (big dots, then small) */
.persona-sidebar::before,
.persona-sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;                 /* below the tab list (z-index 1) */
  pointer-events: none;
}
.persona-sidebar::before {
  background-image: radial-gradient(circle, rgba(211,0,0,0.75) 2.8px, transparent 3.3px);
  background-size: 16px 16px;
  -webkit-mask-image: radial-gradient(ellipse 60% 32% at 100% 92%, #000 25%, transparent 100%);
          mask-image: radial-gradient(ellipse 60% 32% at 100% 92%, #000 25%, transparent 100%);
}
.persona-sidebar::after {
  background-image: radial-gradient(circle, rgba(211,0,0,0.6) 1.5px, transparent 2px);
  background-size: 16px 16px;
  -webkit-mask-image: radial-gradient(ellipse 100% 55% at 100% 92%, transparent 45%, #000 68%, transparent 100%);
          mask-image: radial-gradient(ellipse 100% 55% at 100% 92%, transparent 45%, #000 68%, transparent 100%);
}

/* Pointer fixed at the focus line; the wheel rolls the chosen tab up to it */
.pointer {
  position: absolute;
  left: 8px;
  top: var(--focus-y);
  width: 30px;
  height: 46px;
  transform: translateY(-50%);
  background: #fff;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  z-index: 3;
  animation: pointer-nudge 1s ease-in-out infinite;
}
@keyframes pointer-nudge {
  0%, 100% { translate: 0 0; }
  50%      { translate: 6px 0; }
}

/* The wheel: positioned absolutely so JS can slide it up/down */
.menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1;                 /* above the sidebar dots */
  display: flex;
  flex-direction: column;
  gap: calc(16px * var(--wheel-scale, 1));
}
.ready .menu-list { transition: transform 0.6s var(--swap-ease); }

.menu-item {
  position: relative;
  width: max-content;
  cursor: pointer;
  isolation: isolate;
  transform: translateX(var(--item-translate)) rotate(var(--item-angle)) scale(var(--item-scale));
  transform-origin: left center;
}
.ready .menu-item {
  transition: --item-angle 0.6s var(--swap-ease),
              --item-translate 0.6s var(--swap-ease),
              --item-scale 0.6s var(--swap-ease);
}

/* Intro: tabs of the main wheel slide in one after another on page load */
.intro .main-shell .menu-item {
  animation: tab-in 0.7s var(--swap-ease) backwards;
  animation-delay: calc(var(--i, 0) * 90ms + 150ms);
}
@keyframes tab-in {
  from { translate: -130% 0; opacity: 0; }
  to   { translate: 0 0;     opacity: 1; }
}

/* Hard red offset shadow behind each button */
.menu-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--p5-red);
  transform: translate(9px, 7px);
  clip-path: polygon(2% 8%, 100% 0%, 97% 100%, 0% 92%);
  z-index: -1;
}

.menu-item a {
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
}

.plate {
  position: absolute;
  inset: 0;
  background: var(--plate-bg);
  clip-path: polygon(2% 8%, 100% 0%, 97% 100%, 0% 92%);
  z-index: 0;
  transition: background 0.4s ease;
}
.is-selected .plate { background: var(--plate-sel); }

.text-label {
  position: relative;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  height: 1.6em;
  padding: 0 calc(32px * var(--wheel-scale, 1));
  color: #fff;
  font-family: var(--p5-custom);
  font-size: calc(2.4rem * var(--wheel-scale, 1));
  line-height: 1.1;
  letter-spacing: 1px;
  white-space: nowrap;
  z-index: 1;
}

/* BACK button: pinned over the footer band of the projects wheel; red plate, white shadow, little arrow */
.sub-panel .back-item {
  position: absolute;
  left: 0;
  bottom: 7px;
  z-index: 7;
  --item-angle: -3deg;
  --item-translate: 34px;
}
.sub-panel .back-item .text-label { font-size: 1.3rem; height: 1.7em; padding: 0 24px; }
.back-item::before { background: #fff; }
.back-item .plate { background: var(--p5-red); }
.back-item .text-label::before {
  content: "";
  display: inline-block;
  margin-right: 12px;
  border: solid transparent;
  border-width: 9px 14px 9px 0;
  border-right-color: currentColor;
}

/* --- CYAN SLIDER + INVERTED TEXT --- */
.p5-morph-slider {
  position: absolute;
  inset: 0;
  background: var(--p5-cyan);
  z-index: 2;
  transform: translateX(-115%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  clip-path: polygon(3% 6%, 99% 0%, 97% 96%, 1% 100%);
}
.p5-morph-slider .text-label.inverted {
  color: #000;
  transform: translateX(115%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- HOVER / FOCUS (wobble uses the individual rotate/translate properties so it never fights the wheel's tilt) --- */
@keyframes persona-slow-twist {
  0%   { rotate: -1.2deg; translate: 0 0; }
  50%  { rotate: 1.2deg;  translate: 4px 0; }
  100% { rotate: -1.2deg; translate: 0 0; }
}
@keyframes panbg {
  0%   { clip-path: polygon(3% 6%, 99% 0%, 97% 96%, 1% 100%); }
  50%  { clip-path: polygon(0% 0%, 96% 10%, 100% 92%, 4% 94%); }
  100% { clip-path: polygon(3% 6%, 99% 0%, 97% 96%, 1% 100%); }
}
.menu-item:hover,
.menu-item:focus-within {
  animation: persona-slow-twist 2.8s infinite ease-in-out;
}
.menu-item:hover .p5-morph-slider,
.menu-item a:focus-visible .p5-morph-slider {
  transform: translateX(0);
  animation: panbg 0.6s linear infinite;
}
.menu-item:hover .p5-morph-slider .text-label.inverted,
.menu-item a:focus-visible .p5-morph-slider .text-label.inverted {
  transform: translateX(0);
}

/* --- HEADER / FOOTER BANDS (hide tabs cleanly as the wheel rolls past the ends) --- */
.wheel-header,
.wheel-footer {
  position: absolute;
  left: 0;
  right: 0;
  background: #000;
  z-index: 6;
}
.wheel-header {
  top: 0;
  height: 118px;
  box-sizing: border-box;
  padding: 28px 0 0 36px;
}
.wheel-footer {
  bottom: 0;
  height: 60px;
}
.wheel-header::after,
.wheel-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 9px;
  background: var(--p5-red);
}
.wheel-header::after { bottom: -9px; clip-path: polygon(0 0, 100% 0, 90% 100%, 0 45%); }
.wheel-footer::before { top: -9px; clip-path: polygon(0 55%, 90% 0, 100% 100%, 0 100%); }

.brand-name {
  display: flex;
  align-items: center;
  font-family: var(--p5-custom);
  /* Full 1.5rem when the wheel is wide; shrinks with the wheel so the name always fits inside the curved edge.
     Reads as: (82% of wheel width - left padding - spare room) / roughly how many "ems" wide the name is. */
  font-size: min(1.5rem, calc((var(--w, 500px) * 0.82 - 64px) / 14));
  line-height: 1;
  letter-spacing: 1px;
  color: #fff;
  transform: rotate(-3deg);
  transform-origin: left center;
  white-space: nowrap;
}
.brand-tag {
  display: inline-block;
  margin-top: 10px;
  padding: 2px 16px 2px 12px;
  background: var(--p5-red);
  color: #fff;
  font-family: var(--p5-label-font);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 4px;
  clip-path: polygon(0 0, 100% 0, 94% 100%, 0 100%);
  transform: rotate(-3deg);
  transform-origin: left center;
}

/* --- PROJECTS WHEEL: narrower, smaller text, smaller blue selection box --- */
.sub-panel .pointer { width: 22px; height: 34px; }
.sub-panel .menu-list { gap: calc(16px * var(--wheel-scale, 1)); }
.sub-panel .text-label { font-size: calc(1.7rem * var(--wheel-scale, 1)); height: 1.65em; padding: 0 calc(28px * var(--wheel-scale, 1)); }
.sub-panel .menu-item::before { transform: translate(6px, 5px); }
.sub-panel .wheel-header { height: 100px; padding: 24px 0 0 30px; }
.sub-panel .wheel-footer { height: 64px; }
.sub-panel .brand-name { font-size: 1.35rem; }
.sub-panel .brand-tag { font-size: 0.9rem; letter-spacing: 3px; margin-top: 8px; }
.sub-panel .back-item .text-label::before { border-width: 6px 10px 6px 0; margin-right: 9px; }

@media (prefers-reduced-motion: reduce) {
  .pointer,
  .menu-item:hover,
  .menu-item:focus-within,
  .menu-item:hover .p5-morph-slider,
  .intro .main-shell .menu-item { animation: none; }
  .ready .menu-list, .ready .menu-item,
  .shell, .sub-open .shell, .content-viewport { transition: none; }
  .wiper-blade { display: none; }
}

/* =========================================================
   RANSOM-NOTE LETTERS (Persona 5 menu style)
   Stand-ins for the fonts suggested in the screenshot, all open-licensed:
   f0 Times New Roman -> Tinos Bold        f3 Clarendon     -> Alfa Slab One
   f1 Cooper Black    -> Caprasimo         f4 Futura        -> Jost ExtraBold
   f2 Avant Garde     -> Montserrat 800    f5 Helvetica Now -> Archivo Black
   Noto Sans is the fallback for accents / odd characters.
   ========================================================= */
.rl {
  display: inline-block;
  flex: none;
  font-size: calc(1em * var(--s, 1));
  line-height: 1;
  white-space: pre;
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
}
.rl-space { display: inline-block; flex: none; width: 0.32em; overflow: hidden; }

.f0 { font-family: 'Tinos', 'Times New Roman', 'Noto Sans', serif;               font-weight: 700; }
.f1 { font-family: 'Caprasimo', 'Cooper Black', 'Noto Sans', serif;              font-weight: 400; }
.f2 { font-family: 'Montserrat', 'ITC Avant Garde Gothic', 'Noto Sans', sans-serif; font-weight: 800; }
.f3 { font-family: 'Alfa Slab One', 'Clarendon', 'Noto Sans', serif;             font-weight: 400; }
.f4 { font-family: 'Jost', 'Futura', 'Noto Sans', sans-serif;                    font-weight: 800; }
.f5 { font-family: 'Archivo Black', 'Helvetica Neue', 'Noto Sans', sans-serif;   font-weight: 400; }

/* Highlight styles. Normal copy on the left, the cyan "inverted" copy on the right. */
.rl.sA { color: #fff; }
.rl.sB { color: #000; background: #fff; }
.rl.sC { color: #fff; background: var(--p5-red); }
.rl.sB, .rl.sC { padding: 0.03em 0.1em; margin: 0 0.04em; }

.text-label.inverted .rl.sA { color: #000; }
.text-label.inverted .rl.sB { color: #fff; background: #000; }
.text-label.inverted .rl.sC { color: var(--p5-red); background: #fff; }

/* =========================================================
   PAGES (the content inside the light area)
   Each .page is one tab's content. Only .is-active is shown.
   ========================================================= */
.page {
  display: none;
  box-sizing: border-box;
  height: 100%;
  overflow-y: auto;
  /* top/bottom clear the black frame strips; right clears the wall + vertical watermark */
  padding: 100px 140px 100px 48px;
  font-family: 'Noto Sans', Arial, sans-serif;
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.65;
  color: #1a1a1a;
  scrollbar-width: thin;
  scrollbar-color: var(--p5-red) transparent;
}
.page.is-active { display: block; }
.page > * { max-width: 860px; }

/* Page title: white ransom-style box with a red shadow */
.page-title {
  margin: 0 0 22px;
  font-family: var(--p5-font);
  font-weight: 400;
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  line-height: 1.1;
  text-transform: uppercase;
}
.page-title span {
  display: inline-block;
  padding: 6px 18px 8px;
  background: #fff;
  color: #000;
  transform: rotate(-1.8deg);
  box-shadow: 8px 8px 0 var(--p5-red);
}

.page h2 {
  margin: 34px 0 8px;
  font-family: var(--p5-font);
  font-weight: 400;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: var(--p5-red);
}
.page h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.page h3 small { font-weight: 400; font-size: 0.9rem; opacity: 0.7; margin-left: 8px; }
.page p { margin: 0 0 14px; }
.page .lead { font-size: 1.3rem; font-weight: 700; line-height: 1.4; }

/* Images. Wrap each in <figure class="shot"> so they get the frame + shadow. */
.shot {
  position: relative;
  margin: 22px 0;
  background: #cfcdc7;
  border: 4px solid #000;
  box-shadow: 8px 8px 0 var(--p5-red);
  overflow: hidden;
}
.shot img { display: block; width: 100%; height: auto; }
.shot.wide { aspect-ratio: 16 / 9; }
.shot.wide img, .shot.portrait img { height: 100%; object-fit: cover; }
.shot.portrait { aspect-ratio: 3 / 4; margin-top: 6px; }
/* Placeholder shown when the image file isn't there yet */
.shot.missing img { display: none; }
.shot.missing { min-height: 160px; }
.shot.missing::after {
  content: attr(data-label);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--p5-font);
  font-size: 0.95rem;
  color: rgba(0, 0, 0, 0.45);
}

/* Layout helpers */
.two-col { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 40px; align-items: start; }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 24px; margin-top: 30px; }
.gallery .shot { margin: 0; aspect-ratio: 4 / 3; }
.gallery .shot img { height: 100%; object-fit: cover; }

/* Resume entries */
.entry { margin-bottom: 18px; padding-left: 16px; border-left: 5px solid var(--p5-red); }
.entry .when { display: block; font-size: 0.85rem; opacity: 0.65; margin-bottom: 4px; }
.entry p { margin: 0; }

/* Skill tags */
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.tags li { padding: 4px 14px; background: #000; color: #fff; font-weight: 700; font-size: 0.9rem; transform: rotate(-1deg); }
.tags li:nth-child(even) { background: var(--p5-red); transform: rotate(1deg); }

/* Contact links + button */
.links { list-style: none; margin: 24px 0 0; padding: 0; }
.links li { margin-bottom: 14px; }
.links a, .button {
  display: inline-block;
  padding: 8px 20px;
  background: #000;
  color: #fff;
  font-family: var(--p5-font);
  font-size: 1.05rem;
  text-decoration: none;
  transform: rotate(-1.2deg);
  box-shadow: 6px 6px 0 var(--p5-red);
  transition: transform 0.15s, box-shadow 0.15s;
}
.links a:hover, .button:hover { transform: rotate(0) translate(-2px, -2px); box-shadow: 9px 9px 0 var(--p5-red); }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Cleaner, more professional title variant (add class="pro" to any .page-title).
   Montserrat is already loaded in the Google Fonts link. */
.page-title.pro {
  font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.page {
  /* Keeps the page column at most 940px wide (so the scrollbar sits at the edge of your content on big
     screens) but always leaves at least 120px on the right for the watermark on smaller laptops. */
  margin-right: max(120px, calc(100% - 940px));
  padding-right: 20px;
}

.entry ul { margin: 6px 0 0; padding-left: 20px; }
.entry li { margin-bottom: 4px; }

.shot figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 12px;
  background: #000;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.3;
}

/* Forces a gallery into exactly 2 columns (add class="gallery two-by-two") */
.gallery.two-by-two {
  grid-template-columns: repeat(2, 1fr);
}

/* Stack to a single column on narrow screens */
@media (max-width: 600px) {
  .gallery.two-by-two { grid-template-columns: 1fr; }
}

/* Shows an image at its own proportions, never cropped and never stretched past its real size */
.shot.native {
  width: fit-content;
  max-width: 860px;
}
.shot.native img {
  width: auto;
  max-width: 100%;
  height: auto;
}
/* Caption sits below the image instead of on top, so it can't cover graph labels */
.shot.native figcaption {
  position: static;
}

/* First photo fills the whole left column; the other two stack on the right.
   Add class="gallery feature-left" to a gallery of 3 photos. */
.gallery.feature-left {
  grid-template-columns: repeat(2, 1fr);
}
.gallery.feature-left .shot:first-child {
  grid-row: 1 / span 2;   /* spans both rows */
  aspect-ratio: auto;     /* height comes from the two stacked photos instead */
}
.gallery.feature-left .shot:first-child img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* On narrow screens, stack everything in one column */
@media (max-width: 600px) {
  .gallery.feature-left { grid-template-columns: 1fr; }
  .gallery.feature-left .shot:first-child {
    grid-row: auto;
    aspect-ratio: 4 / 3;
  }
}

/* Wider image column for a two-column layout (add class="two-col wide-left") */
.two-col.wide-left {
  grid-template-columns: minmax(220px, 40%) 1fr;
}
/* Line the image and the text up at the top */
.two-col.wide-left > .shot { margin: 6px 0 0; }
.two-col.wide-left h2:first-child { margin-top: 0; }

/* Third photo fills the whole right column; the first two stack on the left.
   Add class="gallery feature-right" to a gallery of 3 photos. */
.gallery.feature-right {
  grid-template-columns: repeat(2, 1fr);
}
.gallery.feature-right .shot:nth-child(1) { grid-column: 1; grid-row: 1; }
.gallery.feature-right .shot:nth-child(2) { grid-column: 1; grid-row: 2; }
.gallery.feature-right .shot:nth-child(3) {
  grid-column: 2;
  grid-row: 1 / span 2;   /* spans both rows */
  aspect-ratio: auto;     /* height comes from the two stacked photos instead */
}
.gallery.feature-right .shot:nth-child(3) img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* On narrow screens, stack everything in one column */
@media (max-width: 600px) {
  .gallery.feature-right { grid-template-columns: 1fr; }
  .gallery.feature-right .shot:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 4 / 3;
  }
}

/* Makes every photo in a gallery tall and narrow (add class="gallery tall") */
.gallery.tall .shot {
  aspect-ratio: 3 / 4;
}

/* Space below the tall gallery, before the text that follows */
.gallery.tall {
  margin-bottom: 44px;
}

/* =========================================================
   MOBILE / SMALL SCREENS
   Applies to phones, tablets, and short or narrow browser windows. The wheels are hidden and a header
   with a strip of tabs takes over; the script keeps that strip in sync with the real tabs.
   ========================================================= */
.mobile-header { display: none; }

@media (max-width: 1100px), (max-height: 520px) {
  :root {
    --sb-w: 100vw;    /* the (hidden) wheels shrink to the screen so nothing sticks out sideways */
    --sub-w: 100vw;
    --mh: 108px;      /* height of the mobile header */
  }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { height: 100dvh; }

  /* Wheels, watermark and the top frame strip are replaced by the header */
  .shell { visibility: hidden !important; pointer-events: none !important; }
  .watermark { display: none; }
  .frame-top { display: none; }
  .frame-black { height: 12px; }
  .frame-edge  { height: 17px; }
  .edge-line-r { --wall-bottom: 6px; --wall-lean: 10px; --wall-border: 3px; }

  /* Content area: full screen, no wheel padding */
  .content-viewport,
  .sub-open .content-viewport {
    position: fixed;
    padding: 0;
    transition: none;
  }
  .page {
    max-width: 900px;
    margin: 0 auto;
    /* top clears the header, bottom clears the bottom frame strip, right clears the slim wall */
    padding: calc(var(--mh) + 28px) 30px 56px 20px;
    font-size: 1rem;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Header ---- */
  .mobile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--mh);
    box-sizing: border-box;
    padding: 8px 0 0 16px;
    background: #000;
    z-index: 10;
  }
  .mobile-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -9px;
    height: 9px;
    background: var(--p5-red);
    clip-path: polygon(0 0, 100% 0, 90% 100%, 0 45%);
  }
  .mobile-brand { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; height: 30px; }
  .mobile-brand .brand-name { font-size: 1.15rem; }
  .mobile-brand .brand-tag { margin-top: 0; font-size: 0.75rem; letter-spacing: 3px; padding: 1px 12px 1px 9px; }

  /* ---- Tab strips (main tabs, or BACK + projects) ---- */
  .mnav {
    display: none;
    position: relative;               /* so the script can measure tab positions */
    flex: 1 1 100%;
    min-width: 0;
    gap: 16px;
    padding: 6px 36px 14px 4px;       /* room for the red tab shadows and the end fade */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .mnav::-webkit-scrollbar { display: none; }
  .mnav-main { display: flex; }
  .sub-open .mnav-main { display: none; }
  .sub-open .mnav-sub  { display: flex; }

  .mnav .menu-item { flex: none; --item-angle: -2deg; -webkit-tap-highlight-color: transparent; }
  .mnav .menu-item:nth-child(even) { --item-angle: 1.5deg; }
  .mnav .menu-item::before { transform: translate(5px, 5px); }
  .mnav .menu-item:hover,
  .mnav .menu-item:focus-within { animation: none; }   /* no stuck wobble after a tap */
  .mnav .text-label { font-size: 1.05rem; height: 44px; padding: 0 16px; }
  .mnav .back-item .text-label::before { border-width: 6px 10px 6px 0; margin-right: 8px; }
  /* Selected tab = the cyan highlight (same look as hovering on desktop) */
  .mnav .is-selected .p5-morph-slider,
  .mnav .is-selected .p5-morph-slider .text-label.inverted { transform: translateX(0); }

  /* Tabs slide in on load, like the wheel does on desktop */
  .intro .mnav-main .menu-item { animation: tab-in 0.7s var(--swap-ease) backwards; animation-delay: 150ms; }
  .intro .mnav-main .menu-item:nth-child(2) { animation-delay: 240ms; }
  .intro .mnav-main .menu-item:nth-child(3) { animation-delay: 330ms; }
  .intro .mnav-main .menu-item:nth-child(4) { animation-delay: 420ms; }
  .intro .mnav-main .menu-item:nth-child(5) { animation-delay: 510ms; }

  /* ---- Page content ---- */
  .page-title { font-size: clamp(1.25rem, 6.4vw, 2rem); margin-bottom: 16px; }
  .page-title span { padding: 5px 14px 7px; box-shadow: 6px 6px 0 var(--p5-red); }
  .page h2 { margin-top: 28px; font-size: 1.15rem; }
  .page .lead { font-size: 1.15rem; }
  .page h3 small { display: block; margin-left: 0; }
  .entry { padding-left: 12px; }

  .shot { border-width: 3px; box-shadow: 6px 6px 0 var(--p5-red); }
  .shot.portrait { max-width: 260px; }
  .shot.native { max-width: 100%; }
  .two-col,
  .two-col.wide-left { grid-template-columns: 1fr; gap: 20px; }   /* also stacks the CH Controllers layout */
  .gallery { gap: 20px; margin-top: 22px; }
  .gallery.tall { margin-bottom: 30px; }
}

/* Wide enough for one row: brand on the left, tabs beside it (landscape phones, tablets) */
@media (min-width: 700px) and (max-width: 1100px), (min-width: 700px) and (max-height: 520px) {
  :root { --mh: 76px; }
  .mobile-header { flex-wrap: nowrap; padding-top: 0; }
  .mobile-brand { height: auto; }
  .mnav { flex: 1 1 0; }
}

/* Phones in portrait: stack the tall Home gallery */
@media (max-width: 600px) {
  .gallery.tall { grid-template-columns: 1fr; }
  .gallery.tall .shot { aspect-ratio: 4 / 3; }
}

@media (prefers-reduced-motion: reduce) {
  .intro .mnav-main .menu-item { animation: none; }
}

/* Home page hero image: shaped to match the rocket photo (1600x1271) so nothing is cropped.
   max-width keeps it about as tall as the old 16:9 banner; it shrinks to fit on small screens. */
.shot.hero {
  aspect-ratio: 1600 / 1271;
  max-width: 610px;
}
.shot.hero img {
  object-position: 50% 50%;
}