/* Grid is an independent presentation. The app reparents #work-entry directly
   into #journey and measures its complete border box. --grid-start/--grid-after
   are the helper's preRange/postRange in px; --grid-header-height is measured.
   Per-card --grid-media-aspect preserves each original preview's source ratio. */
/* Native previews already reserve their complete viewport in .card-image.
   Let the browser skip the source DOM while that viewport is offscreen; the
   original readiness and visible-time clocks still own loading and animation. */
body[data-work-presentation='grid'] #project-grid .project-live-preview {
  content-visibility: auto;
}

body[data-work-presentation='grid'] {
  --grid-gutter: clamp(20px, 6vw, 80px);
  min-height: 100vh;
}

body[data-work-presentation='grid'] #journey {
  position: relative;
  inset: auto;
  display: flow-root;
  width: 100%;
  height: auto;
  min-height: 100vh;
  padding: 0 0 calc(var(--grid-after, 0px) + 100vh);
  overflow: visible;
  perspective: none;
  transform-style: flat;
}

/* These chapters keep viewport geometry while the work section owns document
   flow. Perspective lives on the scene window, never on their long ancestor. */
body[data-work-presentation='grid'] :is(.opening, .craft-view, .client-logos, .journey-footer) {
  position: fixed;
}
body[data-work-presentation='grid'] .scene-window {
  position: fixed;
  inset: 0;
  perspective: 1500px;
}
body[data-work-presentation='grid'] #contact-entry {
  position: fixed;
  inset: 0;
}

body[data-work-presentation='grid'] #work-entry {
  position: relative;
  inset: auto;
  width: min(1280px, calc(100% - var(--grid-gutter) * 2));
  height: auto;
  min-height: 0;
  max-height: none;
  margin: var(--grid-start, 0px) auto 0;
  padding: calc(var(--grid-header-height, 96px) + 32px) 0 80px;
  overflow: visible;
  opacity: 1;
  visibility: visible;
  transform: none;
  transform-origin: center;
  will-change: auto;
  scroll-margin-top: var(--grid-header-height, 96px);
}
body[data-work-presentation='grid'] #work-entry .gallery-heading {
  position: relative;
  inset: auto;
  margin: 0 0 28px;
}
body[data-work-presentation='grid'] #work-entry .gallery-heading .chapter-label {
  margin: 0;
  font: 500 italic clamp(28px, 3vw, 40px)/1.15 'Bodoni Moda', Georgia, serif;
  letter-spacing: -.025em;
}

body[data-work-presentation='grid'] #project-grid {
  position: relative;
  inset: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 32px;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
  clip-path: none;
  perspective: none;
  transform: none;
  isolation: auto;
  scroll-snap-type: none;
  touch-action: pan-y;
}

/* The semantic link stays still. Existing pointer depth belongs to its visual
   surface and original media, so it cannot move the document's focus target. */
body[data-work-presentation='grid'] #project-grid .project-card {
  position: relative;
  inset: auto;
  display: block;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  flex: none;
  border: 0;
  border-radius: 14px;
  background: none;
  opacity: 1;
  visibility: visible;
  transform: none !important;
  transform-origin: center;
  transform-style: preserve-3d;
  perspective: 1500px;
  will-change: auto;
  outline-offset: 7px;
  scroll-margin-top: calc(var(--grid-header-height, 96px) + 24px);
  --card-drift: 0px;
}
body[data-work-presentation='grid'] #project-grid .project-card:focus-visible {
  outline: 2px solid var(--paper);
}
body[data-work-presentation='grid'] #project-grid .card-surface {
  position: relative;
  inset: auto;
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 16px 0 0;
  border: 0;
  border-radius: 14px;
  background: #081a2f;
  box-shadow: 0 20px 64px #01081240, inset 0 0 0 1px #fff5df38;
  overflow: visible;
  transform-style: preserve-3d;
}
body[data-work-presentation='grid'] #project-grid .card-image {
  position: relative;
  inset: auto;
  display: block;
  width: calc(100% - 32px);
  height: auto;
  max-height: none;
  aspect-ratio: var(--grid-media-aspect, 11/6);
  margin: 0 16px;
  border: 0;
  border-radius: 7px;
  background: #07182d;
  box-shadow: none;
  overflow: hidden;
  transform-origin: center;
  filter: none;
  transition: none;
}
body[data-work-presentation='grid'] #project-grid .card-image > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50% !important;
  transform: none !important;
  transition: none;
}
/* Keep a complete source composition behind the preload gate. Source geometry
   and bytes are unchanged; failed loads retain the catalog-image fallback. */
body[data-work-presentation='grid'] .project-card[data-project-images-ready='false'] .card-image > :is(img,.project-live-preview) { visibility: hidden; }
/* Native actor visibility can override inherited visibility. Composite the
   whole preview only after readiness so partially loaded SVGs cannot leak. */
body[data-work-presentation='grid'] .project-card[data-project-images-ready='false'] .card-image > .project-live-preview { opacity: 0; }
body[data-work-presentation='grid'] .project-card[data-project-images-state='error'] .card-image > img { visibility: visible; }
body[data-work-presentation='grid'] #project-grid .card-caption-clip {
  position: relative;
  inset: auto;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  perspective: none;
  transform-style: preserve-3d;
}
body[data-work-presentation='grid'] #project-grid .card-caption {
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 24px;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 24px;
  background: none;
  color: var(--paper);
  transform: none;
}
body[data-work-presentation='grid'] #project-grid .card-attribution {
  position: relative;
  inset: auto;
  display: block;
  flex: 1 1 220px;
  width: auto;
  min-width: 0;
}
body[data-work-presentation='grid'] #project-grid .card-name {
  display: block;
  font: 500 italic clamp(30px, 3vw, 42px)/1.05 'Bodoni Moda', Georgia, serif;
  letter-spacing: -.04em;
  white-space: normal;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
body[data-work-presentation='grid'] #project-grid .card-role {
  display: block;
  max-width: none;
  margin-top: 12px;
  font: 400 12px/1.45 'DM Sans', sans-serif;
  letter-spacing: 0;
  opacity: 1;
}
body[data-work-presentation='grid'] #project-grid .card-explore {
  position: relative;
  inset: auto;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 13px;
  width: 128px;
  max-width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #fff5df70;
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font: 500 italic 21px/1.2 'Bodoni Moda', Georgia, serif;
  transition: background-color .3s, color .3s, border-color .3s;
}
body[data-work-presentation='grid'] #project-grid .card-explore::after {
  content: none;
}
body[data-work-presentation='grid'] #project-grid .card-explore i {
  position: static;
  display: block;
  flex: none;
  width: 19px;
  height: 19px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: currentColor;
  opacity: 1;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 24L24 8M9 8H24V23' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform .35s var(--ease);
}
body[data-work-presentation='grid'] #project-grid .card-explore svg {
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .35s var(--ease);
}
body[data-work-presentation='grid'] #project-grid .project-card:is(:hover, :focus-visible) .card-image {
  border: 0;
  box-shadow: none;
  filter: none;
}
body[data-work-presentation='grid'] #project-grid .project-card:is(:hover, :focus-visible) .card-explore {
  background: var(--paper);
  color: #07182d;
  border-color: var(--paper);
}
body[data-work-presentation='grid'] #project-grid .project-card:is(:hover, :focus-visible) :is(.card-explore i, .card-explore svg) {
  transform: translate(2px, -2px);
}

body[data-work-presentation='grid'] :is(#work-globe-navigation, .project-orbit, .card-number) {
  display: none !important;
}
body[data-work-presentation='grid'][data-work-scene='on'] #scroll-cue {
  visibility: hidden !important;
}
/* Keep the original shared navigation and its responsive geometry. Only its
   transparent shadow borrows the project header's soft gradient treatment. */
body[data-work-presentation='grid'] #navigation {
  background: linear-gradient(#07182dcc, transparent);
}

@media (min-width: 900px) {
  body[data-work-presentation='grid'] #project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 40px 32px;
  }
}
@media (max-width: 899px) {
  body[data-work-presentation='grid'] #work-entry {
    padding-top: calc(var(--grid-header-height, 96px) + 24px);
    padding-bottom: 56px;
  }
  body[data-work-presentation='grid'] #project-grid .card-surface {
    padding-top: 12px;
  }
  body[data-work-presentation='grid'] #project-grid .card-image {
    width: calc(100% - 24px);
    margin-inline: 12px;
  }
  body[data-work-presentation='grid'] #project-grid .card-caption {
    padding: 20px;
  }
  body[data-work-presentation='grid'] #project-grid .card-name {
    font-size: clamp(30px, 6vw, 42px);
  }
}
@media (prefers-reduced-motion: reduce) {
  body[data-work-presentation='grid'] :is(.card-surface, .card-image, .card-caption, .card-explore, .card-explore i, .card-explore svg) {
    transition: none;
  }
}
body.reduced[data-work-presentation='grid'] :is(.card-surface, .card-image, .card-caption, .card-explore, .card-explore i, .card-explore svg) {
  transition: none;
}
