/* BRAINDANCE · Selected Work (Portfolio)
   One real project, shown as a film in three chapters: product site, dashboard, mobile.
   Desktop: pinned stage, scroll moves the chapters, click on the chapter index scrolls to it. No hover switching. */

.work { position: relative; z-index: 2; background: var(--obsidian); padding-bottom: clamp(120px, 14vw, 220px); }


/* intro */
.work-intro { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: end; padding-top: clamp(96px, 10vw, 160px); }
.work-h2 { grid-column: 1 / span 7; margin: 0; font-family: var(--font-display); font-weight: 800; font-stretch: 104%; font-size: clamp(44px, 5.8vw, 92px); line-height: .94; letter-spacing: -.04em; }
.work-h2 .row { display: block; overflow: hidden; padding-bottom: .08em; }
.work-h2 .row > span { display: inline-block; transition: transform 900ms var(--ease-out); }
.work-h2 .row:nth-child(2) > span { transition-delay: 120ms; }
.work-h2 em { font-style: normal; color: var(--lime); }
.work-lead { grid-column: 8 / -1; margin: 0; max-width: 40ch; font-size: 17px; line-height: 1.6; font-weight: 500; color: var(--text-2); transition: opacity 700ms var(--ease-out) 120ms, transform 700ms var(--ease-out) 120ms; }
.js .work-h2:not(.is-in) .row > span { transform: translateY(108%); }
.js .work-lead:not(.is-in), .js .index-list:not(.is-in), .js .work-next:not(.is-in) { opacity: 0; transform: translateY(24px); }
.index-list, .work-next { transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out); }

/* stage */
.work-stage { position: relative; margin-top: clamp(64px, 7vw, 112px); }
.work-pin { position: relative; overflow: hidden; padding-block: 24px 40px; }
.work-name {
  position: absolute; left: 0; right: 0; bottom: 1.2vw; z-index: 0; pointer-events: none; text-align: center; white-space: nowrap;
  font-family: var(--font-display); font-weight: 900; font-stretch: 125%; font-size: 15.2vw; line-height: .8; letter-spacing: -.05em; text-indent: .05em;
}
.work-name span { color: rgba(245, 245, 242, .05); transition: color 700ms var(--ease-out); }
.work-name span.on { color: rgba(245, 245, 242, .16); }
.work-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: center; }

.work-info { grid-column: 1 / span 4; min-width: 0; display: grid; gap: 18px; align-content: center; }
.work-meta { margin: 0; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); display: flex; gap: 12px; align-items: center; }
.wm-num { color: var(--lime); }
.work-title { margin: 0; font-family: var(--font-display); font-weight: 900; font-stretch: 112%; font-size: clamp(44px, 4.6vw, 76px); line-height: .9; letter-spacing: -.045em; }
.work-desc { margin: 0; color: var(--text-2); font-size: 16.5px; line-height: 1.6; max-width: 40ch; }
.work-chapter { border-top: 1px solid var(--border); padding-top: 16px; display: grid; gap: 6px; min-height: 6.4em; }
.work-chapter b { font-family: var(--font-mono); font-weight: 500; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--lime); }
.work-chapter p { margin: 0; color: var(--text); font-size: 17px; line-height: 1.55; font-weight: 500; }
.work-chapter > * { transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out); }
.work-chapter.is-out > * { opacity: 0; transform: translateY(-10px); }
.work-chapter.is-pre > * { opacity: 0; transform: translateY(10px); transition: none; }
.work-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.work-tags li { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); border: 1px solid var(--border-strong); border-radius: 2px; padding: 5px 8px; }
.work-link { justify-self: start; display: inline-flex; align-items: center; gap: 12px; height: 52px; padding: 0 22px; border-radius: var(--radius-btn); box-shadow: inset 0 0 0 1.5px var(--border-strong); color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-stretch: 108%; font-size: 15px; transition: box-shadow var(--dur-ui) var(--ease-out); }
.work-link:hover { box-shadow: inset 0 0 0 1.5px var(--text); }
.wl-arrow { color: var(--lime); font-size: 18px; transition: transform var(--dur-ui) var(--ease-out); }
.work-link:hover .wl-arrow { transform: translate(3px, -3px); }

/* frame */
.work-visual { grid-column: 6 / -1; display: grid; gap: 18px; }
.work-frame {
  position: relative; display: block; aspect-ratio: 16 / 10; max-height: 64vh; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: 6px; background: #0f0f0f; color: inherit; text-decoration: none;
  transition: transform 800ms var(--ease-out), border-color 400ms var(--ease-out);
  --mx: 50%; --my: 50%;
}
.work-frame:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.wscene { position: absolute; inset: 0; visibility: hidden; }
.wscene.is-shown { visibility: visible; }
.scene-cap { display: none; }

.wsc-web { display: flex; flex-direction: column; background: #111; }
.wsc-chrome { height: 28px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 0 12px; background: #141414; border-bottom: 1px solid var(--border); }
.wsc-chrome i { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.wsc-chrome span { margin-left: 10px; font-family: var(--font-mono); font-size: 10px; color: var(--text-2); }
.wsc-screen { position: relative; flex: 1; overflow: hidden; background: #fff; }

.web-col-dash { width: 100%; animation-duration: 20s; }

.wsc-mob { background: radial-gradient(70% 70% at 50% 30%, #1d1d1b, #0b0b0b 70%); }
.wm-phone { position: absolute; width: 24%; aspect-ratio: 390 / 844; border-radius: 22px; border: 5px solid #1d1d1d; overflow: hidden; background: #fff; box-shadow: 0 40px 70px -24px rgba(0, 0, 0, .95), 0 0 0 1px var(--border-strong); transition: transform 900ms var(--ease-out), opacity 700ms var(--ease-out); }
.wm-phone img { width: 100%; height: auto; }
.wm-phone.p1 { left: 24%; top: 9%; transform: translateY(40px); opacity: 0; }
.wm-phone.p2 { left: 52%; top: 16%; transform: translateY(60px); opacity: 0; transition-delay: 90ms; }
.wsc-mob.is-shown .wm-phone { transform: none; opacity: 1; }

.work-frame .wipe { z-index: 5; }

/* custom cursor (desktop, fine pointer) */
.work-cursor { position: absolute; z-index: 6; left: var(--mx); top: var(--my); width: 104px; height: 104px; margin: -52px 0 0 -52px; border-radius: 50%; background: var(--lime); color: var(--obsidian); display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; transform: scale(0); transition: transform 400ms cubic-bezier(.22, 1, .36, 1); pointer-events: none; }
@media (pointer: fine) {
  .work-frame { cursor: none; }
  .work-frame:hover { transform: scale(1.015); border-color: var(--text-2); }
  .work-frame:hover .work-cursor, .work-frame:focus-visible .work-cursor { transform: scale(1); }
}

/* chapter index with the lime arrow */
.work-chapters { position: relative; display: flex; flex-wrap: wrap; gap: 0 4px; border-top: 1px solid var(--border); }
.work-chapters button { background: none; border: 0; cursor: pointer; color: var(--muted); font-family: var(--font-display); font-weight: 700; font-stretch: 104%; font-size: 17px; padding: 16px 14px 6px 48px; display: inline-flex; gap: 8px; align-items: baseline; transition: color 400ms var(--ease-out); }
.work-chapters button span { font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .08em; }
.work-chapters button:hover { color: var(--text-2); }
.work-chapters button[aria-selected="true"] { color: var(--text); }
.work-chapters button[aria-selected="true"] span { color: var(--lime); }
.wc-arrow { position: absolute; left: 0; top: 19px; width: 40px; height: 16px; transform: translateX(var(--wx, 0px)); transition: transform 560ms cubic-bezier(.22, 1, .36, 1); }
.wc-arrow svg { display: block; width: 100%; height: 100%; fill: none; stroke: var(--lime); overflow: visible; }
.wc-arrow .shaft { stroke-width: 2; }
.wc-arrow .head { stroke-width: 4; stroke-linecap: square; }

/* more projects: cards under the main stage, two per row */
.work-more { margin-top: clamp(96px, 10vw, 160px); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 56px 24px; position: relative; z-index: 2; }
.more-card { display: grid; gap: 24px; align-content: start; transition: opacity 800ms var(--ease-out), transform 800ms var(--ease-out); }
.more-card:nth-child(even) { transition-delay: 120ms; }
.js .more-card:not(.is-in) { opacity: 0; transform: translateY(40px); }
.more-frame { display: flex; flex-direction: column; aspect-ratio: 16 / 10; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 6px; background: #111; color: inherit; text-decoration: none; transition: transform 800ms var(--ease-out), border-color 400ms var(--ease-out); }
.more-frame:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.more-frame:hover { transform: scale(1.015); border-color: var(--text-2); }
.web-col-full { width: 100%; animation-duration: 30s; }
.more-info { display: grid; gap: 14px; }
.more-title { margin: 0; font-family: var(--font-display); font-weight: 900; font-stretch: 112%; font-size: clamp(32px, 3vw, 48px); line-height: .95; letter-spacing: -.04em; }
.more-desc { margin: 0; color: var(--text-2); font-size: 16px; line-height: 1.6; max-width: 46ch; }

/* index + call to action */
.work-index { margin-top: clamp(96px, 10vw, 160px); position: relative; z-index: 2; }
.index-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.index-list li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 24px; align-items: baseline; padding: 22px 0; border-bottom: 1px solid var(--border); }
.ix-num { font-family: var(--font-mono); font-size: 12px; color: var(--lime); letter-spacing: .1em; }
.ix-name { font-family: var(--font-display); font-weight: 800; font-stretch: 108%; font-size: clamp(28px, 3vw, 44px); letter-spacing: -.035em; line-height: 1; }
.ix-cat { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.ix-link { color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; }
.ix-link span:first-of-type { color: var(--lime); display: inline-block; transition: transform var(--dur-ui) var(--ease-out); }
.ix-link:hover span:first-of-type { transform: translate(3px, -3px); }
.work-next { margin-top: clamp(64px, 7vw, 112px); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 28px; }
.work-next p { margin: 0; font-family: var(--font-display); font-weight: 800; font-stretch: 104%; font-size: clamp(30px, 3.6vw, 56px); letter-spacing: -.035em; line-height: 1; }

/* exit thread into Process */
.work-thread { position: absolute; z-index: 1; left: var(--tx, 75%); top: var(--ty, 0px); height: var(--th, 0px); width: 2px; margin-left: -1px; pointer-events: none; }
.work-thread i { position: absolute; inset: 0; background: var(--lime); clip-path: inset(0 0 calc((1 - var(--t, 0)) * 100%) 0); }

/* ── Desktop: pinned stage ── */
@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  .work-stage { height: 340vh; }
  .work-pin { position: sticky; top: 0; height: 100vh; padding-block: calc(var(--header-h) + 16px) 24px; display: flex; align-items: center; }
  .work-pin > .container { width: 100%; }
}

/* ── Tablet: no pin, chapters by click ── */
@media (max-width: 1023px) {
  .work-h2 { grid-column: 1 / -1; }
  .work-lead { grid-column: 1 / -1; margin-top: 24px; }
  .work-info { grid-column: 1 / -1; }
  .work-visual { grid-column: 1 / -1; margin-top: 40px; }
  .work-frame { max-height: none; }
  .work-name { font-size: 15.2vw; bottom: auto; top: 0; }
  .index-list li { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .ix-cat { display: none; }
  .work-more { grid-template-columns: minmax(0, 1fr); }
}

/* ── Mobile: three chapters stacked, full bleed ── */
@media (max-width: 639px) {
  .work-intro { display: block; }
  .work-h2 { font-size: clamp(38px, 11vw, 52px); }
  .work-title { font-size: clamp(44px, 15vw, 76px); }
  .work-name { display: none; }
  .work-chapter, .work-chapters { display: none; }
  .work-frame { aspect-ratio: auto; border: 0; border-radius: 0; background: none; overflow: visible; margin-inline: calc(-1 * max(var(--gutter), env(safe-area-inset-left, 0px))); display: grid; gap: 40px; transform: none !important; }
  .work-frame .wipe, .work-cursor { display: none; }
  .wscene { position: relative; inset: auto; visibility: visible; aspect-ratio: 4 / 5; overflow: hidden; }
  .wsc-web { aspect-ratio: auto; }
  .wsc-web .wsc-screen { aspect-ratio: 4 / 5; flex: none; }
  .wsc-mob .wm-phone { width: 40%; }
  .wsc-mob .wm-phone.p1 { left: 8%; }
  .wsc-mob .wm-phone.p2 { left: 52%; }
  .scene-cap { display: block; position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 40px max(var(--gutter), env(safe-area-inset-left, 0px)) 18px; background: linear-gradient(transparent, rgba(9, 9, 9, .92) 45%); color: var(--text); font-size: 15px; line-height: 1.5; }
  .scene-cap b { display: block; font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--lime); margin-bottom: 4px; }
  .wsc-web .scene-cap { position: relative; background: #0b0b0b; padding-top: 16px; }
  .js .wscene:not(.is-in) { clip-path: inset(0 0 100% 0); }
  .wscene { transition: clip-path 900ms var(--ease-out); clip-path: inset(0 0 0 0); }
  .work-link { width: 100%; justify-content: center; height: 56px; }
  .work-next { flex-direction: column; align-items: stretch; }
  .work-next .btn { justify-content: space-between; }
  .index-list li { grid-template-columns: 40px minmax(0, 1fr); row-gap: 8px; }
  .ix-link { grid-column: 2; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .js .work-h2:not(.is-in) .row > span, .js .work-lead:not(.is-in), .js .index-list:not(.is-in), .js .work-next:not(.is-in) { opacity: 1; transform: none; }
  .js .wscene:not(.is-in) { clip-path: none; }
  .js .more-card:not(.is-in) { opacity: 1; transform: none; }
  .more-frame:hover { transform: none; }
  .wm-phone.p1, .wm-phone.p2 { transform: none; opacity: 1; }
  .work-thread i { clip-path: none; }
}
