/* ============================================================
   Unknown Sender — shared styles
   ============================================================ */
:root {
  --bg-image: url('assets/background.jpg'); /* drop your image here, or leave missing for gradient fallback */
  --accent: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: #000;
}

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  color: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
}
.screen.active { opacity: 1; pointer-events: auto; }

/* ---------- LOADING SCREEN ----------
   Shown while sanity-loader.js fetches content; covers everything (z-index
   above the video screen) and fades out once initGame() is ready to run. */
.loading-screen {
  position: fixed; inset: 0; z-index: 50;
  background: #0b0b10;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.4s ease;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- LOCK SCREEN ---------- */
#lockScreen {
  background-image: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.55)), var(--bg-image);
  background-color: #1c1c2e;
  background-size: cover;
  background-position: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 24px) 0 40px 0;
}

.status-bar {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 24px 0 24px;
  font-size: 15px; font-weight: 600;
  box-sizing: border-box;
  flex-shrink: 0;
}
.status-bar .icons { display: flex; gap: 6px; align-items: center; opacity: 0.95; }
.status-bar .lock-toggle { cursor: pointer; opacity: 0.8; font-size: 15px; }

.clock-block {
  text-align: center;
  margin-top: 8vh;
  text-shadow: 0 1px 12px rgba(0,0,0,0.35);
}
.clock-date { font-size: 17px; font-weight: 600; opacity: 0.9; }
.clock-time { font-size: 88px; font-weight: 300; line-height: 1; margin-top: 4px; letter-spacing: -2px; }

.notification {
  width: 88%;
  max-width: 360px;
  margin-top: 6vh;
  background: rgba(120,120,130,0.35);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  animation: pulseIn 0.6s ease;
}
.notification .icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #2c2c2e;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.notification .text { text-align: left; overflow: hidden; }
.notification .title { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.notification .title span.time { font-weight: 400; opacity: 0.75; font-size: 13px; }
.notification .preview { font-size: 14px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.swipe-hint {
  margin-top: auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 13px; opacity: 0.85;
  cursor: pointer;
}
.swipe-hint .chevron {
  width: 22px; height: 12px;
  border-top: 2.5px solid #fff; border-right: 2.5px solid #fff;
  transform: rotate(-45deg);
  animation: bob 1.6s ease-in-out infinite;
  border-radius: 2px;
}

@keyframes bob {
  0%, 100% { transform: rotate(-45deg) translateY(0); opacity: 0.5; }
  50% { transform: rotate(-45deg) translateY(-6px); opacity: 1; }
}
@keyframes pulseIn {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- PASSCODE SCREEN ---------- */
#passcodeScreen {
  background: #17171c;
  justify-content: flex-start;
  padding-top: 12vh;
}
.cancel-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 24px) + 8px); left: 20px;
  font-size: 17px; color: #fff; opacity: 0.85; cursor: pointer; padding: 8px;
}
.passcode-title { font-size: 17px; font-weight: 500; opacity: 0.95; margin-bottom: 28px; }
.passcode-error { font-size: 13px; color: #ff5c5c; height: 16px; margin: -18px 0 12px 0; opacity: 0; transition: opacity 0.2s; }
.passcode-error.show { opacity: 1; }

.dots { display: flex; gap: 18px; margin-bottom: 44px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.7);
  background: transparent;
  transition: background 0.15s, transform 0.15s;
}
.dot.filled { background: #fff; transform: scale(1.1); }
.dots.shake { animation: shakeX 0.42s; }
@keyframes shakeX {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 22px;
  justify-content: center;
}
.key {
  width: 74px; height: 74px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.1s;
}
.key:active { background: rgba(255,255,255,0.28); }
.key .num { font-size: 30px; font-weight: 400; }
.key .letters { font-size: 9px; letter-spacing: 1.5px; opacity: 0.8; margin-top: 1px; }
.key.ghost { background: transparent; cursor: default; }
.key.ghost:active { background: transparent; }
.key.action { font-size: 14px; background: transparent; }

/* smaller keypad variant used inside the Files app modal */
.keypad.small {
  grid-template-columns: repeat(3, 54px);
  gap: 14px;
}
.keypad.small .key { width: 54px; height: 54px; }
.keypad.small .key .num { font-size: 22px; }

/* ---------- VIDEO SCREEN ----------
   z-index puts it above the app overlay (20) and file modal (30) so it can be
   opened from inside the Files app and simply layers on top, no navigation. */
#videoScreen {
  background: #000;
  justify-content: center;
  z-index: 40;
}
#videoScreen video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.call-chip {
  position: absolute; top: calc(env(safe-area-inset-top, 24px) + 14px);
  left: 50%; transform: translateX(-50%);
  background: rgba(30,30,30,0.55);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 20px;
  padding: 7px 16px 7px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  z-index: 3;
}
.call-chip .dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff453a;
  animation: liveBlink 1.2s infinite;
}
@keyframes liveBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.video-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 0 30px; text-align: center;
  color: rgba(255,255,255,0.6); font-size: 14px; z-index: 2; background: #000;
}

.tap-to-play {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35);
  z-index: 4; cursor: pointer;
}
.tap-to-play.show { display: flex; }
.tap-to-play .btn {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #111;
}

.end-call {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
  left: 50%; transform: translateX(-50%);
  width: 58px; height: 58px; border-radius: 50%;
  background: #ff3b30;
  display: flex; align-items: center; justify-content: center;
  z-index: 3; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.end-call svg { width: 24px; height: 24px; }

/* ---------- HOME SCREEN ---------- */
#homeScreen {
  background-image: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.45)), var(--bg-image);
  background-color: #1c1c2e;
  background-size: cover;
  background-position: center;
  padding: env(safe-area-inset-top, 24px) 0 30px 0;
}

.app-grid {
  width: 100%;
  max-width: 420px;
  margin-top: 6vh;
  padding: 0 22px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px 14px;
  overflow-y: auto;
}
.app-icon-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer;
}
.app-icon-wrap.disabled { opacity: 0.4; cursor: default; }
.app-icon {
  position: relative;
  width: 58px; height: 58px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  color: #fff;
  background: rgba(255,255,255,0.14);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.1s;
}
/* Icons with a set app.color (real SVG glyph, colored tile) skip the glass
   blur look and read as a solid icon square, closer to a real iOS app icon. */
.app-icon[style*="background"] {
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.app-icon-svg { width: 28px; height: 28px; }
.app-icon-emoji { font-size: 26px; line-height: 1; }
.app-icon-wrap:active .app-icon { transform: scale(0.92); }
.app-icon .badge {
  position: absolute; margin-left: 34px; margin-bottom: 34px;
  background: #ff3b30; color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.app-lock-badge {
  position: absolute; bottom: -4px; right: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.app-label { font-size: 12px; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }

.shake-icon { animation: shakeX 0.42s; }

.toast {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: rgba(40,40,40,0.9);
  padding: 10px 18px; border-radius: 12px;
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

/* ---------- APP OVERLAY (News / Mail / Messages / Social / Files) ---------- */
.app-overlay {
  position: fixed; inset: 0;
  background: #101014;
  color: #fff;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(.32,.72,0,1);
  z-index: 20;
}
.app-overlay.open { transform: translateY(0); }

.app-header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 24px) + 10px) 16px 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: #17171c;
}
.back-btn { font-size: 16px; color: #4da3ff; cursor: pointer; min-width: 60px; }
.app-title { font-size: 16px; font-weight: 600; }
.app-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; }

/* Camera — live feed + Cardan grille overlay */
.camera-view { position: absolute; inset: 0; background: #000; overflow: hidden; }
#cameraVideo, #cameraFreezeCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#cameraFreezeCanvas { display: none; }
#cameraFreezeCanvas.show { display: block; }
.grille-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.camera-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 0 30px; text-align: center;
  color: rgba(255,255,255,0.75); font-size: 14px; line-height: 1.5;
  background: rgba(0,0,0,0.55); z-index: 2;
}
.camera-controls {
  position: absolute; bottom: 18px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  z-index: 3; padding: 0 12px;
}
.puzzle-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.puzzle-chip {
  padding: 6px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12px; cursor: pointer;
}
.puzzle-chip.active { background: #4da3ff; font-weight: 600; }
.freeze-btn {
  padding: 10px 22px; border-radius: 20px;
  background: rgba(0,0,0,0.55);
  font-size: 13px; cursor: pointer;
}

/* News — real-newspaper-style masthead + serif headline */
.news-masthead { padding: 18px 20px 14px 20px; text-align: center; }
.news-masthead-name {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700; font-size: 26px; letter-spacing: 0.5px;
}
.news-masthead-rule { height: 2px; background: #fff; opacity: 0.85; margin-top: 10px; }
.news-article { padding: 18px 20px 20px 20px; }
.news-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: #ff9f0a; font-weight: 700; margin-bottom: 8px; }
.news-headline {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px; font-weight: 700; margin: 0 0 8px 0; line-height: 1.25;
}
.news-meta { font-size: 12px; opacity: 0.55; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,0.12); }
.news-body p { font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.65; opacity: 0.92; margin: 0 0 14px 0; }

/* Mail */
.mail-toolbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 16px 10px 16px;
}
.mail-toolbar-title { font-size: 22px; font-weight: 700; }
.mail-unread-count { font-size: 12px; opacity: 0.55; }
.mail-list-item {
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
}
.mail-unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4da3ff;
  margin-top: 16px; flex-shrink: 0;
}
.mail-unread-dot.spacer { background: transparent; }
.mail-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: #4da3ff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.mail-info { flex: 1; overflow: hidden; }
.mail-row1 { display: flex; justify-content: space-between; font-size: 14px; }
.mail-from { font-weight: 400; }
.mail-from.unread { font-weight: 700; }
.mail-time { opacity: 0.5; font-size: 12px; }
.mail-subject { font-size: 14px; font-weight: 400; margin-top: 2px; }
.mail-subject.unread { font-weight: 700; }
.mail-preview { font-size: 13px; opacity: 0.6; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-detail { padding: 20px; }
.mail-detail-subject { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.mail-detail-meta { font-size: 13px; opacity: 0.6; margin-bottom: 20px; line-height: 1.6; }
.mail-detail-body p { font-size: 15px; line-height: 1.6; opacity: 0.9; margin: 0 0 14px 0; }

/* Generic per-item lock indicator/placeholder — reused by News, Mail, Pulse */
.lock-badge-inline {
  margin-left: auto; align-self: center;
  font-size: 13px; opacity: 0.6; flex-shrink: 0;
}
.locked-content {
  border: 1px dashed rgba(255,255,255,0.25); border-radius: 10px;
  padding: 16px; text-align: center; font-size: 13px; opacity: 0.6;
  cursor: pointer;
}

/* Messages */
.msg-contact-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 16px 14px 16px;
}
.msg-contact-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #4da3ff, #2f6df6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px;
}
.msg-contact-name { font-size: 13px; opacity: 0.75; }
.msg-thread { padding: 4px 16px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg-contact-header { text-align: center; font-size: 12px; opacity: 0.55; margin-bottom: 10px; }
.bubble {
  max-width: 75%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.4;
}
.bubble.them { align-self: flex-start; background: #2c2c2e; }
.bubble.me { align-self: flex-end; background: #2f6df6; }
.bubble-time { font-size: 10px; opacity: 0.4; text-align: center; margin: 4px 0; }
.msg-receipt { align-self: flex-end; font-size: 11px; opacity: 0.45; margin-top: -2px; }

/* Social */
.social-post {
  padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.07);
}
.social-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.social-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #ff6a6a, #a35cff);
  flex-shrink: 0;
}
.social-name { font-size: 14px; font-weight: 700; }
.social-handle { font-size: 12px; opacity: 0.5; }
.social-text { font-size: 15px; line-height: 1.5; opacity: 0.92; margin-bottom: 10px; }
.social-image {
  width: 100%; aspect-ratio: 16/9; border-radius: 10px;
  background: repeating-linear-gradient(45deg, #232328, #232328 10px, #29292f 10px, #29292f 20px);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; opacity: 0.4; margin-bottom: 10px;
}
.social-stats { font-size: 13px; opacity: 0.7; display: flex; gap: 20px; }
.social-stat { display: flex; align-items: center; gap: 5px; color: inherit; }
.social-stat svg { flex-shrink: 0; }

/* Files */
.file-list { padding: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.file-card {
  background: #1c1c22; border-radius: 14px; padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; position: relative;
}
.file-card .file-icon { font-size: 30px; }
.file-card .file-name { font-size: 12px; text-align: center; opacity: 0.85; word-break: break-word; }
.file-card .lock-badge {
  position: absolute; top: 8px; right: 8px; font-size: 12px;
  background: rgba(0,0,0,0.5); border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}
.file-card.unlocked .lock-badge { display: none; }

.file-content { padding: 20px; }
.file-content-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.file-content p { font-size: 15px; line-height: 1.6; opacity: 0.9; }
.file-content .image-frame {
  width: 100%; aspect-ratio: 4/5; border-radius: 12px; margin-bottom: 14px;
  background: repeating-linear-gradient(45deg, #232328, #232328 10px, #29292f 10px, #29292f 20px);
  display: flex; align-items: center; justify-content: center; font-size: 13px; opacity: 0.45;
}
.file-content .audio-frame {
  background: #1c1c22; border-radius: 12px; padding: 16px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 12px;
}
.file-content .audio-frame .play-dot {
  width: 40px; height: 40px; border-radius: 50%; background: #4da3ff;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}

/* file passcode modal
   Note: this modal is NOT inside a .screen element (it's a fixed overlay
   used from any screen), so it doesn't inherit the `color: #fff` that
   .screen normally provides — set explicitly here instead, otherwise it
   falls back to the browser's default black text on this dark card. */
.file-modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.72);
  display: none; align-items: center; justify-content: center;
  color: #fff;
}
.file-modal.show { display: flex; }
.file-modal-card {
  background: #17171c; border-radius: 20px; padding: 28px 22px 22px 22px;
  display: flex; flex-direction: column; align-items: center;
  width: 88%; max-width: 320px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.file-modal-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; text-align: center; color: #fff; }
.file-modal-error { font-size: 12px; color: #ff5c5c; height: 14px; margin: -14px 0 10px 0; opacity: 0; transition: opacity 0.2s; }
.file-modal-error.show { opacity: 1; }
.file-modal-cancel { margin-top: 18px; font-size: 14px; color: #fff; opacity: 0.7; cursor: pointer; }
.file-modal .key { background: rgba(255,255,255,0.1); color: #fff; }
.file-modal .key:active { background: rgba(255,255,255,0.3); }
.file-modal .dot { border-color: rgba(255,255,255,0.7); }
.file-modal .dot.filled { background: #fff; }
