/* ═══════════════════════════════════════════════════════════════
   نبض المغرب — التصميم الرئيسي (RTL · Mobile First)
   الألوان مستوحاة من العلم المغربي: الأحمر، الأخضر، الذهبي
   ═══════════════════════════════════════════════════════════════ */

:root {
    --red:       #c1272d;
    --red-dark:  #8f1b20;
    --red-bright:#e0393f;
    --green:     #006233;
    --green-2:   #0a7d44;
    --gold:      #d9a441;
    --sand:      #f6f3ec;
    --ink:       #171a21;
    --ink-2:     #14161e;
    --muted:     #6b7280;
    --card:      #ffffff;
    --line:      #eae5d9;
    --radius:    20px;
    --shadow:    0 10px 34px rgba(23, 26, 33, .08);
    --shadow-sm: 0 4px 14px rgba(23, 26, 33, .06);
    --font:      'Tajawal', 'Segoe UI', Tahoma, system-ui, sans-serif;
    --pattern:   url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.10' stroke-width='1.4'%3E%3Crect x='18' y='18' width='28' height='28'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3C/g%3E%3C/svg%3E");
}

/* ─── أساسيات ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    font-family: var(--font);
    background: var(--sand);
    color: var(--ink);
    line-height: 1.7;
    min-height: 100vh;
}

[hidden] { display: none !important; }

img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container { width: min(100% - 32px, 780px); margin-inline: auto; }

.muted { color: var(--muted); font-size: .92rem; }

/* ─── الترويسة ─── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(20, 22, 30, .92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(217, 164, 65, .35);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-block: 10px;
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.logo { width: 40px; height: 40px; flex-shrink: 0; filter: drop-shadow(0 3px 8px rgba(0,0,0,.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.12rem; font-weight: 800; }
.brand-text small { font-size: .72rem; color: #c9cdd6; }

.header-left { display: flex; align-items: center; gap: 14px; }

.main-nav { display: none; gap: 18px; }
.main-nav a { color: #d8dbe2; font-size: .95rem; font-weight: 500; transition: color .2s; }
.main-nav a:hover { color: var(--gold); }

@media (min-width: 640px) { .main-nav { display: flex; } }

/* شارة "مباشر" */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(10, 125, 68, .18);
    border: 1px solid rgba(46, 204, 113, .45);
    color: #4ade80;
    font-size: .8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
.live-badge.small { font-size: .75rem; padding: 3px 10px; }

.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #22c55e;
    position: relative;
}
.live-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: ping 1.6s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping {
    0%   { transform: scale(.6); opacity: 1; }
    80%, 100% { transform: scale(1.6); opacity: 0; }
}

/* ─── الواجهة (Hero) ─── */
.hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(155deg, var(--red-dark) 0%, var(--red) 42%, #7a2d16 68%, var(--green) 130%);
    color: #fff;
    text-align: center;
    padding: 52px 0 64px;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--pattern);
    opacity: .5;
    pointer-events: none;
}
.hero::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 90px;
    background: linear-gradient(to top, rgba(23,26,33,.22), transparent);
    pointer-events: none;
}

.hero-inner { position: relative; z-index: 1; }

.kicker {
    display: inline-block;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    padding: 5px 16px;
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 18px;
    backdrop-filter: blur(4px);
}

.hero-title {
    font-size: clamp(1.55rem, 5.6vw, 2.6rem);
    font-weight: 800;
    line-height: 1.45;
    text-shadow: 0 3px 18px rgba(0, 0, 0, .3);
    margin-bottom: 12px;
}

.hero-sub {
    font-size: clamp(.95rem, 2.6vw, 1.1rem);
    color: rgba(255, 255, 255, .88);
    max-width: 560px;
    margin: 0 auto 22px;
}

/* ملاحظة "ليس نتيجة رسمية" */
.disclaimer {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: rgba(23, 26, 33, .42);
    border: 1px solid var(--gold);
    border-radius: 14px;
    padding: 10px 18px;
    font-size: .88rem;
    font-weight: 500;
    color: #ffe9bf;
    max-width: 100%;
    text-align: right;
    backdrop-filter: blur(4px);
}
.disclaimer svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--gold); }

/* ─── شريط الإحصائيات ─── */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: -34px;
    position: relative;
    z-index: 2;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 14px 8px;
    text-align: center;
}

.stat-num {
    display: block;
    font-size: clamp(1.05rem, 4vw, 1.5rem);
    font-weight: 800;
    color: var(--red);
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}
.stat-time  { color: var(--green-2); font-size: clamp(.95rem, 3.4vw, 1.25rem); }
.stat-status{ color: var(--ink); font-size: clamp(.85rem, 3.2vw, 1.1rem); }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; }

/* ─── البطاقات ─── */
.layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-block: 26px 40px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 20px;
    animation: fadeUp .55s cubic-bezier(.22, 1, .36, 1) both;
}
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }

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

.card-head { margin-bottom: 18px; }
.card-head h2 { font-size: 1.3rem; font-weight: 800; }
.card-sub { color: var(--muted); font-size: .9rem; margin-top: 3px; }

@media (min-width: 640px) { .card { padding: 30px 32px; } }

/* ─── رسائل التنبيه ─── */
.alert {
    border-radius: 12px;
    padding: 11px 16px;
    font-size: .92rem;
    font-weight: 500;
    margin-bottom: 16px;
}
.alert-success { background: #e8f7ee; color: #146c43; border: 1px solid #b7e4c7; }
.alert-error   { background: #fdecec; color: #b02a37; border: 1px solid #f5c2c7; }

/* ─── خيارات التصويت ─── */
.hp-field {
    position: absolute !important;
    right: -9999px;
    width: 1px; height: 1px;
    overflow: hidden;
    opacity: 0;
}

.options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid var(--line);
    border-radius: 15px;
    padding: 14px 16px;
    cursor: pointer;
    background: #fff;
    transition: border-color .2s, background .2s, transform .18s, box-shadow .2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.option:hover {
    border-color: var(--c);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(23, 26, 33, .07);
}

.option-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-dot {
    width: 20px; height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2.5px solid var(--c);
    position: relative;
    transition: background .2s;
}
.option-dot::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--c);
    transform: scale(0);
    transition: transform .22s cubic-bezier(.34, 1.56, .64, 1);
}

.option-label { flex: 1; font-weight: 700; font-size: 1.02rem; }

.option-check {
    width: 22px; height: 22px;
    color: var(--c);
    opacity: 0;
    transform: scale(.4);
    transition: opacity .2s, transform .25s cubic-bezier(.34, 1.56, .64, 1);
}

.option.selected {
    border-color: var(--c);
    background: color-mix(in srgb, var(--c) 7%, #fff);
    box-shadow: 0 8px 22px rgba(23, 26, 33, .09);
}
.option.selected .option-dot::after { transform: scale(1); }
.option.selected .option-check { opacity: 1; transform: scale(1); }

/* ─── زر التصويت ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 15px;
    font-weight: 800;
    font-size: 1.08rem;
    padding: 15px 26px;
    transition: transform .18s, box-shadow .2s, opacity .2s;
}

.btn-vote {
    width: 100%;
    color: #fff;
    background: linear-gradient(120deg, var(--red-bright), var(--red) 55%, var(--red-dark));
    box-shadow: 0 10px 26px rgba(193, 39, 45, .35);
}
.btn-vote:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(193, 39, 45, .42); }
.btn-vote:not(:disabled):active { transform: translateY(0); }
.btn-vote:disabled { background: #c9cdd4; box-shadow: none; cursor: not-allowed; }

.btn-spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-vote.loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.vote-note {
    text-align: center;
    font-size: .82rem;
    color: var(--muted);
    margin-top: 13px;
}

/* ─── بطاقة الشكر ─── */
.voted-card { text-align: center; }
.voted-icon {
    width: 74px; height: 74px;
    margin: 4px auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a7d44, #006233);
    display: grid;
    place-items: center;
    box-shadow: 0 12px 28px rgba(0, 98, 51, .3);
    animation: popIn .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
.voted-icon svg { width: 40px; height: 40px; color: #fff; }
@keyframes popIn {
    from { transform: scale(.3); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.voted-card h2 { font-size: 1.35rem; font-weight: 800; margin-bottom: 6px; }
.my-vote { color: var(--red); }

/* ─── النتائج ─── */
.results-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.results-list { display: flex; flex-direction: column; gap: 18px; }

.r-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.r-name {
    font-weight: 700;
    font-size: .98rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.crown { display: none; width: 18px; height: 18px; color: var(--gold); }
.is-leader .crown { display: inline-block; }
.is-leader .r-name { color: var(--ink); }

.r-nums { display: inline-flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.r-pct { font-size: 1.12rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.r-votes { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.bar {
    height: 13px;
    background: #efece3;
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--c);
    background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 62%, #fff));
    position: relative;
    transition: width 1.1s cubic-bezier(.22, 1, .36, 1);
    animation: barIn 1.3s cubic-bezier(.22, 1, .36, 1) .25s both;
}
@keyframes barIn { from { width: 0; } }

.bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 25%, rgba(255, 255, 255, .45) 50%, transparent 75%);
    background-size: 220% 100%;
    animation: shimmer 2.6s linear infinite;
}
@keyframes shimmer {
    from { background-position: 220% 0; }
    to   { background-position: -120% 0; }
}

.results-note {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
    font-size: .82rem;
    color: var(--muted);
    text-align: center;
}

/* ─── بطاقة فارغة ─── */
.empty-card { text-align: center; padding-block: 44px; }

/* ─── المشاركة ─── */
.share-card { text-align: center; }
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 13px;
    padding: 11px 18px;
    color: #fff;
    font-weight: 700;
    font-size: .93rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s, box-shadow .2s, opacity .2s;
}
.share-btn svg { width: 20px; height: 20px; }
.share-btn:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(23, 26, 33, .18); }

/* ─── المميزات ─── */
.features {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 640px) { .features { grid-template-columns: repeat(3, 1fr); } }

.feature {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 20px 16px;
    text-align: center;
}
.feature-icon { font-size: 1.7rem; margin-bottom: 8px; }
.feature h3 { font-size: .98rem; font-weight: 800; margin-bottom: 4px; }
.feature p { font-size: .83rem; color: var(--muted); }

/* ─── التذييل ─── */
.site-footer {
    background: var(--ink-2);
    color: #cfd3dc;
    text-align: center;
    padding: 40px 0 26px;
    position: relative;
}
.site-footer::before {
    content: '';
    position: absolute;
    top: 0; right: 0; left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 12px;
}
.footer-brand .logo { width: 34px; height: 34px; }

.footer-disclaimer {
    color: var(--gold);
    font-size: .88rem;
    font-weight: 500;
    max-width: 480px;
    margin: 0 auto 16px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-bottom: 16px;
    font-size: .9rem;
}
.footer-links a { color: #aab0bd; transition: color .2s; }
.footer-links a:hover { color: var(--gold); }

.copy { font-size: .78rem; color: #7b8191; }

/* ─── التنبيهات العائمة (Toast) ─── */
.toast {
    position: fixed;
    bottom: 22px;
    right: 50%;
    transform: translate(50%, 180%);
    z-index: 100;
    background: var(--ink-2);
    color: #fff;
    border-radius: 14px;
    padding: 13px 24px;
    font-size: .95rem;
    font-weight: 700;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .3);
    transition: transform .4s cubic-bezier(.22, 1, .36, 1);
    max-width: calc(100vw - 40px);
    text-align: center;
    pointer-events: none;
}
.toast.show { transform: translate(50%, 0); }
.toast.success { border-bottom: 3px solid #22c55e; }
.toast.error   { border-bottom: 3px solid var(--red-bright); }

/* ─── صفحة خطأ قاعدة البيانات ─── */
.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.error-box {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px 30px;
    max-width: 480px;
}
.error-box h1 { font-size: 1.25rem; margin-bottom: 12px; color: var(--red); }
.error-box ol { padding-right: 22px; margin-top: 8px; }
.error-box code {
    background: var(--sand);
    border-radius: 6px;
    padding: 1px 7px;
    font-size: .88em;
}

/* ─── إمكانية الوصول: تقليل الحركة ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   v2 — بطاقات الأحزاب + روابط التواصل + تيليغرام
   ═══════════════════════════════════════════════════════════════ */

/* زر الاختيار (pill) */
.option-select {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    border: 2px solid var(--c);
    border-radius: 999px;
    padding: 6px 13px;
    color: var(--c);
    font-weight: 700;
    font-size: .82rem;
    transition: background .2s, color .2s;
}
.option-select .option-dot { width: 14px; height: 14px; border-width: 2px; }
.option-select .option-dot::after { inset: 2px; }
.option-select .option-check { width: 15px; height: 15px; }

.option.selected .option-select { background: var(--c); color: #fff; }
.option.selected .option-select .option-dot { display: none; }
.option.selected .option-select .option-check { color: #fff; }

/* بطاقة نتيجة حزب */
.r-main { display: flex; align-items: flex-start; gap: 12px; }

.r-info { flex: 1; min-width: 0; }

/* روابط التواصل أسفل بطاقة النتيجة */
.r-social {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}
.r-soc {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    transition: transform .18s, box-shadow .2s;
}
.r-soc svg { width: 15px; height: 15px; }
.r-soc:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(23, 26, 33, .18); }

/* الهواتف الصغيرة */
@media (max-width: 480px) {
    .option { padding: 12px 13px; gap: 10px; }
    .option-label { font-size: .95rem; }
    .option-select { padding: 6px 11px; font-size: .78rem; }
}

/* ═══════════════════════════════════════════════════════════════
   v3 — بطاقات تصويت عمودية احترافية
        + تيك توك/إنستغرام/واتساب
   ═══════════════════════════════════════════════════════════════ */

/* شبكة بطاقات: عمودان (تتحول لعمود واحد في الشاشات الضيقة جدًا) */
.options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (max-width: 360px) {
    .options { grid-template-columns: 1fr; }
}

/* البطاقة: الاسم بالأعلى، زر الاختيار بالأسفل */
.option {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 11px;
    padding: 18px 14px 16px;
}

.option-label {
    font-size: .95rem;
    line-height: 1.55;
    min-height: 2.9em; /* توازن ارتفاع البطاقات */
    display: flex;
    align-items: center;
}

/* زر الاختيار بعرض البطاقة */
.option-select {
    width: 100%;
    justify-content: center;
    padding: 8px 14px;
    margin-top: auto; /* يلتصق بأسفل البطاقة */
}

/* ═══════════════════════════════════════════════════════════════
   v4 — أزرار المشاركة بالألوان الرسمية للمنصات + تنسيق متوازن
   ═══════════════════════════════════════════════════════════════ */

.share-buttons { gap: 10px; }

.share-btn {
    flex: 1 1 150px;
    max-width: 230px;
    min-height: 47px;
    justify-content: center;
    color: #fff;
    cursor: pointer;
}
.share-btn svg { flex-shrink: 0; }
.share-btn:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(23, 26, 33, .22); }

/* الألوان الرسمية للمنصات */
.share-btn.facebook  { background: #1877F2; }
.share-btn.tiktok    { background: #010101; }
.share-btn.instagram { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.share-btn.whatsapp  { background: #25D366; }
.share-btn.x         { background: #000000; }
.share-btn.telegram  { background: #229ED9; }
.share-btn.copy      { background: #334155; color: #fff; border: 0; }
.share-btn.copy:hover { background: #1e293b; }

/* أيقونات تواصل الأحزاب بالألوان الرسمية */
.r-soc.fb  { background: #1877F2; }
.r-soc.tt  { background: #010101; }
.r-soc.ig  { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.r-soc.wa  { background: #25D366; }
.r-soc.x   { background: #000000; }
.r-soc.yt  { background: #ff0000; }
.r-soc.web { background: #475569; }

@media (max-width: 480px) {
    .share-btn { flex: 1 1 45%; max-width: none; }
}
