/*!
 * Salawat Counter — front-end card.
 * Scoped to .salawat-counter so theme styles do not leak in or out.
 */

/*
 * Default (light page) palette: the brighter, mint-forward green, so the card
 * lifts off a white page. Dark pages get the deeper surface and the green glow.
 */
.salawat-counter {
    --sq-surface-1: #18654c;
    --sq-surface-2: #0b3628;
    --sq-surface-glow: rgba(199, 255, 226, .12);
    --sq-border: rgba(199, 255, 226, .22);
    --sq-border-strong: rgba(199, 255, 226, .34);
    --sq-ink: #fbf8ee;
    --sq-muted: rgba(214, 255, 235, .78);
    --sq-caption: rgba(246, 241, 228, .68);
    --sq-accent: #d6ffe8;
    --sq-accent-soft: rgba(199, 255, 226, .10);
    --sq-badge-bg: rgba(199, 255, 226, .11);
    --sq-badge-border: rgba(199, 255, 226, .34);
    --sq-badge-ink: #d6ffe8;
    --sq-plate: rgba(199, 255, 226, .12);
    --sq-plate-border: rgba(199, 255, 226, .26);
    --sq-plate-border-hover: rgba(199, 255, 226, .42);
    --sq-plate-top: rgba(199, 255, 226, .14);
    --sq-plate-bottom: rgba(199, 255, 226, .05);
    --sq-plate-ink: #fdfaf1;
    --sq-plate-muted: rgba(246, 241, 228, .78);
    --sq-plate-hint: rgba(214, 255, 235, .86);
    --sq-faraj: #f2dda9;
    --sq-track: rgba(246, 241, 228, .16);
    --sq-bar-from: #a5f2cc;
    --sq-bar-to: #d6ffe8;
    --sq-shadow: 0 28px 54px -34px rgba(7, 34, 26, .50), 0 1px 2px rgba(7, 34, 26, .16);
    --sq-focus: #d6ffe8;
    --sq-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23c7ffe2' stroke-opacity='.12'%3E%3Cpath d='M36 2 70 36 36 70 2 36Z'/%3E%3Cpath d='M36 16 56 36 36 56 16 36Z'/%3E%3C/g%3E%3C/svg%3E");

    container-name: salawat;
    container-type: inline-size;

    width: 100%;
    max-width: none;
    margin: 1.25rem auto;
    /* #salawat-counter links should not hide under a sticky site header. */
    scroll-margin-top: 6rem;
    color-scheme: light;
    text-align: left;
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.salawat-theme-dark,
[data-scheme="dark"] .salawat-counter:not(.salawat-theme-light),
html[data-theme="dark"] .salawat-counter:not(.salawat-theme-light) {
    color-scheme: dark;

    --sq-surface-1: #0d3628;
    --sq-surface-2: #061e17;
    --sq-surface-glow: rgba(199, 255, 226, .08);
    --sq-border: rgba(199, 255, 226, .22);
    --sq-border-strong: rgba(199, 255, 226, .30);
    --sq-ink: #f6f1e4;
    --sq-muted: rgba(199, 255, 226, .68);
    --sq-caption: rgba(246, 241, 228, .60);
    --sq-accent: #c7ffe2;
    --sq-accent-soft: rgba(199, 255, 226, .08);
    --sq-badge-bg: rgba(199, 255, 226, .07);
    --sq-badge-border: rgba(199, 255, 226, .24);
    --sq-badge-ink: #c7ffe2;
    --sq-plate: rgba(199, 255, 226, .08);
    --sq-plate-border: rgba(199, 255, 226, .18);
    --sq-plate-border-hover: rgba(199, 255, 226, .32);
    --sq-plate-top: rgba(199, 255, 226, .09);
    --sq-plate-bottom: rgba(199, 255, 226, .03);
    --sq-plate-ink: #f7f2e6;
    --sq-plate-muted: rgba(246, 241, 228, .70);
    --sq-plate-hint: rgba(199, 255, 226, .76);
    --sq-faraj: #e8cd93;
    --sq-track: rgba(246, 241, 228, .12);
    --sq-bar-from: #8fe6bb;
    --sq-bar-to: #c7ffe2;
    --sq-shadow:
        0 40px 80px -34px rgba(0, 0, 0, .92),
        0 0 72px -24px rgba(76, 197, 147, .42);
    --sq-focus: #c7ffe2;
    --sq-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23c7ffe2' stroke-opacity='.10'%3E%3Cpath d='M36 2 70 36 36 70 2 36Z'/%3E%3Cpath d='M36 16 56 36 36 56 16 36Z'/%3E%3C/g%3E%3C/svg%3E");
}

/* A light card on a light page. */
.salawat-theme-light {
    color-scheme: light;
}

.salawat-counter,
.salawat-counter *,
.salawat-counter *::before,
.salawat-counter *::after {
    box-sizing: border-box;
}

/* ------------------------------------------------------------------
   Theme-proof spacing
   Themes such as Networker (the live almuntazar.ca theme) force
   `p { margin: 5px 0 20px !important }` and `h2 { margin-top: 5px !important }`,
   which pulled every block in the card apart. The card therefore owns its
   rhythm through gaps, and the forced margins are cancelled here.
   ------------------------------------------------------------------ */

.salawat-counter p,
.salawat-counter .sq-title {
    margin: 0 !important;
}

/* ------------------------------------------------------------------
   Card shell
   ------------------------------------------------------------------ */

.salawat-counter .sq-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    grid-template-areas:
        "head"
        "personal"
        "plate"
        "community"
        "foot";
    width: 100%;
    padding: 26px 22px 20px;
    border: 1px solid var(--sq-border);
    border-radius: 26px;
    color: var(--sq-ink);
    background:
        radial-gradient(72% 48% at 100% 0%, var(--sq-surface-glow), rgba(0, 0, 0, 0) 72%),
        linear-gradient(168deg, var(--sq-surface-1) 0%, var(--sq-surface-2) 74%);
    box-shadow: var(--sq-shadow);
    font-size: 16px;
    line-height: 1.5;
    text-align: left;
    transition: background-color .35s ease, border-color .35s ease, box-shadow .35s ease;
}

.salawat-counter .sq-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: var(--sq-pattern);
    background-size: 72px 72px;
    -webkit-mask-image: radial-gradient(115% 85% at 88% -5%, #000 0%, transparent 68%);
            mask-image: radial-gradient(115% 85% at 88% -5%, #000 0%, transparent 68%);
    opacity: .9;
    pointer-events: none;
}

/* ------------------------------------------------------------------
   Header
   ------------------------------------------------------------------ */

.salawat-counter .sq-head {
    grid-area: head;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.salawat-counter .sq-head > div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.salawat-counter .sq-badge {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--sq-badge-ink);
    background: var(--sq-badge-bg);
    border: 1px solid var(--sq-badge-border);
    transition: color .35s ease, background-color .35s ease, border-color .35s ease;
}

.salawat-counter .sq-eyebrow {
    margin: 0 0 3px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .17em;
    text-transform: uppercase;
    color: var(--sq-accent);
    line-height: 1.5;
}

.salawat-counter .sq-title {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 22px;
    font-size: clamp(19px, 4.8cqi, 22px);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--sq-ink);
    text-transform: none;
}

.salawat-counter .sq-honorific {
    font-weight: 400;
    font-size: .78em;
    color: var(--sq-muted);
    white-space: nowrap;
}

/* ------------------------------------------------------------------
   Personal count
   ------------------------------------------------------------------ */

.salawat-counter .sq-personal {
    grid-area: personal;
    display: grid;
    gap: 6px;
    margin: 22px 0 14px;
    text-align: center;
}

.salawat-counter .sq-label {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--sq-muted);
    line-height: 1.5;
}

.salawat-counter .sq-count {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 74px;
    font-size: clamp(58px, 17cqi, 74px);
    font-weight: 500;
    line-height: .95;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
    color: var(--sq-ink);
    transform-origin: 50% 60%;
}

.salawat-counter .sq-count.sq-pop {
    animation: sq-pop .26s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes sq-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.075); }
    100% { transform: scale(1); }
}

/* ------------------------------------------------------------------
   Dhikr plate
   ------------------------------------------------------------------ */

.salawat-counter .sq-dhikr-btn {
    position: relative;
    grid-area: plate;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    margin: 0;
    padding: 20px 18px 17px;
    overflow: hidden;
    border: 1px solid var(--sq-plate-border);
    border-radius: 18px;
    background:
        linear-gradient(180deg, var(--sq-plate-top), var(--sq-plate-bottom)),
        var(--sq-plate);
    color: var(--sq-plate-ink);
    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
    text-transform: none;
    box-shadow: none;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease, border-color .2s ease, background-color .35s ease;
}

.salawat-counter .sq-dhikr-btn:hover {
    border-color: var(--sq-plate-border-hover);
}

.salawat-counter .sq-dhikr-btn:active {
    transform: scale(.994);
}

.salawat-counter .sq-dhikr-btn:focus-visible,
.salawat-counter .sq-share:focus-visible {
    outline: 2px solid var(--sq-focus);
    outline-offset: 3px;
}

.salawat-counter .sq-dhikr {
    display: block;
    font-family: "Amiri", "Noto Naskh Arabic", "Scheherazade New", serif;
    font-size: 23px;
    font-weight: 400;
    line-height: 1.65;
    letter-spacing: normal;
    word-spacing: normal;
    color: var(--sq-plate-ink);
}

.salawat-counter .sq-faraj {
    display: block;
    color: var(--sq-faraj);
}

.salawat-counter .sq-hint {
    display: block;
    margin-top: 9px;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--sq-plate-hint);
}

.salawat-counter .sq-ripple {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: 0;
    border-radius: 50%;
    background: rgba(199, 255, 226, .22);
    transform: translate(-50%, -50%) scale(.3);
    animation: sq-ripple .55s ease-out forwards;
    pointer-events: none;
}

@keyframes sq-ripple {
    to { transform: translate(-50%, -50%) scale(11); opacity: 0; }
}

.salawat-counter .sq-float {
    position: absolute;
    top: 38%;
    left: 50%;
    font-size: 14px;
    font-weight: 600;
    color: var(--sq-faraj);
    transform: translate(-50%, 0);
    animation: sq-float .85s ease-out forwards;
    pointer-events: none;
}

@keyframes sq-float {
    0% { opacity: 0; transform: translate(-50%, 6px) scale(.9); }
    18% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -38px) scale(1); }
}

/* ------------------------------------------------------------------
   Community total and goal
   ------------------------------------------------------------------ */

.salawat-counter .sq-community {
    grid-area: community;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--sq-border);
    transition: border-color .35s ease;
}

.salawat-counter .sq-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.salawat-counter .sq-k {
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--sq-muted);
}

.salawat-counter .sq-total {
    font-size: 23px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.015em;
    color: var(--sq-ink);
    font-variant-numeric: tabular-nums;
}

.salawat-counter .sq-bar {
    height: 8px;
    margin: 12px 0 9px;
    border-radius: 999px;
    background: var(--sq-track);
    overflow: hidden;
    transition: background-color .35s ease;
}

.salawat-counter .sq-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--sq-bar-from), var(--sq-bar-to));
    box-shadow: 0 0 14px rgba(143, 230, 187, .28);
    transition: width .7s cubic-bezier(.22, .61, .36, 1);
}

.salawat-counter .sq-bar.sq-done .sq-fill {
    background: linear-gradient(90deg, #d8b971, #f0d9a4);
    box-shadow: 0 0 16px rgba(232, 205, 147, .40);
}

.salawat-counter .sq-goalrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--sq-caption);
    transition: color .35s ease;
}

.salawat-counter .sq-goal-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    min-width: 0;
}

.salawat-counter .sq-resetline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--sq-caption);
    white-space: nowrap;
    transition: color .35s ease;
}

.salawat-counter .sq-resetline svg {
    flex: none;
    opacity: .75;
}

.salawat-counter .sq-sync {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--sq-caption);
    white-space: nowrap;
    transition: color .2s ease;
}

.salawat-counter .sq-sync::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--sq-bar-to);
    opacity: .60;
    transition: opacity .2s ease, background .2s ease;
}

.salawat-counter .sq-sync.is-saving {
    color: var(--sq-accent);
}

.salawat-counter .sq-sync.is-saving::before {
    background: var(--sq-accent);
    opacity: 1;
}

.salawat-counter .sq-sync.is-offline {
    color: var(--sq-faraj);
}

.salawat-counter .sq-sync.is-offline::before {
    background: var(--sq-faraj);
    opacity: 1;
}

/* ------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------ */

.salawat-counter .sq-foot {
    grid-area: foot;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--sq-border);
    transition: border-color .35s ease;
}

.salawat-counter .sq-note {
    margin: 0;
    padding: 0;
    font-family: inherit;
    max-width: 34ch;
    font-size: 10.5px;
    line-height: 1.55;
    color: var(--sq-caption);
    transition: color .35s ease;
}

.salawat-counter .sq-share {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--sq-border-strong);
    background: transparent;
    color: var(--sq-accent);
    font: inherit;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.5;
    text-transform: none;
    box-shadow: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color .2s ease, border-color .2s ease, color .35s ease;
    -webkit-tap-highlight-color: transparent;
}

.salawat-counter .sq-share:hover {
    background: var(--sq-accent-soft);
    border-color: var(--sq-accent);
}

.salawat-counter .sq-share svg {
    display: block;
}

/* ------------------------------------------------------------------
   Screen-reader live region and toast (created by JS, outside the card)
   ------------------------------------------------------------------ */

.salawat-counter-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.salawat-counter-toast {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translate(-50%, 14px);
    max-width: min(90vw, 360px);
    padding: 11px 18px;
    border-radius: 999px;
    background: #0c2f24;
    border: 1px solid rgba(199, 255, 226, .22);
    color: #f6f1e4;
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 999999;
}

.salawat-counter-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------
   Tablet: two columns inside the card
   ------------------------------------------------------------------ */

@container salawat (min-width: 700px) {
    .salawat-counter .sq-card {
        padding: 24px 30px 20px;
        border-radius: 30px;
        grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr);
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "head plate"
            "personal plate"
            "foot community";
        column-gap: 36px;
    }

    .salawat-counter .sq-personal {
        align-self: center;
        text-align: left;
        margin: 12px 0 16px;
    }

    .salawat-counter .sq-count {
        font-size: 92px;
        font-size: clamp(64px, 12cqi, 92px);
    }

    .salawat-counter .sq-dhikr-btn {
        align-self: center;
        min-height: 132px;
        padding: 18px;
        border-radius: 20px;
    }

    .salawat-counter .sq-dhikr {
        font-size: 21px;
    }

    .salawat-counter .sq-hint {
        margin-top: 7px;
    }

    .salawat-counter .sq-bar {
        margin: 10px 0 7px;
    }

    .salawat-counter .sq-community {
        align-self: end;
        margin: 0;
        padding: 0;
        border: 0;
    }

    .salawat-counter .sq-foot {
        align-self: end;
        margin: 0;
        padding: 0;
        border: 0;
        justify-content: flex-start;
        gap: 14px;
    }

    .salawat-counter .sq-note {
        max-width: 34ch;
        font-size: 11px;
    }
}

/* ------------------------------------------------------------------
   Desktop: one-line title and salawat, tighter rhythm
   ------------------------------------------------------------------ */

@container salawat (min-width: 970px) {
    .salawat-counter .sq-card {
        padding: 18px 26px 15px;
        column-gap: 28px;
        grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr);
    }

    .salawat-counter .sq-personal {
        margin: 10px 0 12px;
    }

    .salawat-counter .sq-count {
        margin-top: 4px;
        font-size: 80px;
    }

    .salawat-counter .sq-title {
        font-size: 20px;
        white-space: nowrap;
    }

    .salawat-counter .sq-title .sq-title-break {
        display: none;
    }

    .salawat-counter .sq-dhikr {
        font-size: 24px;
        line-height: 1.55;
    }

    .salawat-counter .sq-faraj {
        display: inline;
    }

    .salawat-counter .sq-dhikr-btn {
        align-self: center;
        min-height: 112px;
        padding: 16px 18px;
    }

    .salawat-counter .sq-bar {
        margin: 8px 0 6px;
    }

    .salawat-counter .sq-note {
        max-width: 295px;
        font-size: 10.5px;
    }

    .salawat-counter .sq-total {
        font-size: 25px;
    }
}

/* ------------------------------------------------------------------
   Wide: the card fills its column, so the extra width goes into
   horizontal breathing room and the vertical rhythm gets shorter.
   ------------------------------------------------------------------ */

@container salawat (min-width: 1180px) {
    .salawat-counter .sq-card {
        padding: 16px 26px 14px;
        column-gap: 28px;
        border-radius: 26px;
        grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
    }

    .salawat-counter .sq-personal {
        margin: 8px 0 10px;
    }

    .salawat-counter .sq-count {
        margin-top: 2px;
        font-size: 72px;
    }

    .salawat-counter .sq-dhikr-btn {
        padding: 13px 18px;
    }

    .salawat-counter .sq-hint {
        margin-top: 5px;
    }

    .salawat-counter .sq-bar {
        margin: 7px 0 5px;
        height: 7px;
    }

    .salawat-counter .sq-total {
        font-size: 24px;
    }

    .salawat-counter .sq-note {
        max-width: 34ch;
    }

    .salawat-counter .sq-foot {
        gap: 12px;
    }
}

@container salawat (min-width: 1500px) {
    .salawat-counter .sq-card {
        padding: 14px 24px 12px;
        column-gap: 30px;
        grid-template-columns: minmax(0, 0.72fr) minmax(0, 1fr);
    }

    .salawat-counter .sq-personal {
        margin: 4px 0 8px;
    }

    .salawat-counter .sq-count {
        font-size: 66px;
    }

    .salawat-counter .sq-dhikr {
        font-size: 28px;
    }

    .salawat-counter .sq-dhikr-btn {
        padding: 12px 18px;
    }

    .salawat-counter .sq-hint {
        margin-top: 4px;
    }

    .salawat-counter .sq-bar {
        margin: 6px 0 4px;
    }

    .salawat-counter .sq-note {
        max-width: 46ch;
        font-size: 11px;
    }
}

/* ------------------------------------------------------------------
   Small screens
   ------------------------------------------------------------------ */

@container salawat (max-width: 380px) {
    .salawat-counter .sq-card {
        padding: 22px 18px 18px;
        border-radius: 22px;
    }

    .salawat-counter .sq-dhikr {
        font-size: 21px;
    }

    .salawat-counter .sq-title {
        font-size: 17.5px;
    }

    .salawat-counter .sq-note {
        flex: 1 1 0;
        max-width: 100%;
        font-size: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .salawat-counter *,
    .salawat-counter *::before,
    .salawat-counter *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    .salawat-counter-toast {
        transition: none;
    }
}
