/* Project popup. The clicked tile flies into place as .case-flyer (case.js), then the details fade in around it. */
.case { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); overflow: auto; overscroll-behavior: contain; }
/* The page stays visible but blurred and dimmed behind the popup, so only the popup reads sharp. Clicking the blurred area
   closes it (case.js). */
.case::backdrop { background: rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(24px) saturate(1.1); backdrop-filter: blur(24px) saturate(1.1); }
.case-panel { width: min(1240px, 86vw); min-height: 100%; margin-inline: auto; background: var(--ink-2); overflow: hidden; }
.case-stage { position: relative; height: min(78vh, 48vw); min-height: 300px; background: #000; }
@media (max-width: 760px) { .case-panel { width: 100%; } }
@media (max-width: 720px) { .case-stage { height: 62vh; } }
.case-main { width: 100%; height: 100%; object-fit: contain; }
.case-close { position: fixed; z-index: 3; top: 14px; right: 14px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--text); color: var(--ink); font-size: 26px; line-height: 1; transition: transform 0.25s var(--ease); }
.case-close:hover { transform: rotate(90deg) scale(1.06); }
.case-flyer { position: fixed; z-index: 2; left: 0; top: 0; object-fit: cover; transform-origin: 50% 50%; will-change: transform; pointer-events: none; }
/* Video or Images, Desktop or Mobile (case-view.js). Each group only shows when the project has more than one choice. */
.case-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; padding: 16px 20px 0; }
.seg { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--ink); }
.seg-btn { min-height: 40px; padding: 6px 18px; border-radius: 999px; color: var(--muted); font-size: 15px; font-weight: 500; transition: color 0.2s, background 0.25s var(--ease); }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed='true'] { color: var(--ink); background: var(--text); }
/* Phone media: the stage keeps its height and the portrait image or video sits centred in it (object-fit on .case-main). */
.case-stage.is-mobile { background: radial-gradient(ellipse at 50% 40%, var(--ink-3), #000 70%); }
.case-stage.is-mobile .case-main { padding: 16px 0; }
video.case-main { display: block; background: #000; }
.case-strip { display: flex; gap: 10px; padding: 14px 20px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.case-thumb { flex: none; width: 120px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; opacity: 0.55; outline-offset: 2px; transition: opacity 0.2s; }
.case-thumb.is-mobile { width: auto; height: 120px; aspect-ratio: 9 / 16; }
.case-thumb img { width: 100%; height: 100%; object-fit: cover; }
.case-thumb:hover, .case-thumb[aria-current='true'] { opacity: 1; }
.case-thumb[aria-current='true'] { box-shadow: 0 0 0 2px var(--text); }
.case-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(220px, 1fr); gap: 40px; padding: clamp(24px, 4vw, 44px); }
@media (max-width: 760px) { .case-body { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
/* The media sharpens out of the blurred flying tile once it has loaded (case.js morphs it with this filter). */
.case-main { will-change: filter, opacity; }
/* Same face as the PORTFOLIO title (.work-title): Nebula with the same thin stroke. Nebula is wide, so it runs smaller. */
.case-name { font-family: 'Nebula', var(--body); font-size: clamp(26px, 3.6vw, 58px); line-height: 1; font-weight: 400; letter-spacing: normal; -webkit-text-stroke: 0.022em currentColor; text-transform: uppercase; }
.case-blurb { margin-top: 16px; max-width: 62ch; color: var(--muted); font-size: 19px; }
.case-facts { margin: 0; display: grid; gap: 16px; align-content: start; }
.case-facts dt { font-size: 14px; color: var(--muted); }
.case-facts dd { margin: 2px 0 0; font-size: 17px; }
.case-tags { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.case-refs { padding: 0 clamp(24px, 4vw, 44px) clamp(24px, 4vw, 44px); }
.case-refs h3 { font-size: 20px; font-weight: 500; margin-bottom: 14px; }
.case-links { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.case-videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.case-video { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--ink); }
.case-video img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; transition: opacity 0.2s, transform 0.4s var(--ease); }
.case-video:hover img { opacity: 1; transform: scale(1.04); }
.case-video iframe { width: 100%; height: 100%; border: 0; }
.case-play { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: var(--text); clip-path: none; display: grid; place-items: center; }
.case-play::after { content: ''; margin-left: 4px; border-left: 16px solid var(--ink); border-top: 10px solid transparent; border-bottom: 10px solid transparent; }
.case-video-title { margin-top: 8px; font-size: 15px; color: var(--muted); }

/* Desktop: a floating card that fits the screen, so nothing needs scrolling. The media fills the left column (stage, then
   the switches and the clip or screenshot strip under it); the right column holds the title, text, facts and references,
   and scrolls on its own only if a project has a very long description. */
@media (min-width: 900px) and (min-height: 560px) {
  .case[open] { display: grid; place-items: center; overflow: hidden; }
  .case-panel { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 27vw, 420px); width: min(1500px, 94vw); height: min(900px, 90dvh); min-height: 0; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 22px; box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.8); }
  .case-media { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #000; }
  .case-media .case-stage { flex: 1; height: auto; min-height: 0; }
  .case-controls { padding: 14px 18px 0; }
  .case-strip { flex: none; padding: 12px 18px 16px; border-bottom: 0; }
  .case-thumb { width: 104px; }
  .case-thumb.is-mobile { height: 104px; }
  .case-side { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-left: 1px solid rgba(255, 255, 255, 0.06); }
  .case-side .case-body { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 34px 30px 24px; }
  .case-side .case-name { font-size: clamp(24px, 2.2vw, 40px); }
  .case-side .case-blurb { font-size: 17px; }
  .case-side .case-refs { padding: 0 30px 30px; }
  .case-side .case-videos { grid-template-columns: minmax(0, 1fr); }
  /* The password screen (lock.js) has no side column: its stage takes the whole card. */
  .case-panel.case-locked { grid-template-columns: minmax(0, 1fr); }
  .case-locked .case-stage { height: 100%; }
  .case-close { top: max(14px, calc(5dvh - 24px)); right: max(14px, calc(3vw - 24px)); }
}
