/* ===========================================================
   Agenz - Services morph section (prototype)
   Standalone. Frame is DOM; content inside is swappable.
   =========================================================== */

/* Aliases onto the shared token layer in tokens.css, so a theme or type
   swap carries through this section too. Load tokens.css BEFORE this file.
   Fallbacks keep morph.html working standalone without tokens.css. */
:root {
  --ink:   var(--bg, #0A0A0A);
  --ink-2: var(--bg-raise, #121114);
  --bone:  var(--fg, #F4F0E9);
  --hair:  var(--rule, rgba(244, 240, 233, 0.10));

  --grad-1: var(--g1, #FF7E4D);
  --grad-2: var(--g2, #FF225E);
  --grad-3: var(--g3, #E61867);
  --grad-4: var(--g4, #390E7A);
  --brand-gradient: var(--gradient,
    linear-gradient(135deg, #FF7E4D 0%, #FF225E 45%, #E61867 75%, #390E7A 100%));

  /* Type faces come from tokens.css. Only fall back if this file is
     used standalone (morph.html) without the token layer loaded. */
  --font-display: var(--_display, 'Clash Display', system-ui, sans-serif);
  --font-body: var(--_body, 'Switzer', system-ui, sans-serif);

  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* stage hue - driven by JS per stage */
  --hue-a: var(--g1, #FF7E4D);
  --hue-b: var(--g2, #FF225E);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }

.scroll-hint {
  height: 60vh;
  display: grid;
  place-items: center;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint, rgba(244, 240, 233, 0.32));
}
.scroll-hint--end { height: 70vh; }

/* ---------- section shell ---------- */

.services { position: relative; height: 460vh; }

.services__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 38%) 1fr;
  align-items: center;
  gap: 3vw;
  /* was its own hardcoded clamp(24px, 5vw, 88px), never wired to the
     shared --gutter token every other section's .wrap uses - meant
     the Services headline started 4px off from Statement/Connect/Impact.
     No fallback here: --gutter is always defined on :root in tokens.css,
     and a fallback with nested-comma functions didn't resolve correctly. */
  padding: 0 var(--gutter);
  overflow: hidden;
}

/* soft ambient wash that shifts hue per stage */
.services__sticky::before {
  content: '';
  position: absolute;
  inset: 0;
  background: none;   /* no glow blobs */
  pointer-events: none;
}

/* ---------- left panel ---------- */

.panel { position: relative; z-index: 2; max-width: 30rem; }

/* static section label - does not swap between stages */
.panel__eyebrow {
  display: block;
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: var(--tracking-label, 0.22em);
  text-transform: uppercase;
  color: var(--fg-faint, rgba(244, 240, 233, 0.34));
  margin-bottom: 2.4rem;
}

.panel__index {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: var(--tracking-label, 0.22em);
  color: var(--bone);
  margin-bottom: 1.6rem;
}
.panel__index i { font-style: normal; color: var(--fg-faint, rgba(244, 240, 233, 0.34)); }

.panel__headline {
  font-family: var(--font-display);
  font-weight: var(--display-weight, 400);
  font-size: var(--headline, clamp(2.6rem, 4.4vw, 4.6rem));
  line-height: 0.92;
  letter-spacing: var(--tracking-display, 0.03em);
  text-transform: uppercase;
  margin-bottom: 1.4rem;
}

.panel__body {
  font-size: clamp(0.95rem, 1.1vw, 1.06rem);
  line-height: 1.62;
  color: var(--fg-mute, rgba(244, 240, 233, 0.62));
  max-width: 34ch;
  margin-bottom: 2.2rem;
}

/* copy swap animation */
.panel__index,
.panel__headline,
.panel__body { transition: opacity 260ms var(--ease), transform 260ms var(--ease); }

.panel.is-out .panel__index,
.panel.is-out .panel__headline,
.panel.is-out .panel__body { opacity: 0; transform: translateY(-10px); }

/* Not micro-labels. Condensed display caps at real size.
   Gap-based spacing, not a border-right divider: a divider on the
   last item of a WRAPPED row (not the last item overall) can't be
   targeted with :last-child, so a long label like "Social Media
   Management" pushed the row to wrap and left a dangling trailing
   line - the same bug already fixed on Impact and the Connect
   service selector. */
/* row-gap and column-gap are equal on purpose: this panel column is
   narrow enough that a couple of pixels decide whether chips share a
   row or stack, so the two gap values need to look right in EITHER
   layout, not just the one that happened to render on one screen. */
.chips { list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 1.2em; }

.chips li {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;         /* +1.1px at 11px, as on agenz.in */
  line-height: 1;
  text-transform: uppercase;
  color: var(--fg-mute, rgba(244, 240, 233, 0.74));
  opacity: 0;
  transform: translateY(8px);
  animation: chipIn 420ms var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 45ms + 120ms);
  white-space: nowrap;
}
.chips.is-out li { animation: none; opacity: 0; transform: translateY(-6px); transition: all 200ms var(--ease); }

@keyframes chipIn { to { opacity: 1; transform: none; } }

/* ---------- stage / rig ---------- */

.stage {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  place-items: center;
}

/* fixed logical coordinate space, scaled to fit.
   Absolutely positioned + centred via its own transform, not grid
   place-items - a grid track sized to an item's explicit 760px width
   doesn't shrink for min-width:0 (that only affects intrinsic/flexible
   sizing), so on any container narrower than 760px the oversized track
   anchored at justify-content's default 'start' and overflowed only to
   the right instead of bleeding evenly - the whole device ended up
   shoved off-centre on mobile. This sidesteps grid track sizing
   entirely: fit() in morph.js sets translate(-50%,-50%) scale(s). */
.rig {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 760px;
  height: 560px;
  transform-origin: center center;
  /* Long-lens perspective. At 1600px the deck's front edge splayed 18%
     wider than the lid; 3200px keeps it near-parallel, like a product shot. */
  perspective: 3200px;
  perspective-origin: 50% 40%;   /* eye above the hinge, looking down */
  transform-style: preserve-3d;
}

.glow {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 620px;
  height: 420px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: none;      /* no glow blobs */
  pointer-events: none;
}

/* ---------- the device frame ---------- */

.device {
  position: absolute;
  left: 50%;
  top: 0;                 /* JS sets top/width/height/transform */
  transform: translateX(-50%);
  /* the hinge line: lid rotates about its own bottom edge */
  transform-origin: 50% 100%;
  background: #050506;    /* true black bezel */
  box-shadow:
    /* brushed metal edge: light on top, dark underneath */
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.09),
    0 44px 90px -34px rgba(0, 0, 0, 0.95),
    0 8px 26px -12px rgba(0, 0, 0, 0.8);
  will-change: width, height, border-radius, padding, top;
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  border-radius: 3px;            /* JS keeps this in step with the bezel */
  /* the panel sits *inside* the bezel rather than flush with it */
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.9),
    inset 0 3px 14px rgba(0, 0, 0, 0.85);
}

/* glass sheen - one soft diagonal, never a hard streak */
.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(112deg,
    rgba(255, 255, 255, 0.075) 0%,
    rgba(255, 255, 255, 0.022) 26%,
    transparent 46%);
}

/* ---------- phone-only hardware ---------- */

.btn {
  position: absolute;
  width: 2.5px;
  border-radius: 2px;
  background: linear-gradient(180deg, #131315, #050506);
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.07);
  z-index: 7;
}
.btn--l { left: -2.5px; top: 94px; height: 52px; }
.btn--r { right: -2.5px; top: 114px; height: 74px; }

/* content layers cross-fade */
.content {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.965);
  transition: opacity 300ms var(--ease), transform 300ms var(--ease);
  pointer-events: none;
}
.content.is-on { opacity: 1; transform: none; }

/* ---------- laptop deck ----------
   Anodised slab hinged off the bottom edge of the screen. No keys -
   just hinge, trackpad, and the front opening lip. */

.deck {
  position: absolute;
  left: 50%;
  z-index: 4;                    /* paints over the screen */
  transform-origin: top center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  background:
    linear-gradient(180deg,
      #131315 0%,      /* faint sheen near the hinge */
      #0B0B0C 38%,
      #060607 76%,
      #030304 100%);
  /* rounded at the hinge as well as the front edge - a real deck is
     radiused on all four corners, not squared off at the back */
  border-radius: 16px 16px 20px 20px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 26px 50px -26px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  will-change: transform, opacity, top, width, height;
}

/* Shadow the lid casts onto the deck: solid black at the hinge, falling
   off across the top of the keyboard plane. This is what seats the two
   planes together - without it the deck reads as a separate slab. */
.deck__hinge {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 46%;
  border-radius: 16px 16px 0 0;   /* match the deck's hinge corners */
  background: linear-gradient(180deg,
    #000 0%,
    rgba(0, 0, 0, 0.92) 12%,
    rgba(0, 0, 0, 0.62) 34%,
    rgba(0, 0, 0, 0.28) 62%,
    transparent 100%);
  pointer-events: none;
  z-index: 2;            /* the shadow falls over the trackpad too */
}

/* the hinge barrel itself - a hard dark line at the very top edge */
.deck__hinge::after {
  content: '';
  position: absolute;
  left: 6%; right: 6%; top: 0;
  height: 4px;
  border-radius: 0 0 3px 3px;
  background: #000;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}

.deck__pad {
  position: absolute;
  left: 50%; top: 34%;
  width: 31%; height: 38%;
  transform: translateX(-50%);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.028);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* shallow notch cut into the front edge, plus the machined front lip */
.deck__lip {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 10px;
  border-radius: 0 0 20px 20px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.10));
}
.deck__lip::after {
  content: '';
  position: absolute;
  left: 50%; bottom: 0;
  width: 15%; height: 6px;
  transform: translateX(-50%);
  border-radius: 6px 6px 0 0;
  background: rgba(0, 0, 0, 0.7);
}

/* ---------- video plate ----------
   Any clip, any aspect. object-fit:cover lets the frame crop it. */

.plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #08070A;
}

.site__scroll--hidden { display: none; }

/* ---------- progress rail ---------- */

.rail {
  position: absolute;
  right: clamp(14px, 2vw, 34px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 3;
}
.rail button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--font-body);
  font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg-faint, rgba(244, 240, 233, 0.26));
  transition: color 300ms var(--ease);
  padding: 0;
}
.rail button span {
  width: 22px; height: 1px; background: var(--rule, rgba(244, 240, 233, 0.22));
  transition: all 380ms var(--ease);
}
.rail button.is-on { color: var(--bone); }
.rail button.is-on span { width: 42px; background-image: var(--gradient); }

/* ---------- film ---------- */

.film__grain {
  position: absolute; inset: 0;
  opacity: 0.16;
  background-image: repeating-conic-gradient(rgba(255,255,255,0.5) 0% 25%, transparent 0% 50%);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

/* ===========================================================
   MOBILE - no pin. Stack three static blocks.
   =========================================================== */

@media (max-width: 900px) {
  .services { height: auto; }
  .services__sticky {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
    padding: 12vh 24px;
    gap: 28px;
  }
  /* Without min-width:0, a grid item holding a fixed-width child (the
     760px .rig) forces its track to blow out to that width - the track
     was measuring 760px even inside a 375px viewport. This is what
     broke the section on mobile: there is no tall pinned track to
     scroll through (height:auto above), so the desktop scroll-scrub
     math in morph.js never had anywhere to go, and the blown-out grid
     track made the layout wrong underneath it regardless. */
  .panel, .stage { min-width: 0; }
  .stage { height: 62vw; max-height: 420px; }
  /* Same blowout, one level deeper: .stage is itself a grid
     (place-items:center) and .rig is its fixed 760x560 item. Without
     min-width/min-height:0 here too, .rig's track refused to shrink
     below 760x560, so place-items:center centred it on a phantom
     760-wide cell instead of the real ~327px one - the visible device
     ended up shoved off to one side instead of centred. */
  .rig { width: 760px; height: 560px; min-width: 0; min-height: 0; }
  .panel { max-width: none; }

  /* No pinned scroll on mobile - tap the dots instead. Re-shown here
     (hidden on desktop, where the vertical side rail is used instead). */
  .rail {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: center;
    gap: 14px;
    order: 3;
  }
  .rail button {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }
  .rail button span { width: 22px; }
  .rail button.is-on span { width: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
