/* Sakinah.live — purple/lavender design ported from the approved
   sakinah.health page. UI only; Dograh logic lives in dograh.js. */

:root{
  --purple-deep:#4b3a7a;
  --lavender:#a99fc9;
  --lilac:#c9bfe0;
  --blue-grey:#aab3cf;
  --warm-white:#f7f5fa;
  --pale-grey:#e9e7f0;
  --silver:#cfd2dd;
  --btn-size:clamp(84px, 12vw, 108px);
}

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

body{
  font-family:"Avenir Next","Avenir","SF Pro Display","Helvetica Neue",Helvetica,Arial,sans-serif;
  color:var(--warm-white);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  background:#8d84b5;
}

/* ---------- slow-breathing gradient (40–60s drift) ---------- */
.sky{
  position:fixed; inset:-20%;
  background:
    radial-gradient(ellipse 90% 70% at 50% 42%, rgba(255,251,244,.34), rgba(255,251,244,0) 62%),
    linear-gradient(178deg,
      #9d93c6 0%,
      #a89dce 26%,
      #b9aed8 46%,
      #c4b4d6 58%,
      #b3a6c9 72%,
      #8f87b4 100%);
  animation:drift 52s ease-in-out infinite alternate;
}
.sky::after{
  content:""; position:absolute; inset:0;
  background:radial-gradient(ellipse 120% 34% at 50% 78%, rgba(255,243,226,.22), rgba(255,243,226,0) 70%);
}
@keyframes drift{
  0%  {transform:translate3d(-1.2%,-0.8%,0) scale(1.02); filter:hue-rotate(0deg);}
  100%{transform:translate3d(1.2%,0.8%,0)  scale(1.06); filter:hue-rotate(-6deg);}
}

/* ------------------------- layout --------------------------- */
.stage{
  position:relative; height:100%; height:100dvh;
  display:flex; flex-direction:row; align-items:stretch; justify-content:center;
  text-align:center;
  gap:clamp(16px,3vw,52px);
  padding:3vh 3vw calc(3vh + 30px + env(safe-area-inset-bottom));
}

/* -------------- LEFT: tall avatar/video panel ---------------- */
.avatar-panel{
  position:relative;
  flex:0 0 auto;
  height:100%; aspect-ratio:82/100; max-width:46vw;
  border-radius:26px; overflow:hidden;
  border:1px solid rgba(255,255,255,.34);
  box-shadow:0 18px 54px rgba(75,58,122,.34);
  opacity:0; transform:translateY(10px);
  animation:arrive 1.8s ease .6s forwards;
}
.avatar-panel img{
  position:absolute; inset:0;
  width:100%; height:100%; display:block;
  object-fit:cover; object-position:30% 50%;
}
.panel-backdrop{z-index:1;}
.panel-avatar{z-index:2;}
/* Future MuseTalk/lip-sync video slot: hidden until it has a stream.
   Add class .live when video frames should be shown above the avatar. */
.panel-video{
  position:absolute; inset:0; z-index:3;
  width:100%; height:100%; object-fit:cover;
  opacity:0; transition:opacity .4s ease; pointer-events:none;
}
.panel-video.live{opacity:1;}

/* -------------- RIGHT: console ------------------------------- */
.console{
  flex:1 1 auto; min-width:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:space-between;
}
.brand{opacity:0; transform:translateY(10px);
  animation:arrive 1.8s ease .3s forwards;}
.console .brand{margin-top:clamp(6px,6.5vh,68px);}
.brand h1{
  font-weight:200;
  font-size:clamp(1.5rem, 3.6vw, 3.1rem);
  letter-spacing:clamp(.2em,1.1vw,.42em);
  text-indent:clamp(.2em,1.1vw,.42em); /* optically re-centre tracked type */
  color:var(--warm-white);
  text-shadow:0 2px 30px rgba(75,58,122,.25);
}
.lotus{width:clamp(44px,5vw,68px); margin:clamp(10px,1.8vh,20px) auto 0; display:block;
  filter:drop-shadow(0 2px 14px rgba(255,255,255,.35));}

@keyframes arrive{to{opacity:1; transform:none;}}

.controls{
  display:flex; flex-direction:column; align-items:center; width:100%;
}

/* -------------------- optional phone field ------------------- */
.phone-wrap{
  opacity:0; animation:arrive 1.6s ease 1s forwards;
  margin-top:0;
  width:min(320px, 86vw);
}
.phone-wrap input{
  width:100%; text-align:center;
  font:300 1rem/1 inherit; letter-spacing:.06em;
  color:var(--warm-white);
  background:rgba(255,255,255,.13);
  border:1px solid rgba(255,255,255,.32);
  border-radius:999px;
  padding:13px 20px;
  outline:none; backdrop-filter:blur(6px);
  transition:border-color .4s, background .4s;
}
.phone-wrap input::placeholder{color:rgba(255,255,255,.62); font-weight:300;}
.phone-wrap input:focus{border-color:rgba(255,255,255,.7); background:rgba(255,255,255,.2);}
.phone-hint{margin-top:9px; font-size:.72rem; font-weight:300; letter-spacing:.08em;
  color:rgba(255,255,255,.66);}

/* ------------------------ call beacon ------------------------ */
.beacon-wrap{
  position:relative; margin-top:clamp(24px,4vh,40px);
  opacity:0; animation:arrive 1.6s ease 1.4s forwards;
}
.beacon{
  position:relative; z-index:2;
  width:var(--btn-size); height:var(--btn-size); border-radius:50%;
  border:none; cursor:pointer;
  background:radial-gradient(circle at 50% 38%, #ffffff, #f2effa 78%);
  box-shadow:0 6px 34px rgba(75,58,122,.35), 0 0 0 0 rgba(255,255,255,.5);
  display:flex; align-items:center; justify-content:center;
  transition:transform .35s ease, box-shadow .6s ease;
  -webkit-tap-highlight-color:transparent;
  animation:breathe 5.6s ease-in-out infinite;
}
.beacon svg{width:42%; height:42%; fill:var(--purple-deep); transition:fill .4s, transform .4s;}
.beacon:hover, .beacon:focus-visible{
  box-shadow:0 8px 44px rgba(75,58,122,.4), 0 0 46px 10px rgba(255,255,255,.55);
  transform:scale(1.04);
}
.beacon:focus-visible{outline:3px solid rgba(255,255,255,.85); outline-offset:6px;}
.beacon:active{transform:scale(.96);}

@keyframes breathe{
  0%,100%{box-shadow:0 6px 34px rgba(75,58,122,.35), 0 0 0 0 rgba(255,255,255,.45);}
  50%    {box-shadow:0 6px 34px rgba(75,58,122,.35), 0 0 34px 8px rgba(255,255,255,.5);}
}

/* Continuous Ripple Animation */
.ring{
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,0.45);
  pointer-events: none;
  z-index: 1;
  animation: rippleWave 3s linear infinite;
}
#ring2{animation-delay: 1.5s;}
@keyframes rippleWave{
  0%{transform: translate(-50%, -50%) scale(1); opacity: 0.8;}
  70%{opacity: 0.2;}
  100%{transform: translate(-50%, -50%) scale(2.6); opacity: 0;}
}

/* -------- in-call state: beacon turns deep purple ------------ */
body.in-call .beacon{animation:none;
  background:radial-gradient(circle at 50% 38%, #5d4a92, var(--purple-deep) 80%);
  box-shadow:0 6px 34px rgba(46,34,80,.5);}
body.in-call .beacon svg{fill:#fff; transform:rotate(135deg);}
body.speaking .beacon{box-shadow:0 6px 40px rgba(46,34,80,.5), 0 0 44px 12px rgba(255,255,255,.5);}
body.in-call .phone-wrap{opacity:.35; pointer-events:none;}

.status{
  margin-top:clamp(16px,2.6vh,24px); min-height:1.4em;
  font-size:.82rem; font-weight:300; letter-spacing:.22em; text-transform:uppercase;
  color:rgba(255,255,255,.85);
  opacity:0; transition:opacity .8s ease;
}
.status.show{opacity:1;}

.privacy-note{
  margin-top:clamp(10px,1.6vh,16px);
  font-size:.72rem; font-weight:300; letter-spacing:.1em;
  color:rgba(255,255,255,.62);
}

footer{
  position:fixed; left:0; right:0; bottom:calc(12px + env(safe-area-inset-bottom));
  text-align:center; font-size:.68rem; font-weight:300; letter-spacing:.12em;
  color:rgba(255,255,255,.55);
}

@media (prefers-reduced-motion: reduce){
  .sky,.beacon{animation:none !important;}
  .brand,.phone-wrap,.beacon-wrap,.avatar-panel{animation-duration:.01s !important; animation-delay:0s !important;}
  .ring{display:none;}
}

/* short desktop windows */
@media (min-width:861px) and (max-height:620px){
  .brand h1{font-size:clamp(1.3rem,2.6vw,2.1rem);}
  .lotus{width:clamp(36px,3.6vw,48px);}
}

/* phones / narrow windows: image on top, controls at the bottom */
@media (max-width:860px){
  .stage{
    flex-direction:column; align-items:center; justify-content:space-between;
    gap:clamp(6px,1.2vh,14px);
    padding:2.2vh 20px calc(56px + env(safe-area-inset-bottom));
  }
  .avatar-panel{
    height:auto; width:min(74vw, 34vh); max-width:none;
    aspect-ratio:82/100;
    border-radius:20px;
  }
  .console{width:100%; flex:1 1 auto; justify-content:space-between;}
  .console .brand{margin-top:0;}
  .brand h1{
    font-size:clamp(1.35rem,6.4vw,2.2rem);
    letter-spacing:.28em; text-indent:.28em;
  }
  .lotus{
    width:clamp(30px,7.4vw,46px);
    margin-top:clamp(5px,1.2vh,14px);
  }
  .controls .beacon-wrap{margin-top:clamp(12px,2.2vh,24px);}
  .controls .status{margin-top:clamp(6px,1.2vh,12px);}
  .phone-hint{margin-top:7px;}
}

/* very short phones (browser chrome visible) */
@media (max-width:860px) and (max-height:640px){
  .avatar-panel{width:min(64vw, 27vh);}
  .brand h1{font-size:clamp(1.2rem,5.4vw,1.7rem);}
  .lotus{width:clamp(26px,6vw,36px);}
  .phone-wrap input{padding:11px 18px;}
  :root{--btn-size:clamp(70px,17vw,84px);}
}

/* phone held sideways */
@media (max-width:860px) and (max-height:520px) and (orientation:landscape){
  .stage{
    flex-direction:row; align-items:center; justify-content:center;
    gap:clamp(14px,3vw,34px);
    padding:2.5vh 18px calc(2.5vh + 30px + env(safe-area-inset-bottom));
  }
  .avatar-panel{height:100%; width:auto; aspect-ratio:82/100;}
  .console{justify-content:center;}
  .brand h1{font-size:clamp(1.1rem,3.4vw,1.6rem);}
  .lotus{width:clamp(24px,4vw,32px);}
}

/* ------------------ privacy policy (bottom-left) ------------------ */
.privacy-btn{
  position:fixed; left:16px; bottom:calc(12px + env(safe-area-inset-bottom));
  z-index:60;
  font:300 .68rem/1 inherit; letter-spacing:.12em;
  color:rgba(255,255,255,.75);
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.28);
  border-radius:999px; padding:8px 14px;
  cursor:pointer; backdrop-filter:blur(6px);
  transition:background .3s, color .3s, border-color .3s;
  -webkit-tap-highlight-color:transparent;
}
.privacy-btn:hover,.privacy-btn:focus-visible{
  background:rgba(255,255,255,.22); color:#fff; border-color:rgba(255,255,255,.6);
}
.privacy-btn:focus-visible{outline:2px solid rgba(255,255,255,.85); outline-offset:3px;}

.privacy-overlay{
  position:fixed; inset:0; z-index:70;
  background:rgba(50,40,84,.55); backdrop-filter:blur(8px);
  display:none; align-items:center; justify-content:center;
  padding:5vh 16px calc(5vh + env(safe-area-inset-bottom));
}
.privacy-overlay.open{display:flex; animation:fadeIn .35s ease;}
@keyframes fadeIn{from{opacity:0;}to{opacity:1;}}

.privacy-card{
  position:relative;
  width:min(640px, 100%); max-height:100%;
  overflow-y:auto; -webkit-overflow-scrolling:touch;
  background:rgba(255,255,255,.96);
  color:#3b325c;
  border-radius:22px;
  padding:clamp(24px,4.5vw,42px);
  box-shadow:0 18px 60px rgba(46,34,80,.45);
  font-weight:400; font-size:.92rem; line-height:1.65; text-align:left;
}
.privacy-card h2{
  font-weight:600; font-size:1.3rem; letter-spacing:.06em;
  color:var(--purple-deep); margin-bottom:2px;
}
.privacy-card h3{
  font-weight:600; font-size:.98rem; letter-spacing:.03em;
  color:var(--purple-deep); margin:22px 0 8px;
}
.privacy-card p{margin:0 0 10px;}
.privacy-card ul{margin:0 0 10px; padding-left:20px;}
.privacy-card li{margin:4px 0;}
.privacy-card ul.choices{list-style:none; padding-left:2px;}
.privacy-card ul.choices li{display:flex; gap:10px; align-items:flex-start;}
.privacy-card ul.choices .box{
  flex:0 0 auto; width:15px; height:15px; margin-top:3px;
  border:1.6px solid var(--purple-deep); border-radius:4px; display:inline-block;
}
.privacy-card a{color:var(--purple-deep); font-weight:500; text-decoration:underline;}
.privacy-close{
  position:sticky; top:0; float:right; margin:-6px -6px 0 12px;
  width:34px; height:34px; border-radius:50%;
  border:none; cursor:pointer;
  background:var(--pale-grey); color:var(--purple-deep);
  font-size:1.05rem; line-height:34px; font-weight:600;
  transition:background .3s;
}
.privacy-close:hover,.privacy-close:focus-visible{background:var(--lilac); color:#fff;}
.privacy-close:focus-visible{outline:2px solid var(--purple-deep); outline-offset:2px;}
