/* Project photo and reel gallery — shared by the homepage and /portfolio/. Items come from
   /assets/media.json via assets/media-gallery.js. Works on the navy homepage section and on light
   backgrounds: colours inside the tiles and viewer never depend on the surrounding section. */
.media-gallery { min-height: 300px; }
.mg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.mg-count { margin: 0; color: inherit; font-size: .82rem; opacity: .82; }
.mg-count strong { font-weight: 700; opacity: 1; }
.mg-arrows { display: flex; flex: 0 0 auto; gap: .5rem; }
.mg-arrow { display: grid; width: 44px; height: 44px; place-items: center; padding: 0; border: 1px solid var(--gold, #d7a928); border-radius: 50%; color: var(--navy, #090f20); background: var(--gold, #d7a928); cursor: pointer; transition: opacity .2s, transform .2s; }
.mg-arrow svg { width: 22px; height: 22px; fill: currentColor; }
.mg-arrow:hover:not(:disabled) { transform: scale(1.06); }
.mg-arrow:disabled { opacity: .35; cursor: default; }

.mg-track { display: grid; grid-auto-columns: clamp(210px, 22vw, 270px); grid-auto-flow: column; gap: .85rem; margin: 0; padding: 0 0 1rem; overflow-x: auto; list-style: none; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-color: var(--gold, #d7a928) transparent; scrollbar-width: thin; }
.mg-track:focus-visible { outline: 2px solid var(--gold, #d7a928); outline-offset: 4px; border-radius: 14px; }
.mg-track .mg-item { scroll-snap-align: start; }
.mg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; margin: 1rem 0 0; padding: 0; list-style: none; }

.mg-tile { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; border: 0; border-radius: 14px; background: #1a2747; box-shadow: 0 12px 30px rgba(7,26,49,.16); cursor: zoom-in; }
.mg-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.mg-tile:hover img { transform: scale(1.04); }
.mg-tile:focus-visible { outline: 3px solid var(--gold, #d7a928); outline-offset: 3px; }
.mg-tile.is-video { cursor: pointer; }
.mg-tile.is-video::after { position: absolute; inset: 0; content: ""; background: linear-gradient(rgba(7,26,49,0) 50%, rgba(7,26,49,.5)); pointer-events: none; }
.mg-play { position: absolute; z-index: 1; top: 50%; left: 50%; display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; color: var(--navy, #090f20); background: var(--gold, #d7a928); box-shadow: 0 10px 26px rgba(0,0,0,.3); transform: translate(-50%, -50%); transition: transform .2s; }
.mg-play svg { width: 24px; height: 24px; margin-left: 3px; fill: currentColor; }
.mg-tile:hover .mg-play { transform: translate(-50%, -50%) scale(1.08); }
.mg-badge { position: absolute; z-index: 1; top: .6rem; left: .6rem; padding: .28rem .55rem; border-radius: 999px; color: var(--navy, #090f20); background: rgba(255,255,255,.94); font-size: .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.mg-phase { position: absolute; z-index: 1; bottom: .6rem; left: .6rem; padding: .28rem .6rem; border-radius: 999px; color: var(--navy, #090f20); background: rgba(255,255,255,.94); font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mg-phase.is-before { color: #fff; background: rgba(9,15,32,.88); }
.mg-phase.is-during { background: var(--gold-light, #f0d488); }

.mg-more { display: block; margin: 1.6rem auto 0; padding: .9rem 1.6rem; border: 0; border-radius: 999px; color: var(--navy, #090f20); background: var(--gold, #d7a928); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; }
.mg-more:hover { background: var(--gold-light, #f0d488); }
.mg-status { margin: 0; font-size: .85rem; text-align: center; opacity: .8; }

/* Rolling reel strip: tall 9:16 tiles that loop a silent preview while on screen. */
.media-gallery[data-media-gallery="reels"] { min-height: 420px; }
.mg-reel-track { grid-auto-columns: clamp(190px, 19vw, 240px); }
.mg-tile.mg-reel { aspect-ratio: 9 / 16; cursor: pointer; }
.mg-reel video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s; pointer-events: none; }
.mg-reel.is-playing video { opacity: 1; }
.mg-reel::after { position: absolute; inset: 0; content: ""; background: linear-gradient(rgba(7,26,49,0) 55%, rgba(7,26,49,.82)); pointer-events: none; }
.mg-reel .mg-play { top: auto; right: .65rem; bottom: .65rem; left: auto; width: 42px; height: 42px; transform: none; }
.mg-reel .mg-play svg { width: 18px; height: 18px; }
.mg-reel:hover .mg-play { transform: scale(1.08); }
.mg-reel-title { position: absolute; z-index: 1; right: 3.8rem; bottom: .8rem; left: .8rem; color: #fff; font-size: .82rem; font-weight: 600; line-height: 1.3; text-align: left; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.reels-band { overflow: hidden; }
.reels-band .reels-head { display: grid; grid-template-columns: .9fr 1.1fr; gap: 3rem; align-items: end; margin-bottom: 2rem; }
.reels-band .reels-head h2, .reels-band .reels-head .lead { margin-bottom: 0; }
.reels-band .reels-more { margin: 1.2rem 0 0; font-size: .9rem; font-weight: 600; }
.reels-band .reels-more a { color: inherit; text-decoration: underline; text-decoration-color: var(--gold, #d7a928); text-underline-offset: 3px; }

/* Before/after slider: the after photo sits on top, clipped from the handle to the right edge. */
.mg-compare { position: relative; overflow: hidden; aspect-ratio: var(--ratio, 3 / 4); max-height: 78vh; border-radius: 14px; background: #1a2747; cursor: ew-resize; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.mg-compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.mg-compare-after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.mg-compare-handle { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 3px; background: #fff; box-shadow: 0 0 10px rgba(0,0,0,.45); transform: translateX(-50%); pointer-events: none; }
.mg-compare-handle::after { position: absolute; top: 50%; left: 50%; display: grid; width: 42px; height: 42px; place-items: center; content: "\2194"; border-radius: 50%; color: var(--navy, #090f20); background: var(--gold, #d7a928); box-shadow: 0 6px 18px rgba(0,0,0,.35); font-size: 1.1rem; font-weight: 700; transform: translate(-50%, -50%); }
.mg-compare-tag { position: absolute; z-index: 1; top: .6rem; padding: .28rem .6rem; border-radius: 999px; font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; }
.mg-compare-tag.is-before { left: .6rem; color: #fff; background: rgba(9,15,32,.88); }
.mg-compare-tag.is-after { right: .6rem; color: var(--navy, #090f20); background: rgba(255,255,255,.94); }
/* Kept for keyboards and screen readers; pointer drags are handled on the photo itself. */
.mg-compare-range { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
.mg-compare:focus-within { outline: 3px solid var(--gold, #d7a928); outline-offset: 3px; }
.mg-compare-caption { margin: .6rem 0 0; font-size: .84rem; font-weight: 600; line-height: 1.4; }
.mg-compare-next { margin-top: .5rem; padding: .45rem .9rem; border: 1px solid var(--gold, #d7a928); border-radius: 999px; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; }
.mg-compare-next:hover { background: rgba(215,169,40,.15); }
.mg-compare-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 0 0 1.6rem; padding: 0; list-style: none; }
.mg-compare-card .mg-compare-caption { color: inherit; opacity: .88; }

/* Project cards (/portfolio/) */
.mg-projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.4rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.mg-project { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line, #e2ddd0); border-radius: 16px; color: var(--ink, #141a2b); background: #fff; box-shadow: 0 14px 36px rgba(7,26,49,.08); }
.mg-project-media { padding: .7rem .7rem 0; }
.mg-project-media .mg-compare-caption { color: var(--muted, #545c6b); font-weight: 500; }
.mg-project-media .mg-compare-next { color: var(--navy, #090f20); }
.mg-project-cover { aspect-ratio: 4 / 3; box-shadow: none; }
.mg-project-body { display: flex; flex: 1; flex-direction: column; gap: .55rem; padding: .9rem 1.1rem 1.2rem; }
.mg-project-title { margin: 0; color: var(--navy, #090f20); font-family: var(--serif, Georgia, serif); font-size: 1.4rem; font-weight: 600; line-height: 1.15; }
.mg-project-meta { margin: 0; color: var(--muted, #545c6b); font-size: .8rem; font-weight: 600; }
.mg-project-desc { margin: 0; color: var(--ink, #141a2b); font-size: .88rem; line-height: 1.55; }
.mg-project-details { display: grid; gap: .3rem; margin: .2rem 0 0; font-size: .84rem; }
.mg-project-details div { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; }
.mg-project-details dt { color: var(--muted, #545c6b); font-weight: 600; }
.mg-project-details dd { margin: 0; }
.mg-project-thumbs { display: flex; gap: .4rem; margin-top: .2rem; overflow-x: auto; scrollbar-width: none; }
.mg-project-thumb { position: relative; flex: 0 0 auto; width: 56px; height: 56px; padding: 0; overflow: hidden; border: 0; border-radius: 8px; background: #1a2747; cursor: pointer; }
.mg-project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mg-project-thumb .mg-phase { bottom: 2px; left: 2px; padding: .1rem .3rem; font-size: .48rem; }
.mg-project-thumb.is-video::after { position: absolute; inset: 0; display: grid; place-items: center; content: "\25B6"; color: #fff; background: rgba(7,26,49,.35); font-size: .9rem; }
.mg-project-thumb:focus-visible, .mg-project-open:focus-visible, .mg-compare-next:focus-visible { outline: 3px solid var(--gold, #d7a928); outline-offset: 2px; }
.mg-project-open { align-self: flex-start; margin-top: auto; padding: .65rem 1.1rem; border: 0; border-radius: 999px; color: var(--navy, #090f20); background: var(--gold, #d7a928); font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; }
.mg-project-open:hover { background: var(--gold-light, #f0d488); }

/* Shown in the viewer if a reel cannot play */
.mg-fallback { max-width: 420px; padding: 1.5rem; border-radius: 12px; background: rgba(255,255,255,.08); text-align: center; }
.mg-fallback p { margin: 0 0 .8rem; }
.mg-fallback-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.mg-fallback-links a { padding: .5rem .9rem; border-radius: 999px; color: var(--navy, #090f20); background: var(--gold, #d7a928); font-weight: 700; }

/* Full-screen viewer */
html.mg-locked { overflow: hidden; }
.mg-viewer { width: 100vw; max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; color: #fff; background: rgba(5,9,20,.97); }
.mg-viewer::backdrop { background: rgba(5,9,20,.97); }
.mg-stage { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; padding: 3.8rem 4.5rem 3.4rem; touch-action: pan-y pinch-zoom; }
.mg-media { display: block; width: auto; max-width: 100%; height: auto; max-height: 100%; object-fit: contain; border-radius: 6px; background: #000; user-select: none; }
.mg-close, .mg-nav { position: absolute; z-index: 1; display: grid; width: 48px; height: 48px; place-items: center; padding: 0; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.12); cursor: pointer; transition: background .2s; }
.mg-close svg, .mg-nav svg { width: 26px; height: 26px; fill: currentColor; }
.mg-close:hover, .mg-nav:hover { color: var(--navy, #090f20); background: var(--gold, #d7a928); }
.mg-close:focus-visible, .mg-nav:focus-visible { outline: 3px solid var(--gold, #d7a928); outline-offset: 2px; }
.mg-close { top: .75rem; right: .75rem; }
.mg-nav { top: 50%; transform: translateY(-50%); }
.mg-prev { left: .9rem; }
.mg-next { right: .9rem; }
.mg-elsewhere { position: absolute; top: 1.1rem; left: 1rem; right: 4.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; margin: 0; font-size: .74rem; opacity: .85; }
.mg-elsewhere[hidden] { display: none; }
.mg-elsewhere a { color: var(--gold-light, #f0d488); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.mg-elsewhere.is-stalled { padding: .45rem .8rem; border-radius: 12px; color: var(--navy, #090f20); background: var(--gold, #d7a928); opacity: 1; }
.mg-elsewhere.is-stalled a { color: var(--navy, #090f20); }
.mg-counter { position: absolute; bottom: .9rem; left: 50%; margin: 0; padding: .3rem .8rem; border-radius: 999px; background: rgba(255,255,255,.1); font-size: .78rem; font-weight: 600; letter-spacing: .06em; transform: translateX(-50%); }

@media (max-width: 700px) {
  .mg-track { grid-auto-columns: 62vw; gap: .7rem; }
  .mg-reel-track { grid-auto-columns: 54vw; }
  .reels-band .reels-head { grid-template-columns: 1fr; gap: 1rem; }
  .mg-arrow { width: 38px; height: 38px; }
  .mg-grid { grid-template-columns: repeat(2, 1fr); gap: .55rem; }
  .mg-stage { padding: 3.6rem .5rem 3.4rem; }
  /* On phones the arrows sit at the bottom beside the counter, clear of the photo and video controls. */
  .mg-nav { top: auto; bottom: .45rem; width: 44px; height: 44px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .mg-tile img, .mg-play, .mg-arrow, .mg-reel video { transition: none; } .mg-tile:hover img { transform: none; } }
