/* ========== CSS Variables & Fonts ========== */
:root {
    --black: #0a0a0f;
    --bg-deep: #0e0b1a;
    --bg-card: #1a1230;
    --bg-card-hover: #231945;
    --purple-dark: #2c1e4a;
    --purple-mid: #3a2a5a;
    --purple-light: #5a3e8a;
    --yellow: #f7d44d;
    --yellow-dim: #c9a900;
    --yellow-glow: rgba(247, 212, 77, 0.18);
    --text-primary: #f0eaff;
    --text-muted: #8a7aaa;
    --border: rgba(247, 212, 77, 0.15);
    --header-h: 72px;
    --header-h-mobile: 58px;
    --radius: 10px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --tap-target-min: 44px;
    --red: #ff4d4d;
    --red-glow: rgba(255, 77, 77, 0.15);
    --orange: #ff8c42;
    --green: #48c774;
    --content-max: 1100px;
    --footer-max: 1200px;
}

@font-face {
    font-family: 'BarlowCondensed';
    src: url("/FONTS/BarlowCondensed-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'BarlowCondensed';
    src: url("/FONTS/BarlowCondensed-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazir';
    font-weight: normal;
    src: url('/FONTS/Vazir.eot');
    src: url('/FONTS/Vazir.eot?#iefix') format('embedded-opentype'),
        url('/FONTS/Vazir.woff') format('woff'),
        url('/FONTS/Vazir.ttf') format('truetype');
}

/* ========== Global Reset & Base ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-padding-top: calc(var(--header-h) + 20px);
}
body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Vazir', 'BarlowCondensed', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    overflow-x: hidden;
    min-width: 320px;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--purple-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--yellow-dim); }

/* ========== Header ========== */
#header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h); z-index: 1000;
    background: linear-gradient(90deg, rgba(14,11,26,0.97) 0%, rgba(44,30,74,0.97) 50%, rgba(14,11,26,0.97) 100%);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 32px rgba(0,0,0,0.5);
    display: flex; align-items: center;
    padding: 0 clamp(10px, 4vw, 60px);
}
.header-inner {
    width: 100%; max-width: 1300px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.logo{display:flex;align-items:center;gap:10px;flex-shrink:0;min-height:var(--tap-target-min)}
.logo-circle{width:42px;height:42px;border-radius:50%;border:1px solid var(--yellow);display:flex;align-items:center;justify-content:center;font-family:'BarlowCondensed',sans-serif;font-size:1.4rem;font-weight:900;color:var(--yellow);transition:box-shadow var(--transition);flex-shrink:0}
.logo:hover .logo-circle{box-shadow:0 0 24px rgba(247,212,77,0.6)}
.logo-text{font-family:'BarlowCondensed',sans-serif;font-size:1.25rem;font-weight:900;letter-spacing:0.08em;text-transform:uppercase;white-space:nowrap}
.logo-text span{color:var(--yellow)}

.rules-page-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-back {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(247,212,77,0.08); border: 1px solid var(--border);
    color: var(--yellow); font-family: 'Vazir', 'BarlowCondensed', sans-serif;
    font-size: 0.82rem; font-weight: 700; letter-spacing: 0.06em;
    padding: 8px 16px; border-radius: 50px; cursor: pointer;
    transition: all var(--transition); min-height: var(--tap-target-min); white-space: nowrap;
}
/* Responsive text toggles for back button (full vs short) */
.btn-back .label-full { display: inline; }
.btn-back .label-short { display: none; }

.btn-back:hover { background: var(--yellow-glow); border-color: var(--yellow); box-shadow: 0 0 16px rgba(247,212,77,0.2); transform: translateX(4px); }
.btn-back svg { flex-shrink: 0; width: 14px; height: 14px; transition: transform var(--transition); }
.btn-back:hover svg { transform: translateX(3px); }
.nav-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.nav-breadcrumb span { color: var(--yellow); opacity: 0.6; }
.nav-breadcrumb svg { width: 10px; height: 10px; flex-shrink: 0; }

/* ========== Hero ========== */
.rules-hero {
    padding: calc(var(--header-h) + clamp(40px,8vw,60px)) clamp(16px,6vw,80px) clamp(36px,6vw,60px);
    position: relative; overflow: hidden; text-align: center;
}
.rules-hero::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse 70% 60% at 50% 30%, rgba(90,62,138,0.4) 0%, transparent 70%),
                linear-gradient(180deg, var(--black) 0%, var(--bg-deep) 60%, var(--bg-deep) 100%);
    z-index: -1;
}
.rules-hero::after {
    content: ''; position: absolute; inset: 0;
    background-image: linear-gradient(rgba(247,212,77,0.035) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(247,212,77,0.035) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 0%, transparent 80%);
    z-index: -1; animation: gridShift 20s linear infinite;
}
@keyframes gridShift {
    from { background-position: 0 0; }
    to { background-position: 60px 60px; }
}

.hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: clamp(0.7rem,1.4vw,0.78rem); font-weight: 500;
    letter-spacing: 0.2em; text-transform: uppercase; color: var(--yellow); margin-bottom: 16px;
}
.hero-eyebrow::before,
.hero-eyebrow::after {
    content: ''; display: block; width: clamp(20px,5vw,32px); height: 1px;
    background: var(--yellow); opacity: 0.5;
}
.rules-hero h1 {
    font-family: 'Vazir', 'BarlowCondensed', sans-serif;
    font-size: clamp(2.2rem,7vw,5.5rem); font-weight: 900; line-height: 1.05;
    text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-primary);
    margin-bottom: 16px; word-break: break-word;
}
.rules-hero h1 span { color: var(--yellow); }
.rules-hero p { font-size: clamp(0.85rem,1.8vw,1.05rem); color: var(--text-muted); max-width: 620px; margin: 0 auto 28px; padding: 0 8px; }

.hero-stats {
    display: inline-flex; align-items: center; gap: clamp(12px,3vw,28px);
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: 50px; padding: 8px clamp(16px,3vw,28px); flex-wrap: wrap; justify-content: center;
}
.hero-stat { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; }
.hero-stat-val { font-family: 'BarlowCondensed', sans-serif; font-size: clamp(1.1rem,2vw,1.3rem); font-weight: 900; color: var(--yellow); line-height: 1; }
.hero-stat-lbl { color: var(--text-muted); font-size: clamp(0.7rem,1.2vw,0.75rem); }
.hero-divider { width: 1px; height: clamp(20px,3vw,28px); background: rgba(255,255,255,0.1); flex-shrink: 0; }

/* ========== Penalty Banner ========== */
.penalty-banner {
    background: linear-gradient(90deg, var(--black) 0%, var(--purple-dark) 50%, var(--black) 100%);
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    padding: 12px clamp(16px,5vw,60px); animation: fadeInUp 0.7s ease forwards;
}
.penalty-banner-inner { max-width: var(--content-max); margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 0; flex-wrap: wrap; }
.penalty-item { display: flex; align-items: center; gap: 10px; padding: 6px 14px; }
.penalty-dot {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'BarlowCondensed', sans-serif; font-size: 0.8rem; font-weight: 900; flex-shrink: 0;
}
.penalty-dot.l1 { background: rgba(247,212,77,0.15); border: 2px solid var(--yellow); color: var(--yellow); }
.penalty-dot.l2 { background: rgba(255,140,66,0.15); border: 2px solid var(--orange); color: var(--orange); }
.penalty-dot.l3 { background: rgba(255,77,77,0.15); border: 2px solid var(--red); color: var(--red); }
.penalty-text { font-size: 0.78rem; line-height: 1.4; }
.penalty-text strong { display: block; color: var(--text-primary); font-size: 0.82rem; margin-bottom: 1px; }
.penalty-text span { color: var(--text-muted); font-size: 0.72rem; }
.penalty-sep { width: 1px; height: 28px; background: rgba(255,255,255,0.1); flex-shrink: 0; display: block; }

/* ========== Sticky Nav ========== */
.sticky-nav {
    position: sticky; top: var(--header-h); z-index: 100;
    background: linear-gradient(90deg, rgba(14,11,26,0.96) 0%, rgba(44,30,74,0.96) 50%, rgba(14,11,26,0.96) 100%);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(247,212,77,0.08);
    padding: 0 clamp(8px,3vw,40px); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.sticky-nav-inner { max-width: var(--content-max); margin: 0 auto; display: flex; align-items: center; gap: 0; scrollbar-width: none; }
.sticky-nav-inner::-webkit-scrollbar { display: none; }
.sticky-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 12px 14px; font-size: clamp(0.7rem,1.3vw,0.78rem); font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
    border-bottom: 2px solid transparent; transition: all var(--transition);
    white-space: nowrap; cursor: pointer; flex-shrink: 0; min-height: var(--tap-target-min);
}
.sticky-link:hover { color: var(--yellow); }
.sticky-link.active { color: var(--yellow); border-bottom-color: var(--yellow); }
.sticky-link span { font-family: 'BarlowCondensed', sans-serif; font-size: 0.85rem; opacity: 0.6; }

/* ========== Main Content ========== */
.rules-main { max-width: var(--content-max); margin: 0 auto; padding: clamp(36px,6vw,60px) clamp(12px,5vw,40px) clamp(60px,10vw,100px); position: relative; z-index: 1; }
.category-block { margin-bottom: clamp(36px,6vw,56px); }
.category-header { display: flex; align-items: center; gap: clamp(10px,2vw,16px); margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.category-icon { width: clamp(38px,6vw,48px); height: clamp(38px,6vw,48px); border-radius: 12px; background: var(--yellow-glow); border: 1px solid rgba(247,212,77,0.25); display: flex; align-items: center; justify-content: center; font-size: clamp(1.2rem,2vw,1.5rem); flex-shrink: 0; }
.category-title-wrap { flex: 1; min-width: 0; }
.category-label { font-family: 'Vazir', 'BarlowCondensed', sans-serif; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--yellow); margin-bottom: 2px; }
.category-title { font-family: 'Vazir', 'BarlowCondensed', sans-serif; font-size: clamp(1.2rem,3vw,1.9rem); font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-primary); word-break: break-word; }
.category-count { font-family: 'BarlowCondensed', sans-serif; font-size: clamp(1.8rem,4vw,2.8rem); font-weight: 900; color: var(--yellow); opacity: 0.15; line-height: 1; flex-shrink: 0; }

/* ========== Rules Grid & Accordion ========== */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
    align-items: stretch;
    overflow: visible;                /* allow absolutely positioned panels to escape */
}

.rule-accordion {
    position: relative;               /* anchor for the panel */
    display: flex;
    flex-direction: column;
    justify-content: center;          /* center the trigger vertically */
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: var(--radius);
    overflow: visible;                /* panel can overflow outside */
    height: 190px !important;                    /* fixed identical height for all cards */
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
    z-index: 1;
}
.rule-accordion:hover {
    border-color: var(--yellow);
    box-shadow: 0 0 18px rgba(247, 212, 77, 0.25);
    background: var(--yellow-glow);
    transform: translateY(-2px);
}
.rule-accordion.open {
    z-index: 20;                     /* on top of adjacent cards */
    background: rgba(255, 255, 255, 0.025);
    border-color: rgba(247, 212, 77, 0.25);
    box-shadow: none;
}
.rule-accordion.open:hover {
    border-color: rgba(247, 212, 77, 0.4);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(247, 212, 77, 0.08);
    background: rgba(247, 212, 77, 0.06);
    transform: none;                  /* no lift when open */
}

/* Trigger (the clickable button) */
.rule-trigger {
    display: flex;
    align-items: center;
    gap: clamp(8px,2vw,14px);
    padding: clamp(12px,2vw,16px) clamp(12px,2vw,18px);
    width: 100%;
    height: 100%;                     /* fill the card */
    background: none;
    border: none;
    color: inherit;
    text-align: right;
    cursor: pointer;
    min-height: var(--tap-target-min);
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
}
.rule-trigger:hover {
    background: transparent;         /* no background hover effect */
}
.rule-accordion.open .rule-trigger {
    background: rgba(247,212,77,0.06);
}

.rule-num {
    font-family: 'BarlowCondensed', sans-serif;
    font-size: clamp(1.2rem,2vw,1.5rem);
    font-weight: 900;
    color: var(--yellow);
    opacity: 0.45;
    line-height: 1;
    flex-shrink: 0;
    min-width: 26px;
    text-align: center;
    transition: opacity var(--transition), color var(--transition);
}
.rule-accordion.open .rule-num { opacity: 1; }

.rule-body {
    flex: 1;
    text-align: right;
    font-family: 'Vazir', sans-serif;
    min-width: 0;
}
.rule-body strong {
    display: block;
    font-size: clamp(0.82rem,1.3vw,0.88rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    line-height: 1.4;
    transition: color var(--transition);
}
.rule-accordion.open .rule-body strong { color: var(--yellow); }
.rule-body span {
    font-size: clamp(0.73rem,1.1vw,0.77rem);
    color: var(--text-muted);
    line-height: 1.5;
}

.rule-arrow {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform var(--transition), color var(--transition);
    margin-right: auto;
}
[dir="rtl"] .rule-arrow {
    margin-right: 0;
    margin-left: auto;
}
.rule-accordion.open .rule-arrow {
    transform: rotate(180deg);
    color: var(--yellow);
}

/* Panel – absolutely positioned, appears below the card */
.rule-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(26, 18, 48, 0.98);
    border: 1px solid rgba(247, 212, 77, 0.3);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
    padding: 14px 18px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}
.rule-accordion.open .rule-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Panel inner content */
.rule-panel-inner {
    transform: translateY(-8px);
    transition: transform 0.35s cubic-bezier(0.25,0.1,0.25,1);
}
.rule-accordion.open .rule-panel-inner {
    transform: translateY(0);
}

.penalty-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--yellow);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.penalty-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(247,212,77,0.15);
}

.penalty-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.penalty-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    position: relative;
    flex-wrap: wrap;
}
.penalty-row.l1 { background: rgba(247,212,77,0.06); border-right: 2px solid rgba(247,212,77,0.35); }
.penalty-row.l2 { background: rgba(255,140,66,0.06); border-right: 2px solid rgba(255,140,66,0.35); }
.penalty-row.l3 { background: rgba(255,77,77,0.06); border-right: 2px solid rgba(255,77,77,0.35); }
.penalty-row.instant { background: rgba(255,77,77,0.1); border-right: 2px solid var(--red); }

.penalty-tag {
    font-family: 'Vazir', 'BarlowCondensed', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.penalty-row.l1 .penalty-tag { background: rgba(247,212,77,0.15); color: var(--yellow); }
.penalty-row.l2 .penalty-tag { background: rgba(255,140,66,0.15); color: var(--orange); }
.penalty-row.l3 .penalty-tag { background: rgba(255,77,77,0.15); color: var(--red); }
.penalty-row.instant .penalty-tag { background: rgba(255,77,77,0.2); color: var(--red); }

.penalty-desc {
    color: var(--text-muted);
    line-height: 1.5;
    font-size: 0.78rem;
    flex: 1;
    min-width: 100px;
}

.admin-penalty {
    background: rgba(247,212,77,0.05);
    border: 1px dashed rgba(247,212,77,0.2);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.admin-penalty strong { color: var(--yellow); }

/* ========== Notes Section ========== */
.notes-section {
    background: linear-gradient(135deg, rgba(26,18,48,0.9) 0%, rgba(44,30,74,0.6) 100%);
    border: 1px solid rgba(247,212,77,0.2);
    border-radius: 16px;
    padding: clamp(22px,4vw,36px) clamp(18px,4vw,40px);
    margin-top: 20px;
    margin-bottom: 60px;
    position: relative;
    overflow: hidden;
}
.notes-section::before {
    content: '⚠️';
    position: absolute;
    top: -10px;
    right: 32px;
    font-size: 4rem;
    opacity: 0.07;
    pointer-events: none;
}
.notes-title {
    font-family: 'Vazir', 'BarlowCondensed', sans-serif;
    font-size: clamp(1.1rem,2vw,1.3rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--yellow);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: clamp(0.8rem,1.2vw,0.88rem);
    color: var(--text-muted);
    padding: 9px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    border-right: 3px solid rgba(247,212,77,0.3);
}
.note-item::before {
    content: '◆';
    color: var(--yellow);
    opacity: 0.6;
    font-size: 0.55rem;
    margin-top: 5px;
    flex-shrink: 0;
}
.note-item strong { color: var(--text-primary); }

/* ========== Responsive Header: Back Button & Breadcrumb ========== */

/* Tablet & medium screens: shorten button text and simplify breadcrumb */
@media (max-width: 768px) {
    .btn-back {
        padding: 6px 14px;
        gap: 5px;
    }
    .rules-page-nav {
        gap: 8px;
    }
}

/* Mobile landscape & small tablets: use short button label, keep only current page in breadcrumb */
@media (max-width: 640px) {
    /* Back button: hide full label, show short label */
    .btn-back .label-full {
        display: none;
    }
    .btn-back .label-short {
        display: inline;
    }
    
    /* Breadcrumb: keep only the last item (current page) */
    .nav-breadcrumb span:first-child,
    .nav-breadcrumb svg {
        display: none;
    }
    
    /* Slightly reduce button padding and gap */
    .btn-back {
        padding: 6px 12px;
        gap: 4px;
        font-size: 0.75rem;
    }
    .rules-page-nav {
        gap: 6px;
        flex-wrap: nowrap;          /* keep both items on one line */
    }
    .nav-breadcrumb {
        font-size: 0.72rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;           /* prevent overflow on very narrow devices */
    }
}

/* Mobile portrait: hide breadcrumb completely, rely on back button */
@media (max-width: 480px) {
    .nav-breadcrumb {
        display: none;
    }
    .btn-back {
        padding: 5px 10px;
        gap: 3px;
    }
    .btn-back svg {
        width: 12px;
        height: 12px;
    }
}

/* Extra small devices (below 380px): minimal back button */
@media (max-width: 380px) {
    .btn-back {
        padding: 5px 8px;
    }
    .btn-back .label-short {
        font-size: 0.7rem;
    }
}