/* ─────────────────────────────────────────────────────────────
   Muthawifku — style.css
   Dark navy + Islamic teal/green, mobile-first, voice-first
   OKLCH throughout for perceptual consistency
   ───────────────────────────────────────────────────────────── */

/* ── Tokens ──────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep:   oklch(15% 0.04 245);   /* #0d1b36 — night sky */
  --bg-card:   oklch(20% 0.045 245);  /* #1a2744 — elevated surface */
  --bg-subtle: oklch(24% 0.04 245);   /* slightly lifted */

  /* Accent — Islamic green/teal */
  --accent:      oklch(63% 0.10 172);
  --accent-hi:   oklch(70% 0.12 172);
  --accent-dim:  oklch(45% 0.07 172);
  --accent-glow: oklch(63% 0.10 172 / 0.35);

  /* SOS red */
  --sos:       oklch(50% 0.20 25);
  --sos-hi:    oklch(56% 0.22 25);
  --sos-glow:  oklch(50% 0.20 25 / 0.40);

  /* Text */
  --ink:       oklch(92% 0.02 245);
  --ink-muted: oklch(62% 0.04 245);
  --ink-faint: oklch(42% 0.04 245);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-mid:  300ms;

  /* Layout */
  --radius-sm: 12px;
  --radius:    20px;
  --radius-lg: 28px;

  /* Z-index scale */
  --z-banner:  40;
  --z-sos:     50;
  --z-modal:   80;
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.0625rem);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── App shell ───────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Header ──────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--bg-card);
  border-bottom: 1px solid oklch(100% 0 0 / 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: oklch(100% 0 0 / 0.05);
  border-radius: 10px;
  border: 1px solid var(--accent-dim);
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-hi);
  letter-spacing: -0.01em;
}

/* Connection status */
.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: background var(--dur-mid) var(--ease-out);
}

.conn-dot.online  { background: oklch(65% 0.18 145); }
.conn-dot.offline { background: var(--sos); }

/* ── Main ────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 20px 120px;
  gap: 40px;
  /* 120px bottom padding clears the fixed SOS bar */
}

/* ── Greeting ────────────────────────────────────────────────── */
.greeting {
  text-align: center;
  max-width: 360px;
}

.basmallah {
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
  font-family: 'Traditional Arabic', 'Scheherazade New', serif;
  line-height: 1.8;
}

.greeting-title {
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
  text-wrap: balance;
}

.greeting-sub {
  font-size: 0.95rem;
  color: var(--ink-muted);
  text-wrap: balance;
}

/* ── Voice section ───────────────────────────────────────────── */
.voice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Mic shell: holds button + rings */
.mic-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
}

/* Pulse rings — only visible while listening */
.mic-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent-glow);
  opacity: 0;
  pointer-events: none;
}

.mic-ring.r1 { width: 150px; height: 150px; }
.mic-ring.r2 { width: 178px; height: 178px; }

.mic-shell.listening .mic-ring.r1 {
  animation: ring-pulse 1.6s var(--ease-out) infinite;
}
.mic-shell.listening .mic-ring.r2 {
  animation: ring-pulse 1.6s var(--ease-out) 0.45s infinite;
}

@keyframes ring-pulse {
  0%   { opacity: 0.9; transform: scale(0.85); }
  100% { opacity: 0;   transform: scale(1.15); }
}

/* Mic button */
.mic-btn {
  position: relative;
  z-index: 2;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-dim), var(--accent));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform  var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-mid)  var(--ease-out),
    background var(--dur-mid)  var(--ease-out);
  box-shadow: 0 8px 32px var(--accent-glow);
  -webkit-tap-highlight-color: transparent;
}

.mic-btn:hover  { transform: scale(1.04); box-shadow: 0 12px 40px var(--accent-glow); }
.mic-btn:active { transform: scale(0.96); }

.mic-btn[aria-pressed="true"],
.mic-btn.listening {
  background: linear-gradient(145deg, var(--accent), var(--accent-hi));
  box-shadow: 0 0 0 4px oklch(100% 0 0 / 0.12), 0 12px 40px var(--accent-glow);
}

.mic-btn.loading {
  background: linear-gradient(145deg, var(--bg-subtle), var(--bg-card));
  box-shadow: none;
  cursor: wait;
}

.mic-icon {
  width: 48px;
  height: 48px;
  color: white;
  display: block;
}

.mic-spinner {
  width: 48px;
  height: 48px;
  color: var(--accent);
  display: none;
  animation: spin 0.8s linear infinite;
}

.mic-btn.loading .mic-icon    { display: none; }
.mic-btn.loading .mic-spinner { display: block; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Voice hint */
.voice-hint {
  font-size: 0.875rem;
  color: var(--ink-muted);
  text-align: center;
  min-height: 1.4em;
  transition: color var(--dur-mid) var(--ease-out);
}

.voice-hint.active { color: var(--accent-hi); }

/* ── Conversation bubbles ─────────────────────────────────────── */
.convo-section {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  line-height: 1.55;
  max-width: 65ch;
  transition: opacity var(--dur-mid) var(--ease-out);
}

.bubble.hidden { display: none; }

.bubble-user {
  background: var(--bg-subtle);
  color: var(--ink);
  border: 1px solid oklch(100% 0 0 / 0.06);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble-ai {
  background: oklch(100% 0 0 / 0.04);
  color: var(--accent-hi);
  border: 1px solid var(--accent-dim);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ── SOS Bar (fixed bottom) ──────────────────────────────────── */
.sos-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-deep) 70%, transparent);
  z-index: var(--z-sos);
}

.sos-btn {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 28px;
  background: var(--sos);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition:
    transform  var(--dur-fast) var(--ease-out),
    background var(--dur-mid)  var(--ease-out),
    box-shadow var(--dur-mid)  var(--ease-out);
  box-shadow: 0 6px 28px var(--sos-glow);
  -webkit-tap-highlight-color: transparent;
  /* Make the whole block a touch target */
  min-height: 64px;
}

.sos-btn:hover  { background: var(--sos-hi); transform: translateY(-2px); }
.sos-btn:active { transform: scale(0.98); }

.sos-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: white;
}

/* ── Modal (native <dialog>) ─────────────────────────────────── */
.modal {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 380px;
  width: calc(100% - 40px);
  margin: auto;
}

.modal::backdrop {
  background: oklch(0% 0 0 / 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-inner {
  background: var(--bg-card);
  border: 1px solid oklch(100% 0 0 / 0.08);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 24px 64px oklch(0% 0 0 / 0.5);
}

.modal-icon { font-size: 2.5rem; margin-bottom: 12px; }

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-wrap: balance;
}

.modal-body {
  font-size: 0.9rem;
  color: var(--ink-muted);
  line-height: 1.6;
  margin-bottom: 24px;
  text-wrap: pretty;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-confirm {
  padding: 15px;
  background: var(--sos);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.btn-confirm:hover  { background: var(--sos-hi); }
.btn-confirm:active { transform: scale(0.98); }

.btn-cancel {
  padding: 13px;
  background: oklch(100% 0 0 / 0.06);
  color: var(--ink-muted);
  border: 1px solid oklch(100% 0 0 / 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.btn-cancel:hover { background: oklch(100% 0 0 / 0.10); }

/* ── Install banner ──────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 108px; /* above SOS bar */
  left: 16px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: var(--z-banner);
  box-shadow: 0 8px 32px oklch(0% 0 0 / 0.35);
  animation: slide-up var(--dur-mid) var(--ease-out);
}

.install-banner.hidden { display: none; }

.install-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-install {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out);
}

.btn-install:hover { background: var(--accent-hi); }

.btn-dismiss {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
  transition: color var(--dur-fast) var(--ease-out);
}

.btn-dismiss:hover { color: var(--ink-muted); }

/* ── Utilities ───────────────────────────────────────────────── */
.hidden { display: none !important; }

@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Focus visible ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive (tablet+) ────────────────────────────────────── */
@media (min-width: 540px) {
  .main { padding-top: 56px; }
  .sos-bar { padding-left: 32px; padding-right: 32px; }
  .mic-btn { width: 136px; height: 136px; }
  .mic-icon, .mic-spinner { width: 56px; height: 56px; }
}

/* ══════════════════════════════════════════════════════════════
   Step 3 — Manasik Copilot + Waktu Ibadah UI
   ══════════════════════════════════════════════════════════════ */

/* ── Manasik start bar (above SOS bar) ──────────────────────── */
.manasik-bar {
  position: fixed;
  bottom: 100px; /* clears SOS bar */
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: oklch(20% 0.045 245 / 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid oklch(100% 0 0 / 0.07);
  z-index: calc(var(--z-sos) - 5);
}

.btn-ibadah {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: oklch(63% 0.10 172 / 0.15);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  color: var(--accent-hi);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn-ibadah:hover  { background: oklch(63% 0.10 172 / 0.28); }
.btn-ibadah:active { transform: scale(0.96); }

.ibadah-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Prayer times compact widget inside manasik bar */
.prayer-times-widget {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.prayer-times-widget::-webkit-scrollbar { display: none; }

.prayer-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 44px;
  padding: 4px 6px;
  background: oklch(100% 0 0 / 0.04);
  border-radius: 8px;
  border: 1px solid oklch(100% 0 0 / 0.05);
}

.prayer-name {
  font-size: 0.58rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.prayer-time {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-hi);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Ritual panel (full overlay) ───────────────────────────── */
.ritual-panel {
  position: fixed;
  top: 58px; /* below sticky header */
  left: 0;
  right: 0;
  bottom: 210px; /* above manasik bar + SOS bar */
  background: var(--bg-card);
  border-bottom: 1px solid oklch(100% 0 0 / 0.07);
  z-index: calc(var(--z-sos) - 2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 24px;
  animation: slide-up var(--dur-mid) var(--ease-out);
}

.ritual-panel.hidden { display: none; }

.ritual-panel.ritual-complete { border-bottom-color: var(--accent-dim); }

/* Panel header */
.ritual-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ritual-title-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.btn-end-ritual {
  padding: 6px 14px;
  background: oklch(100% 0 0 / 0.06);
  border: 1px solid oklch(100% 0 0 / 0.08);
  border-radius: 8px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--dur-fast);
}

.btn-end-ritual:hover { background: oklch(100% 0 0 / 0.10); }

/* Counter */
.ritual-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.round-label {
  font-size: clamp(2.8rem, 14vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* 7 progress dots */
.round-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.round-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: oklch(100% 0 0 / 0.12);
  border: 2px solid oklch(100% 0 0 / 0.15);
  transition: background var(--dur-mid) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.round-dot.done {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}

/* Progress bar */
.ritual-progress-track {
  width: 160px;
  height: 4px;
  background: oklch(100% 0 0 / 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.ritual-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-mid) var(--ease-out);
}

/* Step count (accelerometer) */
.step-count-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.step-count {
  font-weight: 700;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* +/- control row */
.ritual-controls {
  display: flex;
  gap: 32px;
  align-items: center;
}

.btn-round {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid oklch(100% 0 0 / 0.12);
  background: oklch(100% 0 0 / 0.05);
  color: var(--ink);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast),
    transform var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn-round:hover  { background: oklch(100% 0 0 / 0.10); border-color: oklch(100% 0 0 / 0.20); }
.btn-round:active { transform: scale(0.92); }

.btn-plus {
  background: oklch(63% 0.10 172 / 0.15);
  border-color: var(--accent-dim);
  color: var(--accent-hi);
}

.btn-plus:hover { background: oklch(63% 0.10 172 / 0.30); }

/* ── Niat reminder banner ────────────────────────────────────── */
.niat-banner {
  position: fixed;
  top: 70px;
  left: 12px;
  right: 12px;
  background: oklch(50% 0.14 40);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  z-index: calc(var(--z-modal) - 5);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--dur-mid) var(--ease-out), transform var(--dur-mid) var(--ease-out);
  pointer-events: none;
}

.niat-banner.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Prayer reminder toast ───────────────────────────────────── */
.prayer-toast {
  position: fixed;
  top: 70px;
  left: 12px;
  right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  color: var(--accent-hi);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  z-index: calc(var(--z-modal) - 5);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--dur-mid) var(--ease-out), transform var(--dur-mid) var(--ease-out);
  pointer-events: none;
  box-shadow: 0 4px 24px oklch(0% 0 0 / 0.4);
}

.prayer-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Adjust main padding when manasik bar is present */
.main { padding-bottom: 200px; }
