/* ==========================================================================
   FLARESHOOT — Work page (portfolio grid + detail modal)
   Extends the "Liquid Intelligence" design system in styles.css
   ========================================================================== */

/* ============ PAGE HEADER ============ */

.work-page {
  /* fully fluid canvas — the tiles always fill the screen proportionally,
     no rigid pixel cap on large monitors */
  width: 100%;
  margin: 0 auto;
  padding: 170px clamp(16px, 2.5vw, 48px) 120px;
}

.work-hero {
  text-align: center;
  margin-bottom: var(--space-6);
}

.work-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(38px, 6vw, 76px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: var(--space-3) 0;
}

.work-sub {
  color: var(--text-dim);
  font-size: clamp(15px, 1.4vw, 19px);
  max-width: 62ch;
  margin: 0 auto;
}

/* ============ PORTFOLIO GRID — 2 per row ============ */

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 48px) clamp(16px, 2vw, 32px);
  /* cap the grid so a 1:1 tile PLUS its hover info always fits inside the
     viewport height (≈240px reserved for info text + breathing room) —
     centered, so the side margins stay perfectly symmetric on any monitor */
  max-width: min(100%, calc((100vh - 240px) * 2 + clamp(16px, 2vw, 32px)));
  margin: 0 auto;
}

.work-tile {
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
}

.work-tile:focus-visible {
  outline: 2px solid var(--violet-soft);
  outline-offset: 4px;
  border-radius: var(--radius);
}

.tile-frame {
  /* thin rim — the image fills nearly the whole tile */
  padding: 8px;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.35s ease, box-shadow 0.35s ease;
  will-change: transform;
}

.work-tile:hover .tile-frame,
.work-tile:focus-visible .tile-frame {
  transform: scale(1.03);
  border-color: rgba(196, 181, 253, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 28px 70px rgba(5, 2, 12, 0.6),
    0 0 46px rgba(139, 92, 246, 0.28);
}

.tile-stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
}

.tile-stage .ph { border-radius: 16px; }

/* highlight preview crossfades in on hover */
.tile-highlight {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  background:
    radial-gradient(120% 100% at 30% 20%, rgba(168, 85, 247, 0.30), transparent 60%),
    radial-gradient(110% 110% at 80% 85%, rgba(249, 115, 22, 0.20), transparent 55%),
    linear-gradient(165deg, #221540 0%, #120A1F 100%);
}

.work-tile:hover .tile-highlight,
.work-tile:focus-visible .tile-highlight {
  opacity: 1;
}

/* info revealed under the tile on hover */
.tile-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* generous top spacing: the title sits centered between the
     scaled-up tile and the package line instead of hugging the frame */
  padding: 34px 8px 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.work-tile:hover .tile-info,
.work-tile:focus-visible .tile-info {
  opacity: 1;
  transform: translateY(0);
}

.tile-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 19px;
  color: var(--text);
}

.tile-package { color: var(--orange); }
.tile-addons  { color: var(--text-dim); }

/* touch devices: no hover — keep the info always visible */
@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .tile-info { opacity: 1; transform: none; }
}

/* ============ DETAIL MODAL — CINEMA MODE ============ */

.work-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  /* near-edgeless: only a hair of breathing room around the panel */
  padding: clamp(6px, 0.8vw, 12px);
}

.work-modal[hidden] { display: none; }

.work-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 3, 12, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.work-modal-panel {
  /* edge-to-edge cinema panel: giant viewer left, slim sidebar right */
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(240px, 18vw, 340px);
  gap: clamp(14px, 1.6vw, 28px);
  width: 100%;
  max-width: none;
  height: 100%;
  /* visible: glows (e.g. the CTA) may breathe past the panel edge;
     children handle their own scrolling */
  overflow: visible;
  padding: clamp(12px, 1.3vw, 22px);
  animation: modal-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  /* well above every slide layer — and on its own GPU layer, so WebKit's
     hit-testing can't put the (3D-transformed) slide image above it */
  z-index: 20;
  transform: translateZ(0);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(18, 10, 31, 0.8);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.modal-close:hover {
  border-color: rgba(249, 115, 22, 0.5);
  box-shadow: 0 0 22px rgba(249, 115, 22, 0.25);
}

/* gallery side — the image claims every available pixel */

.modal-gallery {
  position: relative; /* hosts the thumbs overlay zone at its bottom edge */
  display: flex;
  flex-direction: column;
  min-height: 0; /* allow the stage to shrink-fit inside the grid row */
}

.modal-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-slide {
  /* as large as the viewport allows, never squished: height-driven 1:1 */
  height: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  width: auto;
  max-width: 100%;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(196, 181, 253, 0.32);
  background:
    radial-gradient(circle at 30% 25%, rgba(168, 85, 247, 0.28), transparent 65%),
    rgba(18, 10, 31, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 26px rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease,
              transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-nav svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-nav:hover {
  border-color: rgba(196, 181, 253, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 28px rgba(139, 92, 246, 0.5);
  transform: translateY(-50%) scale(1.08);
}
.modal-prev:hover svg { transform: translateX(-2px); }
.modal-next:hover svg { transform: translateX(2px); }
.modal-nav:active { transform: translateY(-50%) scale(0.96); }

/* page counter — desktop: quiet editorial numbers top-left of the stage,
   beside (not on) the image */
.modal-count {
  position: absolute;
  top: 6px;
  left: 14px;
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  pointer-events: none;
  user-select: none;
}
.mc-cur { font-size: 22px; color: #fff; font-weight: 500; }
.mc-sep { font-size: 14px; color: rgba(196, 181, 253, 0.5); }
.mc-total { font-size: 14px; color: var(--text-dim); }
.mc-chev { display: none; }

.modal-prev { left: 12px; }
.modal-next { right: 12px; }

/* invisible trigger strip along the bottom edge of the gallery — entering
   it slides the thumb bar up; leaving it (back into the image) hides it */
.modal-thumbs-zone {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 118px;
  z-index: 3;
}

.modal-thumbs {
  position: absolute;
  bottom: 12px;
  left: 50%;
  display: grid;
  /* one column per slide, so 6-slide (Basic) and 8-slide (Premium)
     strips both sit centred under the hint */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 74px);
  justify-content: center;
  gap: 8px;
  width: min(calc(100% - 24px), 660px);
  /* hidden by default — slides up + fades in on zone hover */
  opacity: 0;
  transform: translateX(-50%) translateY(16px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* :has(:focus-visible) instead of :focus-within — keyboard tabbing keeps
   the bar open, but a mouse CLICK on a thumb must not pin it visible
   after the pointer moves back up into the image */
.modal-thumbs-zone:hover .modal-thumbs,
.modal-thumbs-zone:has(:focus-visible) .modal-thumbs {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* subtle glass badge hinting at the hidden overview — fades out
   as soon as the thumbs slide in */
.modal-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 18px;
  border-radius: 999px;
  border: 1px solid rgba(196, 181, 253, 0.22);
  /* dark enough to stay readable on white cutout slides too */
  background: rgba(12, 7, 22, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 22px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  letter-spacing: 0.28em;
  color: rgba(232, 226, 248, 0.92);
  z-index: 4;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-thumbs-zone:hover .modal-hint,
.modal-thumbs-zone:has(:focus-visible) .modal-hint {
  opacity: 0;
}

.modal-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid rgba(196, 181, 253, 0.12);
  background: linear-gradient(165deg, #17102A 0%, #0C0716 100%);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.modal-thumb.is-active {
  border-color: rgba(249, 115, 22, 0.6);
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.25);
  color: var(--orange);
}

/* info side — slim, elegant, scrolls if needed */

.modal-info {
  display: flex;
  flex-direction: column;
  /* top: keep the title clear of the ✕ button (44px + 14px offset) */
  padding: 62px 2px 2px 0;
  min-height: 0;
  /* NO overflow clipping here — the CTA sits outside the scroll area,
     so its glow can spread freely into the page */
  overflow: visible;
}

.modal-info-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-right: 6px;
}

.modal-cta { margin-top: 16px; }

.modal-title {
  /* compact — project names can get long */
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(17px, 1.3vw, 22px);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid rgba(196, 181, 253, 0.12);
  padding-top: var(--space-3);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.meta-row dd {
  color: var(--text);
  font-size: 15px;
  text-align: right;
}

.modal-briefing {
  border: 1px solid rgba(196, 181, 253, 0.14);
  border-radius: 14px;
  background: rgba(139, 92, 246, 0.05);
  padding: 14px 18px;
}

.modal-briefing summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 15px;
  color: var(--violet-soft);
  list-style: none;
}

.modal-briefing summary::before {
  content: '+';
  color: var(--orange);
  margin-right: 10px;
  font-weight: 700;
}

.modal-briefing[open] summary::before { content: '–'; }

.modal-briefing-body {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 14.5px;
}

/* real briefing: question = readable heading, client answer = dimmer text */
.brief-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.brief-item {
  padding-top: 16px;
  border-top: 1px solid rgba(196, 181, 253, 0.10);
}
.brief-item:first-child { padding-top: 4px; border-top: 0; }
.brief-num { display: block; color: var(--orange); margin-bottom: 6px; }
.brief-q {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.4;
}
.brief-a { color: rgba(155, 143, 181, 0.92); font-size: 14px; line-height: 1.55; }
.brief-a p { margin: 0 0 6px; }
.brief-a p:last-child { margin-bottom: 0; }
.brief-a ul { margin: 0 0 6px; padding-left: 18px; }
.brief-a li { margin: 0 0 3px; }
.brief-a li::marker { color: rgba(249, 115, 22, 0.7); }

/* real images on tiles, modal and thumbs */
.tile-img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 16px;
}
img.tile-highlight { background: none; }
.modal-slide.has-img { padding: 0; background: #0C0716; }
.modal-slide.has-img::before { display: none; }
/* the static label is replaced by animated slide layers */
.modal-slide > #modal-slide-label { display: none; }
.modal-slide { touch-action: pan-y; }
.slide-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);   /* own GPU layer from the start */
  contain: layout paint;
  transition: none;
  border-radius: 16px;      /* keeps rounded corners while a slide is scaled mid-swipe */
  overflow: hidden;
}
.slide-layer.is-leaving { pointer-events: none; }
.slide-layer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.modal-thumb.has-img { padding: 0; overflow: hidden; }
.modal-thumb.has-img img { display: block; width: 100%; height: 100%; object-fit: cover; }

.modal-cta { margin-top: auto; align-self: stretch; }

/* touch devices: no hover — keep the thumbs in flow and always visible */
@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .modal-thumbs-zone { position: static; height: auto; }
  /* touch browsers keep :hover "stuck" after a tap — the desktop hover rule
     (translateX(-50%)) would then shove the in-flow bar half off-screen to
     the left. Match its specificity so the bar always stays put. */
  .modal-thumbs,
  .modal-thumbs-zone:hover .modal-thumbs,
  .modal-thumbs-zone:has(:focus-visible) .modal-thumbs {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    width: 100%;
    margin-top: 12px;
  }
  .modal-hint { display: none; }

  /* touch (tablet): small glass counter top-left on the image */
  .modal-count {
    top: 10px;
    left: 10px;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(12, 7, 22, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .mc-cur { font-size: 13px; }
  .mc-sep, .mc-total { font-size: 11px; }

  /* one-time swipe hint — semi-transparent, fades after the first swipe */
  .swipe-hint {
    display: flex;
    position: absolute;
    left: 50%;
    bottom: 14px;
    z-index: 4;
    transform: translateX(-50%);
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(12, 7, 22, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(196, 181, 253, 0.2);
    color: rgba(242, 238, 250, 0.9);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.5s ease;
  }
  .swipe-hint .sh-chev {
    font-size: 15px;
    letter-spacing: 0;
    color: rgba(196, 181, 253, 0.85);
    animation: sh-nudge-l 1.6s ease-in-out infinite;
  }
  .swipe-hint .sh-chev:last-child { animation-name: sh-nudge-r; }
  .swipe-hint.is-gone { opacity: 0; }
}
.swipe-hint { display: none; }
@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .swipe-hint { display: flex; }
}
@keyframes sh-nudge-l { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-3px); } }
@keyframes sh-nudge-r { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }

/* modal open: lock page scroll */
body.modal-open { overflow: hidden; }

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  .work-modal-panel {
    grid-template-columns: 1fr;
    height: auto;
    max-height: calc(100dvh - 20px);
    overflow: auto;
  }
  .modal-slide { height: auto; width: 100%; }
  .modal-info { overflow: visible; padding-top: 6px; padding-bottom: 8px; }
}

@media (max-width: 640px) {
  .work-grid { grid-template-columns: 1fr; }
  .work-page { padding-top: 130px; }
  .modal-thumbs { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); }

  /* 6 — no side arrows on mobile; navigation is by swipe or the 1–8 thumbs */
  .modal-nav { display: none; }

  /* 7 — reserve a header strip so the ✕ sits ABOVE the 1:1 image, not over it */
  .work-modal-panel { padding-top: 66px; }
  /* phone: counter sits ABOVE the image in that header strip, level with the ✕ */
  .modal-count {
    top: -46px;
    left: 2px;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .mc-cur { font-size: 18px; }
  .mc-sep, .mc-total { font-size: 12px; }

  /* 8 — breathing room between the briefing accordion and the CTA button */
  .modal-cta { margin-top: 24px; }
}

/* ============ finishing touches (js/work-fx.js) ============ */
.tile-frame { --rx: 0deg; --ry: 0deg; }
@media (hover: hover) and (pointer: fine) {
  .work-tile:hover .tile-frame,
  .work-tile:focus-visible .tile-frame {
    transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) scale(1.03);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s ease, box-shadow 0.35s ease;
  }
}
/* the Menu cannot be hit through an open gallery (or the click right after closing it) */
body.modal-open .site-header .nav-toggle,
body.nav-lock .site-header .nav-toggle { pointer-events: none; }

/* the tiles are built by js/work.js after first paint — reserve the room so the
   footer never flashes up top and jumps down (layout shift / CLS) */
.work-grid { min-height: 100vh; }

/* 2026-11-22 — touch: a tap opens the set straight away. No highlight
   crossfade / scale on the (sticky) touch hover, which made iOS need a
   second tap and showed a preview first. */
@media (hover: none), (pointer: coarse) {
  .tile-highlight { display: none; }
  .work-tile:hover .tile-frame { transform: none; }
}
