/* ============================================================
   JnJ Arcade — iPhone Home Screen Interface
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --phone-w: 393px;
  --phone-h: 852px;
  --screen-radius: 44px;
  --body-radius: 50px;
  --icon-size: 64px;
  --icon-radius: 14.5px;
  --grid-gap: 20px;
  --grid-cols: 4;
  --bezel-color: #1a1a1e;
  --bezel-highlight: #2c2c30;
  --wallpaper-top: #130028;
  --wallpaper-mid: #0a1040;
  --wallpaper-bot: #001530;
  --status-h: 54px;
}

/* ── Page background (desktop only) ── */
body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(120, 40, 200, 0.35) 0%, transparent 65%),
    radial-gradient(ellipse 60% 50% at 20% 100%, rgba(0, 80, 200, 0.3) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(0, 150, 180, 0.2) 0%, transparent 60%),
    linear-gradient(160deg, #0d0020 0%, #05092e 50%, #00101e 100%);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Phone wrapper ── */
.phone-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ── Physical phone body ── */
.phone-body {
  position: relative;
  width: var(--phone-w);
  height: var(--phone-h);
  background: linear-gradient(160deg, #2a2a30 0%, var(--bezel-color) 40%, #111115 100%);
  border-radius: var(--body-radius);
  box-shadow:
    inset 0 0 0 1.5px rgba(255,255,255,0.08),
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 40px 120px rgba(0,0,0,0.9),
    0 10px 40px rgba(0,0,0,0.6),
    0 0 0 1px rgba(0,0,0,0.8);
  overflow: visible;
}

/* Side volume buttons */
.btn-vol-up, .btn-vol-down, .btn-power {
  position: absolute;
  background: linear-gradient(90deg, #222226, #2e2e33);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn-vol-up {
  left: -4px; top: 120px;
  width: 4px; height: 36px;
}
.btn-vol-down {
  left: -4px; top: 168px;
  width: 4px; height: 36px;
}
.btn-power {
  right: -4px; top: 140px;
  width: 4px; height: 64px;
}

/* ── Dynamic Island ── */
.dynamic-island {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 126px;
  height: 37px;
  background: #000;
  border-radius: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 22px;
}
.di-camera {
  width: 11px;
  height: 11px;
  background: radial-gradient(circle at 35% 35%, #1a3a5c, #050c14);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.04);
}

/* ── Phone screen (inner display) ── */
.phone-screen {
  position: absolute;
  inset: 8px;
  border-radius: calc(var(--body-radius) - 6px);
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(140, 60, 255, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse 70% 60% at 10% 80%, rgba(20, 80, 220, 0.2) 0%, transparent 55%),
    linear-gradient(175deg, var(--wallpaper-top) 0%, var(--wallpaper-mid) 50%, var(--wallpaper-bot) 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Status Bar ── */
.status-bar {
  flex-shrink: 0;
  height: var(--status-h);
  padding: 14px 28px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 4px;
  color: #fff;
}
.status-time {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  font-family: -apple-system, 'SF Pro Text', sans-serif;
}
.status-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Signal bars */
.signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.bar {
  display: block;
  width: 3px;
  background: white;
  border-radius: 1.5px;
}
.b1 { height: 4px; }
.b2 { height: 6px; }
.b3 { height: 8px; }
.b4 { height: 11px; }

/* WiFi */
.wifi-svg {
  width: 18px;
  height: 14px;
}

/* Battery */
.battery-wrap {
  display: flex;
  align-items: center;
  gap: 1px;
}
.battery-body {
  width: 25px;
  height: 12px;
  border: 1.5px solid rgba(255,255,255,0.8);
  border-radius: 3px;
  padding: 1.5px;
}
.battery-fill {
  width: 80%;
  height: 100%;
  background: #32d74b;
  border-radius: 1.5px;
}
.battery-nub {
  width: 3px;
  height: 5px;
  background: rgba(255,255,255,0.7);
  border-radius: 0 1px 1px 0;
}

/* ── Scrollable app area ── */
.screen-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 24px 18px 12px;
}
.screen-scroll::-webkit-scrollbar { display: none; }

/* ── App Grid ── */
.app-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.icon-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

/* ── Individual Icon ── */
.icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 16px;
  transition: transform 0.1s ease, opacity 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.icon-wrap:active {
  transform: scale(0.88);
  opacity: 0.85;
}

/* Icon face (squircle) */
.icon-face {
  width: var(--icon-size);
  height: var(--icon-size);
  border-radius: var(--icon-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  position: relative;
  overflow: hidden;
  transition: filter 0.4s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.2);
}
.icon-face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(255,255,255,0.18) 0%,
    rgba(255,255,255,0.04) 40%,
    transparent 70%
  );
  border-radius: inherit;
  pointer-events: none;
}

/* Icon label */
.icon-label {
  font-size: 10px;
  font-weight: 500;
  color: #fff;
  text-align: center;
  letter-spacing: -0.1px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  line-height: 1.2;
  max-width: 64px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: -apple-system, 'SF Pro Text', sans-serif;
}

/* ── Locked icon state ── */
.icon-wrap.locked .icon-face {
  filter: grayscale(1) brightness(0.45);
}
.icon-wrap.locked .icon-label {
  opacity: 0.5;
}
.icon-wrap.locked:active {
  transform: scale(0.92);
}

/* Lock overlay (shown on locked icons) */
.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  filter: none !important;
  z-index: 2;
}

/* Week badge (top-right of locked icon) */
.week-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: rgba(28, 28, 30, 0.9);
  color: rgba(255,255,255,0.7);
  font-size: 8.5px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.08);
  font-family: -apple-system, 'SF Pro Text', sans-serif;
  z-index: 3;
}

/* ── Unlock animation ── */
@keyframes unlockPop {
  0%   { filter: grayscale(1) brightness(0.45); transform: scale(0.85); }
  60%  { filter: grayscale(0) brightness(1.1); transform: scale(1.12); }
  80%  { transform: scale(0.97); }
  100% { filter: grayscale(0) brightness(1); transform: scale(1); }
}
.icon-wrap.just-unlocked .icon-face {
  animation: unlockPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── New badge on freshly-unlocked icons ── */
.new-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff3b30;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  letter-spacing: 0.2px;
  font-family: -apple-system, 'SF Pro Text', sans-serif;
  z-index: 3;
}

/* ── Home indicator ── */
.home-indicator {
  flex-shrink: 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-indicator::before {
  content: '';
  display: block;
  width: 130px;
  height: 5px;
  background: rgba(255,255,255,0.35);
  border-radius: 3px;
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 30, 34, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  padding: 12px 20px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: -apple-system, 'SF Pro Text', sans-serif;
  font-size: 14px;
  min-width: 240px;
  max-width: 340px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 999;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-lock { font-size: 24px; flex-shrink: 0; }
.toast-text { display: flex; flex-direction: column; gap: 2px; }
.toast-text strong { font-size: 14px; font-weight: 600; }
.toast-text span { font-size: 12px; color: rgba(255,255,255,0.6); }

/* ── Social row divider ── */
.social-section-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 4px 4px;
  font-family: -apple-system, 'SF Pro Text', sans-serif;
}
.section-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 4px 10px;
}

/* ============================================================
   MOBILE RESPONSIVE — becomes a true full-screen home screen
   ============================================================ */
@media (max-width: 430px) {
  body {
    background:
      radial-gradient(ellipse 90% 50% at 50% -5%, rgba(120, 40, 200, 0.4) 0%, transparent 60%),
      radial-gradient(ellipse 70% 60% at 10% 90%, rgba(20, 80, 220, 0.25) 0%, transparent 55%),
      linear-gradient(175deg, #130028 0%, #0a1040 50%, #001530 100%);
    align-items: flex-start;
    overflow: auto;
  }
  .phone-wrapper {
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .phone-body {
    width: 100%;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .btn-vol-up, .btn-vol-down, .btn-power { display: none; }
  .dynamic-island {
    position: fixed;
    top: env(safe-area-inset-top, 12px);
    left: 50%;
    transform: translateX(-50%);
  }
  .phone-screen {
    position: fixed;
    inset: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0);
    background:
      radial-gradient(ellipse 90% 50% at 50% -5%, rgba(120, 40, 200, 0.4) 0%, transparent 60%),
      linear-gradient(175deg, #130028 0%, #0a1040 50%, #001530 100%);
  }
  .status-bar {
    padding-top: max(14px, env(safe-area-inset-top, 14px));
  }
  .home-indicator::before { width: 120px; }
  :root { --icon-size: 60px; --grid-gap: 16px; }
  .toast {
    bottom: max(60px, env(safe-area-inset-bottom, 60px));
    width: calc(100% - 48px);
    max-width: none;
  }
}

/* Tablet: scale the phone down to fit height */
@media (min-width: 431px) and (max-height: 920px) {
  .phone-body {
    transform-origin: center top;
    transform: scale(min(1, calc(90vh / var(--phone-h))));
    margin-bottom: calc((var(--phone-h) - min(var(--phone-h), 90vh)) * -1);
  }
  .phone-wrapper { align-items: flex-start; padding-top: 5vh; }
}

/* Desktop hover effects */
@media (hover: hover) {
  .icon-wrap:hover .icon-face {
    transform: scale(1.06);
    box-shadow:
      0 6px 20px rgba(0,0,0,0.5),
      0 0 0 2.5px rgba(255,255,255,0.12),
      inset 0 1px 0 rgba(255,255,255,0.25);
  }
  .icon-wrap.locked:hover .icon-face {
    transform: scale(1.03);
    filter: grayscale(0.8) brightness(0.5);
  }
}
