/* ============================================
   دورة ثقافة العمل التطوعي - ملف CSS الرئيسي
   ============================================ */

:root {
    --primary-color: #f59e0b;
    --primary-dark: #d97706;
    --secondary-color: #1e293b;
    --secondary-light: #334155;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --text-dark: #1f2937;
    --text-light: #9ca3af;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   إعادة تعيين عام
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-dark);
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    -webkit-text-size-adjust: 100%;
    /* Long codes and unbroken strings must never widen the layout on small screens. */
    overflow-wrap: break-word;
    min-height: 100%;
    min-height: 100dvh;
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

img,
video,
svg {
    max-width: 100%;
}

/* ============================================
   الحاويات والتخطيط
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-sm {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   الرؤوس والنصوص
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.5rem;
    line-height: 1.4;
}

p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   الأزرار
   ============================================ */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-light);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   النماذج والمدخلات
   ============================================ */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--bg-white);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

/* ============================================
   البطاقات والصناديق
   ============================================ */
.card {
    background: var(--bg-white);
    /* .page-* wrappers set color:white for the dark backdrop; reset it inside cards. */
    color: var(--text-dark);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.card-body {
    margin-bottom: 1.5rem;
}

.card-footer {
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

/* ============================================
   شريط التقدم
   ============================================ */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    transition: width 0.5s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* ============================================
   الخيارات المتعددة (الأسئلة)
   ============================================ */
.option-group {
    display: grid;
    gap: 12px;
    margin: 1.5rem 0;
}

.option {
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-white);
    display: flex;
    align-items: center;
    gap: 12px;
}

.option:hover {
    border-color: var(--primary-color);
    background: rgba(245, 158, 11, 0.05);
}

.option input[type="radio"] {
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.option.selected {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-color: var(--success-color);
}

.option.correct {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-color: var(--success-color);
}

.option.incorrect {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-color: var(--danger-color);
}

/* ============================================
   الفيديو
   ============================================ */
/*
 * The box takes the video's real aspect ratio, which JS reads from the file itself
 * on loadedmetadata. Without that the ratio is guessed and the player shows bars.
 * Width is capped from the viewport height so a wide screen cannot push the player
 * taller than the screen.
 */
.video-container {
    position: relative !important;
    width: 100% !important;
    /* Keeps the frame from growing taller than the screen on wide displays. */
    max-width: calc(68vh * var(--astbyan-video-ratio, 1.7778)) !important;
    aspect-ratio: var(--astbyan-video-aspect, 16 / 9);
    /* The video's intrinsic 1920px must not set a min width inside flex layouts. */
    min-width: 0;
    overflow: hidden !important;
    border-radius: 12px;
    background: #000;
    margin: 0 auto 2rem;
    isolation: isolate;
}

/* Absolute keeps the player out of intrinsic width math; the container owns the ratio. */
.video-container video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain;
    object-position: center center;
    background: #000;
    display: block !important;
    border: 0;
    margin: 0;
    padding: 0;
}

/* Padding-ratio fallback for engines without aspect-ratio support. */
@supports not (aspect-ratio: 16 / 9) {
    .video-container {
        height: 0 !important;
        padding: 0 0 56.25% 0 !important;
    }
}

.intro-greeting {
    margin: 0 0 1.25rem;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.btn.is-locked,
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

.astbyan-wp-wrap .video-container {
    z-index: 1;
}

/*
 * Escape the theme's content column so the player page still fills the screen.
 * No ancestor may clip here: overflow:hidden on the wrap or the card would cut
 * the widened page back down to the theme column width.
 * --astbyan-vw is set from JS to the viewport width without the scrollbar;
 * 100vw includes it and would cause a stray horizontal scrollbar.
 */
.astbyan-wp-wrap .astbyan-wp-header,
.astbyan-wp-wrap .page {
    width: var(--astbyan-vw, 100vw);
    max-width: var(--astbyan-vw, 100vw);
    margin-inline: calc(50% - (var(--astbyan-vw, 100vw) / 2));
}

/* ============================================
   الصفحات والأقسام
   ============================================ */
/* Every step of the course runs edge to edge and fills the screen. */
.page {
    min-height: 100vh;
    /* dvh tracks the collapsing mobile address bar; vh above is the fallback. */
    min-height: 100dvh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
}

.page > .container,
.page > .container-sm {
    max-width: none;
    width: 100%;
    min-width: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.page .card {
    --astbyan-card-pad: clamp(16px, 5vw, 64px);
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 0;
    border-inline: 0;
    box-shadow: none;
    padding: clamp(16px, 3vw, 40px) var(--astbyan-card-pad);
}

.page-intro {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
}

.page-quiz {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
}

.page-success {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
}

/* ============================================
   الهيدر والفوتر
   ============================================ */
header {
    background: white;
    box-shadow: var(--shadow-md);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    text-align: center;
}

header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
    text-align: center;
}

/* ============================================
   الشهادة
   ============================================ */
.certificate {
    background: white;
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    max-width: 600px;
    margin: 2rem auto;
    box-shadow: var(--shadow-lg);
}

.certificate-header {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 700;
}

.certificate-body {
    margin: 2rem 0;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.mishakah-certificate {
    border-color: #C5A059;
    background: #ffffff;
}

.mishakah-certificate .certificate-brand {
    font-size: 0.95rem;
    color: #6b6b6b;
    margin-bottom: 0.75rem;
}

.mishakah-certificate .certificate-header {
    color: #1f1f1f;
}

.mishakah-certificate .certificate-name {
    color: #C5A059;
    margin: 1rem 0;
}

.mishakah-certificate .certificate-course {
    color: #C5A059;
    font-weight: 700;
    font-size: 1.15rem;
    margin: 0.5rem 0 0;
}

.certificate-code {
    background: var(--bg-light);
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    font-weight: 600;
    margin: 1rem 0;
    color: var(--primary-color);
}

/* ============================================
   الرسائل والتنبيهات
   ============================================ */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--info-color);
    color: var(--info-color);
}

/* ============================================
   الشبكات والتخطيطات
   ============================================ */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

.flex {
    display: flex;
    gap: 20px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

/* Action rows: side by side on desktop, full-width stacked buttons on phones. */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.btn-row-center {
    justify-content: center;
}

/* Score summary on the result page. */
.score-box {
    background: rgba(245, 158, 11, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 2rem;
}

.score-box h3 {
    color: var(--primary-color);
    margin: 0 0 10px;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

.score-note {
    margin: 10px 0 0;
    color: var(--primary-color);
}


/* ============================================
   الرموز والعناصر الخاصة
   ============================================ */
.icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin: 0 8px;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--success-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    margin: 0 auto 1rem;
}

/* ============================================
   الحركات والانتقالات
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

/* ============================================
   الحالات الخاصة
   ============================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* ============================================
   الاستجابة
   ============================================ */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .container,
    .container-sm {
        padding: 0 15px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }

    .flex {
        flex-direction: column;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.95rem;
        /* Arabic labels are long: let them wrap instead of pushing the row wider. */
        white-space: normal;
    }

    .card {
        padding: 16px;
    }

    /* Hover lift is meaningless on touch and causes sticky :hover states. */
    .card:hover {
        transform: none;
    }

    .certificate {
        padding: 24px 18px;
        margin: 1.5rem auto;
    }

    .certificate-header {
        font-size: 1.5rem;
    }

    .video-container {
        margin: 0 auto 1.5rem;
        border-radius: 8px;
        /* Phones are short in landscape, so allow more of the height there. */
        max-width: calc(78vh * var(--astbyan-video-ratio, 1.7778)) !important;
    }

    /* Cancel the card padding so the player spans the whole device width. */
    .page .video-container {
        width: calc(100% + (var(--astbyan-card-pad) * 2)) !important;
        margin-inline: calc(var(--astbyan-card-pad) * -1);
        border-radius: 0;
    }

    .video-container video {
        object-fit: contain !important;
        object-position: center center !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .page {
        padding: 0;
        min-height: auto;
    }

    .page > .container,
    .page > .container-sm {
        padding: 0;
    }

    .page .card {
        --astbyan-card-pad: 12px;
        padding: 14px var(--astbyan-card-pad);
        border-radius: 0;
    }

    header {
        padding: 14px 0;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .container,
    .container-sm {
        padding: 0 12px;
    }

    .card {
        padding: 14px;
        border-radius: 10px;
    }

    .card-header {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    /* 16px keeps iOS from zooming in when a field gets focus. */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    select,
    textarea {
        padding: 12px;
        font-size: 16px;
    }

    .option {
        padding: 14px 12px;
        gap: 10px;
        align-items: flex-start;
    }

    .option input[type="radio"] {
        margin-top: 4px;
        flex: 0 0 auto;
    }

    .btn-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-row .btn {
        width: 100%;
    }

    .certificate {
        padding: 18px 14px;
        border-width: 2px;
    }

    .certificate-header {
        font-size: 1.3rem;
    }

    .certificate-body {
        margin: 1.25rem 0;
        font-size: 1rem;
    }

    .certificate-code {
        font-size: 0.9rem;
        padding: 10px;
    }

    .score-box {
        padding: 16px;
    }

    .score-value {
        font-size: 2rem;
    }

    .success-icon {
        font-size: 2.2rem;
        width: 64px;
        height: 64px;
    }
}
