/* ==========================================================================
   Parments — base.css
   The single shared stylesheet loaded by templates/base.html on every page.
   1) Base layout: reset, floating navigation, messages, footer, mobile rules
      (moved verbatim from the former inline <style> in base.html)
   2) Design system: tokens, global safety nets, touch targets, ui-* components
   Page-specific styles stay in each template's {% block extra_css %}.
   ========================================================================== */

/* ---------- 1) Base layout ---------- */
* {
    font-family: 'Vazirmatn', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #8B1538;
    --secondary: #0A1628;
    --accent: #A91D3A;
    --gold: #D4AF37;
    --blur-desktop: 22px;
    --blur-mobile: 12px;
}

body {
    background: #000;
    overflow-x: hidden;
    color: white;
}

/* ✅ Fix for numbers, IDs, and codes display */
.user-btn span,
.user-name,
.message-content bdi,
[dir="ltr"] {
    direction: ltr !important;
    unicode-bidi: embed;
    font-family: 'Courier New', Consolas, monospace;
}

/* GPU Acceleration */
.nav-floating,
.nav-links,
.user-dropdown,
.message-alert {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* NAVIGATION */
.nav-floating {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateZ(0);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    padding: 10px 30px;
    max-width: 95%;
    width: auto;
    border-radius: 100px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
    background: linear-gradient(135deg,
        rgba(10, 22, 40, 0.65) 0%,
        rgba(15, 30, 50, 0.55) 100%);
    backdrop-filter: blur(var(--blur-desktop));
    -webkit-backdrop-filter: blur(var(--blur-desktop));
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);
}

@media (min-width: 993px) {
    .nav-floating::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 50%;
        background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.08) 0%,
            transparent 100%);
        border-radius: 100px 100px 0 0;
        pointer-events: none;
        opacity: 0.5;
    }

    .nav-floating:hover {
        background: linear-gradient(135deg,
            rgba(10, 22, 40, 0.75) 0%,
            rgba(15, 30, 50, 0.65) 100%);
        box-shadow: 0 12px 48px 0 rgba(0, 0, 0, 0.45);
        transform: translateX(-50%) translateY(-2px) translateZ(0);
    }
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.nav-logo {
    display: flex;
    align-items: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    z-index: 1002;
    transition: transform 0.2s ease;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
}

.nav-logo:hover {
    transform: scale(1.05);
}

/* ✅ Resize logo image to prevent CLS */
.nav-logo img {
    height: 45px;
    width: 45px;
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.2));
}

.nav-logo::after {
    display: none !important;
}

.nav-links {
    display: flex;
    gap: 25px;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: nowrap;
}

.nav-links > li > a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s ease;
    position: relative;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.nav-links > li > a:hover {
    color: var(--gold);
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.auth-btn {
    padding: 10px 24px;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.auth-btn::after {
    display: none !important;
}

.auth-btn.login {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(212, 175, 55, 0.5);
    color: var(--gold);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.15);
}

@media (min-width: 993px) {
    .auth-btn.login:hover {
        background: rgba(212, 175, 55, 0.2);
        border-color: var(--gold);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
    }
}

.auth-btn.register {
    background: linear-gradient(135deg,
        rgba(139, 21, 56, 0.95),
        rgba(169, 29, 58, 0.95));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 20px rgba(139, 21, 56, 0.4);
}

@media (min-width: 993px) {
    .auth-btn.register:hover {
        background: linear-gradient(135deg,
            rgba(169, 29, 58, 1),
            rgba(139, 21, 56, 1));
        transform: translateY(-2px);
        box-shadow: 0 8px 30px rgba(139, 21, 56, 0.6);
    }
}

.user-menu {
    position: relative;
}

.user-btn {
    background: linear-gradient(135deg,
        rgba(139, 21, 56, 0.95),
        rgba(169, 29, 58, 0.95));
    padding: 0 24px;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 48px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(139, 21, 56, 0.4);
}

/* ✅ Fix username display */
.user-btn .user-name {
    direction: rtl !important;
    unicode-bidi: embed;
    font-family: 'Vazirmatn', sans-serif !important;
}

@media (min-width: 993px) {
    .user-btn:hover {
        background: linear-gradient(135deg,
            rgba(169, 29, 58, 1),
            rgba(139, 21, 56, 1));
        transform: translateY(-2px);
        box-shadow: 0 8px 30px rgba(139, 21, 56, 0.6);
    }
}

.user-btn i {
    font-size: 1.1rem;
}

.user-dropdown {
    position: absolute;
    top: 120%;
    left: 0;
    background: linear-gradient(135deg,
        rgba(10, 22, 40, 0.82) 0%,
        rgba(15, 30, 50, 0.78) 100%);
    backdrop-filter: blur(var(--blur-desktop));
    -webkit-backdrop-filter: blur(var(--blur-desktop));
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    min-width: 220px;
    padding: 10px 0;
    display: none;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    z-index: 1001;
    overflow: hidden;
}

@media (min-width: 993px) {
    .user-dropdown::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 30%;
        background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.08) 0%,
            transparent 100%);
        pointer-events: none;
    }
}

.user-dropdown.show {
    display: block;
    animation: dropdownSlide 0.2s ease;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-dropdown a {
    display: block;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.user-dropdown a::after {
    display: none;
}

.user-dropdown a:hover {
    background: rgba(255, 255, 255, 0.15);
    padding-right: 25px;
    color: var(--gold);
}

.user-dropdown a[href*="admin-panel"] {
    background: linear-gradient(90deg,
        rgba(139, 21, 56, 0.4),
        rgba(212, 175, 55, 0.3));
    font-weight: 700;
}

.user-dropdown a[href*="admin-panel"]:hover {
    background: linear-gradient(90deg,
        rgba(139, 21, 56, 0.6),
        rgba(212, 175, 55, 0.4));
    padding-right: 30px;
}

.user-dropdown a[href*="admin-panel"] i {
    color: var(--gold) !important;
}

.user-dropdown .divider {
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent);
    margin: 10px 0;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 1002;
    padding: 8px;
    background: transparent;
    border: none;
}

.hamburger span {
    width: 28px;
    height: 3px;
    background: white;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: block;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(9px, 9px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}

/* MESSAGES */
.messages-container {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    width: 90%;
    max-width: 500px;
    pointer-events: none;
}

.message-alert {
    background: linear-gradient(135deg,
        rgba(10, 22, 40, 0.82) 0%,
        rgba(10, 22, 40, 0.78) 100%);
    backdrop-filter: blur(var(--blur-mobile));
    -webkit-backdrop-filter: blur(var(--blur-mobile));
    border-radius: 16px;
    padding: 18px 25px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    border: 2px solid;
    opacity: 0;
    transform: translateY(-20px) translateZ(0);
    animation: slideDown 0.3s ease forwards, fadeOut 0.3s ease 3.7s forwards;
    pointer-events: auto;
}

@keyframes slideDown {
    to {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px) translateZ(0);
    }
}

.message-alert i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.5;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.message-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1) rotate(90deg);
}

.message-alert.success {
    border-color: rgba(40, 167, 69, 0.6);
    background: linear-gradient(135deg,
        rgba(40, 167, 69, 0.2),
        rgba(40, 167, 69, 0.1));
}

.message-alert.success i {
    color: #51cf66;
}

.message-alert.error,
.message-alert.danger {
    border-color: rgba(220, 53, 69, 0.6);
    background: linear-gradient(135deg,
        rgba(220, 53, 69, 0.2),
        rgba(220, 53, 69, 0.1));
}

.message-alert.error i,
.message-alert.danger i {
    color: #ff6b6b;
}

.message-alert.warning {
    border-color: rgba(255, 193, 7, 0.6);
    background: linear-gradient(135deg,
        rgba(255, 193, 7, 0.2),
        rgba(255, 193, 7, 0.1));
}

.message-alert.warning i {
    color: #ffd43b;
}

.message-alert.info {
    border-color: rgba(23, 162, 184, 0.6);
    background: linear-gradient(135deg,
        rgba(23, 162, 184, 0.2),
        rgba(23, 162, 184, 0.1));
}

.message-alert.info i {
    color: #3bc9db;
}

section {
    padding: 100px 0;
    position: relative;
}

.section-title {
    text-align: center;
    margin-bottom: 70px;
}

.section-title h2 {
    font-size: 3.5rem;
    font-weight: 900;
    color: white;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.section-title h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 50%;
    transform: translateX(50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--gold));
    border-radius: 8px;
}

.section-title p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    max-width: 700px;
    margin: 20px auto 0;
}

/* Footer */
.footer-unique {
    background: var(--secondary);
    padding: 80px 0 30px;
}

.footer-top {
    margin-bottom: 50px;
}

.footer-logo-unique {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.footer-logo-unique img {
    height: 120px;
    width: auto;
    object-fit: contain;
}

.footer-content {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.8;
    margin-bottom: 30px;
}

.social-unique {
    display: flex;
    gap: 15px;
}

.social-unique a {
    width: 45px;
    height: 45px;
    background: rgba(10, 22, 40, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
}

.social-unique a:hover {
    background: linear-gradient(135deg,
        rgba(10, 22, 40, 0.8),
        rgba(212, 175, 55, 0.6));
    transform: translateY(-5px);
}

.footer-title {
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 25px;
}

.footer-links {
    list-style: none;
    padding: 0;
}

.footer-links li {
    margin-bottom: 12px;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
}

.footer-links a:hover {
    color: var(--gold);
    padding-right: 10px;
}

.newsletter-form {
    display: flex;
    gap: 10px;
}

.newsletter-form input {
    flex: 1;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
}

.newsletter-form input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.newsletter-form button {
    padding: 15px 30px;
    background: linear-gradient(135deg,
        rgba(10, 22, 40, 0.9),
        rgba(212, 175, 55, 0.7));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.newsletter-form button:hover {
    transform: scale(1.05);
}

.footer-bottom {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255, 255, 255, 0.6);
    gap: 20px;
}

.footer-bottom-links {
    display: flex;
    gap: 30px;
}

.footer-bottom-links a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: all 0.2s ease;
}

.footer-bottom-links a:hover {
    color: var(--gold);
}

/* MOBILE OPTIMIZATIONS */
@media (max-width: 1200px) {
    .nav-links {
        gap: 18px;
    }

    .nav-links > li > a {
        font-size: 0.88rem;
    }

    .auth-btn {
        padding: 8px 18px;
        font-size: 0.85rem;
    }

    .section-title h2 {
        font-size: 3rem;
    }
}

@media (max-width: 992px) {
    :root {
        --blur-desktop: var(--blur-mobile);
    }

    .nav-floating {
        border-radius: 24px;
        padding: 12px 20px;
        top: 15px;
        width: 95%;
        background: linear-gradient(135deg,
            rgba(10, 22, 40, 0.7) 0%,
            rgba(15, 30, 50, 0.6) 100%);
        backdrop-filter: blur(var(--blur-mobile));
        -webkit-backdrop-filter: blur(var(--blur-mobile));
    }

    .nav-logo {
        font-size: 1.3rem;
    }

    .nav-logo img {
        height: 40px;
        width: 40px;
    }

    .hamburger {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 100px;
        left: 50%;
        transform: translateX(-50%) translateY(-20px) translateZ(0);
        background: linear-gradient(135deg,
            rgba(10, 22, 40, 0.75) 0%,
            rgba(20, 35, 55, 0.7) 100%);
        backdrop-filter: blur(var(--blur-mobile));
        -webkit-backdrop-filter: blur(var(--blur-mobile));
        flex-direction: column;
        width: 90%;
        max-width: 450px;
        padding: 25px 20px;
        border-radius: 20px;
        gap: 0;
        opacity: 0;
        visibility: hidden;
        transition: all 0.25s ease;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
        border: 1.5px solid rgba(255, 255, 255, 0.18);
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }

    .nav-links.active {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0) translateZ(0);
    }

    .nav-links > li {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .nav-links > li:last-child {
        border-bottom: none;
    }

    .nav-links > li > a {
        display: block;
        padding: 15px 10px;
        font-size: 1rem;
    }

    .auth-buttons {
        width: 100%;
        flex-direction: column;
        gap: 12px;
        padding-top: 15px;
        margin-top: 15px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .auth-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 24px;
        font-size: 1rem;
    }

    .user-menu {
        width: 100%;
        padding-top: 15px;
        margin-top: 15px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .user-btn {
        width: 100%;
        justify-content: center;
        height: 50px;
    }

    .user-dropdown {
        position: static;
        margin-top: 15px;
        width: 100%;
        border-radius: 12px;
        background: linear-gradient(135deg,
            rgba(10, 22, 40, 0.82) 0%,
            rgba(20, 35, 55, 0.78) 100%);
        backdrop-filter: blur(var(--blur-mobile));
        -webkit-backdrop-filter: blur(var(--blur-mobile));
    }

    .section-title h2 {
        font-size: 2.5rem;
    }

    .section-title p {
        font-size: 1.1rem;
    }

    .messages-container {
        width: 95%;
        top: 100px;
    }

    .footer-logo-unique img {
        height: 100px;
    }
}

@media (max-width: 768px) {
    .nav-floating {
        top: 10px;
        padding: 10px 15px;
    }

    .nav-logo {
        font-size: 1.2rem;
    }

    .nav-logo img {
        height: 35px;
        width: 35px;
    }

    .section-title h2 {
        font-size: 2rem;
    }

    .section-title p {
        font-size: 1rem;
    }

    section {
        padding: 70px 0;
    }

    .footer-unique {
        padding: 60px 0 30px;
    }

    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-form button {
        width: 100%;
    }

    .footer-logo-unique img {
        height: 90px;
    }
}

@media (max-width: 576px) {
    .nav-floating {
        min-height: 60px;
    }

    .nav-logo {
        font-size: 1.1rem;
    }

    .nav-logo img {
        height: 32px;
        width: 32px;
    }

    .hamburger span {
        width: 24px;
    }

    .nav-links {
        top: 85px;
        width: 92%;
        padding: 20px 15px;
    }

    .nav-links > li > a {
        font-size: 0.95rem;
        padding: 12px 8px;
    }

    .section-title h2 {
        font-size: 1.8rem;
    }

    .section-title p {
        font-size: 0.95rem;
    }

    .message-alert {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .message-alert i {
        font-size: 1.2rem;
    }

    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-bottom-links {
        flex-direction: column;
        gap: 15px;
    }

    .messages-container {
        top: 80px;
    }

    .footer-logo-unique img {
        height: 80px;
    }
}

@media (max-width: 380px) {
    .nav-logo span {
        display: none;
    }

    .user-btn span {
        font-size: 0.9rem;
    }

    .footer-logo-unique img {
        height: 70px;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .nav-links {
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .nav-links > li > a {
        padding: 10px 8px;
    }
}

.nav-links::-webkit-scrollbar {
    width: 6px;
}

.nav-links::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.nav-links::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
        rgba(212, 175, 55, 0.5),
        rgba(139, 21, 56, 0.5));
    border-radius: 12px;
}

@supports not (backdrop-filter: blur(10px)) {
    .nav-floating,
    .nav-links,
    .user-dropdown,
    .message-alert {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(10, 22, 40, 0.95);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- 2) Design system ---------- */
:root {
    /* brand */
    --primary: #8B1538;
    --primary-hover: #A91D3A;
    --secondary: #0A1628;
    --accent: #A91D3A;
    --gold: #D4AF37;
    --gold-soft: #E5BE3C;

    /* semantic (use these instead of ad-hoc greens/reds/oranges) */
    --success: #28A745;          /* solid fills with white text */
    --success-text: #4ADE80;     /* text/icons on dark surfaces */
    --danger: #DC3545;           /* solid fills with white text */
    --danger-text: #FF6B6B;      /* text/icons on dark surfaces */
    --warning: #FFA500;
    --warning-text: #FFD43B;
    --info: #3BC9DB;

    /* neutrals on the dark theme */
    --text: #FFFFFF;
    --text-muted: rgba(255, 255, 255, 0.72);
    --text-faint: rgba(255, 255, 255, 0.55);
    --surface: rgba(255, 255, 255, 0.05);
    --surface-strong: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.14);

    /* radius scale — 5 steps only */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-pill: 999px;

    /* type scale (rem) — nothing below --fs-xs so text stays legible on phones */
    --fs-xs: 0.8rem;       /* 12.8px: badges, captions, meta */
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.5rem;
    --fs-2xl: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
    --fs-3xl: clamp(1.9rem, 1.3rem + 2.4vw, 3rem);
    --lh-body: 1.75;       /* Persian script needs generous leading */
    --lh-tight: 1.35;

    /* spacing scale */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 72px;

    /* layout */
    --container-max: 1200px;
    --container-narrow: 920px;
    --gutter: 16px;
    --tap: 44px;            /* minimum touch target */

    /* shadows & motion */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- global safety nets ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 100px; }
body { line-height: var(--lh-body); text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
/* NOTE: no global `img { max-width:100% }` — inside shrink-to-fit parents (e.g. the header logo link) it resolves to 0px and collapses the image. */
pre, code { overflow-wrap: anywhere; }
h1, h2, h3, h4, h5, h6 { line-height: var(--lh-tight); overflow-wrap: anywhere; }
p, li, td, th { overflow-wrap: anywhere; }

/* consistent gutters + max width for Bootstrap containers on every page */
.container { padding-inline: var(--gutter); }
@media (min-width: 1400px) { .container { max-width: var(--container-max); } }

/* ---------- checkbox / radio rows (RTL fix) ----------
   Bootstrap's offsets assume LTR (float:left; margin-left:-1.5em), which on this RTL site pushed the box
   over its label text ("remember me" on the login page, terms on register, …). Lay every .form-check
   out as a flex row instead; page CSS can still restyle padding/background of the row. */
.form-check { display: flex; align-items: center; gap: 0.6rem; padding-left: 0; padding-right: 0; }
.form-check .form-check-input { float: none; margin: 0; flex-shrink: 0; }
.form-check-inline { display: inline-flex; margin-inline-end: 1rem; }

/* ---------- keyboard focus (visible, consistent, never removed) ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ---------- touch targets (phones & tablets) ---------- */
@media (max-width: 992px), (pointer: coarse) {
    .nav-logo { min-width: var(--tap); min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; }
    .hamburger { min-width: var(--tap) !important; min-height: var(--tap) !important; }
    .footer-links a, .footer-bottom-links a, .footer-content a {
        display: inline-flex; align-items: center; min-height: var(--tap);
    }
    .footer-links li { margin-bottom: 0 !important; }
    .footer-bottom-links { gap: 4px 20px !important; flex-wrap: wrap; justify-content: center; }
    .btn, .btn-sm, button[type=submit], .filter-btn, .share-btn, .btn-action, .btn-save-card, .copy-btn,
    .quick-amount-btn, .currency-favorite, .message-close, .back-link, .article-category, .article-category-badge,
    .guide-btn, .blog-link, .filter-type-btn { min-height: var(--tap) !important; }
    .share-btn, .copy-btn, .message-close, .currency-favorite, .btn-save-card, .btn-action { min-width: var(--tap) !important; }
    select, input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), textarea { min-height: var(--tap); }
    /* iOS zooms into inputs under 16px — keep form controls at 16px on phones */
    input, select, textarea { font-size: max(16px, 1em); }
    input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }

    /* standalone text links / small buttons found by the touch-target audit */
    .article-read-more, .tag-link, .read-more, .article-link, .author-social-link, .page-link, .back-button,
    .terms-link, .btn-view, .btn-secondary, .btn-icon, .rf-btn, .ube-glance-link {
        display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap) !important;
    }
    .author-social-link, .btn-icon, .page-link, .btn-contact { min-width: var(--tap) !important; }
    .article-read-more, .read-more, .article-link, .ube-glance-link, .terms-link, .back-button { justify-content: flex-start; padding-block: 8px; }
    /* honeypot / hidden helpers must never be counted as controls */
    .visually-hidden { min-height: 0 !important; }
}

/* never let small helper text fall under the legibility floor */
small, .small, code, .text-muted.small { font-size: max(var(--fs-xs), 0.875em); }
.badge { font-size: max(var(--fs-xs), 0.75em); }
.opportunity-code-small, .archive-code { font-size: var(--fs-xs) !important; }

/* ---------- footer newsletter: never wider than its column ---------- */
.newsletter-form { flex-wrap: wrap; }
.newsletter-form input { flex: 1 1 140px; min-width: 0; padding: 12px 16px; }
.newsletter-form button { flex: 0 0 auto; padding: 12px 24px; min-height: var(--tap); }
.newsletter-status { flex-basis: 100%; font-size: var(--fs-sm); margin: 0; }

/* ---------- reusable components (use in new templates) ---------- */
.ui-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
    padding: var(--space-5); box-shadow: var(--shadow-sm);
}
.ui-badge {
    display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700;
    padding: 4px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border); line-height: 1.4;
}
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
    padding: 10px 24px; border-radius: var(--radius-pill); font-weight: 700; font-size: var(--fs-base);
    text-decoration: none; border: 1px solid transparent; cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.ui-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ui-btn-primary { background: var(--primary); color: #fff; }
.ui-btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-soft)); color: var(--secondary); }
.ui-btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.ui-section { padding-block: clamp(40px, 6vw, var(--space-8)); }
.ui-section-title { font-size: var(--fs-2xl); font-weight: 800; margin-bottom: var(--space-4); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
