/* Skambučio ekranas – kaip FaceTime / Messenger */
:root {
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --green: #34c759;
  --red: #ff3b30;
  --glass: rgba(255, 255, 255, 0.18);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --page: #000000;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Telefone – visas ekranas; kompiuteryje – telefono formos langas viduryje. */
.phone {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
  isolation: isolate;
}
@media (min-width: 600px) {
  .phone {
    width: 420px;
    height: min(880px, 100vh - 40px);
    border-radius: 44px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 10px #1c1c1e;
  }
}

/* Fonas */
.backdrop {
  position: absolute;
  inset: -40px;
  z-index: -3;
  background: #2b1a14 url("senelis.webp") center 20% / cover no-repeat;
  filter: blur(28px) saturate(1.2) brightness(0.55);
  transform: scale(1.1);
  transition: filter 0.6s ease;
}
.phone[data-state="idle"] .backdrop { filter: blur(0) brightness(0.9); transform: none; inset: 0; }

.shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 60%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}
/* Pradiniame ekrane vardas stovi ant baltos barzdos – apačią patamsiname stipriau. */
.phone[data-state="idle"] .shade {
  background: linear-gradient(180deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 45%, rgba(0,0,0,0.6) 68%, rgba(0,0,0,0.88) 100%);
}

.santa-video {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: #000;
}
.phone[data-video="1"][data-state="talking"] .santa-video { opacity: 1; }

/* Skambintojo informacija */
.caller { text-align: center; }
.avatar-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
}
.avatar {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 22%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.speaking-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  opacity: 0;
  transform: scale(1);
  transition: opacity 0.12s linear;
}
.phone[data-state="ringing"] .speaking-ring {
  border-color: rgba(255, 255, 255, 0.5);
  animation: ring 1.6s ease-out infinite;
}
@keyframes ring {
  0% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.45); }
}

.name {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.3px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}
.status {
  margin: 6px 0 0;
  min-height: 22px;
  font-size: 17px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

/* Prieš skambutį – didelė nuotrauka, informacija apačioje */
.phone[data-state="idle"] .caller { margin-top: auto; margin-bottom: 28px; }
.phone[data-state="idle"] .avatar-wrap { display: none; }
.phone[data-state="idle"] .name { font-size: 34px; }

/* Vaizdo skambutyje – mažesnė informacija viršuje, be nuotraukos */
.phone[data-video="1"][data-state="talking"] .avatar-wrap { display: none; }
.phone[data-video="1"][data-state="talking"] .name { font-size: 20px; }
.phone[data-video="1"][data-state="talking"] .status { font-size: 15px; }

/* Mygtukai */
.controls { display: flex; justify-content: center; }
.row { display: flex; gap: 56px; justify-content: center; }
.phone[data-state="idle"] .call-only,
.phone:not([data-state="idle"]) .idle-only { display: none; }

.btn {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background 0.2s ease;
}
.circle svg { width: 32px; height: 32px; fill: currentColor; }
.btn:active .circle { transform: scale(0.92); }
.btn:focus-visible .circle { outline: 3px solid #fff; outline-offset: 3px; }
.green { background: var(--green); }
.red { background: var(--red); }
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.label { font-size: 13px; color: var(--text); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }

.mic-off { display: none; }
#muteBtn[aria-pressed="true"] .glass { background: var(--glass-strong); color: #000; }
#muteBtn[aria-pressed="true"] .mic-on { display: none; }
#muteBtn[aria-pressed="true"] .mic-off { display: block; }

@media (prefers-reduced-motion: reduce) {
  .phone[data-state="ringing"] .speaking-ring { animation: none; opacity: 0.6; }
  .backdrop, .santa-video { transition: none; }
}

/* Skambutis baigtas – trumpai rodome užrašą be mygtukų */
.phone[data-state="ended"] .controls { visibility: hidden; }

/* Pastaba apie DI personažą */
.controls { flex-direction: column; align-items: center; gap: 18px; }
.notice {
  margin: 0;
  max-width: 320px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}
.notice a { color: #fff; }
.btn[hidden] { display: none; }
.phone:not([data-state="idle"]) .notice { display: none; }

/* Kodo įvedimas */
/* ---------- Pranešimų lapas (nemokama minutė baigėsi, nuoroda ir pan.) ---------- */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 20px 18px;
  border-radius: 24px;
  text-align: center;
  background: rgba(28, 28, 30, 0.92);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.sheet h2 { margin: 0; font-size: 22px; }
.sheet p { margin: 0; color: var(--muted); line-height: 1.45; }
.sheet-link { display: flex; gap: 8px; }
.sheet-link[hidden] { display: none; }
.sheet-check { display: flex; gap: 10px; align-items: flex-start; text-align: left; font-size: 14px; line-height: 1.4; color: #fff; }
.sheet-check[hidden] { display: none; }
.sheet-check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--green); }
.sheet-check.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.sheet-link input {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.sheet-link button, .sheet-primary, .sheet-secondary {
  padding: 14px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.sheet-link button { padding: 12px 14px; font-size: 15px; background: rgba(255, 255, 255, 0.2); color: #fff; }
.sheet-primary { background: var(--green); color: #fff; }
.sheet-primary[hidden] { display: none; }
.sheet-secondary { background: transparent; color: var(--muted); font-weight: 500; }

.minutes { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.minutes[hidden] { display: none; }
.invite { margin-top: 10px; padding: 8px 14px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; background: rgba(0, 0, 0, 0.25); color: #fff; font: inherit; font-size: 14px; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.invite[hidden] { display: none; }
.home-link {
  position: absolute;
  z-index: 3;
  top: calc(12px + env(safe-area-inset-top));
  left: 14px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 16px;
}
.phone:not([data-state="idle"]) .home-link { display: none; }

/* ---------- Vaizdo skambutis kaip FaceTime ---------- */
.self-view {
  position: absolute;
  z-index: -1;
  object-fit: cover;
  transform: scaleX(-1); /* veidrodinis vaizdas, kaip priekinėje kameroje */
  background: #000;
  display: none;
  transition: all 0.35s ease;
}
/* Skambinant: jūsų kamera per visą ekraną */
.phone[data-video="1"][data-state="ringing"] .self-view { display: block; inset: 0; width: 100%; height: 100%; border-radius: 0; }
.phone[data-video="1"][data-state="ringing"] .avatar-wrap { display: none; }
.phone[data-video="1"][data-state="ringing"] .backdrop { opacity: 0; }
/* Pokalbio metu: Senelis per visą ekraną, jūs – kampe */
.phone[data-video="1"][data-state="talking"] .self-view {
  display: block;
  z-index: 2;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 104px;
  height: 148px;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.phone[data-camera="off"] .self-view { display: none !important; }
.phone[data-video="1"][data-state="talking"] .caller { align-self: flex-start; text-align: left; padding-right: 120px; }
.phone[data-video="1"] .row { gap: 32px; }
.cam-off { display: none; }
#cameraBtn[aria-pressed="true"] .glass { background: var(--glass-strong); color: #000; }
#cameraBtn[aria-pressed="true"] .cam-on { display: none; }
#cameraBtn[aria-pressed="true"] .cam-off { display: block; }

/* Senelio vaizdas platus (16:9), o telefonas stovi – rodome visą Senelį, ne nukirptą vidurį.
   Viršų ir apačią užpildo išblukintas fonas (kaip FaceTime, kai pašnekovas laiko telefoną gulsčiai). */
.phone[data-video="1"][data-state="talking"] .santa-video { object-fit: contain; background: transparent; }
.phone[data-video="1"][data-state="talking"] .backdrop { opacity: 1; filter: blur(30px) brightness(0.45); }
@media (orientation: portrait) {
  /* Telefone: vaizdas užima didžiąją ekrano dalį, centre – Senelis su krėslu (kadre jis kiek dešiniau). */
  .phone[data-video="1"][data-state="talking"] .santa-video {
    object-fit: cover;
    object-position: 63% 50%;
    top: 14%;
    height: 66%;
    border-radius: 0;
  }
}
