/* Shared TESORIN device presentation.
   Home screenshots and feature videos use the same shell, hardware and viewport. */

:root {
  --tesorin-phone-width: 304px;
  --tesorin-home-ratio: 832 / 1804;
  --tesorin-feature-media-ratio: 564 / 1280;
  /* Slim Space Black iPhone, matching the promo frame (promo-video/src/Phone.tsx):
     rim 1.3% of the width with a light line through the metal, a black bezel
     2.1%, corners 17%, keys 0.55% proud. The frame scales with the phone through
     container units (cqw); these px values are the fallback for a ~300px phone. */
  --tesorin-frame-radius: 50px;
  --tesorin-frame-inset: 4px;
  --tesorin-bezel: 6px;
  --tesorin-screen-radius: 46px;
  --tesorin-frame-outer: #3B3A3B;
  --tesorin-frame-line: #8A888D;
  --tesorin-frame-body: #232224;
  --tesorin-frame-finish: var(--tesorin-frame-body);
  --tesorin-button-finish: linear-gradient(90deg, #5C5B5E 0%, #2E2D2F 60%, #1C1B1D 100%);
}

html body main .spread .spread-grid > div:nth-child(2) {
  min-width: 0;
}

/* One physical phone shell everywhere. */
html body .tesorin-device-stage {
  box-sizing: border-box;
  position: relative;
  display: block;
  width: min(var(--tesorin-phone-width), 78vw);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  padding: 0;
  border: 0;
  outline: 0;
  border-radius: 17% / 7.9%;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  isolation: isolate;
  container-type: inline-size;
}

/* Shared hardware: action + volume pair on the left, power on the right, at the
   promo frame's fractions of the body height (background-position percentages
   are pre-solved so each key starts exactly at its fraction). */
html body .tesorin-device-stage::before {
  display: block;
  content: "";
  position: absolute;
  top: 0;
  left: -1.5px;
  left: calc(.5px - max(1px, .55cqw));
  width: calc(100% + 3px);
  width: calc(100% + 2 * max(1px, .55cqw) - 1px);
  height: 100%;
  border: 0;
  border-radius: 0;
  background:
    var(--tesorin-button-finish) left 0 top 20.27% / 2px 3.3% no-repeat,
    var(--tesorin-button-finish) left 0 top 28.59% / 2px 5.9% no-repeat,
    var(--tesorin-button-finish) left 0 top 37.83% / 2px 5.9% no-repeat,
    linear-gradient(270deg, #5C5B5E 0%, #2E2D2F 60%, #1C1B1D 100%) right 0 top 32.56% / 2px 9.7% no-repeat;
  background:
    var(--tesorin-button-finish) left 0 top 20.27% / max(1px, .55cqw) 3.3% no-repeat,
    var(--tesorin-button-finish) left 0 top 28.59% / max(1px, .55cqw) 5.9% no-repeat,
    var(--tesorin-button-finish) left 0 top 37.83% / max(1px, .55cqw) 5.9% no-repeat,
    linear-gradient(270deg, #5C5B5E 0%, #2E2D2F 60%, #1C1B1D 100%) right 0 top 32.56% / max(1px, .55cqw) 9.7% no-repeat;
  box-shadow: none;
  filter: none;
  pointer-events: none;
  z-index: 0;
}

html body .tesorin-device-stage::after {
  display: none;
  content: none;
}

/* One clipped screen viewport everywhere. Page variants only set media ratio.
   The viewport also paints the metal around itself: from the screen outward,
   body, the light line, then the graphite band out to the rim's edge (spread
   shadows), then the hairline and the soft drop shadows. */
html body .tesorin-device-stage > .tesorin-device-viewport {
  box-sizing: border-box;
  position: relative;
  display: block;
  width: auto;
  height: auto;
  margin: var(--tesorin-frame-inset);
  margin: 1.3cqw;
  padding: 0;
  border: var(--tesorin-bezel) solid #030303;
  border-width: 2.1cqw;
  border-radius: var(--tesorin-screen-radius);
  border-radius: 15.7cqw;
  background: #F6F6F7;
  box-shadow:
    0 0 0 1.7px var(--tesorin-frame-body),
    0 0 0 2.6px var(--tesorin-frame-line),
    0 0 0 4px var(--tesorin-frame-outer),
    0 0 0 4.5px rgba(0, 0, 0, .35),
    0 22px 48px -14px rgba(17, 17, 17, .22),
    0 5px 12px -1px rgba(17, 17, 17, .1);
  box-shadow:
    0 0 0 min(.57cqw, calc(.86cqw - .7px)) var(--tesorin-frame-body),
    0 0 0 .86cqw var(--tesorin-frame-line),
    0 0 0 1.3cqw var(--tesorin-frame-outer),
    0 0 0 calc(1.3cqw + .5px) rgba(0, 0, 0, .35),
    0 7cqw 16cqw -4.7cqw rgba(17, 17, 17, .2),
    0 1.5cqw 4cqw -.2cqw rgba(17, 17, 17, .1);
  overflow: hidden;
  z-index: 1;
}

html body .tesorin-device-stage--home {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

html body .tesorin-device-stage--home > .tesorin-device-viewport {
  aspect-ratio: var(--tesorin-home-ratio);
}

html body .tesorin-device-stage--home.is-dragging {
  cursor: grabbing;
}

html body .tesorin-device-stage--feature {
  width: min(var(--tesorin-phone-width), 78vw);
}

html body .tesorin-device-stage--feature > .tesorin-device-viewport {
  aspect-ratio: var(--tesorin-feature-media-ratio);
}

html body .tesorin-device-viewport > .tesorin-device-screen {
  box-sizing: border-box;
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  border-radius: 0;
  background: #faf9f7;
  box-shadow: none;
  overflow: visible;
  object-fit: cover;
  object-position: center top;
  clip-path: none;
  -webkit-clip-path: none;
  -webkit-mask: none;
  mask: none;
  z-index: 1;
}

html body .tesorin-device-screen--slide > img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  object-fit: cover;
  object-position: center;
  box-shadow: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

html body .tesorin-device-screen--slide {
  opacity: 1;
  transform: translate3d(100%,0,0);
  will-change: transform;
  pointer-events: none;
}

html body .tesorin-device-screen--slide.active {
  opacity: 1;
  transform: translate3d(0,0,0);
}

html body .tesorin-device-visual {
  display: grid;
  place-items: center;
  justify-self: stretch;
}

html body .tesorin-feature-text-only .spread-grid,
html body .tesorin-feature-grid-text-only {
  grid-template-columns: minmax(0, 760px);
  justify-content: start;
  direction: ltr;
}

html body .tesorin-feature-text-only .spread-grid > div:first-child {
  width: 100%;
  max-width: 760px;
  direction: ltr;
}

/* Home carousel layout. This single scene owns phone centering at every width;
   breakpoints only change the device size, never its horizontal position. */
html body .home-shell .phone-scene {
  --phone-width: min(340px, 78vw);
  box-sizing: border-box;
  position: relative;
  display: grid;
  grid-template-columns: var(--phone-width);
  grid-template-rows: auto auto;
  justify-content: center;
  justify-items: center;
  justify-self: center;
  align-self: center;
  row-gap: 18px;
  width: min(100%, 760px);
  max-width: 100%;
  min-height: 0;
  margin-inline: auto;
  overflow: visible;
}

@media (max-width: 980px) {
  :root {
    --tesorin-phone-width: 300px;
  }

  html body .home-shell .phone-scene {
    --phone-width: min(318px, 76vw);
  }
}

@media (max-width: 520px) {
  :root {
    --tesorin-phone-width: 286px;
  }

  html body .home-shell .phone-scene {
    --phone-width: min(286px, 82vw);
    row-gap: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .tesorin-device-screen--slide {
    transition-duration: 1ms;
  }
}

/* --------------------------------------------------------------------------
   Real hardware. Apple's iPhone 18 Pro Max product bezel in Black (from
   Apple Design Resources, in app-tutorial-frames/design-resources) is laid
   over the live screen; the rules above draw the CSS phone it replaces. The
   stage takes the bezel's proportions (1470 x 3000) and the viewport sits in
   its screen opening (75, 66, 1320 x 2868), with corners that stay under the
   frame. The bezel carries the buttons and the Dynamic Island.
   -------------------------------------------------------------------------- */
html body .tesorin-device-stage {
  aspect-ratio: 1470 / 3000;
  height: auto;
  border-radius: 0;
}

html body .tesorin-device-stage::before {
  display: none;
  content: none;
}

html body .tesorin-device-stage::after {
  display: block;
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: url("/assets/devices/iphone-18-pro-max-black.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 18px 26px rgba(17, 17, 17, .17)) drop-shadow(0 4px 8px rgba(17, 17, 17, .09));
  pointer-events: none;
}

html body .tesorin-device-stage > .tesorin-device-viewport,
html body .tesorin-device-stage--home > .tesorin-device-viewport,
html body .tesorin-device-stage--feature > .tesorin-device-viewport {
  position: absolute;
  left: 5.102%;
  top: 2.2%;
  width: 89.796%;
  height: 95.6%;
  margin: 0;
  border: 0;
  border-radius: 13.26% / 6.1%;
  box-shadow: none;
  aspect-ratio: auto;
}

html[data-theme="dark"] body .tesorin-device-stage::after {
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)) drop-shadow(0 4px 8px rgba(0, 0, 0, .3));
}
