/* EL STUDIO — darkroom: prints on a drying line, faint red safelight on the wall */
.darkroom {
  --accent: var(--red);
  --gap: clamp(150px, 12vw, 200px);
  --s: 1;      /* type scale, steps with --maxw */
  --pu: 1;     /* print unit: pegs, wire, tags and gaps scale with the print height (set by darkroom.js on the pinned line) */
  position: relative; background: #0d0606; color: var(--text); overflow-x: clip;
}
.dr-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.dr-pin { position: relative; }

/* ---------- the wall: one dim safelight wash from above, nothing else */
.dr-wall {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(70% 55% at 50% 0%, rgba(255, 40, 20, .13), transparent 70%),
    radial-gradient(120% 90% at 50% 45%, #150807, #0d0505 60%, #070303);
}
.dr-wall::before { content: ""; position: absolute; inset: 0; background: url(../assets/ui/darkroom/wall.svg) 0 0 / 400px 400px; opacity: .3; }
.dr-wall::after { content: ""; position: absolute; inset: 0; background: url(../assets/ui/darkroom/grain.svg) 0 0 / 220px 220px; opacity: .16; mix-blend-mode: overlay; }

/* ---------- head: the shared .sec-head, trip tabs on the right */
.dr-head { position: relative; z-index: 4; width: min(var(--maxw), 100% - 2 * var(--gutter)); }
.dr-tabs { max-width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; background: rgba(13, 6, 6, .6); }
.dr-tabs::-webkit-scrollbar { display: none; }
.dr-tabs button { flex: none; cursor: pointer; white-space: nowrap; }
.dr-tabs button:focus-visible { outline: 2px solid var(--text); outline-offset: -4px; }

/* ---------- the line */
.dr-stage { position: relative; }
.dr-line { position: relative; }
.dr-wire, .is-swipe .dr-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: calc(var(--wy, 0px) + 22px * var(--pu)); height: max(3px, calc(3px * var(--pu))); z-index: 0;
  background: repeating-linear-gradient(118deg, #b4a49d 0 2px, #5a4a44 2px 3.5px, #8a7a73 3.5px 5px), #6d5d57;
  box-shadow: 0 -1px 0 rgba(255, 200, 185, .14), 0 20px 5px -1px rgba(0, 0, 0, .38);
}
.dr-track { position: relative; z-index: 1; display: flex; align-items: flex-start; transition: opacity .24s ease; }
.dr-track.is-out { opacity: 0; }
.dr-print { position: relative; flex: none; padding-top: calc(30px * var(--pu)); margin-right: var(--gap); animation: drHang .9s cubic-bezier(.2, 1.3, .4, 1) calc(var(--i, 0) * 70ms) both; }
.dr-print:last-child { margin-right: 0; }
@keyframes drHang { from { opacity: 0; transform: translateY(-36px); } }
.dr-print__hang {
  position: relative; transform-origin: 50% 0;
  transform: rotate(calc(var(--swing, 0) * var(--k, 1) * 1deg));
  rotate: var(--tilt);
  animation: drSway var(--sw, 6s) ease-in-out var(--sd, 0s) infinite alternate;
}
@keyframes drSway { from { rotate: calc(var(--tilt) - .45deg); } to { rotate: calc(var(--tilt) + .45deg); } }

.dr-paper {
  --b: calc(var(--ph, 520px) * .042);
  position: relative; display: block; margin: 0; padding: var(--b); border: 0; border-radius: 1.5px; cursor: zoom-in;
  height: var(--ph, 520px); width: calc((var(--ph, 520px) - 2 * var(--b)) * var(--ar) + 2 * var(--b));
  background: url(../assets/ui/darkroom/grain.svg) 0 0 / 220px 220px, linear-gradient(170deg, #f6efe6, #ebe1d5 70%, #e2d6c8);
  background-blend-mode: soft-light, normal;
  box-shadow: 0 1px 1px rgba(0,0,0,.4), 0 24px 26px -10px rgba(0,0,0,.62), 0 56px 70px -34px rgba(0,0,0,.75);
}
.dr-paper::after { /* fibre-paper curl: light catches the top-left edge, the lower edge rolls into shadow */
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(100deg, rgba(255,255,255,.14), transparent 22%, transparent 74%, rgba(60,30,20,.12)), linear-gradient(rgba(255,255,255,.08), transparent 10%, transparent 86%, rgba(50,20,10,.16));
}
.dr-paper:focus-visible { outline: 3px solid #ffd2c4; outline-offset: 6px; }
.dr-paper__img { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; background: #e9dfd2; box-shadow: inset 0 0 0 .5px rgba(60,30,20,.25); }
.dr-paper__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.dr-lat { filter: grayscale(1) contrast(.62) brightness(1.18); opacity: .5; mix-blend-mode: multiply; }
.dr-pos { opacity: 0; }
.is-dev .dr-pos { animation: drDev 1.1s cubic-bezier(.45, 0, .2, 1) forwards; }
@keyframes drDev {
  0% { opacity: 0; filter: grayscale(1) contrast(.5) brightness(1.5); }
  30% { opacity: .55; filter: grayscale(.9) contrast(.75) brightness(1.3); }
  65% { opacity: .92; filter: grayscale(.35) contrast(1.05) brightness(1.04); }
  100% { opacity: 1; filter: none; }
}
@media (hover: hover) {
  .dr-paper:hover { filter: brightness(1.04); }
}

.dr-peg { position: absolute; left: 50%; top: calc(8px * var(--pu)); z-index: 2; width: calc(22px * var(--pu)); height: calc(66px * var(--pu)); margin-left: calc(-11px * var(--pu)); pointer-events: none; filter: drop-shadow(0 7px 4px rgba(0,0,0,.5)) drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.dr-peg svg { display: block; width: 100%; height: 100%; }
.dr-print__hang > .dr-peg { top: calc(-22px * var(--pu)); }

/* small manila tag on a string in the gap after each print: place + date, written by hand.
   Sized from ONE font-size (em everywhere inside) so it keeps its proportions at every print size. Each line's line-height
   matches its font's own glyph box, so the place and the date never share a pixel even while the tag swings. */
.dr-tag {
  --tw: 7.8em;
  position: absolute; top: calc(22px * var(--pu)); left: calc(100% + (var(--gap) - var(--tw)) / 2); width: var(--tw); transform-origin: 50% 0;
  font-size: calc(15px * var(--pu));
  animation: drTag 5.5s ease-in-out var(--sd, 0s) infinite alternate;
  filter: drop-shadow(0 .66em .53em rgba(0,0,0,.5)) drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
@keyframes drTag { from { rotate: calc(var(--tr) - .8deg); } to { rotate: calc(var(--tr) + .8deg); } }
.dr-tag::before { content: ""; position: absolute; left: 50%; top: -.13em; width: max(1px, .08em); height: 3.33em; translate: -50% 0; background: linear-gradient(#cbb9a5, #8c7a68); }
.dr-tag::after { content: ""; position: absolute; left: 50%; top: -.33em; width: .53em; height: .4em; translate: -50% 0; border: max(1px, .08em) solid #b9a691; border-radius: 50%; }
.dr-tag__card {
  position: relative; margin-top: 2.93em; padding: 1.4em .6em .7em; display: flex; flex-direction: column; align-items: center; gap: .3em;
  color: #24120a; text-align: center; overflow-wrap: anywhere;
  background: url(../assets/ui/darkroom/grain.svg) 0 0 / 160px 160px, linear-gradient(172deg, #e9dcc0, #dccaa2 70%, #d2bd92);
  background-blend-mode: soft-light, normal;
  clip-path: polygon(20% 0, 80% 0, 100% 14%, 100% 100%, 0 100%, 0 14%);
}
.dr-tag__card::before { content: ""; position: absolute; left: 50%; top: .47em; width: .53em; height: .53em; translate: -50% 0; border-radius: 50%; background: #1a0b07; box-shadow: 0 0 0 .17em #c9a96c; }
.dr-tag__card b { display: block; max-width: 100%; font: 400 1em/1.62 var(--f-marker); }
.dr-tag__card span { display: block; font: 400 1.27em/1.14 var(--f-pen); color: #4a2616; white-space: nowrap; }

/* ---------- bottom row: counter left, one button right */
.dr-meta {
  position: relative; z-index: 5; width: min(var(--maxw), 100% - 2 * var(--gutter)); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.dr-count { margin: 0; font: 400 calc(26px * var(--s))/1 var(--f-crt); letter-spacing: .06em; color: var(--text); white-space: nowrap; }
.dr-meta .btn { cursor: pointer; white-space: nowrap; }

/* =================================================================== PIN (desktop) */
.is-pin .dr-pin {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: clip;
  display: flex; flex-direction: column; padding-top: calc(var(--osd-h) + clamp(14px, 3vh, 32px)); padding-bottom: clamp(14px, 3vh, 32px);
}
.is-pin .dr-head { margin-bottom: 0; }
.is-pin .dr-head .sec-head__row { margin-top: clamp(4px, 1vh, 12px); }
/* line-height = Anton's own glyph box (1.5em), so the title's box is its real ink-plus-ascender area and nothing above or
   below can slide under it; the deck sits straight under that box */
.is-pin .dr-head .sec-head__title { font-size: clamp(48px, min(7.2vw, 11vh), 108px); line-height: 1.5; }
.is-pin .dr-head .sec-head__deck { margin-top: 0; }
.is-pin .dr-stage { flex: 1 1 auto; min-height: 0; margin-top: clamp(8px, 2vh, 20px); }
.is-pin .dr-line { position: absolute; inset: 0; overflow: clip; }
.is-pin .dr-track { position: absolute; left: 0; top: var(--wy, 0px); height: 100%; will-change: transform; }

/* big screens: type steps up with --maxw (base.css breakpoints) */
@media (min-width: 1800px) {
  .darkroom { --s: 1.12; }
  .is-pin .dr-head .sec-head__title { font-size: clamp(96px, min(6.6vw, 11.5vh), 150px); }
}
@media (min-width: 2300px) {
  .darkroom { --s: 1.3; }
  .is-pin .dr-head .sec-head__title { font-size: clamp(130px, min(6.4vw, 11.5vh), 190px); }
}

/* =================================================================== SWIPE (phone) */
.is-swipe { --gap: 0px; padding: var(--sec-pad) 0 calc(var(--sec-pad) * .6); }
.is-swipe .dr-head { margin-bottom: 24px; }
.is-swipe .dr-tabs { display: flex; width: max-content; }
.is-swipe .dr-head .sec-head__row > div:first-child { flex: 1 1 100%; }
.is-swipe .dr-line { overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.is-swipe .dr-line::-webkit-scrollbar { display: none; }
.is-swipe .dr-wire { display: none; }
.is-swipe .dr-track { padding: 0 7vw 24px; width: max-content; gap: 5vw; align-items: center; }
.is-swipe .dr-print { scroll-snap-align: center; margin-right: 0; }
.is-swipe .dr-paper { --b: 3vw; height: auto; width: min(80vw, calc(44svh * var(--ar))); }
.is-swipe .dr-paper__img { height: auto; aspect-ratio: var(--ar); }
.is-swipe .dr-tag { position: relative; top: auto; left: auto; margin: -12px 6vw 0 auto; }
.is-swipe .dr-tag::before { height: 2em; top: 0; }
.is-swipe .dr-tag::after { display: none; }
.is-swipe .dr-tag__card { margin-top: 1.73em; }
.is-swipe .dr-meta { margin-top: 16px; }

/* =================================================================== STACK (reduced motion) */
.is-stack { padding: var(--sec-pad) 0; }
.is-stack .dr-wire { display: none; }
.is-stack .dr-track { width: min(var(--maxw), 100% - 2 * var(--gutter)); margin: 0 auto; flex-wrap: wrap; justify-content: center; gap: 56px 48px; }
.is-stack .dr-print { margin: 0; padding-top: 0; animation: none; }
.is-stack .dr-print__hang, .is-stack .dr-tag { animation: none; }
.is-stack .dr-print { width: min(100%, calc(360px * var(--ar) + 28px)); }
.is-stack .dr-paper { --b: 14px; height: auto; width: 100%; }
.is-stack .dr-peg { display: none; }
.is-stack .dr-paper__img { height: auto; aspect-ratio: var(--ar); }
.is-stack .dr-pos { opacity: 1; animation: none; }
.is-stack .dr-tag { position: relative; top: auto; left: auto; margin: -8px 6% 0 auto; }
.is-stack .dr-tag::before { height: 2em; } .is-stack .dr-tag::after { display: none; }
.is-stack .dr-tag__card { margin-top: 1.73em; }
.is-stack .dr-meta { margin-top: 40px; }

/* =================================================================== SHORT LANDSCAPE (phone on its side, 844x390 / 932x430)
   The pinned line needs the height. The head goes compact, and its bar, title and deck slide away under the top bar as the line
   pins (sticky with a negative top = exactly their height), so the stuck screen is: trip tabs, the line, counter + button.
   --dr-lift = bar (6 + 15 + 1) + row gap 4 + title 36*1.2 + deck 14*1.4 + tabs gap 8 + the 2px that tucks the tabs under the bar */
@media (orientation: landscape) and (max-height: 540px) {
  .is-pin .dr-pin {
    --dr-lift: calc(22px + 4px + 36px * 1.2 + 14px * 1.4 + 8px + 2px);
    top: calc(var(--dr-lift) * -1); height: calc(100svh + var(--dr-lift));
    padding-top: calc(var(--osd-h) + 8px); padding-bottom: 8px;
  }
  .is-pin .dr-head .sec-head__bar { padding-top: 6px; font-size: 15px; }
  .is-pin .dr-head .sec-head__row { margin-top: 4px; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: 8px; }
  .is-pin .dr-head .sec-head__title { font-size: 36px; line-height: 1.2; }
  .is-pin .dr-head .sec-head__deck { margin-top: 0; font-size: 14px; line-height: 1.4; }
  .is-pin .dr-stage { margin-top: 6px; }
  .is-pin .dr-count { font-size: 22px; }
  /* phone-width landscape (swipe): one print plus its tag fits the screen */
  .is-swipe { padding-top: calc(var(--osd-h) + 28px); }
  .is-swipe .dr-head { margin-bottom: 14px; }
  .is-swipe .dr-paper { width: min(86vw, calc((100svh - var(--osd-h) - 120px) * var(--ar))); }
}
