/* Studio page: a hand-drawn studio (studio-bg.svg) with the wall
   images placed on top of it.
   1. Stage   2. Wall frames   3. Work sheet (strip boxes)
   4. Artwork sheet (artworks) */


/* ---------- 0. Page colour ---------- */
/* The page, header, stage and work sheets all use the site's own
   background colour (--bg in base.css), like the other pages. The
   sheets stand out by their borders and inner frame. */


/* ---------- 1. Stage ---------- */
/* Desktop (960px and up): the stage fills the screen below the header,
   edge to edge (the header is 78px: 20px padding top and bottom +
   37.6px of text, measured). Below 960px the stage is 960 x 540 and the
   wrapper scrolls sideways, so the frames stay tappable; below 600px
   the stage is narrower and the scroll ends after the last artwork
   (see "Phones" below). */
.studio-scroll {
  overflow-x: auto;
}

.studio {
  position: relative;
  width: 960px;
  aspect-ratio: 1600 / 900;
  background: var(--bg);
  container-type: size;
  overflow: hidden;
}

@media (min-width: 960px) {
  .studio {
    width: 100%;
    height: calc(100svh - 78px);
    aspect-ratio: auto;
  }
}

/* The scene: the whole 2400 x 900 drawing (viewBox -400 0 2400 900; the
   original 1600 x 900 sits in the middle, only lines continue to the
   sides). It is as tall as the stage, so the whole height shows, but
   no taller than lets the safe zone, x -170 to 1580 of the drawing
   (1750 wide, so ART 6 at x -147 with its corner tape to about
   x -167, the note at x -131 and ART 2 at x -50 are never cropped),
   fit the stage's width (100cqw = the stage's width). The safe
   zone's middle (x 705, 46.0417% of the 2400) sits at the stage's
   middle; top-aligned; the sides past the screen edges are cropped. */
.studio-scene {
  position: absolute;
  top: 0;
  left: 50%;
  height: min(100%, calc(100cqw * 900 / 1750));
  aspect-ratio: 2400 / 900;
  transform: translateX(-46.0417%);
}

.studio-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* The original 1600 x 900 area (x 0–1600 of 2400, from 400). The frames
   are placed in % of it, so they stay on the drawing. --u is one unit
   of the drawing (the scene's height / 900, from the stage's cqw and
   cqh), for the tape sizes. No container or stacking context here, so
   the tape can blend with the drawing behind it. */
.studio-content {
  position: absolute;
  top: 0;
  left: 16.6667%;
  width: 66.6667%;
  height: 100%;
  --u: calc(min(100cqh, 100cqw * 900 / 1750) / 900);
}

.studio-content > * {
  position: absolute;
}

/* Phones (below 600px): the scroll stops just after the last artwork.
   The stage is 512px wide (ART 4's tape ends at 495.5px, plus 16px),
   or the screen width if that is wider. The scene keeps exactly the
   size, position and tape scale it has on the 960 x 540 stage, so the
   frames don't move: its height and --u are fixed to the 960px
   values (960 * 900 / 1750), and left: 480px is the 960px stage's
   middle. The drawing past 512px is cropped, like the sides on
   desktop. */
@media (max-width: 599px) {
  .studio {
    width: max(512px, 100%);
    height: 540px;
    aspect-ratio: auto;
  }

  .studio-scene {
    left: 480px;
    height: calc(960px * 900 / 1750);
  }

  .studio-content {
    --u: calc(960px / 1750);
  }
}

/* "Swipe to see more": only where the stage scrolls sideways (below
   512px, and 600–959px, where it is 960px wide). Inside the scene, so
   it scrolls with it: in the gap between the long double floor line
   (y 737–744 of the drawing) and the faint line below it (y 813),
   centred in it, from x -147 (ART 6's left edge), ending before the
   small arch (about x 174). Same handwriting, size and blue as the
   note; the arrow is a thin hand-drawn line, about the text's height.
   Visual only: hidden from screen readers. */
.studio-hint {
  display: none;
  left: calc(-147 / 1600 * 100%);
  top: calc(760 / 900 * 100%);
  margin: 0;
  align-items: center;
  gap: .35em;
  font-family: 'Architects Daughter', var(--font-label);
  font-size: calc(28.35 * var(--u));
  line-height: 1.3;
  white-space: nowrap;
  color: var(--blue);
  pointer-events: none;
}

.studio-hint svg {
  width: 1.9em;
  height: .9em;
  overflow: visible;
}

@media (max-width: 511px), (min-width: 600px) and (max-width: 959px) {
  .studio-hint {
    display: flex;
  }
}

/* Handwritten note, in the empty paper at the top left, above the
   small arch: inside x -131 to 257, y 122 to 278, left-aligned,
   centred top to bottom. In the site blue (--blue
   from base.css). 28.35 units: 1.5x the earlier 18.9 (whose caps
   were 1.3x the 10.4-unit caps of the drawing's "h = 2.40"). At this
   size the first sentence wraps onto four lines and the second onto
   two (six in all); the text runs slightly past the area top and
   bottom, still clear of the header, the arch and the wall items. */
.studio-note {
  left: calc(-131 / 1600 * 100%);
  top: calc(122 / 900 * 100%);
  width: calc(388 / 1600 * 100%);
  height: calc(156 / 900 * 100%);
  display: grid;
  align-content: center;
  margin: 0;
  font-family: 'Architects Daughter', var(--font-label);
  font-size: calc(28.35 * var(--u));
  line-height: 1.3;
  color: var(--blue);
}


/* ---------- 2. Wall frames ---------- */
/* Placed from the drawing's pixels (--x, --y, --w, --h on each button,
   on the 1600 x 900 drawing). Just the image: no button border or
   background. */
.studio-frame {
  left: calc(var(--x) / 1600 * 100%);
  top: calc(var(--y) / 900 * 100%);
  width: calc(var(--w) / 1600 * 100%);
  height: calc(var(--h) / 900 * 100%);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* Invisible hit area: at least 44 x 44, centred on the frame */
.studio-frame::before {
  content: "";
  position: absolute;
  top: min(0px, calc(50% - 22px));
  bottom: min(0px, calc(50% - 22px));
  left: min(0px, calc(50% - 22px));
  right: min(0px, calc(50% - 22px));
}

/* Paper on the wall: each image is tilted by its own fixed --tilt
   (on the button, studio.html), with a very light shadow. Only the
   image turns, not the button, so the focus ring stays square. */
.studio-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateY(var(--lift, 0px)) rotate(var(--tilt, 0deg)) scale(var(--grow, 1));
  box-shadow: 0 1px 2px rgba(60, 50, 30, .18);
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}

/* Hover and keyboard focus: the item lifts a little, as if its tape is
   coming loose (up 3 units, scale 1.03, keeping its tilt; the tape
   moves with it), and its shadow grows. Not while it's open or moving
   (.is-lifted), not with reduced motion, and hover only on screens
   that can hover. */
@media (prefers-reduced-motion: no-preference) {
  .studio-frame:not(.is-lifted):focus-visible {
    --lift: calc(-3 * var(--u));
    --grow: 1.03;
  }

  .studio-frame:not(.is-lifted):focus-visible img {
    box-shadow: 0 4px 10px rgba(60, 50, 30, .22);
  }
}

@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .studio-frame:not(.is-lifted):hover {
    --lift: calc(-3 * var(--u));
    --grow: 1.03;
  }

  .studio-frame:not(.is-lifted):hover img {
    box-shadow: 0 4px 10px rgba(60, 50, 30, .22);
  }
}

/* Focus ring: drawn above the tape (a normal outline would sit under
   it), same look as everywhere else: 3px red, 3px away */
.studio-frame:focus-visible {
  outline: none;
}

.studio-frame:focus-visible::after {
  content: "";
  position: absolute;
  inset: -6px;
  z-index: 2;
  border: 3px solid var(--red);
  pointer-events: none;
}

/* Tape strips (.tape spans in each button). Sizes in drawing units
   (--u). Each strip starts centred on the item, then: its own
   rotation (--r), a move to its spot (--ox, --oy, from the item's
   centre), and the item's own transform (tilt, hover lift and grow)
   around the item's centre, so it stays on the corner or edge. Multiply lets the image and the
   drawing show through. */
.tape {
  --tw: 40;
  --th: 13;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: calc(var(--tw) * var(--u));
  height: calc(var(--th) * var(--u));
  margin: calc(var(--th) * var(--u) / -2) 0 0 calc(var(--tw) * var(--u) / -2);
  background: rgba(222, 208, 170, .78);
  mix-blend-mode: multiply;
  clip-path: polygon(100% 0%, 97% 15%, 100% 30%, 96% 48%, 100% 65%, 97% 82%, 100% 100%, 0% 100%, 3% 85%, 0% 68%, 4% 50%, 0% 34%, 3% 17%, 0% 0%);
  transform:
    translateY(var(--lift, 0px))
    rotate(var(--tilt, 0deg))
    scale(var(--grow, 1))
    translate(calc(var(--ox) * var(--u)), calc(var(--oy) * var(--u)))
    rotate(var(--r));
  pointer-events: none;
  transition: opacity 150ms ease, transform 200ms ease-out;
}

/* Faint paper texture */
.tape::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .10) 0 2px, transparent 2px 5px);
}

/* Artworks: two diagonal strips, 40 x 13, centred on the top-left and
   bottom-right corners */
.tape-tl,
.tape-br {
  --r: -38deg;
}

.tape-tl {
  --ox: calc(var(--w) / -2);
  --oy: calc(var(--h) / -2);
}

.tape-br {
  --ox: calc(var(--w) / 2);
  --oy: calc(var(--h) / 2);
}

/* Strip boxes: one strip, 52 x 16, centred across the top edge, with
   the box's own small rotation (--tape) */
.tape-top {
  --tw: 52;
  --th: 16;
  --r: var(--tape, 0deg);
  --ox: 0;
  --oy: calc(var(--h) / -2);
}

/* Taken off the wall: the image is gone (it's the one in the large
   view or the sheet) and the tape stays on the wall and fades out.
   It fades back in once the image is back (studio.js). */
.studio-art.is-lifted img,
.studio-work.is-lifted img {
  visibility: hidden;
}

.is-lifted .tape {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .tape,
  .studio-frame img {
    transition: none;
  }
}


/* ---------- 3. Work sheet (dialog; also the artwork sheet, 4) ---------- */
/* One dialog for every work sheet, filled from SHEETS in studio.js.
   It covers the screen but draws nothing, so
   the studio stays exactly as it is behind it. A click anywhere but
   the sheet closes it. */
.sheet-view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.sheet-view::backdrop {
  background: transparent;
}

/* The area below the header (its top is set by studio.js). A sheet
   that fits the screen doesn't scroll; a taller one scrolls here. */
.sheet-scroll {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
}

/* Takes the sheet's size on screen (after scaling), so the scroll
   area knows how tall it is. Size and margins set by studio.js. */
.sheet-sizer {
  position: relative;
  margin: 0 auto;
}

/* 600px and up: one fixed layer at its design size (1240 wide,
   --sheet-h tall), scaled by studio.js (transform: scale(--k)). All
   positions inside are px on that design, from SHEETS (--l, --t,
   --r, --b, --w, --h). */
.sheet {
  position: absolute;
  left: 0;
  top: 0;
  width: 1240px;
  height: var(--sheet-h);
  transform-origin: 0 0;
}

/* Everything but the cover: fades in once the cover has landed */
.sheet-rest {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1px solid var(--ink);
  opacity: 0;
}

/* Second frame, 10px inside */
.sheet-rest::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--ink);
  pointer-events: none;
}

.sheet-rest > *,
.sheet-cover {
  position: absolute;
  left: var(--l, auto);
  top: var(--t, auto);
  right: var(--r, auto);
  bottom: var(--b, auto);
  width: var(--w, auto);
  height: var(--h, auto);
}

.sheet-img {
  display: block;
  max-width: none;
  object-fit: cover;
  outline: 1px solid var(--ink);
}

/* The cover's place in the layout. The cover itself (.sheet-cover)
   sits over it; studio.js moves that box and counter-scales the image
   inside it, so the picture never stretches while the box changes
   shape. */
.sheet-slot {
  pointer-events: none;
}

.sheet-cover {
  overflow: hidden;
  outline: 1px solid var(--ink);
  transform-origin: 50% 50%;
  will-change: transform;
}

.sheet-cover img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* × : 16px, top 18 / right 22, with an invisible 44 x 44 screen-px
   hit area (--k is the sheet's scale). On a sheet that scrolls,
   studio.js keeps it in view (translateY). */
.sheet-rest > .sheet-close {
  top: 18px;
  right: 22px;
  z-index: 1;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 16px;
  color: var(--ink);
  cursor: pointer;
}

.sheet-close::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(44px / var(--k, 1));
  height: calc(44px / var(--k, 1));
  transform: translate(-50%, -50%);
}

.sheet-close:hover {
  color: var(--red);
}

/* Text block */
.sheet-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.02;
  color: var(--ink);
}

.sheet-issue {
  margin: 10px 0 0;
  font-family: var(--font-label);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--blue);
}

.sheet-body {
  margin: 24px 0 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

/* Title block: two rows */
.sheet-titleblock {
  border: 1px solid var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
}

.sheet-row {
  margin: 0;
  padding: 6px 8px;
}

.sheet-row + .sheet-row {
  border-top: 1px solid var(--ink);
}

.sheet-label {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-label);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--blue);
}

/* Below 600px: not scaled down. The same content in one column: the
   text block, the title block, then every image full width at its
   own proportions, in the SHEETS order, 30px apart (the sheet's gap).
   Same border, inner frame and ×. */
@media (max-width: 599px) {
  .sheet {
    position: relative;
    width: auto;
    height: auto;
  }

  .sheet-rest {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 48px 30px 40px;
  }

  .sheet-rest > * {
    position: static;
    width: auto;
    height: auto;
  }

  .sheet-rest > .sheet-close {
    position: absolute;
  }

  .sheet-titleblock {
    width: 210px;
    max-width: 100%;
  }

  .sheet-img {
    width: 100%;
    height: auto;
  }

  .sheet-slot {
    aspect-ratio: var(--ratio);
  }
}


/* ---------- 4. Artwork sheet ---------- */
/* The work sheet (above) for an artwork: the same dialog, border,
   inner frame and ×; studio.js sizes it in screen px (not scaled) and
   places the artwork's slot and the text column. The artwork shows
   whole, at its own proportions, with no outline (like on the wall). */
.sheet--art .sheet-cover {
  outline: none;
}

/* Title and description: handwritten, like the note on the wall
   (Architects Daughter, site blue). They scale with the drawing the
   same way the note does: --art-u is one drawing unit, worked out from
   the screen because the sheet sits outside the stage (desktop: the
   stage is the full width and the screen height minus the 78px
   header; below 960px it is 960 x 540). Title 31.6 units, description
   24.3 units: 26px and 20px at 1440 x 900; never smaller than 21px
   and 18px. */
.sheet--art {
  --art-u: calc(min(540px, 960px * 900 / 1750) / 900);
}

@media (min-width: 960px) {
  .sheet--art {
    --art-u: calc(min(100svh - 78px, 100vw * 900 / 1750) / 900);
  }
}

.art-sheet-title,
.art-sheet-note {
  font-family: 'Architects Daughter', var(--font-label);
  font-weight: 400;
  line-height: 1.3;
  color: var(--blue);
}

.art-sheet-title {
  margin: 0 0 8px;
  font-size: max(21px, calc(31.6 * var(--art-u)));
}

.art-sheet-note {
  margin: 0;
  font-size: max(18px, calc(24.3 * var(--art-u)));
}
