html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f8ff;
    /* A fallback background color in case the gradient doesn't load. */
    background-image: linear-gradient(to bottom, #f0f8ff, #ffffff);
    /* Creates a vertical gradient from light blue to white. */
    background-attachment: fixed;
    /* The background image stays in place when the user scrolls. */
    font-display: swap;
    /* Improves font loading performance */
    margin: 0;
    /* Remove default browser margins to avoid bottom gap */
}

[lang="ar"] {
    font-family: 'Traditional Arabic', 'Amiri', 'Mirza', 'Noto Sans Arabic', 'Tahoma', serif;
    /* Sets the font for Arabic text with multiple fallbacks. */
    color: #000000;
    /* Sets the text color to black. */
    font-display: swap;
    /* Improves font loading performance for Arabic fonts */
}

[lang="ur"] {
    font-family: 'Mirza', 'Noto Nastaliq Urdu', 'Noto Sans Arabic', 'Tahoma', serif;
    font-display: swap;
}

.rtl-text {
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
    overflow-wrap: anywhere;
}

/* Traditional Arabic font for brand Arabic title (header + drawer) */
.brand-ar {
    font-family: 'Traditional Arabic', 'Amiri', 'Noto Naskh Arabic', 'Noto Sans Arabic', 'Sakkal Majalla', 'Tahoma', serif;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.15;
}

.writing-arabic-font {
    font-family: 'Traditional Arabic', 'Amiri', 'Mirza', 'Noto Sans Arabic', 'Tahoma', serif;
    letter-spacing: 0;
    line-height: 1.35;
    font-weight: 700;
    font-synthesis: weight;
    font-size: 1.08em;
}

/* Font loading optimization */
@font-face {
    font-family: 'Inter-fallback';
    src: local('Arial'), local('Helvetica Neue'), local('sans-serif');
    font-display: swap;
}

/* Show fallback fonts immediately while custom fonts load */
.font-loading body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.font-loading [lang="ar"] {
    font-family: 'Traditional Arabic', 'Amiri', 'Noto Sans Arabic', 'Tahoma', serif;
}

/* Custom Font Classes */
.font-aptos-display {
    font-family: 'Aptos Display', sans-serif;
}

/* --- Animation Keyframes --- */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .7;
    }
}

/* Defines the 'gentle-shake' animation. The element moves up and down slightly. */
@keyframes gentle-shake {

    0%,
    100% {
        transform: translateY(0);
    }

    /* Start and end position */
    25% {
        transform: translateY(-5px);
    }

    /* Moves 5px up */
    75% {
        transform: translateY(5px);
    }

    /* Moves 5px down */
}

/* Defines the 'nudge-right' animation. The element moves slightly to the right and back. */
@keyframes nudge-right {

    0%,
    100% {
        transform: translateX(0);
    }

    /* Start and end position */
    50% {
        transform: translateX(3px);
    }

    /* Moves 3px to the right */
}

/* Defines the 'shake-horizontal' animation. The element moves slightly left and right. */
@keyframes shake-horizontal {

    0%,
    100% {
        transform: translateX(0);
    }

    /* Start and end position */
    25% {
        transform: translateX(-2px);
    }

    /* Moves 2px left */
    75% {
        transform: translateX(2px);
    }

    /* Moves 2px right */
}

/* Small bounce for action icons */
@keyframes bounce-mini {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-3px) scale(1.05);
    }
}

/* Idle (continuous) cycles with pauses to catch the eye */
@keyframes writing-wiggle-idle {

    0%,
    70%,
    100% {
        transform: translateX(0) rotate(0deg);
    }

    74% {
        transform: translateX(-2px) rotate(-6deg);
    }

    78% {
        transform: translateX(2px) rotate(6deg);
    }

    82% {
        transform: translateX(-1px) rotate(-3deg);
    }

    86% {
        transform: translateX(1px) rotate(3deg);
    }

    90% {
        transform: translateX(0) rotate(0deg);
    }
}

@keyframes writing-nudge-idle {

    0%,
    72%,
    100% {
        transform: translateX(0);
    }

    78% {
        transform: translateX(4px);
    }

    84% {
        transform: translateX(0);
    }
}

@keyframes writing-bounce-idle {

    0%,
    72%,
    100% {
        transform: translateY(0) scale(1);
    }

    78% {
        transform: translateY(-4px) scale(1.06);
    }

    84% {
        transform: translateY(0) scale(1);
    }
}

/* Defines the 'pan-left' animation for the image gallery. */
@keyframes pan-left {
    0% {
        transform: translateX(0%);
    }

    /* Starts at the beginning */
    100% {
        transform: translateX(-75%);
    }

    /* Moves left by the width of 3 images (since there are 4 total). */
}

/* Defines the 'blink-alternative' animation for important notices. */
@keyframes blink-alternative {
    50% {
        color: #ff4400;
        /* Changes color to orange at the midpoint. */
        opacity: 0.8;
        /* Becomes slightly transparent. */
    }
}

/* Keyframe animation for the blinking event day */
@keyframes event-blink {
    50% {
        opacity: 0.7;
    }
}

.event-day-blinking {
    animation: event-blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Ensure footer Arabic brand uses Traditional Arabic */
.footer-ar-brand {
    font-family: 'Traditional Arabic', 'Amiri', 'Mirza', serif !important;
    color: #ffffff !important;
}

/* Modern Button Animation */
.btn-modern-animate {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-modern-animate::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    animation: shine 3s infinite;
    pointer-events: none;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    100% {
        left: 200%;
    }
}

.btn-modern-pulse {
    animation: subtle-pulse 2s infinite;
}

@keyframes subtle-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(22, 163, 74, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
    }
}

/* --- Animation Application Classes --- */
/* This class applies the 'pulse' animation to an element. */
.btn-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* This class applies the 'pulse' animation to a title. */
.title-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* This class applies the 'gentle-shake' animation. */
.card-shake {
    animation: gentle-shake 2.5s ease-in-out infinite;
}

/* This class applies the 'shake-horizontal' animation. */
.icon-shake {
    display: inline-block;
    animation: shake-horizontal 1.2s ease-in-out infinite;
}

/* This class applies the 'blink-alternative' animation. */
.blinking-dawrah {
    animation: blink-alternative 1.5s infinite alternate;
}

/* Hide scrollbar but keep scroll (used for Notice Board list) */
.hide-scrollbar {
    -ms-overflow-style: none;
}

@supports (scrollbar-width: none) {
    .hide-scrollbar {
        scrollbar-width: none;
    }
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* About section: collapsed text (Tailwind build doesn't include small max-h utilities) */
.about-collapsed {
    max-height: 7rem;
    overflow: hidden;
}

.about-expanded {
    max-height: none;
    overflow: visible;
}

/* Notice ticker (vertical loop) */
@keyframes notice-ticker {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(var(--notice-ticker-end, -50%));
    }
}

/* NEW notice badge (red + blinking) */
@keyframes notice-badge-blink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0.15;
    }
}

.blink-badge {
    animation: notice-badge-blink 1s step-end infinite;
}

@media (prefers-reduced-motion: reduce) {
    .blink-badge {
        animation: none !important;
    }
}

.notice-ticker-track {
    display: flex;
    flex-direction: column;
    width: 100%;
    will-change: transform;
    animation: notice-ticker var(--notice-ticker-duration, 40s) linear infinite;
}

.notice-ticker:hover .notice-ticker-track,
.notice-ticker.is-paused .notice-ticker-track {
    animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
    .notice-ticker-track {
        animation: none !important;
        transform: none !important;
    }
}

/* --- Writings card icon animations (hover/tap) --- */
.writing-icon {
    display: inline-block;
    will-change: transform;
}

/* Continuous animations */
.writing-share-btn .writing-icon {
    animation: writing-wiggle-idle 3.2s ease-in-out infinite;
}

.writing-read-btn .writing-icon {
    animation: writing-nudge-idle 3.6s ease-in-out infinite;
}

.writing-download-btn .writing-icon {
    animation: writing-bounce-idle 3.3s ease-in-out infinite;
}

#writing-modal-share .writing-icon {
    animation: writing-wiggle-idle 3.2s ease-in-out infinite;
}

#writing-modal-download .writing-icon {
    animation: writing-bounce-idle 3.3s ease-in-out infinite;
}

/* Stronger interaction animations */
.writing-share-btn:hover .writing-icon,
.writing-share-btn:active .writing-icon {
    animation: shake-horizontal 0.65s ease-in-out;
}

.writing-read-btn:hover .writing-icon,
.writing-read-btn:active .writing-icon {
    animation: nudge-right 0.65s ease-in-out;
}

.writing-download-btn:hover .writing-icon,
.writing-download-btn:active .writing-icon {
    animation: bounce-mini 0.75s ease-in-out;
}

#writing-modal-share:hover .writing-icon,
#writing-modal-share:active .writing-icon {
    animation: shake-horizontal 0.65s ease-in-out;
}

#writing-modal-download:hover .writing-icon,
#writing-modal-download:active .writing-icon {
    animation: bounce-mini 0.75s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {

    .writing-share-btn .writing-icon,
    .writing-read-btn .writing-icon,
    .writing-download-btn .writing-icon,
    #writing-modal-share .writing-icon,
    #writing-modal-download .writing-icon,
    .writing-share-btn:hover .writing-icon,
    .writing-share-btn:active .writing-icon,
    .writing-read-btn:hover .writing-icon,
    .writing-read-btn:active .writing-icon,
    .writing-download-btn:hover .writing-icon,
    .writing-download-btn:active .writing-icon,
    #writing-modal-share:hover .writing-icon,
    #writing-modal-share:active .writing-icon,
    #writing-modal-download:hover .writing-icon,
    #writing-modal-download:active .writing-icon {
        animation: none !important;
    }
}

/* --- Share sheet (stable CSS; JS creates the markup) --- */
#writing-share-sheet [data-sheet-card] {
    width: min(92vw, 440px);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(2, 6, 23, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.35);
    overflow: hidden;
    max-height: 85vh;
}

#writing-share-sheet [data-sheet-header] {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

#writing-share-sheet [data-sheet-title] {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: #1e3a8a;
    line-height: 1.2;
}

#writing-share-sheet [data-sheet-subtitle] {
    margin: 6px 0 0;
    font-size: 14px;
    color: #64748b;
}

#writing-share-sheet [data-action="close"] {
    height: 42px;
    width: 42px;
    border-radius: 999px;
    border: 0;
    background: #f1f5f9;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#writing-share-sheet [data-sheet-body] {
    padding: 16px 18px 18px;
    overflow: auto;
}

#writing-share-sheet .share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    font-weight: 800;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#writing-share-sheet .share-btn--full {
    width: 100%;
    margin-top: 12px;
}

#writing-share-sheet button[data-action="copy"] {
    background: #1e3a8a;
    color: #ffffff;
}

#writing-share-sheet button[data-action="native"] {
    background: #059669;
    color: #ffffff;
}

#writing-share-sheet button[data-action="pdf"] {
    background: #dc2626;
    color: #ffffff;
}

#writing-share-sheet a[data-share="email"] {
    background: #f1f5f9;
    color: #0f172a;
}

#writing-share-sheet [data-sheet-note] {
    margin: 14px 2px 0;
    font-size: 12px;
    color: #64748b;
}

/* --- Writing reader modal (stable CSS) --- */
#writing-modal>div {
    border-radius: 28px;
    overflow: hidden;
}

@media (min-width: 640px) {
    #writing-modal>div {
        border-radius: 28px;
    }
}

#writing-modal-content {
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
}

#writing-modal-content img {
    max-width: 100%;
    height: auto;
}

#writing-modal-content hr {
    border: 0;
    border-top: 1px solid rgba(226, 232, 240, .9);
    margin: 18px 0;
}

#writing-modal-close {
    height: 56px;
    width: 56px;
    min-height: 56px;
    min-width: 56px;
    aspect-ratio: 1 / 1;
    border-radius: 999px;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
    -webkit-tap-highlight-color: transparent;
}

#writing-modal-close:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
}

#writing-modal-close:active {
    transform: translateY(0px) scale(0.97);
}

#writing-modal-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.18), 0 18px 38px rgba(15, 23, 42, 0.16);
}

#writing-modal-close i {
    font-size: 22px;
    color: #0f172a;
    transition: transform 160ms ease;
}

.writing-reader-font {
    font-family: 'Inter', 'Aptos Display', 'Georgia', 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.9;
    color: #1f2937;
}

.writing-reader-font:lang(ar),
.writing-reader-font [lang="ar"] {
    font-family: 'Traditional Arabic', 'Amiri', 'Mirza', 'Noto Sans Arabic', 'Tahoma', serif;
    line-height: 2;
}

#writing-modal-close:hover i {
    transform: rotate(90deg);
}


/* --- Keyframe for Final Call Blink --- */
@keyframes final-call {
    50% {
        color: #dc2626;
        /* A strong red color */
        opacity: 0.7;
        transform: scale(1.02);
        /* Makes the text pop slightly */
    }
}

/* --- Class to apply the new animation --- */
.final-call-blink {
    animation: final-call 1s infinite alternate;
    /* Faster animation */
    display: inline-block;
    /* Needed for transform to work properly */
}

/* Add this to your <style> block */

/* --- Form Loader Styles --- */
#form-loader.visible {
    display: flex;
    /* Use flex instead of toggling hidden to allow transitions */
    opacity: 1;
    pointer-events: auto;
}

/* Keyframes for the flying animation */
@keyframes fly {
    0% {
        transform: translateX(-100px) translateY(40px) rotate(-15deg);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        transform: translateX(100px) translateY(-60px) rotate(15deg);
        opacity: 0;
    }
}

/* Apply animation to the SVG inside the loader when visible */
#form-loader.visible svg {
    animation: fly 1.8s ease-in-out infinite;
}

/* Optional: Add a subtle pulse to the text */
@keyframes pulse-text {
    50% {
        opacity: 0.6;
    }
}

#form-loader.visible #loader-text {
    animation: pulse-text 1.8s ease-in-out infinite;
}

/* --- Custom Color Classes --- */
/* These classes provide consistent branding colors throughout the site. */
.text-logo-blue {
    color: #1e3a8a;
}

.bg-logo-blue {
    background-color: #1e3a8a;
}

.text-logo-green {
    color: #16a34a;
}

.bg-logo-green {
    background-color: #16a34a;
}

.border-logo-green {
    border-color: #16a34a;
}

/* --- Modern background for the Writings section --- */
.writings-modern-bg {
    background-color: #f8fafc !important; /* Premium ultra-clean light slate background */
    background-image: none !important;
    position: relative;
}

.writings-modern-bg::before,
.writings-modern-bg::after {
    display: none !important;
}

/* --- Strict layout definitions for writings card components --- */
.writing-card__header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin-bottom: 1rem !important;
    gap: 0.75rem !important;
}

.writing-card__category-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.375rem !important;
    border-radius: 9999px !important;
    flex-shrink: 0 !important;
}

.writing-share-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
    max-width: 2rem !important;
    max-height: 2rem !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.writings-submit-btn {
    padding: 1.05rem 2.25rem !important; /* Increased height and comfort */
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    border-radius: 9999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.writings-submit-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px -4px rgba(22, 163, 74, 0.2) !important;
}

.writings-submit-btn:active {
    transform: translateY(0) !important;
}



/* --- Modern Responsive Writings Grid & Glassmorphic Cards --- */
.writings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.75rem;
    width: 100%;
}

@media (min-width: 768px) {
    .writings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .writings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.writing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 1.5rem;
    padding: 1.75rem;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 8px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    height: 100%;
}

.writing-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    border-color: rgba(30, 58, 138, 0.2);
}

/* Bi-color gradient top border highlight appearing on hover */
.writing-card__accent-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #1e3a8a, #16a34a);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}

.writing-card:hover .writing-card__accent-bar {
    transform: scaleX(1);
}

.writing-card__title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #1e3a8a;
    line-height: 1.45;
    height: 52px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1.25rem;
    transition: color 0.3s ease;
}

.writing-card:hover .writing-card__title {
    color: #1c3d99;
}

/* Traditional Arabic Typography rendering */
.writing-arabic-font {
    font-family: 'Traditional Arabic', 'Amiri', 'Mirza', 'Noto Naskh Arabic', serif !important;
    font-size: 1.45rem !important;
    line-height: 1.4 !important;
    direction: rtl;
    text-align: right;
    height: 56px !important;
    font-weight: 700 !important;
}

.writing-card__details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.writing-card__detail-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.writing-card__detail-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    flex-shrink: 0;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.writing-card:hover .writing-card__detail-icon {
    transform: scale(1.08);
}

.writing-card__detail-icon--writer {
    background-color: rgba(30, 58, 138, 0.08);
    color: #1e3a8a;
}

.writing-card__detail-icon--reviewer {
    background-color: rgba(22, 163, 74, 0.08);
    color: #16a34a;
}

.writing-card__detail-icon--date {
    background-color: rgba(245, 158, 11, 0.08);
    color: #d97706;
}

.writing-card__detail-content {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.writing-card__detail-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #8b96a5;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.writing-card__detail-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d3748;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* Support Arabic metadata text */
.writing-card__detail-value.writing-arabic-font {
    font-size: 1.15rem !important;
    height: auto !important;
    line-height: 1.2 !important;
    margin-top: 2px;
}

.writing-card__actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    border-top: 1px solid rgba(229, 231, 235, 0.5);
    padding-top: 1.25rem;
}

.writing-card__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 9999px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    text-align: center;
    border: none;
}

.writing-card__btn--read {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
}

.writing-card__btn--read:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 58, 138, 0.25);
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}

.writing-card__btn--pdf {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: white;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.15);
}

.writing-card__btn--pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.25);
    background: linear-gradient(135deg, #15803d, #4ade80);
}

.writing-card__btn:active {
    transform: translateY(0);
}

.bg-gradient-footer {
    background-color: #16a34a;
    /* Fallback color. */
    background-image: linear-gradient(to bottom right, #16a34a, #319a28);
    /* Green gradient for the footer. */
}

/* --- Footer brand letter-fall animation --- */
@keyframes letter-fall {
    0% {
        opacity: 0;
        transform: translateY(-30px) rotate(-6deg);
    }

    60% {
        opacity: 1;
        transform: translateY(4px) rotate(2deg);
    }

    100% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
}

.letters-assemble {
    display: inline-block;
    white-space: nowrap;
}

.letters-assemble .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(-30px);
    will-change: transform, opacity;
}

.letters-assemble .char.animate {
    animation: letter-fall 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Accessibility: respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .letters-assemble .char {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }
}

/* Footer Exams CTA animation removed as per request */

/* --- Hamburger Icon Animation (Corrected) --- */
.hamburger-top,
.hamburger-middle,
.hamburger-bottom {
    transition: all 0.3s ease-in-out;
    /* This ensures the lines rotate from their center */
    transform-origin: center;
}

.open .hamburger-top {
    /* Moves the line down to the middle, then rotates */
    transform: translateY(5px) rotate(45deg);
}

.open .hamburger-middle {
    /* Fades the middle line out */
    opacity: 0;
}

.open .hamburger-bottom {
    /* Moves the line up to the middle, then rotates */
    transform: translateY(-5px) rotate(-45deg);
}

/* --- Active Navigation Link Style --- */
.nav-active {
    color: #16a34a;
    /* This is your logo-green color */
    font-weight: 700;
    /* This makes the text bold */
}

/* --- New Mobile Sidebar Styles --- */
/* Increase icon size in the mobile menu */
.menu-link i {
    font-size: 1.3rem;
    /* This is like Tailwind's text-2xl. You can change it to 1.75rem if you want it even bigger. */
}

/* Overlay transition parity with Teacher */
#mobile-menu-overlay {
    transition: opacity 200ms ease-out;
    will-change: opacity;
}

/* Teacher drawer: fixed width, transform/opacity transitions */
#mobile-menu {
    width: 16rem;
    overflow: hidden;
    transform: translateZ(0);
    will-change: transform, opacity;
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease-out;
    opacity: 0;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: saturate(160%) blur(8px);
    backdrop-filter: saturate(160%) blur(8px);
    border-left: 1px solid #e5e7eb;
    border-top-left-radius: 1rem;
    border-bottom-left-radius: 1rem;
    box-shadow: -6px 0 24px rgba(2, 6, 23, 0.15);
}

/* Small tablets / large phones: widen drawer a bit (560â€“640px) */
@media (min-width: 560px) {
    #mobile-menu {
        width: 19rem;
    }
}

/* Tablet/desktop drawer: wider so brand fits comfortably */
@media (min-width: 640px) {
    #mobile-menu {
        width: 20rem;
    }
}

@media (min-width: 768px) {
    #mobile-menu {
        width: 22rem;
    }
}

@media (min-width: 1024px) {
    #mobile-menu {
        width: 24rem;
    }
}

/* When the menu is brought on-canvas (translate-x removed), make it visible and interactive */
#mobile-menu:not(.translate-x-full) {
    opacity: 1;
    pointer-events: auto;
}

/* Teacher-style menu list */
.menu-modern {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.5rem 0.5rem;
}

/* Base style for all menu items */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #4b5563;
    /* text-gray-600 */
    width: 100%;
    overflow: hidden;
    padding: 0.625rem 0.75rem;
    border-radius: 0.75rem;
    transition: background-color 0.2s ease, transform 0.08s ease;
}

.menu-item:hover {
    background: linear-gradient(90deg, #f3f4f6, #eef2ff);
}

/* Label text parity with Teacher: always visible */
.menu-item-text {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    opacity: 1;
    padding-left: 0.25rem;
}

/* Style for the active link (Teacher parity) */
.menu-item.active,
.menu-item[aria-current="true"] {
    background: linear-gradient(90deg, #e0f2fe, #ecfeff);
    box-shadow: inset 0 0 0 1px #bae6fd;
    color: #1e3a8a;
    font-weight: 700;
}

.menu-item .icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #334155;
    box-shadow: inset 0 0 0 1px #e5e7eb;
}

.menu-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.25);
}

/* Style for the group titles */
.menu-group-title {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    /* text-gray-500 */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Styles for the action buttons at the bottom */
.action-button-portal,
.action-button-donate {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-align: center;
    transition: background-color 0.2s;
}

.action-button-portal {
    background-color: #334155;
    /* This is a dark slate color */
    color: white;
}

.action-button-portal:hover {
    background-color: #1e293b;
    /* A slightly darker slate for hover */
}

.action-button-donate {
    background-color: #22c55e;
    /* bg-green-500 */
    color: white;
}

.action-button-donate:hover {
    background-color: #16a34a;
    /* bg-green-600 */
}

/* Drawer header + close button (Teacher parity) */
#mobile-menu .drawer-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #eef2f7;
    min-height: 72px;
    position: relative;
}

#mobile-menu .drawer-brand {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    padding-right: 3.25rem;
}

#mobile-menu .drawer-brand .title {
    font-weight: 700;
    color: #1e3a8a;
    font-size: clamp(0.86rem, 2.5vw, 0.95rem);
    line-height: 1.08;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

#mobile-menu .drawer-brand .subtitle {
    color: #16a34a;
    font-weight: 700;
    font-size: clamp(0.78rem, 2.3vw, 0.9rem);
    line-height: 1.08;
}

/* Drawer: Arabic brand line should align left under English title */
#mobile-menu .drawer-brand .subtitle[lang="ar"] {
    text-align: left;
}

#mobile-menu .drawer-header #mobile-menu-close-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    /* Add a visible box around the close button */
    border: 1px solid #e5e7eb;
    /* gray-200 */
    background: linear-gradient(180deg, #ffffff, #f3f4f6);
    box-shadow: 0 2px 8px rgba(2, 6, 23, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
    transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 160ms ease, background-color 160ms ease;
    will-change: transform;
}

#mobile-menu .drawer-header #mobile-menu-close-btn i {
    transition: transform 180ms ease;
    font-size: 1.15rem;
}

#mobile-menu .drawer-header #mobile-menu-close-btn:hover {
    transform: translateY(-50%) scale(1.05);
    background: linear-gradient(180deg, #ffffff, #eef2ff);
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.10), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

#mobile-menu .drawer-header #mobile-menu-close-btn:active {
    transform: translateY(-50%) scale(0.98);
    background: linear-gradient(180deg, #f8fafc, #eef2ff);
}

#mobile-menu .drawer-header #mobile-menu-close-btn:hover i {
    transform: rotate(90deg);
}

#mobile-menu .drawer-header #mobile-menu-close-btn:active i {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
    #mobile-menu .drawer-header #mobile-menu-close-btn {
        transition: none;
    }

    #mobile-menu .drawer-header #mobile-menu-close-btn i {
        transition: none;
    }

    #mobile-menu .drawer-header #mobile-menu-close-btn:hover,
    #mobile-menu .drawer-header #mobile-menu-close-btn:active {
        transform: translateY(-50%);
    }

    #mobile-menu .drawer-header #mobile-menu-close-btn:hover i,
    #mobile-menu .drawer-header #mobile-menu-close-btn:active i {
        transform: none;
    }
}

/* Limit focus ring to keyboard navigation only */
#mobile-menu .drawer-header #mobile-menu-close-btn:focus {
    outline: none;
    box-shadow: none;
}

#mobile-menu .drawer-header #mobile-menu-close-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.25);
    border-radius: 10px;
}

/* Scroll lock parity with Teacher */
.scroll-locked {
    overflow: hidden !important;
    padding-right: var(--scrollbar-comp, 0px);
}

.scroll-locked-root {
    overflow: hidden !important;
}

/* When menu is open (scroll-locked), hide the back-to-top FAB so it doesn't appear inside the drawer */
.scroll-locked #back-to-top-btn {
    display: none !important;
}

/* --- New Carousel Gallery Styles --- */
.carousel-slide {
    min-width: 100%;
    height: 100%;
    position: relative;
    /* Render only when near viewport to reduce paint/JS cost */
    content-visibility: auto;
}

.image-wrap {
    position: relative;
    width: 100%;
    height: 100%;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensures images fill the space without distortion */
}

.carousel-loader,
.carousel-error {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transition: opacity .2s ease;
}

.carousel-loader {
    background: rgba(0, 0, 0, 0.06);
}

.carousel-loader.hidden,
.carousel-error.hidden {
    display: none;
}

.carousel-error {
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    text-align: center;
    padding: 0.75rem;
}

.carousel-error button.retry-btn {
    margin-top: .5rem;
    background: #ffffff;
    color: #111827;
    border-radius: 9999px;
    padding: .35rem .75rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Help the browser plan for transforms for smoother sliding */
#carousel-track {
    will-change: transform;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1.5rem;
    line-height: 1;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

.carousel-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background-color 0.2s;
}

.carousel-dot.active {
    background-color: white;
}

/* --- Global Behavior --- */
/* This rule enables smooth scrolling when a user clicks on an anchor link (e.g., <a href="#about">). */
html {
    scroll-behavior: smooth;

}

/* --- Scroll Target Offset --- */
/* This adds space above a section when scrolling to it, preventing the sticky header from hiding the title. */
.scroll-target {
    scroll-margin-top: 80px;
    /* Adjust this value to match your header's height */
}

/* --- Keyframes for the new event button animation --- */
@keyframes wiggle {

    0%,
    7% {
        transform: rotateZ(0);
    }

    15% {
        transform: rotateZ(-10deg);
    }

    20% {
        transform: rotateZ(8deg);
    }

    25% {
        transform: rotateZ(-6deg);
    }

    30% {
        transform: rotateZ(4deg);
    }

    35% {
        transform: rotateZ(-2deg);
    }

    40%,
    100% {
        transform: rotateZ(0);
    }
}

/* --- Class to apply the animation --- */
.event-link-button {
    display: inline-block;
    background-color: #1e3a8a;
    /* bg-logo-blue */
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    animation: wiggle 2.5s infinite;
    box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.1);
}

.event-link-button:hover {
    transform: scale(1.05);
    background-color: #16a34a;
    /* bg-logo-green */
    animation-play-state: paused;
    /* Pause animation on hover */
}

.event-link-closed {
    display: inline-block;
    background-color: #6b7280;
    /* bg-gray-500 */
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    cursor: not-allowed;
}

/* --- Keyframes for Loader Logo Animation --- */
@keyframes pulse-zoom {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

/* --- Class for Loader Logo --- */
.loader-logo {
    animation: pulse-zoom 2.5s ease-in-out infinite;
}

/* --- Keyframes for a smooth back-and-forth animation --- */
@keyframes smooth-back-and-forth {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(5px);
    }
}

/* --- Class to apply the smooth animation --- */
.smooth-shake {
    animation: smooth-back-and-forth 2s ease-in-out infinite;
}

/* Floating Acknowledge a Volunteer button (top-right) */
@keyframes pulse-ring-index {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    }

    70% {
        box-shadow: 0 0 0 14px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.ack-fab {
    position: fixed;
    top: 8rem;
    right: 1rem;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(22, 163, 74, 0.25), 0 6px 6px rgba(22, 163, 74, 0.2);
    animation: pulse-ring-index 2s infinite;
    transition: transform .15s ease, box-shadow .2s ease;
}

.ack-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(22, 163, 74, 0.3), 0 10px 10px rgba(22, 163, 74, 0.22);
}

.ack-fab:active {
    transform: translateY(0);
}

.ack-fab.hidden {
    display: none !important;
}

/* Utility: hide FAB/carpet while menu is open without affecting their normal visibility logic */
.menu-open-mask {
    display: none !important;
}

/* Rolling "carpet" banner that expands left from the FAB */
.ack-carpet {
    position: fixed;
    top: 9.5rem;
    /* align with FAB */
    right: calc(1rem + 3.75rem);
    /* a bit right of FAB width */
    height: 3rem;
    max-width: 80vw;
    padding: 0 .9rem 0 1rem;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #ffffff;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    box-shadow: 0 10px 20px rgba(22, 163, 74, 0.25), 0 6px 6px rgba(22, 163, 74, 0.2);
    z-index: 59;
    /* just under the FAB */
    transform-origin: right center;
    transform: scaleX(0);
    opacity: 0;
    transition: transform 400ms ease, opacity 300ms ease;
    white-space: nowrap;
    overflow: hidden;
    /* ensure text stays within max width */
    pointer-events: none;
    /* banner is informational; don't block taps */
}

.ack-carpet.open {
    transform: scaleX(1);
    opacity: 1;
}

.ack-carpet.hidden {
    display: none !important;
}

.ack-carpet span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .ack-fab {
        top: 7.5rem;
        right: 0.75rem;
        width: 2.75rem;
        height: 2.75rem;
    }

    .ack-carpet {
        top: 7.5rem;
        right: calc(0.75rem + 3.1rem);
        /* align with smaller FAB */
        min-height: 2.5rem;
        height: auto;
        /* allow wrapping height */
        max-width: 85vw;
        padding: 0 0.6rem 0 0.75rem;
        white-space: nowrap;
        /* keep single line, but truncate */
        font-size: 0.85rem;
    }

    .ack-carpet i {
        display: none;
    }

    /* save space on very small screens */
}

/* === Calendar: Modern Visual Upgrade (CSS-only, no functional changes) === */
/* Ambient backdrop for the calendar section */
#calendar {
    position: relative;
}

#calendar::before {
    content: "";
    position: absolute;
    inset: -20px 0 0 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(1200px 400px at 10% -10%, rgba(30, 58, 138, 0.09), transparent 60%),
        radial-gradient(900px 320px at 90% 0%, rgba(22, 163, 74, 0.08), transparent 60%);
}

/* Card glass/gradient treatment */
#calendar .rounded-lg.shadow-lg {
    position: relative;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.98));
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.10), 0 2px 6px rgba(2, 6, 23, 0.04);
    overflow: hidden;
}

#calendar .rounded-lg.shadow-lg::before {
    content: "";
    position: absolute;
    inset: -30% -30% auto -30%;
    height: 220px;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(600px 200px at 20% 0%, rgba(30, 58, 138, 0.08), transparent 60%),
        radial-gradient(500px 160px at 80% 0%, rgba(22, 163, 74, 0.08), transparent 60%);
    filter: blur(6px);
}

/* Elevate the top controls */
#calendar #prev-month-btn,
#calendar #next-month-btn {
    position: relative;
    z-index: 1;
    background: linear-gradient(180deg, #ffffff, #f3f4f6);
    border: 1px solid #e5e7eb;
    color: #334155;
    box-shadow: 0 6px 16px rgba(2, 6, 23, 0.10), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease;
}

#calendar #prev-month-btn:hover,
#calendar #next-month-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(2, 6, 23, 0.14);
    background: linear-gradient(180deg, #ffffff, #eef2ff);
}

#calendar #prev-month-btn:active,
#calendar #next-month-btn:active {
    transform: translateY(0);
}

#calendar #prev-month-btn:focus-visible,
#calendar #next-month-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.25);
}

/* Today action: minimal, no fancy gradient */
/* Hide Today button completely (visual only) */
#calendar #today-btn {
    display: none !important;
}

/* Weekday header pills */
#calendar .grid.grid-cols-7.text-center.text-gray-500.font-semibold>div {
    background: linear-gradient(180deg, #f8fafc, #eef2ff);
    border: 1px solid #e5e7eb;
    color: #475569;
    border-radius: 12px;
    padding: .5rem 0;
}

/* Calendar grid days base */
#calendar #calendar-days-grid {
    position: relative;
    z-index: 1;
}

#calendar #calendar-days-grid>div {
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border: 1px solid rgba(15, 23, 42, 0.06);
    transition: transform .1s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
}

/* Scale cell heights and text responsively */
#calendar #calendar-days-grid>div {
    min-height: clamp(40px, 8.5vw, 60px);
    font-size: clamp(0.8rem, 2.8vw, 1rem);
}

#calendar #calendar-days-grid>div:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(2, 6, 23, 0.10);
}

/* Filler empty cells (no day number) */
#calendar #calendar-days-grid>div:empty {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

/* Current day chip (original class preserved) */
#calendar #calendar-days-grid>div.bg-logo-blue {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6) !important;
    box-shadow: 0 8px 22px rgba(30, 58, 138, 0.30), 0 2px 6px rgba(30, 58, 138, 0.25);
    border-color: transparent;
    color: #fff;
    font-weight: 800;
}

/* Event day chip (future) */
#calendar #calendar-days-grid>div.bg-logo-green {
    background: linear-gradient(135deg, #22c55e, #16a34a) !important;
    color: #ffffff;
    font-weight: 800;
    border-color: transparent;
}

/* Past event day chip: make clearly visible */
#calendar #calendar-days-grid>div.bg-gray-400 {
    background: linear-gradient(135deg, #64748b, #475569) !important;
    /* slate 500->600 */
    color: #ffffff !important;
    border-color: transparent;
    opacity: 1 !important;
}

/* Animated aura for event days */
@keyframes calendar-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.0);
        transform: translateY(0);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.15);
        transform: translateY(-1px);
    }
}

#calendar .event-day-blinking {
    animation: event-blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite, calendar-glow 2.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    #calendar .event-day-blinking {
        animation: none;
    }
}

/* Legend chips refresh */
#calendar .flex.flex-wrap.justify-center.items-center.gap-x-4.gap-y-2>.flex.items-center .w-4.h-4.rounded-full.bg-logo-blue {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
}

#calendar .flex.flex-wrap.justify-center.items-center.gap-x-4.gap-y-2>.flex.items-center .w-4.h-4.rounded-full.bg-logo-green {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

#calendar .flex.flex-wrap.justify-center.items-center.gap-x-4.gap-y-2>.flex.items-center .w-4.h-4.rounded-full.bg-gray-400 {
    background: linear-gradient(135deg, #64748b, #475569);
}

/* Modal polish */
#event-modal .max-w-sm.w-full {
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.25), 0 2px 8px rgba(2, 6, 23, 0.10);
}

#event-modal #event-modal-title {
    background: linear-gradient(135deg, #1e3a8a, #16a34a);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#event-modal #close-modal-btn {
    background: linear-gradient(180deg, #f3f4f6, #e5e7eb);
    border: 1px solid #d1d5db;
    color: #111827;
    font-weight: 700;
}

#event-modal #close-modal-btn:hover {
    background: linear-gradient(180deg, #eef2ff, #eafaf0);
}

#event-modal #close-modal-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.28);
}

/* --- Responsive tweaks for compact/mobile screens --- */
/* Allow the month/year header to size naturally on small screens (override w-36) */
#calendar #month-year-header {
    width: auto !important;
}

@media (max-width: 640px) {

    /* Tighter gaps for weekday header and days grid */
    #calendar .grid.grid-cols-7.text-center.text-gray-500.font-semibold {
        gap: 0.35rem;
    }

    #calendar #calendar-days-grid {
        gap: 0.35rem;
    }

    /* Smaller weekday pills */
    #calendar .grid.grid-cols-7.text-center.text-gray-500.font-semibold>div {
        padding: 0.35rem 0;
        font-size: 0.8rem;
        border-radius: 10px;
    }

    /* Slightly smaller day tiles */
    #calendar #calendar-days-grid>div {
        border-radius: 12px;
    }
}

@media (max-width: 400px) {

    /* Ultra-compact layout */
    #calendar .grid.grid-cols-7.text-center.text-gray-500.font-semibold {
        gap: 0.25rem;
    }

    #calendar #calendar-days-grid {
        gap: 0.25rem;
    }

    #calendar .grid.grid-cols-7.text-center.text-gray-500.font-semibold>div {
        font-size: 0.72rem;
        padding: 0.3rem 0;
    }

    #calendar #calendar-days-grid>div {
        font-size: 0.78rem;
        border-radius: 10px;
    }
}

@media (max-width: 350px) {

    /* Horizontal scroll fallback so cells remain tappable (keep 7 columns) */
    #calendar #calendar-days-grid {
        min-width: 520px;
        overflow-x: auto;
        overflow-y: visible;
        padding-bottom: 2px;
    }

    #calendar .grid.grid-cols-7.text-center.text-gray-500.font-semibold {
        min-width: 520px;
        overflow: hidden;
    }
}

/* === Premium Back-to-Top FAB (ring removed, show % inside) === */
#back-to-top-btn.back-to-top-fab {
    position: fixed;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 9999px;
    background-image: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 12px 26px rgba(22, 163, 74, 0.25), 0 6px 10px rgba(2, 6, 23, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

#back-to-top-btn.back-to-top-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(22, 163, 74, 0.30), 0 10px 14px rgba(2, 6, 23, 0.16);
}

#back-to-top-percent {
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

#back-to-top-btn.back-to-top-fab:active {
    transform: translateY(0);
}

#back-to-top-btn .tooltip {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.25);
}

#back-to-top-btn:hover .tooltip,
#back-to-top-btn:focus-visible .tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

@media (max-width: 480px) {
    #back-to-top-btn .tooltip {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #back-to-top-btn.back-to-top-fab:hover {
        transform: none;
    }
}

/* --- Footer Quick Links: alignment for inline icons --- */
.footer-quick-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Newsletter country code select: bring arrow slightly inward */
/* Newsletter country code select: custom inward arrow */
#newsletter-form #country-code {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%231e3a8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 4l3 4 3-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 1.4rem center;
    /* move arrow inside */
    background-size: 12px 12px;
    padding-right: 3.4rem;
    /* ensure text doesn't overlap arrow */
}

@media (max-width: 640px) {
    #newsletter-form #country-code {
        background-position: right 1.2rem center;
        padding-right: 3rem;
    }
}

/* Hide default arrow on IE (legacy) */
#newsletter-form #country-code::-ms-expand {
    display: none;
}

/* --- Buy a Book (Donation Sponsorship) --- */
#buy-book-wrapper {
    position: relative;
}

.sponsor-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .75rem;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #e0f2fe, #ecfeff);
    color: #1e3a8a;
    border-radius: 9999px;
    box-shadow: inset 0 0 0 1px #bae6fd;
}

.book-suggestion-item {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: #f1f5f9;
    color: #475569;
    padding: .5rem .75rem;
    margin: .4rem;
    border-radius: .75rem;
    font-size: .75rem;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: background .25s ease, transform .25s ease;
}

.book-suggestion-item:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.book-suggestion-item i {
    color: #16a34a;
}

#book-suggestions-panel {
    display: none;
}

#book-suggestions-panel.open {
    display: block;
    animation: fadeIn .35s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#sponsor-book-status[role="status"] {
    min-height: 1.25rem;
}

#progress-bar {
    width: 1%;
}

@media (prefers-reduced-motion: reduce) {
    .book-suggestion-item:hover {
        transform: none;
    }

    #book-suggestions-panel.open {
        animation: none;
    }
}