/* =====================================================================
   Home: every piece of media sits in a glass frame, after
   iushev.com. The frame has no body and no drawn outline: its edge is
   lit from inside, softly at rest and brighter on hover. Loaded after
   home.css; everything is scoped to body.home-glass.
   ===================================================================== */

.home-glass {
  --glass-pad: 16px;                 /* gap between the frame and the media; one value on every screen */
  --glass-r: 26px;                   /* frame radius; the media gets r − pad = 10px */
  --glass-bg: none;                  /* no body: only the light inside the edge */
}

/* ---------- The frame (works and Playground share it) ---------- */
.home-glass .glass {
  position: relative;
  isolation: isolate;
  display: block;
  padding: var(--glass-pad);
  border-radius: var(--glass-r);
  background: var(--glass-bg);
}

/* No drawn outline: light comes from inner shadows, after iushev at half
   strength. --glass-k scales it: 1 at rest, 2 on hover; the media itself is never
   covered, only the edge lights up. */
@property --glass-k { syntax: '<number>'; inherits: true; initial-value: 1; }

/* :where() keeps this at one class, so hover and stage rules (.gw-card:hover .glass …) win */
.home-glass :where(.glass, .pg-tile, .case-study .image-card:not(.note-thumb), .case-study .phone-grid-card) { --glass-k: 1; transition: --glass-k 0.3s var(--ease-out); }

.home-glass :is(.glass, .pg-tile, .case-study .image-card:not(.note-thumb), .case-study .phone-grid-card)::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow:
    inset 0 -1px 1px rgba(var(--glass-light-rgb), calc(0.05 * var(--glass-k))),
    inset 0 1px 1px rgba(var(--glass-light-rgb), calc(0.1 * var(--glass-k))),
    inset 0 -4px 4px rgba(var(--glass-light-rgb), 0.04),
    inset 0 28px 40px rgba(var(--glass-light-rgb), 0.04);
  pointer-events: none;
}

.home-glass .glass-media {
  position: relative;
  display: block;
  aspect-ratio: var(--ar);
  border-radius: calc(var(--glass-r) - var(--glass-pad));
  background: var(--frame-bg);
  overflow: hidden;
}

.home-glass .glass-media > img,
.home-glass .glass-media > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform 0.35s var(--ease-out), opacity 0.4s ease;
}

/* devices composed on transparency (Craftify): shown whole, standing on the bottom */
.home-glass .gw-media--contain { background: none; }
.home-glass .gw-media--contain > img { object-fit: contain; object-position: bottom; }

/* A cover staged on colour, by the Playground's staged-piece rule (.pg-tile--stage):
   no frame padding, the background runs to the frame edge under the glass outline
   (lit 1.8 at rest, 3.4 on hover), with the frame's outer radius. */
.home-glass .glass.glass--stage { padding: 0; --glass-k: 1.8; }
/* no padding, so to share the row height with padded neighbours the card's basis is
   the padding they carry, measured in height: 2 × pad × ar */
.gw-card:has(> .glass--stage) { flex-basis: calc(var(--glass-pad) * 2 * var(--ar)); }
.home-glass .glass--stage > .glass-media { border-radius: var(--glass-r); }
@media (hover: hover) and (pointer: fine) {
  .gw-card:hover .glass.glass--stage { --glass-k: 3.4; }
}
/* Gaming Platform cover: three product components fanned on a quiet graphite field (so the
   Ami aurora next to it stays the accent). Each card has no bezel: a 1px edge, light on top
   and fading out by 45% of its height (7%, close to the Ami dark phone's ring). Sized by the
   well's width (cqw). */
.home-glass .gw-media--gp {
  container-type: inline-size;
  isolation: isolate;
  background:
    radial-gradient(90% 110% at 15% 0%, #2b2b33 0%, transparent 60%),
    radial-gradient(80% 90% at 95% 100%, #22222a 0%, transparent 60%),
    #141417;
}
.gp-card { position: absolute; display: block; border-radius: 2.2cqw; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7); }
.home-glass .gw-media--gp .gp-card > img { display: block; width: 100%; height: auto; border-radius: inherit; }
.gp-card::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 45%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.gp-card--back { filter: brightness(0.78); }

.home-glass .gw-media--ami {
  background:
    radial-gradient(120% 90% at 20% 0%, #3b2ca8 0%, transparent 55%),
    radial-gradient(90% 80% at 85% 10%, #1f4fd1 0%, transparent 60%),
    #0c0d1a;   /* Ami's Home aurora */
}

/* Ami Speak cover: two phones on the aurora, dark in front, light behind on a glass
   bezel, both running off the bottom edge. Sized by the well's width (cqw);
   --k = phone width in % of the well. Inner radius = outer − bezel, so the gap
   round the corner is even. Motion and playback: home.js initAmiCover. */
.home-glass .ami-cover { container-type: inline-size; isolation: isolate; }
.ami-phone {
  --k: 34;
  --b: calc(var(--k) * 0.042cqw);
  --r: calc(var(--k) * 0.13cqw);
  position: absolute;
  width: calc(var(--k) * 1cqw);
  aspect-ratio: 402 / 874;
  padding: var(--b);
  border-radius: var(--r);
}
.ami-phone > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  border-radius: calc(var(--r) - var(--b));
  position: relative;
  opacity: 0;   /* managed here, not by the site's lazy-video fade: shown once it plays */
  transition: opacity 0.2s ease;
}
.ami-phone > video.is-playing { opacity: 1; }
/* the poster as a real image under the video (home.js adds it): the phone is never empty */
.ami-phone > .ami-poster {
  position: absolute;
  inset: var(--b);
  width: calc(100% - 2 * var(--b));
  height: calc(100% - 2 * var(--b));
  object-fit: cover;
  object-position: top;
  border-radius: calc(var(--r) - var(--b));
}
.ami-phone--dark {
  left: 17%;   /* 17–51%: overlaps the light phone by ~2%, its shadow falls on it */
  top: 8%;
  z-index: 2;
  background: #0b0b0c;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 30px 30px 60px -10px rgba(0, 0, 0, 0.6);
}
.ami-phone--dark > video { background-color: #000; }
.ami-phone--light {
  right: 17%;   /* 49–83% */
  top: 15%;
  background: rgba(255, 255, 255, 0.12);   /* a glass bezel: the gradient shows through */
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}
.ami-phone--light > video { background-color: #f5f6f8; }
/* the phones come in with the card itself (.reveal), like every Playground piece: no extra motion here */

/* ---------- Works: frame on top, caption under it ---------- */
.gw-grid { display: flex; flex-direction: column; gap: 48px; }

/* frames in a row share a height: widths follow --ar, the padding is in the basis */
.gw-row { display: flex; gap: var(--gap); }

.gw-card {
  flex: var(--ar) 1 calc(var(--glass-pad) * 2);
  min-width: 0;
  display: flex;
  flex-direction: column;
  color: inherit;
}

.gw-card:hover { color: inherit; }

.gw-cap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding: 0 4px;
}

.gw-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.gw-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 25px;
  letter-spacing: -0.085px;
  color: var(--white-90);
}

.gw-desc {
  font-size: 15px;
  font-weight: 400;
  line-height: 23px;
  letter-spacing: -0.03px;
  color: var(--white-50);
}

@media (hover: hover) and (pointer: fine) {
  .gw-card:hover .glass { --glass-k: 2; }
  /* the arrow behaves as on the work cards */
  .gw-card:hover .work-arrow { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--white-90); }
  .gw-card:hover .work-arrow svg:first-child { transform: translateX(24px); }
  .gw-card:hover .work-arrow svg + svg { transform: none; }
  .gw-card:hover .glass-media > img,
  .gw-card:hover .glass-media > video { transform: scale(1.015); }
}

/* ---------- Playground: the same frame around every piece ---------- */

.home-glass .pg-tile,
.home-glass .pg-tile--cutout {
  padding: var(--glass-pad);
  border-radius: var(--glass-r);
  background: var(--glass-bg);
  overflow: hidden;
  isolation: isolate;
}

.home-glass .pg-tile > img,
.home-glass .pg-tile > video {
  border-radius: calc(var(--glass-r) - var(--glass-pad));
}

.home-glass .pg-tile--cutout > img { border-radius: 0; }

/* staged pieces: no frame padding, the background runs to the edge under the
   glass outline, which is lit a bit more at rest and more again on hover */
.home-glass .pg-tile.pg-tile--stage { padding: 0; --glass-k: 1.8; }
.home-glass .pg-tile--stage .pg-stage { border-radius: var(--glass-r); }
@media (hover: hover) and (pointer: fine) {
  .home-glass .pg-item:hover .pg-tile--stage { --glass-k: 3.4; }
}
.home-glass .pg-stage[data-fit="phone"] > img { border-radius: 0; }   /* phone mockups bring their own device corners */

@media (hover: hover) and (pointer: fine) {
  .home-glass .pg-item:hover .pg-tile > img,
  .home-glass .pg-item:hover .pg-tile > video { transform: none; }
  .home-glass .pg-item:hover .pg-tile { --glass-k: 2; }
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .gw-row { flex-direction: column; gap: 40px; }
  .gw-card { flex: none; }
}

/* ---------- Tabs: the capsule gets the same inner light ---------- */
.home-glass .hl-nav,
.home-glass .seg {
  box-shadow: inset 0 -1px 1px rgba(var(--glass-light-rgb), 0.05), inset 0 1px 1px rgba(var(--glass-light-rgb), 0.1), inset 0 6px 10px rgba(var(--glass-light-rgb), 0.03);
}
.home-glass .hl-navbar.is-stuck .hl-nav {
  box-shadow: inset 0 -1px 1px rgba(var(--glass-light-rgb), 0.05), inset 0 1px 1px rgba(var(--glass-light-rgb), 0.1), inset 0 6px 10px rgba(var(--glass-light-rgb), 0.03),
              0 12px 32px -12px rgba(0, 0, 0, 0.7);
}
.home-glass .hl-nav-hover { background: rgba(var(--glass-light-rgb), 0.035); }
.home-glass .hl-nav-pill,
.home-glass .seg-pill,
.home-glass .seg:not(.is-ready) .seg-item[aria-checked="true"] {
  background: rgba(var(--glass-light-rgb), 0.06);
  box-shadow: inset 0 1px 1px rgba(var(--glass-light-rgb), 0.12);
}

/* ---------- Case pages: screens sit in the same frame ---------- */
.home-glass .case-study .image-card:not(.note-thumb) {
  position: relative;
  isolation: isolate;
  padding: var(--glass-pad);
  border-radius: var(--glass-r);
  background: var(--glass-bg);
}
.home-glass .case-study .image-card:not(.note-thumb) :is(img, video, .media-ph) {
  border-radius: calc(var(--glass-r) - var(--glass-pad));
}
.home-glass .case-study :is(.image-with-caption, .opts-panel) > .image-caption { padding: 0 var(--glass-pad); }
/* phone grids (older cases): the same glass frame instead of the grey mat; the
   phone mockups keep their own padding, they stand in the middle of the frame */
.home-glass .case-study .phone-grid-card {
  position: relative;
  isolation: isolate;
  border-radius: var(--glass-r);
  background: var(--glass-bg);
}

/* ---------- Earlier work: a small deck that opens the older row in place ----------
   Closed, the two previews lie fanned out; open, they square up into a neat pile.
   Nothing else moves: the title stays, the chevron turns. */
.gw-deck {
  display: flex;
  align-items: center;
  gap: 20px;
  width: calc(100% + 28px);
  margin: 0 -16px 0 -12px;
  padding: 12px 20px 12px 12px;   /* chevron's right edge = the card arrows' (caption has 4px inset) */
  border: 0;
  border-radius: 24px;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s ease;
}
.gw-deck .gw-text { flex: 1; }

.gw-deck-cards { position: relative; flex: none; width: 190px; height: 112px; }

/* the thumbnails: smaller frames; .gw-archive lifts this over the frame's own transition */
.home-glass .gw-archive .gw-deck .gw-deck-thumb {
  --glass-pad: 6px;
  --glass-r: 14px;
  position: absolute;
  top: 8px;
  width: 150px;
  transition: transform 0.35s var(--ease-out), opacity 0.5s ease, --glass-k 0.3s ease;
}
.home-glass .gw-archive .gw-deck .gw-deck-thumb:first-child { left: 34px; transform: rotate(5deg); opacity: 0.7; }
.home-glass .gw-archive .gw-deck .gw-deck-thumb:last-child { left: 4px; transform: rotate(-3deg); }

/* open: squared up, the back one tucked behind */
.home-glass .gw-archive.is-open .gw-deck .gw-deck-thumb:first-child { transform: translate(-18px, -6px) scale(0.94); opacity: 0.5; }
.home-glass .gw-archive.is-open .gw-deck .gw-deck-thumb:last-child { transform: none; }

.gw-deck-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--white-50);
  transition: background-color 0.3s ease, color 0.3s ease;
}
.gw-deck-icon svg { transition: transform 0.35s var(--ease-out); }   /* in step with the deck folding (0.35s) */
.gw-archive.is-open .gw-deck-icon svg { transform: rotate(180deg); }

@media (hover: hover) and (pointer: fine) {
  .gw-deck:hover { background: rgba(var(--glass-light-rgb), 0.06); }
  .gw-deck:hover .gw-deck-thumb { --glass-k: 2; }
  .gw-deck:hover .gw-deck-icon { background: rgba(255, 255, 255, 0.1); color: var(--white-90); }
  .home-glass .gw-archive:not(.is-open) .gw-deck:hover .gw-deck-thumb:first-child { transform: rotate(6.5deg) translateX(4px); }
  .home-glass .gw-archive:not(.is-open) .gw-deck:hover .gw-deck-thumb:last-child { transform: rotate(-4deg) translateX(-2px); }
}

.gw-deck:focus-visible { outline-offset: 0; }

/* the older row folds by its height: 0fr → 1fr */
.gw-fold {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease-out);
}
.gw-fold-inner {
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.gw-fold-inner > .gw-row { padding-top: 40px; }
.gw-archive.is-open .gw-fold { grid-template-rows: 1fr; }
.gw-archive.is-open .gw-fold-inner { opacity: 1; }

@media (max-width: 600px) {
  .gw-deck { gap: 14px; width: calc(100% + 16px); margin: 0 -8px; padding: 8px 12px 8px 8px; }
  .gw-deck-cards { width: 132px; height: 84px; }
  .home-glass .gw-archive .gw-deck .gw-deck-thumb { width: 104px; }
  .home-glass .gw-archive .gw-deck .gw-deck-thumb:first-child { left: 24px; }
}

/* ── Case grid: the text guide runs along the mockup, not the frame ──────────
   A frame is the text column plus its padding on each side, so the mockup inside
   starts where the text starts and the frame hangs out by --glass-pad. Wide
   media stays wide (up to 1040) once the column has room for it. */
.home-glass.case-centered .case-study .image-with-caption {
  --case-img-w: max(calc(min(var(--text-max), 100%) + var(--glass-pad) * 2), min(1040px, 100%));
  width: var(--case-img-w);
  max-width: none;
  margin-left: calc((100% - var(--case-img-w)) / 2);
  margin-right: calc((100% - var(--case-img-w)) / 2);
}
.home-glass.case-centered .case-study .image-with-caption:has(> .media-pair) {
  --case-img-w: calc(min(var(--text-max), 100%) + var(--glass-pad) * 2);
}

/* Phones: the wrapper itself carries the page padding, so the frame hangs out by
   shrinking that padding instead (24 − 16 = 8px from the screen edge) */
@media (max-width: 768px) {
  .home-glass.case-centered .case-study .image-with-caption,
  .home-glass.case-centered .case-study .image-with-caption:has(> .media-pair) {
    width: auto;
    margin-left: 0;
    margin-right: 0;
    padding-left: calc(var(--mobile-pad, 16px) - var(--glass-pad));
    padding-right: calc(var(--mobile-pad, 16px) - var(--glass-pad));
  }
}

/* THE TEXT GUIDE RULE. Every card follows the text guide: its side padding equals
   the frame padding (--glass-pad) and the card hangs out of the text column by it,
   so the content inside (text, a mockup, a nested panel) starts exactly on the
   guide of the text above and below. A new card row must be added to these lists. */
.home-glass.case-centered .case-study :is(.comparison-cards, .gap-flow, .pillars, .cost-chart, .user-cards, .results-cards, .flow-diagram,  .testimonial-card, .facts, .table-card),
.home-glass.case-centered .case-next .gw-card {
  margin-left: calc(-1 * var(--glass-pad));
  margin-right: calc(-1 * var(--glass-pad));
}
.home-glass.case-centered .case-study :is(.comparison-card, .gap-node, .pillar, .cost-chart, .user-card, .result-card, .flow-step,  .testimonial-card, .fact, .table-card) {
  padding-left: var(--glass-pad);
  padding-right: var(--glass-pad);
}

/* Phones: every frame and card sits 8px from the screen edge, the text 24px (16px frame padding, as on desktop) */
@media (max-width: 768px) {
  .home-glass.case-centered { --mobile-pad: 24px; }
  /* sliders and phone grids carry the page padding too: shrink it the same way */
  .home-glass.case-centered .case-study :is(.slider-container, .phone-grid) {
    width: auto;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: calc(var(--mobile-pad) - var(--glass-pad));
    padding-right: calc(var(--mobile-pad) - var(--glass-pad));
  }
}

/* Small details scenes: captions start on the media edge, like the text guide */
.home-glass.case-centered :is(.scene, .tile) > p { padding-inline: var(--glass-pad); }

/* ── Home grid: the same rule as the case pages ─────────────────────────────
   Text (section heads, captions) starts on the content edge; frames hang out by
   --glass-pad, so the media inside lines up with the text. The right padding
   grows by the same amount, so frames keep the page gutter on both sides. */
.home-glass .hl-main { padding-right: calc(var(--gutter) + var(--glass-pad)); }
.home-glass .hl-section-head { padding-inline: 0; }
.home-glass :is(.gw-grid, .pg-grid) { margin-inline: calc(-1 * var(--glass-pad)); }
.home-glass :is(.gw-cap, .pg-item figcaption) { padding-inline: var(--glass-pad); }
/* the deck's chevron keeps the card arrows' right edge (overhang 16 + frame pad) */
.home-glass .gw-deck { padding-right: calc(16px + var(--glass-pad)); }

/* One column (≤900): text at 24px, frames 8px from the screen edge (24 − 16 padding), as on the case */
@media (max-width: 900px) {
  .home-glass { --gutter: 24px; }   /* the frame keeps its 16px padding on every screen */
  .home-glass .hl-main { padding-inline: var(--gutter); }
  .home-glass .gw-deck { width: calc(100% + 16px); margin: 0 -8px; padding-right: calc(8px + var(--glass-pad)); }
}

/* Sliders (older cases): the frame is --glass-pad wide here, not the old 40px mat,
   so the first card's screenshot lands on the text guide */
.home-glass.case-centered .case-study .slider-section { --card-padding: var(--glass-pad); }

/* Desktop sliders on the centred case grid: every row starts on the image guide
   (where the frames of the pictures above start) and runs out to the right edge of
   the screen; the last card stops on the image column's right edge */
@media (min-width: 1201px) {
  .home-glass.case-centered .case-study .slider-section {
    --sl-col: max(calc(min(var(--text-max), 100cqw) + var(--glass-pad) * 2), min(1040px, 100cqw));   /* = the image column */
    --sl-off: calc((100cqw - var(--sl-col)) / 2);
  }
  .home-glass.case-centered .case-study .slider-container {
    width: auto;
    max-width: none;
    margin-left: var(--sl-off);
    margin-right: calc(-1 * var(--case-pr));   /* the column's right padding: out to the screen edge */
    padding-left: 0;
  }
  .home-glass.case-centered .case-study .slider-track {
    padding-right: calc(var(--case-pr) + var(--sl-off));
  }
  /* counter and arrows sit under the first card */
  .home-glass.case-centered .case-study .slider-nav { margin-left: var(--sl-off); }
}

/* Phone grids take the image column on every width above phones */
@media (min-width: 769px) {
  .home-glass.case-centered .case-study .phone-grid {
    --case-img-w: max(calc(min(var(--text-max), 100%) + var(--glass-pad) * 2), min(1040px, 100%));
    width: var(--case-img-w);
    max-width: none;
    margin-left: calc((100% - var(--case-img-w)) / 2);
    margin-right: calc((100% - var(--case-img-w)) / 2);
    padding-left: 0;
    padding-right: 0;
  }
}

/* Tablet (stacked sliders): sliders take the image column too */
@media (min-width: 769px) and (max-width: 1200px) {
  .home-glass.case-centered .case-study .slider-container {
    --case-img-w: max(calc(min(var(--text-max), 100%) + var(--glass-pad) * 2), min(1040px, 100%));
    width: var(--case-img-w);
    max-width: none;
    margin-left: calc((100% - var(--case-img-w)) / 2);
    margin-right: calc((100% - var(--case-img-w)) / 2);
    padding-left: 0;
    padding-right: 0;
  }
}

/* Next case: the home work card (glass frame, caption under it); the label sits on the text guide */
.home-glass.case-centered .case-next-label { padding-left: 0; padding-right: 0; }
@media (max-width: 768px) {
  .home-glass.case-centered .case-next { max-width: none; margin: 0; padding-left: var(--mobile-pad); padding-right: var(--mobile-pad); }
}
