/* The supplied illustration is the coordinate system for the living room. */
:root { --scene-width: max(100vw, calc(100svh * 2.041)); --u: calc(var(--scene-width) / 1792); }
html { zoom: 1; background: #302418; color: #29251c; }
body { padding: 0; overflow-x: clip; }
html { overflow-x: clip; }
.studio { position: relative; width: var(--scene-width); height: calc(var(--scene-width) * .489955); margin-left: calc((100% - var(--scene-width)) / 2); }
.room { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.room-art { position: absolute; inset: 0; background: url("assets/studio-room.jpg") center / 100% 100% no-repeat; }
.room-layers { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sketchbook { position: absolute; left: 30.8%; top: 9.55%; bottom: 0; width: 49.3%; max-width: none; margin: 0; border: 0; display: grid; grid-template-columns: calc(114 * var(--u)) minmax(0,1fr); grid-template-rows: calc(34 * var(--u)) minmax(0,1fr); background: transparent; transform: skewY(-.85deg); transform-origin: top left; overflow: hidden; }
.sketchbook::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3; background: linear-gradient(123deg,#e3a74116,transparent 25%,#fff8d411 55%,#8b61340a); box-shadow: inset 0 8px 12px -10px #5e4839; }
.topbar { height: calc(34 * var(--u)); min-height: 0; margin: 0; padding: 0 calc(20 * var(--u)); gap: calc(20 * var(--u)); font-size: calc(13 * var(--u)); flex-wrap: nowrap; background-color: transparent; background-size: 100% calc(2 * var(--u)); }
.brand { font-family: "Patrick Hand",cursive; }
.contact { min-height: 0; gap: calc(4 * var(--u)); padding: 0 calc(7 * var(--u)); font-size: calc(13 * var(--u)); border-width: 1px; background-color: #fff8df; border-image-width: 3px; box-shadow: 1px 1px #463f3b30; }
.contact img { width: calc(13 * var(--u)); height: calc(13 * var(--u)); mix-blend-mode: multiply; }
.github { background-size: 100% 2px; }
.sidebar { position: static; min-height: 0; padding: calc(17 * var(--u)) calc(9 * var(--u)) 0; }
nav { display: grid; gap: calc(5 * var(--u)); background: none; box-shadow: none; }
nav button { width: 100%; min-height: calc(34 * var(--u)); padding: calc(5 * var(--u)) calc(11 * var(--u)); font-size: calc(15 * var(--u)); }
nav button::before, nav button::after { inset: -2px; }
main { padding: 0 calc(8 * var(--u)) calc(12 * var(--u)) calc(10 * var(--u)); background-color: #fcf4d9; background-size: calc(2 * var(--u)) 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #87795850 transparent; container-type: normal; }
.intro { min-height: calc(64 * var(--u)); flex-direction: row; align-items: center; padding: 0; gap: calc(10 * var(--u)); }
.intro-title { gap: calc(10 * var(--u)); width: auto; }
h1 { font: calc(39 * var(--u))/1.25 Kalam,cursive; }
h1::after { height: calc(4 * var(--u)); bottom: calc(5 * var(--u)); background: #d38d3f; clip-path: polygon(0 35%,100% 0,100% 45%,0 100%); }
.heading-art { width: calc(58 * var(--u)); flex-basis: calc(58 * var(--u)); mix-blend-mode: multiply; }
.intro > p { font-size: calc(14 * var(--u)); margin: 0; }
.result { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.projects { gap: calc(5 * var(--u)); grid-template-columns: repeat(3,minmax(0,1fr)); scroll-margin-top: 0; }
.project { padding: calc(5 * var(--u)) calc(12 * var(--u)) calc(3 * var(--u)); height: calc(148 * var(--u)); border-width: 1px; border-image-width: calc(4 * var(--u)); background: #fffbed80; }
.project::after { border-image-width: 4px; box-shadow: 0 3px 8px #49341620; }
.project-art { height: calc(88 * var(--u)); flex-shrink: 0; width: calc(176 * var(--u)); max-width: 100%; margin: 0 auto; aspect-ratio: 2; clip-path: none; mix-blend-mode: multiply; }
.project { animation: none; }
h2, .project h2 { font: calc(15 * var(--u))/1.15 "Patrick Hand",cursive; padding: 0; }
.project > p { margin: 0; font-size: calc(12 * var(--u)); line-height: 1.15; }
.links { gap: calc(8 * var(--u)); font-size: calc(12 * var(--u)); line-height: 1.1; }
.links a { padding: calc(1 * var(--u)) 0; background-size: 65% 2px; }
.links a + a { padding-left: calc(12 * var(--u)); }
.links a + a::before { width: 2px; }
footer { padding: calc(12 * var(--u)) 0; font-size: calc(13 * var(--u)); }
.skip-link { z-index: 30; font-size: 16px; background: #fff8df; }
@media (max-width: 900px), (max-aspect-ratio: 6/5) {
  :root { --scene-width: 1200px; --u: 1px; --mobile-header: 108px; }
  body { background: #302418; }
  .studio { width: 100%; height: auto; min-height: 100svh; margin: 0; padding: var(--mobile-header) 14px 24px; }
  .room { position: absolute; inset: 0 auto auto 50%; width: 1200px; height: 588px; transform: translateX(-345px); }
  /* Keep the cat intact; blend the room into the mobile page instead of
     cutting a hard silhouette out of the painting. */
  .room {
    clip-path: none;
    -webkit-mask-image: linear-gradient(#000 0 70px, transparent 125px);
    mask-image: linear-gradient(#000 0 70px, transparent 125px);
  }
  .sketchbook { min-width: 0; }
  .motion-toggle { position: relative; display: flex; width: fit-content; margin: 0 14px 16px auto; inset: auto; }
  .motion-toggle[hidden] { display: none; }
  .sketchbook { position: relative; left: auto; top: auto; bottom: auto; width: 100%; transform: none; grid-template-columns: minmax(0,1fr); grid-template-rows: auto; border: 8px solid #332d2a; border-radius: 14px 14px 7px 7px; background: #fcf4d9; box-shadow: 0 0 0 2px #8e7254,0 16px 60px #0008; overflow: clip; }
  .topbar { height: auto; min-height: 48px; margin: 0 12px; gap: 14px; padding: 4px; font-size: 18px; }
  .contact { font-size: 16px; padding: 4px 7px; }
  .contact img { width: 16px; height: 16px; }
  .sidebar { padding: 12px 14px 10px; }
  nav { display: flex; flex-wrap: wrap; gap: 6px; }
  nav button { width: auto; min-height: 44px; padding: 8px 12px; font-size: 17px; }
  main { overflow: visible; background: none; padding: 0 14px 18px; }
  .intro { min-height: 75px; flex-wrap: wrap; gap: 0; padding-bottom: 12px; }
  h1 { font-size: clamp(30px, 8.5vw, 38px); }
  .heading-art { width: 42px; flex-basis: 42px; }
  .intro > p { font-size: 15px; }
  .projects { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .project { height: auto; padding: 10px 12px 4px; }
  .project-art { display: block; width: 100%; height: auto; aspect-ratio: auto; }
  .project h2 { font-size: 21px; }
  .project > p { font-size: 16px; }
  .links { font-size: 16px; gap: 6px; }
  .links a { padding-block: 12px; min-height: 44px; }
  footer { font-size: 16px; padding-top: 16px; }
  .cat-hit { position: absolute; width: 160px; height: 90px; left: calc(50% - 340px); top: 0; }
  .soot-hit, .console-hit { display: none; }
  .motion-label { max-width: 130px; }
}
@media (max-width: 900px) {
  .studio { --mobile-header: 40px; }
  .sketchbook { max-width: 820px; margin-inline: auto; }
  /* Use the top-right strip of the painting above the bezel. At this scale,
     it only shows the room to the right of the cat and the painted screen. */
  .room {
    inset: 0 0 auto;
    width: auto;
    height: var(--mobile-header);
    transform: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .room-art { background-position: right top; background-size: 1792px auto; }
  .room-layers, .scene-interaction { display: none; }
}
@media (max-width: 540px) {
  :root { --mobile-header: 108px; }
  .studio { padding: var(--mobile-header) 10px 24px; }
  .cat-hit { left: 0; top: 0; width: 145px; height: 85px; }
  .sketchbook { border-width: 6px; }
  .topbar { gap: 12px; margin: 0 8px; font-size: 16px; }
  .contact { font-size: 15px; }
  .sidebar { padding: 10px; }
  nav { gap: 5px; }
  nav button { font-size: 16px; padding-inline: 10px; }
  main { padding: 0 10px 16px; }
  .intro { display: block; }
  .intro-title { justify-content: flex-start; }
  .intro > p { margin-top: -2px; }
  .projects { grid-template-columns: minmax(0,1fr); }
  .project { padding: 12px 16px 5px; }
  .project h2 { font-size: 24px; }
  .project > p { font-size: 18px; }
  .links { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *:not(.room-motion *, .screen-reflections *), *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .room-paused .room-motion * { animation: none !important; }
}

/* Cover the old printed catalogue below the tilted live screen. */
.studio::after { content: ""; position: absolute; left: 37.2%; width: 42.9%; height: calc(28 * var(--u)); bottom: 0; background: #fcf4d9; z-index: 0; pointer-events: none; }
.sketchbook { z-index: 1; }
@media (max-width: 900px), (max-aspect-ratio: 6/5) { .studio::after { display: none; } }

/* Keep the restored source pixels above the scrolling catalogue, never in it. */
.desk-foreground {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 4; pointer-events: none;
}
main { padding-bottom: calc(50 * var(--u)); scroll-padding-block: calc(20 * var(--u)) calc(55 * var(--u)); }
@media (max-width: 900px), (max-aspect-ratio: 6/5) {
  .desk-foreground { display: none; }
  main { padding-bottom: 18px; }
}

/* Register the live interface inside the original tablet's inner glass edge. */
@media (min-width: 901px) and (min-aspect-ratio: 6/5) {
  .sketchbook {
    top: 10.5%;
    border-radius: calc(2 * var(--u)) calc(5 * var(--u)) 0 0;
    isolation: isolate;
  }
  .topbar { height: calc(28 * var(--u)); background-color: transparent; }
  .sidebar { padding-top: calc(9 * var(--u)); }
  main { background-color: transparent; }
  .project { background-color: #fffcec30; }
  .sketchbook::after {
    z-index: 6;
    background: none;
    box-shadow: inset 0 calc(2 * var(--u)) calc(7 * var(--u)) #49362136,
      inset calc(1 * var(--u)) 0 calc(3 * var(--u)) #7963462b,
      inset calc(-2 * var(--u)) 0 calc(6 * var(--u)) #715a3230;
  }
}

/* Only the actual, clipped foreground blocks links hidden underneath it. */
.desk-foreground image { pointer-events: visiblePainted; }

/* One continuous screen surface replaces the separate rectangular UI patches.
   The feathered L-shaped mask clears the old printed interface while keeping
   the original notes on the lower left of the tablet fully visible. */
@media (min-width: 901px) and (min-aspect-ratio: 6/5) {
  .sketchbook::before {
    content: "";
    position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: radial-gradient(ellipse at 12% 22%, #fff1c85c, transparent 58%),
      linear-gradient(112deg, #fbf1d3, #fbf4dc 45%, #faf3db);
    -webkit-mask: url("assets/tablet-surface-mask.svg") 0 0 / 100% 100% no-repeat;
    mask: url("assets/tablet-surface-mask.svg") 0 0 / 100% 100% no-repeat;
  }
  .sidebar nav button { mix-blend-mode: multiply; }
}

/* SVG viewports preserve complete artwork in Safari flex layouts. */
svg.project-art { background: none; overflow: hidden; }
