/* ===========================================================
   iPhone 17 Pro chassis + status bar + home indicator
   + screen index side panel
   =========================================================== */

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--stage-w, auto);
  height: var(--stage-h, auto);
}

/* preview tap target — mobile only */
.tap-shield,
.tap-hint,
.immersive-close {
  display: none;
}

/* ---------- Chassis ---------------------------------------- */
.device {
  position: relative;
  width: calc(var(--screen-w) + 22px);
  height: calc(var(--screen-h) + 22px);
  border-radius: 66px;
  flex: none;
  /* dark grey titanium rail — brushed highlights kept subtle */
  background: linear-gradient(
    155deg,
    #2b2b2f 0%,
    #0c0c0e 16%,
    #3a3a40 33%,
    #131316 50%,
    #08080a 68%,
    #323238 86%,
    #101012 100%
  );
  padding: 11px;
  box-shadow:
    0 1px 1px rgba(255, 255, 255, 0.22) inset,
    0 -2px 2px rgba(0, 0, 0, 0.6) inset,
    0 30px 60px -18px rgba(0, 0, 0, 0.62),
    0 70px 90px -40px rgba(0, 0, 0, 0.5);
  transform: scale(var(--device-scale, 1));
  transform-origin: center center;
}

/* inner black bezel */
.device::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 58px;
  background: #0a0a0a;
  pointer-events: none;
}

/* side buttons */
.device .btn-rail {
  position: absolute;
  background: linear-gradient(180deg, #2e2e34, #0d0d0f);
  border-radius: 2px;
}

.device .btn-rail.volume-up {
  left: -2px;
  top: 168px;
  width: 3px;
  height: 60px;
}

.device .btn-rail.volume-down {
  left: -2px;
  top: 242px;
  width: 3px;
  height: 60px;
}

.device .btn-rail.action {
  left: -2px;
  top: 108px;
  width: 3px;
  height: 38px;
}

.device .btn-rail.power {
  right: -2px;
  top: 210px;
  width: 3px;
  height: 96px;
}

.device .btn-rail.camera-ctl {
  right: -2px;
  top: 348px;
  width: 3px;
  height: 44px;
  background: linear-gradient(180deg, #3a3a42, #101013);
}

/* ---------- Screen / viewport ------------------------------ */
.viewport {
  position: relative;
  width: var(--screen-w);
  height: var(--screen-h);
  border-radius: var(--radius-screen);
  overflow: hidden;
  background: #fff;
  isolation: isolate;
  z-index: 1;
}

/* ---------- Dynamic Island --------------------------------- */
.dynamic-island {
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 124px;
  height: 36px;
  border-radius: 20px;
  background: #000;
  z-index: 900;
  pointer-events: none;
}

.dynamic-island::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    #253044 0%,
    #0d1017 55%,
    #05070a 100%
  );
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ---------- Status bar ------------------------------------- */
.statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-top);
  padding: 20px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  z-index: 890;
  pointer-events: none;
  color: #000;
  transition: color 240ms linear;
}

.statusbar.light {
  color: #fff;
}

.statusbar .clock {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  font-family: var(--font);
  width: 62px;
  text-align: center;
}

.statusbar .indicators {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 2px;
}

.statusbar svg {
  display: block;
  fill: currentColor;
}

/* ---------- Home indicator --------------------------------- */
.home-indicator {
  position: absolute;
  bottom: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 144px;
  height: 5px;
  border-radius: 3px;
  background: #000;
  opacity: 0.85;
  z-index: 880;
  pointer-events: none;
  transition: background-color 240ms linear;
}

.home-indicator.light {
  background: #fff;
}

/* ---------- Screen index — slide-over overlay ---------------- */
.panel-toggle {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 120;
  width: 44px;
  height: 62px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms linear, transform 320ms var(--ease-ios);
}

.panel-toggle:hover {
  background: rgba(255, 255, 255, 0.82);
}

/* three stacked bars that morph into an arrow when the panel is open */
.panel-toggle .bars,
.panel-toggle .bars::before,
.panel-toggle .bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #2c2c30;
  transition: transform 320ms var(--ease-ios), width 320ms var(--ease-ios);
}

.panel-toggle .bars {
  position: relative;
}

.panel-toggle .bars::before,
.panel-toggle .bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.panel-toggle .bars::before {
  top: -6px;
}

.panel-toggle .bars::after {
  top: 6px;
}

.panel-toggle[aria-expanded="true"] .bars {
  width: 0;
}

.panel-toggle[aria-expanded="true"] .bars::before {
  width: 14px;
  transform: translate(2px, 6px) rotate(-45deg);
}

.panel-toggle[aria-expanded="true"] .bars::after {
  width: 14px;
  transform: translate(2px, -6px) rotate(45deg);
}

.index-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 68vw;
  z-index: 110;
  padding: 40px 76px 40px 56px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;

  background: linear-gradient(
    90deg,
    rgba(246, 246, 248, 0) 0%,
    rgba(246, 246, 248, 0.55) 26%,
    rgba(246, 246, 248, 0.86) 62%,
    rgba(246, 246, 248, 0.94) 100%
  );
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 20%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 20%);

  transform: translateX(24px);
  opacity: 0;
  visibility: hidden;
  transition: transform 420ms var(--ease-ios), opacity 260ms linear,
    visibility 0s linear 420ms;
}

.index-panel::-webkit-scrollbar {
  display: none;
}

.index-panel.open {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition: transform 420ms var(--ease-ios), opacity 260ms linear,
    visibility 0s;
}

.index-panel h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: #6d6d72;
  margin: 20px 0 8px 12px;
}

.index-panel h3:first-child {
  margin-top: 0;
}

.index-panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  letter-spacing: -0.1px;
  color: #3b3b40;
  transition: background 140ms ease, color 140ms ease;
}

.index-panel button:hover {
  background: rgba(255, 255, 255, 0.75);
}

.index-panel button.active {
  background: var(--enel-magenta);
  color: #fff;
  font-weight: 600;
}

.index-panel .hint {
  margin: 22px 12px 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: #7a7a80;
}

@media (prefers-color-scheme: dark) {
  .panel-toggle {
    background: rgba(40, 40, 44, 0.62);
    border-color: rgba(255, 255, 255, 0.14);
  }
  .panel-toggle:hover {
    background: rgba(52, 52, 58, 0.8);
  }
  .panel-toggle .bars,
  .panel-toggle .bars::before,
  .panel-toggle .bars::after {
    background: #e8e8ec;
  }
  .index-panel {
    background: linear-gradient(
      90deg,
      rgba(18, 18, 20, 0) 0%,
      rgba(18, 18, 20, 0.5) 26%,
      rgba(18, 18, 20, 0.82) 62%,
      rgba(18, 18, 20, 0.92) 100%
    );
  }
  .index-panel h3 {
    color: #8e8e94;
  }
  .index-panel button {
    color: #d2d2d6;
  }
  .index-panel button:hover {
    background: rgba(255, 255, 255, 0.09);
  }
  .index-panel .hint {
    color: #85858b;
  }
}

/* ===========================================================
   Mobile: inline preview → immersive full-screen prototype
   =========================================================== */
@media (max-width: 760px) {
  body {
    padding: 22px 16px;
  }

  /* --- inline preview ------------------------------------- */
  .is-mobile .tap-shield {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 130;
    border-radius: 40px;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .is-mobile .tap-shield:active {
    background: rgba(0, 0, 0, 0.06);
  }

  /* the preview is a picture, not a control */
  .is-mobile:not(.immersive) .viewport,
  .is-mobile:not(.immersive) .device {
    pointer-events: none;
  }

  .is-mobile .tap-hint {
    display: block;
    position: absolute;
    left: 50%;
    bottom: -34px;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12.5px;
    letter-spacing: -0.1px;
    color: #6d6d72;
  }

  .is-mobile .panel-toggle {
    display: none;
  }

  /* --- immersive ------------------------------------------ */
  .is-mobile.immersive {
    padding: 0;
  }

  .is-mobile.immersive .stage {
    position: fixed;
    inset: 0;
    margin: auto;
    z-index: 400;
  }

  .is-mobile.immersive .tap-shield,
  .is-mobile.immersive .tap-hint {
    display: none;
  }

  .is-mobile.immersive .viewport,
  .is-mobile.immersive .device {
    pointer-events: auto;
  }

  .is-mobile.immersive .immersive-close {
    display: inline-flex;
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    right: 12px;
    z-index: 460;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 13px;
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.9);
    color: #1c1c1e;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  .is-mobile.immersive .panel-toggle {
    display: flex;
    z-index: 450;
    width: 38px;
    height: 52px;
    right: 10px;
  }

  .is-mobile.immersive .index-panel {
    max-width: 84vw;
    padding: 40px 60px 40px 34px;
  }

  /* dim the page behind the immersive prototype */
  .is-mobile.immersive::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 390;
    background: #0e0e10;
  }
}

/* the phone is a static image for anyone who can't tap through it */
@media (prefers-reduced-motion: reduce) {
  .device {
    transition: none;
  }
}
