/* ============================================================
   Karana, Deepam gamified onboarding (web/deepam.css)
   Everything namespaced `dpm-`. Flat system: no gradients, no
   glows. Scenes are flat cream / flat deep indigo. The diya SVG
   internals are artwork and untouched; CSS adds no halos.
   ============================================================ */

/* ---------- overlay shell ---------- */
.dpm-overlay {
  position: absolute;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text-main);
  animation: dpmOverlayIn 0.45s ease both;
}
.dpm-overlay:not(.open) { display: none; }

@keyframes dpmOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* keep the shell toast visible above the z-400 overlay */
body:has(.dpm-overlay.open) #toast { z-index: 500; }

/* cream <-> indigo scene layers (cross-fade) */
.dpm-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: opacity 0.7s ease;
  pointer-events: none;
}
.dpm-bg-cream { background: #F9F9F9; opacity: 0; }
body.dark-mode .dpm-bg-cream { background: #101014; }
.dpm-bg-dark { background: #1D1B2E; opacity: 0; }
.dpm-scene-cream .dpm-bg-cream { opacity: 1; }
.dpm-scene-dark .dpm-bg-dark { opacity: 1; }

/* lighting-success ambience: a plain warm-white overlay at low opacity */
.dpm-glowflood {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #FFF6E8;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
.dpm-glow-on .dpm-glowflood { opacity: 0.08; }

/* ---------- top chrome ---------- */
.dpm-top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(48px, env(safe-area-inset-top)) 16px 8px 16px;
}
.dpm-iconbtn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-round, 99px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.dpm-iconbtn:active { transform: scale(0.92); }
.dpm-scene-dark .dpm-iconbtn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ECECF0;
}

/* progress dots */
.dpm-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.dpm-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  transition: width 0.2s ease, background-color 0.2s ease;
  flex: none;
}
.dpm-dot.dpm-done { background: var(--brand-primary); }
.dpm-dot.dpm-on {
  width: 18px;
  background: var(--brand-primary);
}
.dpm-scene-dark .dpm-dot { background: rgba(255, 255, 255, 0.18); }
.dpm-scene-dark .dpm-dot.dpm-done { background: var(--brand-primary); }
.dpm-scene-dark .dpm-dot.dpm-on { background: var(--brand-primary); }

/* quiet sign-in escape for returning users, under the icon row */
.dpm-top-links {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 0 16px;
}
.dpm-signin-link {
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
}
.dpm-signin-link:hover { color: var(--text-main); }
.dpm-scene-dark .dpm-signin-link { color: rgba(236, 236, 240, 0.72); }
.dpm-scene-dark .dpm-signin-link:hover { color: #ECECF0; }

/* ---------- beat stage ---------- */
.dpm-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
}
.dpm-stage::-webkit-scrollbar { display: none; }
.dpm-beat-host {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.dpm-beat {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 24px calc(24px + env(safe-area-inset-bottom)) 24px;
}
.dpm-beat-inner {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  animation: dpmBeatIn 0.45s ease both;
}

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

/* edge tap-zones (invisible; advance / go back) */
.dpm-tap {
  position: absolute;
  top: 110px;
  bottom: 0;
  width: 28px;
  z-index: 4;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dpm-tap-left { left: 0; }
.dpm-tap-right { right: 0; }

/* ---------- typography ----------
   Ritual beats (hook/light/finish) keep centered titles; question beats
   carry .dpm-beat-ask on the beat root and go left-aligned. Body copy
   (.dpm-hint) is always left-aligned. */
.dpm-title {
  font-family: var(--font-title);
  font-size: 1.5625rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1.3;
  text-align: center;
  margin: 18px 0 10px 0;
  color: var(--text-main);
}
.dpm-hint {
  text-align: left;
  font-size: 0.96875rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 18px 0;
  min-height: 44px;
}
.dpm-beat-ask .dpm-title,
.dpm-beat:has(.dpm-cards) .dpm-title,
.dpm-beat:has(.dpm-list) .dpm-title,
.dpm-beat:has(.dpm-input) .dpm-title,
.dpm-beat:has(.dpm-quiz) .dpm-title {
  text-align: left;
}
.dpm-scene-dark .dpm-title { color: #ECECF0; }
.dpm-scene-dark .dpm-hint { color: rgba(236, 236, 240, 0.72); }

/* ---------- Mayu the peacock guide ---------- */
.dpm-mayu {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 340px;
  margin: 8px auto 18px auto;
}
.dpm-mayu-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 1.375rem;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  box-shadow: none;
}
.dpm-mayu-avatar .k-icon { width: 22px; height: 22px; }
.dpm-mayu-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  padding: 12px 14px;
  font-size: 0.9375rem;
  line-height: 1.5;
  text-align: left;
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.dpm-scene-dark .dpm-mayu-bubble {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ECECF0;
}

/* ---------- continue / begin buttons ---------- */
.dpm-continue {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 14px auto 0 auto;
  padding: 10px 16px;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  background: var(--brand-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.dpm-continue:hover { background: var(--brand-primary-shadow); }
.dpm-continue:active { background: var(--brand-primary-shadow); transform: scale(0.985); }
.dpm-continue[hidden] { display: none; }
.dpm-begin { background: var(--brand-primary); }

/* ---------- diya artwork ---------- */
.dpm-diya {
  position: relative;
  width: 210px;
  height: 210px;
  margin: 0 auto;
}
.dpm-diya svg { width: 100%; height: 100%; overflow: visible; display: block; }
.dpm-diya--sm { width: 132px; height: 132px; }
.dpm-diya--md { width: 172px; height: 172px; }
.dpm-diya--lg { width: 240px; height: 240px; }

/* hook beat: unlit silhouette in the dark */
.dpm-silhouette { filter: brightness(0.5) saturate(0.55); opacity: 0.92; }

/* contrast beat: the lamp gone dark */
.dpm-dimmed { filter: grayscale(0.9) brightness(0.55); opacity: 0.55; }

/* flame: hidden until lit */
.dpm-flame-g {
  opacity: 0;
  transform: scale(0);
  transform-origin: 100px 106px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.dpm-halo {
  opacity: 0;
  transform-origin: 100px 76px;
  transition: opacity 0.4s ease;
}
.dpm-spark { opacity: 0; transform-origin: 100px 104px; }
.dpm-oil { transition: opacity 0.6s ease; }

/* lit: flame blooms in, then sways gently (no halo breathing) */
.dpm-lit .dpm-flame-g {
  opacity: 1;
  animation: dpmFlameIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.dpm-lit .dpm-flame-sway {
  transform-origin: 100px 108px;
  animation: dpmFlameSwayX 2.6s ease-in-out infinite;
}
.dpm-lit .dpm-flame-core {
  transform-origin: 100px 92px;
  animation: dpmCorePulseX 1.7s ease-in-out infinite;
}
.dpm-lit .dpm-halo { opacity: 0.3; }
.dpm-lit .dpm-oil { opacity: 1; }

@keyframes dpmFlameIn {
  0% { transform: scale(0); }
  55% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
@keyframes dpmFlameSwayX {
  0%, 100% { transform: rotate(-2.4deg); }
  50% { transform: rotate(2.6deg); }
}
@keyframes dpmCorePulseX {
  0%, 100% { transform: scale(0.92); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* ---------- press-and-hold lighting ---------- */
.dpm-light-wrap { position: relative; margin: 0 auto; }

/* progress ring around the wick (functional; kept) */
.dpm-ring-track { stroke: rgba(232, 137, 28, 0.18); }
.dpm-ring {
  stroke: var(--brand-primary);
  stroke-linecap: round;
  stroke-dasharray: 226.2; /* 2 * pi * r(36) */
  stroke-dashoffset: 226.2;
  transform: rotate(-90deg);
  transform-origin: 100px 102px;
  transition: stroke-dashoffset 0.3s ease;
}
.dpm-holding .dpm-ring {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.2s linear;
}

/* faint flame preview grows while holding */
.dpm-holding .dpm-flame-g {
  opacity: 0.55;
  transform: scale(0.34);
  transition: transform 1.2s ease, opacity 0.3s ease;
}
.dpm-holding .dpm-halo { opacity: 0.2; }

/* sputter on early release: a spark flickers up and dies */
.dpm-sputter .dpm-spark { animation: dpmSputterX 0.9s ease-out both; }

@keyframes dpmSputterX {
  0% { opacity: 0.95; transform: translateY(0) scale(0.5); }
  25% { opacity: 1; transform: translateY(-3px) scale(1.05); }
  45% { opacity: 0.55; transform: translateY(-6px) scale(0.7); }
  65% { opacity: 0.85; transform: translateY(-9px) scale(0.85); }
  100% { opacity: 0; transform: translateY(-16px) scale(0.2); }
}

/* invisible hold target over the wick: a flat ring hint, no blur glow */
.dpm-wick-hit {
  position: absolute;
  left: calc(50% - 52px);
  top: 68px;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dpm-wick-hit::after {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 2px solid rgba(232, 137, 28, 0.45);
  animation: dpmRingHint 2s ease-in-out infinite;
  pointer-events: none;
}
.dpm-holding .dpm-wick-hit::after { animation: none; opacity: 0; }

@keyframes dpmRingHint {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* ---------- teach beats ---------- */
.dpm-chips {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 4px 0 10px 0;
}
.dpm-chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.dpm-contrast {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: flex-end;
}
.dpm-contrast-col { flex: none; }
.dpm-contrast-cap {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

/* ---------- quiz beat ---------- */
.dpm-quiz { max-width: 340px; margin: 0 auto; }
.dpm-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.dpm-opt:active { transform: scale(0.985); }
.dpm-opt.dpm-picked {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}
.dpm-opt.dpm-picked.dpm-good {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.dpm-feedback {
  background: var(--brand-primary-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: left;
  color: var(--text-main);
  margin-top: 4px;
  animation: dpmBeatIn 0.35s ease both;
}
.dpm-feedback[hidden] { display: none; }

/* ---------- question beats ---------- */
.dpm-input {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.dpm-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(232, 137, 28, 0.25);
}
.dpm-input::placeholder { color: var(--text-muted); font-weight: 400; }

.dpm-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 340px;
  margin: 0 auto;
}
.dpm-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  margin: 0 auto;
}
.dpm-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  font-family: inherit;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.dpm-card:active { transform: scale(0.985); }
.dpm-card.dpm-picked {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}
.dpm-card-big {
  font-family: var(--font-title);
  font-size: 1.3125rem;
  font-weight: 700;
}
.dpm-card-sub {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
}
.dpm-card--row {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
}
.dpm-row-emoji { font-size: 1.375rem; flex: none; display: flex; align-items: center; color: var(--text-main); }
.dpm-row-emoji .k-icon { width: 22px; height: 22px; }
.dpm-row-label { font-size: 0.9375rem; font-weight: 600; flex: 1; min-width: 0; }
.dpm-row-time { font-size: 0.8125rem; font-weight: 500; color: var(--text-muted); flex: none; }

/* ---------- finish beat (dark scene) ---------- */
.dpm-summary {
  max-width: 300px;
  margin: 4px auto 16px auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dpm-sum-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  color: #ECECF0;
}
.dpm-sum-row .material-symbols-rounded,
.dpm-sum-row .k-icon {
  font-size: 1.1875rem;
  width: 19px;
  height: 19px;
  color: var(--brand-primary);
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .dpm-overlay,
  .dpm-beat-inner,
  .dpm-feedback,
  .dpm-lit .dpm-flame-g,
  .dpm-lit .dpm-flame-sway,
  .dpm-lit .dpm-flame-core,
  .dpm-sputter .dpm-spark,
  .dpm-wick-hit::after {
    animation: none;
  }
  /* dpmFlameIn normally supplies the end pose; without it the base
     scale(0) would hide the lit flame entirely. */
  .dpm-lit .dpm-flame-g { transform: none; }
}

/* ---------------- first-text picker ---------------- */

.dpm-reco {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--brand-primary-light);
  color: #8A5A10;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  vertical-align: middle;
}
body.dark-mode .dpm-reco { color: #E0B978; }

.dpm-row-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}
