/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * ANHAD — Mala Counter Modal Styling (iOS Sheet & Tactile Cushion Clay)
 * ═══════════════════════════════════════════════════════════════════════════════
 */

.mala-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.mala-modal.open,
.mala-modal.active {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.mala-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mala-modal.open .mala-modal__backdrop {
  opacity: 1;
}

.mala-modal__sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF8EE 100%);
  border-radius: 32px 32px 0 0;
  padding: 16px 24px 36px 24px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.25), inset 0 1.5px 2px rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(212, 148, 58, 0.25);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 1, 0.23, 1);
  box-sizing: border-box;
}

.mala-modal.open .mala-modal__sheet {
  transform: translateY(0);
}

html.dark-mode .mala-modal__sheet,
[data-theme="dark"] .mala-modal__sheet,
[data-time-of-day="night"] .mala-modal__sheet {
  background: linear-gradient(180deg, #1C1924 0%, #121017 100%);
  border-top: 1px solid rgba(212, 148, 58, 0.35);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.8), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

.mala-modal__drag-handle {
  width: 38px;
  height: 4.5px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  margin: 0 auto 14px auto;
}

html.dark-mode .mala-modal__drag-handle,
[data-theme="dark"] .mala-modal__drag-handle {
  background: rgba(255, 255, 255, 0.2);
}

.mala-modal__header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.mala-modal__eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #A3640E;
}

html.dark-mode .mala-modal__eyebrow,
[data-theme="dark"] .mala-modal__eyebrow {
  color: #F7C634;
}

.mala-modal__title {
  font-size: 1.25rem;
  font-weight: 750;
  color: #1A171D;
  margin: 2px 0 0 0;
}

html.dark-mode .mala-modal__title,
[data-theme="dark"] .mala-modal__title {
  color: #FFFDF8;
}

.mala-modal__close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #555;
  transition: transform 0.15s ease, background 0.15s ease;
}

.mala-modal__close-btn:hover {
  transform: scale(1.08);
  background: rgba(0, 0, 0, 0.1);
}

html.dark-mode .mala-modal__close-btn,
[data-theme="dark"] .mala-modal__close-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #EEE;
}

/* Target Selector */
.mala-target-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.mala-target-btn {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(212, 148, 58, 0.08);
  border: 1px solid rgba(212, 148, 58, 0.2);
  color: #7D4C00;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mala-target-btn.active {
  background: linear-gradient(135deg, #E69526 0%, #BD6E09 100%);
  border-color: transparent;
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(212, 148, 58, 0.35);
}

html.dark-mode .mala-target-btn,
[data-theme="dark"] .mala-target-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #E0D0B8;
}

html.dark-mode .mala-target-btn.active,
[data-theme="dark"] .mala-target-btn.active {
  background: linear-gradient(135deg, #E69526 0%, #BD6E09 100%);
  color: #FFFFFF;
}

/* Interactive Bead Circle */
.mala-interactive-circle {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 24px auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #FFFFFF 0%, #FFF5E4 100%);
  box-shadow: 
    0 12px 30px rgba(212, 148, 58, 0.18),
    inset 2px 2px 6px rgba(255, 255, 255, 1),
    inset -2px -2px 6px rgba(212, 148, 58, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mala-interactive-circle:active,
.mala-interactive-circle.pulse {
  transform: scale(0.94);
}

html.dark-mode .mala-interactive-circle,
[data-theme="dark"] .mala-interactive-circle {
  background: linear-gradient(145deg, #24202B 0%, #15131C 100%);
  box-shadow: 
    0 14px 36px rgba(0, 0, 0, 0.65),
    0 0 20px rgba(212, 148, 58, 0.15),
    inset 1.5px 1.5px 4px rgba(255, 255, 255, 0.08),
    inset -1.5px -1.5px 4px rgba(0, 0, 0, 0.7);
}

.mala-ring-svg {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.mala-ring-bg {
  fill: none;
  stroke: rgba(212, 148, 58, 0.15);
  stroke-width: 6;
}

html.dark-mode .mala-ring-bg,
[data-theme="dark"] .mala-ring-bg {
  stroke: rgba(255, 255, 255, 0.08);
}

.mala-ring-fill {
  fill: none;
  stroke: url(#malaGradient, #E69526);
  stroke-width: 6.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.15s ease;
}

.mala-center-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mala-mantra {
  font-size: 1.15rem;
  font-weight: 750;
  color: #B8781E;
  margin-bottom: 2px;
}

html.dark-mode .mala-mantra,
[data-theme="dark"] .mala-mantra {
  color: #F7C634;
}

.mala-count {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  color: #1A171D;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-rounded, -apple-system, sans-serif);
}

html.dark-mode .mala-count,
[data-theme="dark"] .mala-count {
  color: #FFFFFF;
}

.mala-target-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #8C7560;
  margin-top: 4px;
}

html.dark-mode .mala-target-label,
[data-theme="dark"] .mala-target-label {
  color: #A09586;
}

.mala-tap-hint {
  position: absolute;
  bottom: 16px;
  font-size: 0.66rem;
  font-weight: 600;
  color: #B39268;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Stats Bar */
.mala-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(212, 148, 58, 0.08);
  border: 1px solid rgba(212, 148, 58, 0.18);
  border-radius: 18px;
  padding: 10px 16px;
  margin-bottom: 18px;
}

html.dark-mode .mala-stats-bar,
[data-theme="dark"] .mala-stats-bar {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.mala-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mala-stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #8C7560;
}

html.dark-mode .mala-stat-label,
[data-theme="dark"] .mala-stat-label {
  color: #9C9286;
}

.mala-stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: #7D4C00;
  margin-top: 2px;
}

html.dark-mode .mala-stat-value,
[data-theme="dark"] .mala-stat-value {
  color: #F7C634;
}

.mala-stat-divider {
  width: 1px;
  height: 24px;
  background: rgba(212, 148, 58, 0.2);
}

/* Action Controls */
.mala-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.mala-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: #555;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mala-action-btn:hover {
  background: rgba(0, 0, 0, 0.09);
}

html.dark-mode .mala-action-btn,
[data-theme="dark"] .mala-action-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #DDD;
}

html.dark-mode .mala-action-btn:hover,
[data-theme="dark"] .mala-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.mala-action-btn--reset {
  color: #C0392B;
}

html.dark-mode .mala-action-btn--reset,
[data-theme="dark"] .mala-action-btn--reset {
  color: #E74C3C;
}

/* Milestone Bloom Animation */
@keyframes malaMilestoneBloom {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(212, 148, 58, 0.8); }
  50% { transform: scale(1.08); box-shadow: 0 0 40px 15px rgba(212, 148, 58, 0.4); }
  100% { transform: scale(1); box-shadow: 0 12px 30px rgba(212, 148, 58, 0.18); }
}

.mala-interactive-circle.milestone-bloom {
  animation: malaMilestoneBloom 0.9s cubic-bezier(0.25, 1, 0.5, 1);
}
