/* Campaign gallery on the Work page. Everything is prefixed cg- so it cannot affect the rest of the site. */
.cg { --cg-top: 4.5rem; --cg-h: calc(100vh - var(--cg-top)); }
@supports (height: 100svh) { .cg { --cg-h: calc(100svh - var(--cg-top)); } }
/* gallery view: the hallway fills the window and the page does not scroll */
html.cg-walking, html.cg-walking body { overflow: hidden; overscroll-behavior: none; }

:where(.cg, .cg-detail) button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.cg button:focus-visible, .cg-detail button:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 3px; }
.cg [hidden], .cg-detail[hidden], .cg-detail [hidden] { display: none !important; }
.cg-caps { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }

.cg-toggle { position: fixed; top: calc(var(--cg-top) + 1rem); left: var(--space-inline); z-index: 50; display: flex; border: 1px solid rgba(255,255,255,0.14); border-radius: 99px; padding: 3px; background: rgba(0,0,0,0.7); }
.cg-toggle button { padding: 0.5rem 1rem; border-radius: 99px; color: rgba(244,244,245,0.55); }
.cg-toggle button[aria-pressed="true"] { background: var(--text); color: #000; }

/* WALK-THROUGH */
.cg-stage { position: relative; height: var(--cg-h); overflow: hidden; background: #030304; }
.cg-stage:focus-visible { outline: none; } /* it fills the window, so a ring would just frame the page */
.cg-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.cg-stage canvas.over { cursor: pointer; }
.cg-stage canvas.dragging { cursor: grabbing; }
.cg-hud {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 5rem 1.25rem 1.1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.88)); pointer-events: none;
}
.cg-hud button { pointer-events: auto; }
.cg-hud .cg-enter { color: var(--blue-light); padding: 0.35rem 0.6rem; }
.cg-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin-bottom: 0.2rem; max-width: 100%; scrollbar-width: none; }
.cg-chips button { padding: 0.45rem 0.85rem; border: 1px solid rgba(255,255,255,0.1); border-radius: 99px; color: rgba(244,244,245,0.55); background: rgba(0,0,0,0.5); white-space: nowrap; }
.cg-chips button[aria-current="true"] { color: var(--text); border-color: var(--blue-light); }
.cg-hud-row { display: flex; align-items: center; gap: 1rem; margin-top: 0.4rem; color: rgba(244,244,245,0.55); }
.cg-loading { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(244,244,245,0.55); pointer-events: none; }

/* GRID / SWIPE */
.cg-grid { padding: 5.5rem var(--space-inline) 3rem; }
.cg-group { margin-bottom: 3rem; }
.cg-group h3 { font-family: var(--font-display); font-size: 1.8rem; letter-spacing: -0.02em; }
.cg-sub { color: rgba(244,244,245,0.55); margin-top: 0.35rem; }
.cg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.cg-grid .cg-card { position: relative; display: block; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); background: #111; }
.cg-card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s var(--ease-out-expo); }
.cg-card:hover img { transform: scale(1.03); }
.cg-badge { position: absolute; right: 0.6rem; top: 0.6rem; background: rgba(0,0,0,0.7); border-radius: 99px; padding: 0.35rem 0.65rem; }

/* OPEN PIECE */
.cg-detail {
  position: fixed; inset: 0; z-index: 200; background: rgba(4,4,6,0.97);
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 5rem);
  padding: 4.25rem clamp(1.1rem, 4vw, 3.5rem) 2rem; opacity: 0; transition: opacity 0.35s ease; overflow-y: auto;
}
.cg-detail.show { opacity: 1; }
/* small white close button, top left of every opened piece */
.cg-detail .cg-x { position: fixed; top: 1rem; left: 1rem; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #000; box-shadow: 0 4px 18px rgba(0,0,0,0.5); transition: transform 0.2s ease; }
.cg-detail .cg-x:hover { transform: scale(1.08); }
.cg-media { display: flex; align-items: center; justify-content: flex-end; min-height: 0; }
.cg-media img, .cg-media video { max-width: 100%; max-height: calc(100vh - 7.25rem); border-radius: 8px; box-shadow: 0 30px 90px rgba(0,0,0,0.7); }
.cg-info { align-self: center; max-width: 30rem; }
.cg-info .cg-company { color: var(--blue-light); }
.cg-info h2 { font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0.8rem 0 1rem; }
.cg-info p { color: rgba(244,244,245,0.55); line-height: 1.65; }
.cg-info .cg-stat { display: inline-block; margin-top: 1rem; border: 1px solid rgba(255,255,255,0.1); border-radius: 99px; padding: 0.4rem 0.85rem; }
.cg-info .cg-about { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; }
.cg-more { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.cg-more button { width: 56px; aspect-ratio: 4 / 5; border-radius: 5px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); opacity: 0.55; }
.cg-more button[aria-current="true"] { opacity: 1; border-color: var(--blue-light); }
.cg-more img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cg-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.cg-actions button { border: 1px solid rgba(255,255,255,0.1); border-radius: 99px; padding: 0.7rem 1.1rem; }
.cg-actions .cg-close { background: var(--text); color: #000; }

@media (max-width: 760px) {
  .cg-cards { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin-inline: calc(-1 * var(--space-inline)); padding-inline: var(--space-inline); scroll-padding-inline: var(--space-inline); scrollbar-width: none; }
  .cg-grid .cg-card { flex: 0 0 76%; scroll-snap-align: start; }
  .cg-chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; pointer-events: auto; }
  /* stacked: picture first, words underneath, and the whole view scrolls */
  .cg-detail { display: flex; flex-direction: column; }
  .cg-media, .cg-info { flex: none; }
  .cg-info { align-self: stretch; }
  .cg-media { justify-content: center; }
  .cg-media img, .cg-media video { max-height: 62vh; }
}
