/* ============================================================
   Masbaha (Digital Rosary) — Full Redesign
   Tap-first spiritual experience.
   All colors via CSS tokens. No hardcoded values.
   ============================================================ */

/* ── Layout ───────────────────────────────────────────────── */

.section--masbaha .masbaha-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 4px;
}

/* ── Zikr Header ──────────────────────────────────────────── */

.section--masbaha .masbaha-zikr-header-wrap {
    text-align: center;
}

.section--masbaha .masbaha-zikr-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    max-width: 100%;
}

.section--masbaha .masbaha-zikr-header:active {
    background: var(--primary-light);
}

.section--masbaha .masbaha-zikr-name {
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 700;
    color: var(--primary);
    line-height: 1.6;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80vw;
}

.section--masbaha .masbaha-zikr-chevron {
    font-size: 0.9rem;
    color: var(--text-sub);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.section--masbaha .masbaha-next-hint {
    font-size: 0.82rem;
    color: var(--text-sub);
    margin-top: 2px;
    text-align: center;
}

/* ── Tap Surface ──────────────────────────────────────────── */

.section--masbaha .masbaha-tap-surface {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 220px;
    border-radius: 26px;
    border: 1.5px solid color-mix(in srgb, var(--primary) 22%, var(--border));
    background: radial-gradient(
        circle at 50% 40%,
        color-mix(in srgb, var(--primary) 9%, var(--card-bg)),
        var(--card-bg)
    );
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.04),
        0 8px 24px rgba(0, 0, 0, 0.035),
        inset 0 1px 0 color-mix(in srgb, var(--primary) 8%, transparent);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    gap: 10px;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    touch-action: manipulation;
}

.section--masbaha .masbaha-tap-surface:active {
    transform: scale(0.975);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Ripple on tap */
@keyframes masbaha-ripple {
    0%   { transform: scale(0.85); opacity: 0.25; }
    60%  { transform: scale(1.04); opacity: 0.1; }
    100% { transform: scale(1.08); opacity: 0; }
}

.section--masbaha .masbaha-tap-surface.is-tapped::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--primary);
    animation: masbaha-ripple 0.38s ease forwards;
    pointer-events: none;
}

.section--masbaha .masbaha-tap-surface {
    position: relative;
    overflow: hidden;
}

.section--masbaha .masbaha-tap-count {
    font-size: clamp(3.5rem, 16vw, 5.5rem);
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -1px;
    pointer-events: none;
}

.section--masbaha .masbaha-tap-batch {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-sub);
    pointer-events: none;
}

@media (max-width: 768px) {
    .section--masbaha .masbaha-tap-surface { min-height: 200px; }
}
@media (max-width: 480px) {
    .section--masbaha .masbaha-tap-surface { min-height: 185px; border-radius: 22px; }
}

/* ── Batch Progress Dots ──────────────────────────────────── */

.section--masbaha .masbaha-batch-progress {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    align-items: center;
    padding: 4px 0;
    min-height: 20px;
}

/* Dot mode */
.section--masbaha .masbaha-batch-progress[data-batch-mode="dots"] {
    gap: 5px;
}

.section--masbaha .masbaha-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 18%, var(--border));
    flex-shrink: 0;
    transition: background 0.1s ease, transform 0.1s ease;
}

.section--masbaha .masbaha-dot.is-filled {
    background: var(--primary);
    transform: scale(1.15);
}

/* Batch complete flash */
@keyframes masbaha-batch-flash {
    0%   { opacity: 1; }
    40%  { opacity: 0.5; }
    70%  { opacity: 1; }
    100% { opacity: 1; }
}

.section--masbaha .masbaha-batch-progress.is-batch-complete .masbaha-dot.is-filled {
    animation: masbaha-batch-flash 0.45s ease forwards;
}

/* Bar mode (target > 50) */
.section--masbaha .masbaha-batch-progress[data-batch-mode="bar"] {
    display: block;
    padding: 2px 0;
}

.section--masbaha .masbaha-batch-bar-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, var(--border));
    overflow: hidden;
}

.section--masbaha .masbaha-batch-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 80%, var(--accent)));
    transition: width 0.15s ease;
    width: 0%;
}

/* ── Daily Goal ───────────────────────────────────────────── */

.section--masbaha .masbaha-daily-goal {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section--masbaha .masbaha-daily-goal__bar {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 10%, var(--border));
    overflow: hidden;
}

.section--masbaha .masbaha-daily-goal__fill {
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.3s ease;
    width: 0%;
}

.section--masbaha .masbaha-daily-goal__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sub);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Controls Row ─────────────────────────────────────────── */

.section--masbaha .masbaha-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--primary-light);
    border: 1px solid color-mix(in srgb, var(--primary) 10%, transparent);
    border-radius: var(--radius-md);
}

.section--masbaha .masbaha-streak {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-sub);
}

.section--masbaha .masbaha-streak i {
    color: var(--accent);
    font-size: 0.9rem;
}

.section--masbaha .masbaha-streak__unit {
    font-weight: 500;
    font-size: 0.78rem;
}

.section--masbaha .masbaha-controls__actions {
    display: flex;
    gap: 6px;
}

.section--masbaha .masbaha-ctrl-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    background: var(--card-bg);
    color: var(--text-sub);
    font-size: 0.95rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.section--masbaha .masbaha-ctrl-btn:active {
    transform: scale(0.92);
    background: var(--primary-light);
    color: var(--primary);
}

/* ── Reduced Motion ───────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .section--masbaha .masbaha-tap-surface,
    .section--masbaha .masbaha-tap-surface:active,
    .section--masbaha .masbaha-daily-goal__fill,
    .section--masbaha .masbaha-batch-bar-fill,
    .section--masbaha .masbaha-dot {
        transition: none;
        animation: none;
    }
}

/* ── Zikr Selection Sheet ─────────────────────────────────── */

.masbaha-zikr-sheet {
    position: fixed;
    inset: 0;
    z-index: 2000;
    visibility: hidden;
    pointer-events: none;
}

.masbaha-zikr-sheet.is-open {
    visibility: visible;
    pointer-events: auto;
}

.masbaha-zikr-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.masbaha-zikr-sheet.is-open .masbaha-zikr-sheet__backdrop {
    opacity: 1;
}

.masbaha-zikr-sheet__panel {
    position: absolute;
    bottom: 0;
    inset-inline: 0;
    background: var(--card-bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 10px 16px 0;
    padding-bottom: calc(var(--bottom-nav-height, 60px) + max(12px, env(safe-area-inset-bottom, 12px)));
    max-height: 88vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1);
}

.masbaha-zikr-sheet.is-open .masbaha-zikr-sheet__panel {
    transform: translateY(0);
}

.masbaha-zikr-sheet__handle {
    width: 36px;
    height: 4px;
    background: color-mix(in srgb, var(--border) 90%, var(--text-sub));
    border-radius: 2px;
    margin: 0 auto 14px;
}

.masbaha-zikr-sheet__title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    margin-bottom: 14px;
}

/* Target row */
.masbaha-zikr-sheet__target-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    border: 1px solid color-mix(in srgb, var(--primary) 10%, transparent);
}

.masbaha-zikr-sheet__target-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-sub);
}

.masbaha-zikr-sheet__target-input {
    width: 72px;
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

/* Zikr list */
.masbaha-zikr-sheet__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

/* Each zikr item in the sheet */
.masbaha-zikr-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid color-mix(in srgb, var(--border) 70%, transparent);
    background: var(--card-bg);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.14s ease, border-color 0.14s ease;
}

.masbaha-zikr-item:active {
    background: var(--primary-light);
}

.masbaha-zikr-item.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.masbaha-zikr-item__text {
    font-family: "Amiri", serif;
    font-size: 1.12rem;
    color: var(--text-main);
    line-height: 1.7;
    flex: 1;
    cursor: pointer;
}

.masbaha-zikr-item__check {
    color: var(--primary);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.masbaha-zikr-item__delete {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: color-mix(in srgb, var(--color-danger, #ef4444) 85%, var(--text-sub));
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.85rem;
    transition: background 0.14s ease;
}

.masbaha-zikr-item__delete:active {
    background: color-mix(in srgb, var(--color-danger, #ef4444) 12%, transparent);
}

/* Custom section divider */
.masbaha-zikr-divider {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-sub);
    padding: 8px 4px 4px;
}

/* Add section */
.masbaha-zikr-sheet__add-section {
    margin-bottom: 14px;
}

.masbaha-zikr-sheet__add-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-sub);
    margin-bottom: 8px;
}

.masbaha-zikr-sheet__add-row {
    display: flex;
    gap: 8px;
}

.masbaha-zikr-sheet__add-btn {
    flex-shrink: 0;
    padding: 10px 14px;
}
