/* Sorted Studio — spin gallery (Work page). Pairs with js/spin.js.
   The three concept websites as six cards on a CSS 3D ring: drag to spin, click the front card to read about it.
   Desktop with a mouse only. On smaller screens, and without JavaScript, the ring is not rendered and the
   list of .case articles below carries everything. */

.spin { display: none; }
/* The ring sits between the section head and the first case, so the first case keeps its usual gap. */
.spin + .case { margin-top: clamp(var(--space-6), 4vw, var(--space-7)); }

@media (min-width: 961px) and (hover: hover) {
  .js .spin { display: block; margin-top: clamp(var(--space-6), 4vw, var(--space-7)); }
}

.spin {
  --r: 400px;          /* ring radius */
  --step: 60deg;       /* 360 / 6 cards */
  --tilt: -6deg;       /* look down onto the ring a little, so the cards behind peek over the front one */
}

/* The stage: the camera. Clipped, so no card can ever poke outside .wrap. */
.spin__stage {
  position: relative;
  height: 560px;
  overflow: hidden;
  border-radius: var(--r-card);
  perspective: 1400px;
  perspective-origin: 50% 47%;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.spin__stage:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: var(--r-card); }

/* The ring: a point at the middle of the stage. spin.js sets --a (the ring's turn). */
.spin__ring {
  position: absolute; left: 50%; top: 47%; width: 0; height: 0;
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--r) * -1)) rotateX(var(--tilt)) rotateY(var(--a, 0deg));
  will-change: transform;
}

/* A card. Its top-left corner sits on the ring's centre (transform-origin 0 0), it is centred on that point,
   pushed out by the radius, then turned to its place. --o (set by spin.js) dims the cards behind the front. */
.spin__card {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  transform-style: preserve-3d;
  transform: rotateY(calc(var(--i) * var(--step))) translateZ(var(--r)) translate(-50%, -50%);
  pointer-events: none;
}
.spin__card--site { width: 400px; }
.spin__card--phone { width: 190px; }
.spin__card > * { opacity: var(--o, 1); backface-visibility: hidden; -webkit-backface-visibility: hidden; }

.spin__face { transition: transform 0.45s var(--ease-out); }
.spin__face.browser { --bar: 18px; }
.spin__face img { pointer-events: none; -webkit-user-drag: none; }

/* The back of each card: a plain panel, so the far side of the ring never shows a mirrored screenshot. */
.spin__back {
  position: absolute; inset: 0;
  transform: rotateY(180deg);
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
}
.spin__card--phone .spin__back { border-radius: 30px; }

/* Only the front card takes the pointer. */
.spin__card.is-front { pointer-events: auto; cursor: pointer; }
.spin:not(.is-dragging) .spin__card.is-front:hover .spin__face { transform: translateZ(28px); }
.spin.is-dragging .spin__stage, .spin.is-dragging .spin__card { cursor: grabbing; }

/* "Drag to spin", with a drawn arrow pair. Fades after the first drag. */
.spin__hint {
  position: absolute; left: 50%; bottom: 14px; z-index: 1;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: var(--space-2);
  margin: 0;
  font-size: var(--fs-label); font-weight: 600; color: var(--ink-soft); white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.spin__hint svg { width: 26px; height: 16px; flex: none; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spin__hint svg:first-child { transform: scaleX(-1); }
.spin__hint path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: spin-draw 0.7s var(--ease-out) 0.5s forwards; }
.spin__hint path + path { animation-delay: 1s; }
@keyframes spin-draw { to { stroke-dashoffset: 0; } }
.spin.is-used .spin__hint { opacity: 0; }

/* The front card's name and kind. Two layers in one grid cell cross-fade when the front card changes. */
.spin__label { display: grid; justify-items: center; text-align: center; margin-top: var(--space-5); }
.spin__now {
  grid-area: 1 / 1;
  display: grid; gap: var(--space-1);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.6s var(--ease-out);
}
.spin__now.is-on { opacity: 1; transform: none; transition-delay: 0.06s; }
.spin__now.is-out { opacity: 0; transform: translateY(-6px); }
.spin__name { font: 600 var(--fs-h3)/1.12 var(--font-display); letter-spacing: -0.008em; }
.spin__kind { font-size: var(--fs-small); color: var(--ink-soft); }
.spin__note { text-align: center; }

/* Previous, "1 of 3" and Next under the ring (10 Oct 2026, after the GPT Sol review): the same round buttons
   as the phone row of the concept sites, so the look is shared below. Dragging still works as well. */
.spin__controls { display: flex; justify-content: center; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }
.cases-nav__btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1.5px solid var(--ink); border-radius: var(--r-pill); background: transparent; color: var(--ink);
  cursor: pointer; transition: background-color 0.16s ease, transform 0.16s var(--ease-out);
}
.cases-nav__btn svg { width: 20px; height: 20px; }
.cases-nav__btn:hover { background: var(--card); }
.cases-nav__btn:active { transform: scale(0.97); }
.cases-nav__btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 7px var(--lime); }
.cases-nav__btn[aria-disabled="true"] { opacity: 0.35; cursor: default; }
.cases-nav__btn[aria-disabled="true"]:hover { background: transparent; }
.cases-nav__count { min-width: 4.2em; margin: 0; text-align: center; font-size: var(--fs-small); font-weight: 600; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .spin__hint path { animation: none; stroke-dashoffset: 0; }
  .spin:not(.is-dragging) .spin__card.is-front:hover .spin__face { transform: none; }
}

/* ---------- Work page, 10 Oct 2026 (Builder 4) ---------- */

/* Phones and small tablets: each concept site once, tighter spacing. The second (phone-shaped) screenshot of a case
   is for wide screens only, so it drops out here. */
/* On wide screens the row wrapper does not exist as a box; the cases stack as before. */
.cases-row { display: contents; }
.cases-nav { display: none; }
.cases-row > .case:first-child { margin-top: clamp(var(--space-6), 4vw, var(--space-7)); }
.cases-credit { margin-top: 0; }

/* "Skip to the real builds" under the Work hero: the arrow points down, so it nudges down on hover. */
.work-jump { margin-top: var(--space-3); }
.work-jump:hover svg { transform: translateY(3px); }
#real-builds, #concepts { scroll-margin-top: -56px; }   /* html scroll-padding-top (96px) clears the header; this keeps the landing spot it had at 40px before (11 Oct 2026) */

/* Real builds: problem, what I built, status. The labels are longer than For/What, so the label column widens. */
.case--real .case__facts { margin-top: var(--space-2); }
.case--real .case__facts li > span:first-child { flex-basis: 7.2em; font-weight: 600; color: var(--ink); }

@media (max-width: 960px) {
  .shot--wide-only { display: none; }
  /* The three examples sit in one swipe row, so the page is one card tall instead of three.
     Above the row: the swipe hint, then Previous, "1 of 3" and Next (shown by spin.js). */
  .cases-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); }
  .cases-hint { margin: 0; }
  .cases-nav__controls:not([hidden]) { display: flex; align-items: center; gap: var(--space-1); flex: none; }   /* 4px, so the hint keeps two lines at 320px */
  .cases-credit { margin-top: var(--space-1); }
  .cases-row {
    position: relative; display: flex; gap: var(--space-4); margin: var(--space-3) calc(var(--gutter) * -1) 0; padding: 0 var(--gutter) var(--space-4);
    overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter);
    overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  }
  .cases-row > .case:first-child { margin-top: 0; }
  .cases-row > .case {
    flex: 0 0 min(86%, 420px); scroll-snap-align: start; align-self: flex-start;
    padding: var(--space-4); border: 1px solid var(--ash); border-radius: var(--r-card); background: var(--card);
  }
  .case { gap: var(--space-4); padding-block: var(--space-6); }
  .case h3 { font-size: clamp(var(--step-2), 0.5rem + 5vw, var(--step-3)); }
  .case__copy { --gap: var(--space-3); }
  .case__facts { margin-top: var(--space-4); }
  .case__facts li { padding-block: var(--space-2); }
  .work-head + .case { margin-top: var(--space-3); }
  .case__shots { gap: var(--space-3); }
  .case .caption { margin-top: 0; }
}

/* Before and after slider: a ring you can see on the handle strip and the knob, and a short ease for keys and taps.
   --pos is registered so the change can animate; dragging switches the ease off so the handle follows the finger. */
@property --pos { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
.compare { transition: --pos 0.18s var(--ease-out); }
.compare.is-dragging { transition: none; }
.compare__handle:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.compare__handle:focus-visible .compare__knob { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 7px var(--lime); }

/* Real-build screenshots: 4px lift on hover (mouse only), entering 40 ms apart. Only the picture moves, never text.
   `translate` is its own property, so it eases at 200 ms without slowing the 0.9 s entry on `transform`. */
@media (hover: hover) and (pointer: fine) {
  .js .case--real [data-reveal="screen"].is-in {
    transition: clip-path 0.9s var(--ease-out), transform 0.9s var(--ease-out), opacity 0.4s ease, translate 0.2s var(--ease-out);
  }
  .js .case--real [data-reveal="screen"].is-in:hover { translate: 0 -4px; }
}
.js .case--real .case__shots > [data-reveal="screen"]:nth-child(2),
.js .case--real .case__pair > [data-reveal="screen"]:nth-child(2) { transition-delay: 40ms; }
.js .case--real .case__shots > [data-reveal="screen"]:nth-child(3) { transition-delay: 80ms; }
@media (prefers-reduced-motion: reduce) {
  .compare { transition: none; }
  .js .case--real [data-reveal="screen"] { transition: none !important; translate: none !important; }
}
