@media (min-width: 561px) {
  :root { --mast-height: 56px; }
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
:root { scrollbar-gutter: stable; }

.home, .project-page {
  --intro-column: max(365px, 38%);
  --copy-width: 660px;
  --copy-padding: clamp(28px, 3.2vw, 55px);
  /* The copy is centred within the first grid column once it reaches its maximum width. */
  --content-start: calc(max(0px, (var(--intro-column) - var(--copy-width)) / 2) + var(--copy-padding));
}

.home-intro {
  /* The mast has a one-pixel border outside its inner height. Reserve the
     same playable frame on every route, even when a report follows it. */
  --opening-height: calc(100dvh - var(--mast-height) - 1px - var(--dock-height));
  display: grid;
  grid-template-columns: var(--intro-column) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  block-size: var(--opening-height);
  background: #211e30;
}

.home-intro-copy {
  justify-self: center;
  width: min(100%, var(--copy-width));
  padding: var(--copy-padding);
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  overflow-y: auto;
  min-block-size: 0;
}
.home-intro-copy > * { flex: none; }

.home-location, .home-scene-label {
  font: 600 11px/1.4 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.home-location { color: var(--rose); }
.home-intro h1 {
  margin: .22em 0 .16em;
  font: 600 clamp(39px, 3.45vw, 57px)/1.05 var(--pixel);
  letter-spacing: -.045em;
}
.home-intro h1 em { color: var(--moon); font-style: normal; }
.home-role { font-weight: 600; color: #efbdba; font-size: clamp(17px, 1.25vw, 21px); }
.home-bio {
  margin: 1.15em 0 1.5em;
  max-width: 48ch;
  font-size: clamp(16px, 1.12vw, 18px);
  line-height: 1.65;
  color: #f1e3df;
  text-wrap: pretty;
}
.home-bio p + p { margin-top: 1.1em; }
/* Preserve the actions when text settings or a short window limit the reading area. */
.home-intro-copy > .home-bio { flex-shrink: 1; min-block-size: 3.3em; overflow-y: auto; }
.home .home-bio { max-width: 56ch; line-height: 1.5; margin-block: .85em 1em; }
.home .home-bio p + p { margin-top: .8em; }
@media (min-width: 821px) and (max-width: 1450px) and (max-height: 820px) {
  .home, .project-page { --copy-padding: clamp(18px, 2vw, 28px); }
}
.home-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.chapter-spread .home-actions { align-items: stretch; }
.home .home-actions { flex-direction: column; align-items: flex-start; gap: 6px; }
.career-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.career-actions .home-next { min-height: 52px; gap: 10px; padding-inline: 12px; }
.career-actions .next-words strong { font-size: clamp(18px,1.6vw,24px); }
.project-walk-link { display: inline-flex; align-items: center; gap: .4em; min-height: 36px; color: var(--aqua); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

.home-next {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 67px;
  padding: 9px 15px 12px 18px;
  color: #352637;
  filter: drop-shadow(3px 4px 0 #100f1c);
}
.home-next::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #ffe1ab;
  box-shadow: inset 0 3px #fff3ce, inset 0 -5px #b99589;
  clip-path: polygon(0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px));
}
.home-next:hover, .home-next:focus-visible { color: #211e30; }
.home-next:hover::before, .home-next:focus-visible::before { background: #ffebc2; }
.home-next:active { translate: 1px 2px; }
.next-words { display: grid; gap: 4px; }
.next-words strong { font: 650 25px/1 var(--pixel); letter-spacing: -.04em; }
.next-words small { font: 600 11px/1.2 var(--mono); }
.next-arrow {
  display: block;
  width: 18px;
  height: 18px;
  background: #514056;
  clip-path: polygon(0 33%, 50% 33%, 50% 0, 66% 0, 66% 16%, 83% 16%, 83% 33%, 100% 33%, 100% 66%, 83% 66%, 83% 83%, 66% 83%, 66% 100%, 50% 100%, 50% 66%, 0 66%);
}

.home-actions .evidence-link {
  min-height: 44px;
  padding: 8px 12px;
  gap: 6px;
  font-size: 18px;
  color: var(--ink);
  background: #292537;
  border-color: #a78e9e;
}
.home-actions .evidence-link:hover { background: #3b334a; }
.home-actions .action-arrow { width: auto; height: auto; background: none; color: inherit; font: inherit; }
@media (min-width: 821px) and (max-width: 1200px) and (max-height: 820px) {
  .home-bio { margin-block: .9em 1.1em; line-height: 1.55; }
  .home-actions { flex-wrap: nowrap; gap: 10px; }
  .home-actions .evidence-link { flex-shrink: 1; min-width: 0; padding-inline: 8px; }
  .home-next { flex: none; gap: 10px; padding-inline: 12px; }
  .next-words strong { font-size: 23px; }
}

.home-scenery {
  --quay-depth: clamp(8px, 4vh, 44px);
  position: relative;
  container-type: inline-size;
  overflow: hidden;
  border-left: 1px solid #756177;
  background: #29344b url("/assets/quay-bricks.svg") repeat center bottom / 52px 20px;
}
.home-sky {
  position: absolute;
  inset: 0 0 var(--waterline, calc(var(--quay-depth) + 13.8cqw));
  overflow: hidden;
  background: linear-gradient(to bottom, #20233e 0 12%, #282a46 12% 26%, #35324f 26% 41%, #493b5b 41% 56%, #614b69 56% 69%, #805b78 69% 81%, #a87589 81% 92%, #c3949c 92%);
}
.home-sky::before {
  content: ""; position: absolute; inset: 0;
  background: url("/assets/dusk-stars.svg") repeat-x center top / max(100%, 600px) 76%;
  mask-image: linear-gradient(#000, #000a 60%, transparent);
}
.river-moon, .river-cloud {
  position: absolute; display: block; background-size: 100% 100%; image-rendering: pixelated;
}
.river-moon {
  width: clamp(54px, 11cqw, 150px); aspect-ratio: 1;
  top: 22%; right: 18%; background-image: url("/assets/dusk-moon.svg");
}
.river-cloud { width: 17%; aspect-ratio: 82 / 21; background-image: url("/assets/dusk-cloud.svg"); }
.river-cloud:nth-child(2) { top: 31%; left: -3%; }
.river-cloud:nth-child(3) { top: 42%; right: 8%; width: 20%; }
.river-cloud:nth-child(4) { top: 20%; left: 39%; width: 9%; }
.home-panorama { position: absolute; bottom: var(--quay-depth); width: 118%; left: 0; transform: translateX(-4.65%); }
.home-panorama img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.home-scene-label {
  position: absolute; top: 15px; left: 17px; padding: 5px 9px;
  color: #f2c9c0; background: #252234; font-size: 10px;
}
.chapter-spread .evidence-link { background: #b6d9d0; color: #18282c; border-color: #d4eee2; }
.chapter-spread .evidence-link:hover { color: #18282c; background: #d4eee2; }
.project-scene { --quay-depth: clamp(8px,3vh,30px); --terrain-width: max(116cqw,530px); --waterline: calc(var(--quay-depth) + var(--terrain-width) * .112); }
.walk-surface { position: absolute; inset: 0; overflow: hidden; }
.walk-surface[data-ready] { cursor: crosshair; }
.walk-surface:focus-visible { outline-offset: -4px; z-index: 1; }
.project-terrain { position: absolute; left: 0; bottom: var(--quay-depth); width: var(--terrain-width); }
.project-terrain img { width: 100%; height: auto; display: block; image-rendering: pixelated; }
.home-scenery .home-scene-label, .scene-toggle, .walk-hint { z-index: 2; }
.home-scenery .home-scene-label, .walk-hint { pointer-events: none; }
.home-scene-label b { color: var(--moon); }
.scene-toggle, .walk-hint {
  position: absolute; color: #f2e2db; background: #262336; border: 1px solid #76667c;
  padding: 6px 9px; font: 600 10px/1.3 var(--mono);
}
.scene-toggle { top: 12px; right: 14px; min-height: 34px; }
.scene-toggle:hover { background: #42384c; }
/* The control rail is separate from the gameplay surface: multi-touch on
   the buttons never hijacks vertical scrolling through the portfolio. */
.scene-pad { position:absolute; z-index:3; bottom:5px; inset-inline:9px; display:flex; gap:10px; align-items:center; justify-content:space-between; }
.scene-pad .walk-hint { position:static; color:#c5dcd7; pointer-events:none; text-align:center; }
.keyboard-tip, .exit-tip { display:block; }
.exit-tip { color:#f0d7ab; }
.run-pair { display:flex; gap:5px; }
.scene-pad button { touch-action:none; user-select:none; -webkit-user-select:none; min-width:42px; min-height:38px; border:1px solid #908195; border-bottom:3px solid #6d607b; background:#292638; color:#f5e0b5; font:600 17px/1 var(--pixel); }
.scene-pad button:active, .scene-pad button[data-down] { color:#242134; background:#c4ded6; border-color:#7c9ca0; }
.scene-pad .jump-key { padding-inline:10px; }
.home-scenery { --quay-depth:clamp(35px,4vh,46px); }
.project-scene { --quay-depth:clamp(35px,4vh,46px); }
.scene-curtain { position:absolute; z-index:5; inset:0; pointer-events:none; background:#080710; opacity:0; transition:opacity 160ms linear; }
[data-cut] .scene-curtain { opacity:1; }
@media (pointer:coarse), (max-width: 760px) {
  .scene-pad button { min-height:44px; min-width:46px; }
  .scene-pad .walk-hint { padding:4px 7px; font-size:9px; }
  .keyboard-tip { display:none; }
  .home-scenery { --quay-depth:43px; }
}
@media (prefers-reduced-motion:reduce) { .scene-curtain { transition:none; } }

/* Poses are drawn on the sprite grid. The balloon lives in screen space so
   words stay legible on a phone and never mirror when George turns around. */
[data-pose="wave"] .arm-rest, [data-pose="watch"] .arm-rest { display: none; }
[data-pose="wave"] .arm-wave, [data-pose="watch"] .arm-watch { display: inline; }
[data-pose="watch"] .sprite-head { transform: translate(1px,1px); }
.actor-bubble {
  position: absolute; pointer-events: none; width: max-content; padding: 6px 10px;
  background: #ffe9bd; color: #342839; font: 600 clamp(16px,1.2vw,21px)/1.12 var(--pixel);
  box-shadow: 0 -2px #372f41, -2px 0 #372f41, 2px 0 #372f41, 0 2px #372f41, 3px 4px #3b304b66;
}
.actor-bubble::after {
  content: ""; position: absolute; left: var(--tail); top: 100%; width: 5px; height: 5px;
  background: #ffe9bd; box-shadow: -2px 1px #372f41, 2px 2px #372f41, 0 4px #372f41;
}
.daydream { display: none; }
[data-pose="think"] .actor-bubble {
  color: #e3f0e9; background: #383344; border: 2px solid #b2cfc9;
  box-shadow: 0 -2px #383344, -2px 0 #383344, 2px 0 #383344, 0 2px #383344;
  font: 11px/1.1 var(--mono);
}
[data-pose="think"] .actor-bubble::after { width: 4px; height: 4px; top: calc(100% + 3px); background: #b6d9d0; box-shadow: -4px 5px 0 -1px #b6d9d0; }
[data-pose="think"] .greeting { display: none; }
[data-pose="think"] .daydream { display: flex; align-items: center; gap: 7px; }
@media (prefers-reduced-motion: no-preference) {
  [data-animated][data-pose="wave"] .arm-wave { animation: wave-hand .45s steps(1,end) 4; }
  [data-animated][data-pose="watch"] .sprite-head { animation: check-time 2.2s steps(1,end) 1; }
  [data-animated]:is([data-pose="tap"],[data-pose="watch"]) .leg.r { animation: tap-shoe .48s steps(1,end) 5; }
}
[data-animated][data-pose="think"] .dream-accent { animation: dream-detail .95s steps(1,end) 3; }
@keyframes dream-detail { 50% { transform: translate(1px,-1px); } }
@keyframes wave-hand { 50% { transform: translate(1px,-1px); } }
@keyframes check-time { 0%,95% { transform: none; } 20%,75% { transform: translate(1px,2px); } }
@keyframes tap-shoe { 45% { transform: translate(1px,-2px); } 70% { transform: translate(0,-1px); } }
@media (max-width: 820px) {
  .home, .project-page {
    --intro-column: 100%;
    --copy-padding: clamp(20px, 4.4vw, 34px);
  }
  .home-intro {
    --scene-height: clamp(215px,50vw,350px);
    /* At phone widths the longer paragraphs need more lines before the scene. */
    --copy-height: max(34rem, calc(75rem - 145vw));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) var(--scene-height);
    block-size: max(var(--opening-height), calc(var(--copy-height) + var(--scene-height)));
  }
  .home .home-intro {
    block-size: auto;
    min-block-size: max(var(--opening-height), calc(var(--copy-height) + var(--scene-height)));
    grid-template-rows: minmax(max-content,1fr) var(--scene-height);
  }
  .home .home-intro-copy > .home-bio { flex: none; overflow: visible; }
  .home-intro h1 { font-size: clamp(35px, 7vw, 46px); }
  .home-role { font-size: 17px; }
  .home-bio { font-size: 16px; max-width: 62ch; }
  .home-actions { flex-wrap: nowrap; }
  .home-actions .evidence-link { flex-shrink: 1; min-width: 0; }
  .home-next { flex: none; }
  .home-scenery { border: 0; border-top: 1px solid #635269; }
  .home-scene-label { top: 8px; left: 9px; font-size: 9px; }
  .scene-toggle { top: 6px; right: 8px; }
}
@media (max-width: 420px) {
  .home-actions { gap: 11px; }
  .home-next { min-height: 62px; gap: 9px; padding-inline: 12px; }
  .next-words strong { font-size: 22px; }
  .next-words small { font-size: 10px; }
  .home-actions .evidence-link { font-size: 16px; padding-inline: 8px; }
}
