/* =============================================================
   Home — devices: the one frame vocabulary (iPhone, browser window), the tiles that hold them,
   and the video stages. Markup: src/components/home/Screen.astro, Hero.astro, DaySection.astro.
   Every frame reserves its box before the image arrives (aspect-ratio + width/height attributes):
   no layout shift.
   ============================================================= */

/* ---- iPhone ---- */
.dev-phone{--w:300px;width:var(--w);flex:none;padding:calc(var(--w) * .034);border-radius:calc(var(--w) * .168);background:#0E0E10;box-shadow:0 0 0 1.5px #3A3A3E inset,0 0 0 1px rgba(255,255,255,.05),var(--shadow-device)}
.dev-phone-screen{position:relative;aspect-ratio:393/852;border-radius:calc(var(--w) * .134);overflow:hidden;background:#F5F5F7;isolation:isolate}
.dev-phone-screen img{width:100%;height:100%;object-fit:cover}
@media(max-width:640px){.dev-phone{--w:248px}}

/* ---- browser window ---- */
.dev-window{background:#FFF;border-radius:12px;overflow:hidden;box-shadow:0 0 0 1px var(--line),var(--shadow-device)}
.dev-window-bar{position:relative;display:flex;align-items:center;height:34px;padding:0 14px;background:#F7F6F4;border-bottom:1px solid var(--line)}
.dev-window-lights{display:flex;gap:7px}
.dev-window-lights i{width:11px;height:11px;border-radius:50%;background:#DAD7D2;display:block}
.dev-window-address{position:absolute;left:50%;transform:translateX(-50%);font-size:12px;color:var(--muted);background:#EFEDEA;border-radius:7px;padding:3px 22px;letter-spacing:-.005em;white-space:nowrap}
.dev-window-screen{aspect-ratio:1440/900;background:#FAFAFB}
.dev-window-screen img{width:100%;height:100%;object-fit:cover}
.dev-slot{width:100%;height:100%;background:repeating-linear-gradient(135deg,#F0EEEA 0 12px,#ECE9E4 12px 24px)}

/* ---- tiles: the calm ground behind every screen ---- */
.tile{position:relative;background:var(--bg-deep);border-radius:var(--radius-tile);overflow:hidden;isolation:isolate}
.tile-phone{display:flex;justify-content:center;align-items:center;padding:clamp(40px,6vw,72px) 16px}
/* A window in a tile shows a ZOOMED crop of its screen (the chrome stays whole): the screen box takes
   the crop's aspect, the image is scaled by --zoom and shifted by --ox/--oy (fractions of the image). */
.tile-window{padding:clamp(28px,4vw,48px) clamp(28px,4vw,48px) 0}
.tile-window .dev-window{border-bottom-left-radius:0;border-bottom-right-radius:0}
.tile-window .dev-window-screen{position:relative;overflow:hidden;aspect-ratio:var(--crop,4/3)}
.tile-window .dev-window-screen picture,.tile-window .dev-window-screen img{position:absolute;left:0;top:0;width:var(--zoom,150%);max-width:none;height:auto;transform:translate(calc(-1 * var(--ox,0%)),calc(-1 * var(--oy,0%)))}
.tile-window .dev-window-screen picture img{position:static;width:100%;transform:none}
.only-narrow{display:none}
@media(max-width:640px){
  .tile-window{padding:24px 16px 0}
  .tile-window .dev-window-screen{--crop:4/5}
  .tile-window .dev-window-screen picture,.tile-window .dev-window-screen img{width:var(--m-zoom,var(--zoom,150%));transform:translate(calc(-1 * var(--m-ox,0%)),calc(-1 * var(--m-oy,0%)))}
  .tile-swap{display:flex;justify-content:center;padding:40px 16px}
  .only-wide{display:none}
  .only-narrow{display:block}
}

/* ---- control: the same plan on the desk and on the iPhone ---- */
.tile-duo{aspect-ratio:16/9}
.tile-duo .duo-window{position:absolute;top:11%;right:-3%;width:76%}
.tile-duo .duo-phone{--w:clamp(220px,23vw,300px);position:absolute;top:8%;left:6%;z-index:1}
@media(max-width:900px){
  .tile-duo .duo-window{width:86%;right:-18%}
  .tile-duo .duo-phone{left:4%}
}
@media(max-width:640px){
  .tile-duo{aspect-ratio:auto;display:flex;justify-content:center;padding:40px 16px}
  .tile-duo .duo-phone{--w:248px;position:static}
}

/* ---- video stages ---- */
.stage{position:relative;aspect-ratio:16/9;border-radius:var(--radius-tile);overflow:hidden;background:radial-gradient(80% 90% at 50% 46%,#FBFAF8 0%,#F2F0EC 46%,#E7E4DF 100%);box-shadow:0 0 0 1px var(--line)}
.stage-video{width:100%;height:100%;object-fit:cover;background:transparent}
/* Hero: the poster sits under the video, which home.js reveals once it actually plays (Hero.astro). */
.stage-poster,.stage-poster img{position:absolute;inset:0;width:100%;height:100%}
.stage-poster img{object-fit:cover}
.stage-hero .stage-video{position:relative;transition:opacity .4s var(--ease)}
.js-video .stage-hero .stage-video:not(.is-playing){opacity:0}
/* Phones get the 4:5 cut of the loop (and its poster): same media query as the <source>. */
@media(max-width:640px){.stage-hero{aspect-ratio:4/5}}
@media(max-width:640px){.stage-toggle{right:10px;bottom:10px;width:44px;height:44px}}
.stage-toggle{position:absolute;right:16px;bottom:16px;width:40px;height:40px;border-radius:50%;border:0;cursor:pointer;background:rgba(255,255,255,.72);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:0 0 0 1px var(--line),0 4px 12px -4px rgba(40,32,24,.2);display:grid;place-items:center;opacity:.85;transition:opacity .2s}
.stage-toggle:hover{opacity:1}
.stage-toggle-icon{width:12px;height:12px;display:block;background:linear-gradient(90deg,var(--ink) 0 35%,transparent 35% 65%,var(--ink) 65%)}
.stage-toggle.is-paused .stage-toggle-icon{width:0;height:0;background:none;border-style:solid;border-width:7px 0 7px 12px;border-color:transparent transparent transparent var(--ink);margin-left:3px}

/* ---- channels: three phones ---- */
.gallery{list-style:none;display:flex;justify-content:center;align-items:flex-start;gap:clamp(24px,4vw,64px);padding:clamp(48px,6vw,80px) var(--gutter);background:var(--bg-deep);border-radius:var(--radius-tile)}
.gallery-item{display:flex;flex-direction:column;align-items:center;gap:20px}
.gallery-item .dev-phone{--w:clamp(220px,22vw,290px)}
.gallery-raised{margin-top:clamp(-40px,-3vw,-16px);transform:translateY(-24px)}
.gallery-caption{font-size:14px;font-weight:500;color:var(--muted)}
@media(max-width:860px){
  .gallery{justify-content:flex-start;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;-webkit-overflow-scrolling:touch;scroll-padding-inline:24px;padding:40px 24px}
  .gallery::-webkit-scrollbar{display:none}
  .gallery-item{scroll-snap-align:start}
  .gallery-item .dev-phone{--w:240px}
  .gallery-raised{margin-top:0;transform:none}
}
