/* ==========================================================================
   3D phone render — titanium frame, glass screen, cast shadow.
   The pose comes from CSS variables (--ry, --rx, --rz, --s) so js/site.js
   can drive it from scroll; the idle bob uses `translate`, which composes
   with `transform` instead of overwriting it.

   Only .pbr-phone is transformed in 3D. Everything inside it lies flat on the
   phone, so nothing else uses preserve-3d: separate 3D layers (the glow, the
   ground shadow, the frame) would cut through each other and leave hard,
   lighter wedges across the bottom of the phone.
   ========================================================================== */

.pbr-phone-container {
  position: relative;
  perspective: 1600px;
  perspective-origin: 50% 40%;
}

/* Cast ground shadow */
.pbr-phone-container::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -52px;
  width: 74%;
  height: 60px;
  transform: translateX(-50%) rotateX(72deg) scale(1, 0.6);
  background: radial-gradient(ellipse at center, rgba(0,0,0,.45) 0%, rgba(0,0,0,.28) 35%, rgba(0,0,0,.10) 60%, transparent 75%);
  filter: blur(22px);
  z-index: -2;
  pointer-events: none;
  animation: phone-shadow-3d 7s ease-in-out infinite;
}

.pbr-phone {
  position: relative;
  width: 300px;
  height: 620px;
  transform: rotateY(var(--ry, -18deg)) rotateX(var(--rx, 6deg)) rotateZ(var(--rz, 1.5deg)) scale(var(--s, 1));
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  animation: phone-bob 7s ease-in-out infinite;
}

@keyframes phone-bob {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -16px; }
}
@keyframes phone-shadow-3d {
  0%, 100% { opacity: .85; transform: translateX(-50%) rotateX(72deg) scale(1, .6); }
  50%      { opacity: .55; transform: translateX(-50%) rotateX(72deg) scale(.86, .5); }
}

/* Brushed graphite titanium frame */
.pbr-phone-body {
  position: absolute;
  inset: 0;
  border-radius: 52px;
  background:
    linear-gradient(150deg, rgba(255,255,255,.40) 0%, rgba(255,255,255,.10) 12%, transparent 34%),
    linear-gradient(270deg, #6b6f78 0%, #4a4d55 6%, #34363d 16%, #2a2c32 32%, #24262b 50%, #2c2e34 68%, #3c3e45 84%, #2a2c32 94%, #1d1e22 100%),
    linear-gradient(180deg, #34363d 0%, #2a2c31 50%, #1f2024 100%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.22),
    inset 0 -1px 1px rgba(0,0,0,.35),
    inset -2px 0 2px rgba(255,255,255,.18),
    inset 2px 0 2px rgba(0,0,0,.30),
    3px 0 6px rgba(255,255,255,.12),
    0 8px 16px rgba(0,0,0,.35),
    0 20px 40px rgba(0,0,0,.45),
    0 40px 80px rgba(0,0,0,.38),
    0 2px 4px rgba(0,0,0,.5),
    0 0 90px rgba(110,102,91,.10),
    0 0 140px rgba(110,102,91,.06);
}
.pbr-phone-body::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 54px;
  background: linear-gradient(145deg, rgba(255,255,255,.1) 0%, rgba(255,255,255,.03) 30%, rgba(0,0,0,.2) 70%, rgba(0,0,0,.3) 100%);
  z-index: -1;
}
.pbr-phone-body::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,.08);
  pointer-events: none;
}

.pbr-phone-screen-container {
  position: absolute;
  inset: 6px;
  border-radius: 46px;
  overflow: hidden;
  background: #000;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.8), inset 0 2px 4px rgba(0,0,0,.5);
}

.pbr-phone-screen {
  position: absolute;
  inset: 0;
  background: #EDE5D8;
  border-radius: 46px;
  overflow: hidden;
}
/* Glass reflection */
.pbr-phone-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.06) 25%, transparent 45%);
  pointer-events: none;
  z-index: 100;
}
.pbr-phone-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 46px;
  border: 1px solid rgba(255,255,255,.05);
  pointer-events: none;
  z-index: 101;
}

/* Dynamic Island */
.pbr-phone-notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 50;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.5), 0 1px 1px rgba(255,255,255,.05);
}
.pbr-phone-notch::before,
.pbr-phone-notch::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 50%;
}
.pbr-phone-notch::before {
  left: 18px; width: 10px; height: 10px;
  background: radial-gradient(circle, #1a1a2e 30%, #0d0d15 50%, #252538 70%);
  border: 1px solid rgba(255,255,255,.1);
}
.pbr-phone-notch::after {
  right: 18px; width: 8px; height: 8px;
  background: linear-gradient(135deg, #2d1f4e 0%, #1a1a2e 100%);
  border: 1px solid rgba(139,92,246,.3);
}

/* Screens: stacked app screenshots, cross-faded by js/site.js */
.pbr-screens { position: absolute; inset: 0; background: #F6F1EA; }
.pbr-screens img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  will-change: opacity, transform;
}

/* Side buttons */
.pbr-phone-button {
  position: absolute;
  width: 4px;
  background: linear-gradient(90deg, #252538 0%, #3a3a55 50%, #252538 100%);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), inset 0 -1px 0 rgba(0,0,0,.3), 0 0 4px rgba(0,0,0,.5);
}
.pbr-phone-button--power       { right: -4px; top: 140px; height: 80px; }
.pbr-phone-button--volume-up   { left: -4px;  top: 100px; height: 45px; }
.pbr-phone-button--volume-down { left: -4px;  top: 155px; height: 45px; }
.pbr-phone-button--silent      { left: -4px;  top: 70px;  height: 20px; }

/* Ambient glow */
.pbr-phone-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(ellipse at center, var(--glow, rgba(58,53,48,.14)) 0%, rgba(110,102,91,.07) 30%, transparent 60%);
  filter: blur(40px);
}

/* Frame reflection */
.pbr-phone-reflection {
  position: absolute;
  inset: 0;
  border-radius: 52px;
  pointer-events: none;
  z-index: 10;
  opacity: .8;
  background: linear-gradient(155deg, rgba(255,255,255,.12) 0%, rgba(255,255,255,.04) 25%, transparent 45%, transparent 55%, rgba(255,255,255,.02) 75%, rgba(255,255,255,.06) 100%);
}

/* Floating info cards around the phone */
.float-card {
  position: absolute;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(251, 247, 242, .94);
  border: 1px solid rgba(58, 53, 48, .10);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  font: 600 .82rem/1.3 var(--font, system-ui);
  color: #2D2A26;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform, opacity;
}
.float-card small { display: block; font-weight: 400; font-size: .72rem; color: #6E665B; }
.float-card .fc-icon { font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
  .pbr-phone, .pbr-phone-container::after { animation: none; }
}
