/* style.css */

/* ============================
   DESIGN TOKENS
   ============================ */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-card: #141414;
    --bg-hover: #1e1e1e;

    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --text-muted: #707070;
    --text-dim: #505050;

    --accent: #c5a021;
    --accent-light: #d4b84a;
    --accent-dark: #9a7d19;
    --accent-glow: rgba(197, 160, 33, 0.15);
    --accent-border: rgba(197, 160, 33, 0.3);

    --border-color: #222222;
    --border-light: #2a2a2a;

    --font-ar: "Cairo", "Segoe UI", Tahoma, sans-serif;
    --font-en: "Inter", "Segoe UI", system-ui, sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(197, 160, 33, 0.08);

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 300px;
    --header-height: 64px;
}

/* ============================
   RESET & BASE
   ============================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ar);
    font-size: 16px;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: direction var(--transition);
    overflow-x: hidden;
}

[dir="ltr"] body {
    font-family: var(--font-en);
}

::selection {
    background: var(--accent);
    color: var(--bg-primary);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-light);
}

/* ============================
   SCROLLBAR
   ============================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

/* ============================
   HEADER
   ============================ */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--header-height);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    transition: all var(--transition);
}

.site-header.scrolled {
    background: rgba(10, 10, 10, 0.95);
    box-shadow: var(--shadow-md);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent);
    filter: drop-shadow(0 0 6px rgba(197, 160, 33, 0.3));
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: transparent;
    border: 1.5px solid var(--accent-border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.03em;
}

.lang-toggle:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.btn-print {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-print:hover {
    border-color: var(--accent-border);
    color: var(--accent);
}

/* ============================
   HERO
   ============================ */
.hero {
    margin-top: var(--header-height);
    padding: 80px 24px 60px;
    background: linear-gradient(180deg,
            var(--bg-secondary) 0%,
            var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle,
            rgba(197, 160, 33, 0.06) 0%,
            transparent 70%);
    pointer-events: none;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.hero-eyebrow {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin-bottom: 16px;
}

.hero-title {
    font-size: clamp(24px, 4vw, 38px);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 32px;
}

.hero-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.meta-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.meta-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
}

.meta-divider {
    width: 1px;
    height: 36px;
    background: var(--border-light);
}

/* ============================
   MAIN LAYOUT
   ============================ */
.main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
}

/* ============================
   SIDEBAR / TOC
   ============================ */
.sidebar {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    border-inline-end: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 24px 0;
    z-index: 10;
}

.sidebar-inner {
    padding: 0 20px;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.toc {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-link {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    line-height: 1.5;
    border-inline-start: 2px solid transparent;
}

.toc-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.toc-link.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-inline-start-color: var(--accent);
    font-weight: 600;
}

.toc-link.sub {
    padding-inline-start: 28px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================
   CONTENT AREA
   ============================ */
.content {
    padding: 48px 56px 100px;
    max-width: 900px;
}

.doc-section {
    margin-bottom: 64px;
    scroll-margin-top: calc(var(--header-height) + 24px);
}

.section-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--accent);
    position: relative;
}

.section-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.5;
}

/* ============================
   ARTICLE & CLAUSE
   ============================ */
.article-block {
    margin-bottom: 48px;
    padding: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition);
}

.article-block:hover {
    border-color: var(--accent-border);
}

.article-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-light);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.article-intro {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-style: italic;
}

.clause {
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-inline-start: 3px solid var(--accent-dark);
    transition: all var(--transition);
}

.clause:hover {
    border-inline-start-color: var(--accent);
    background: var(--bg-hover);
}

.clause:last-child {
    margin-bottom: 0;
}

.clause-id {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.clause-text {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 2;
}

.clause-text b,
.clause-text strong {
    color: var(--accent-light);
    font-weight: 700;
}

/* Nested list styling inside clauses */
.clause-text ul,
.clause-text ol {
    margin: 12px 0;
    padding-inline-start: 24px;
}

.clause-text li {
    margin-bottom: 8px;
    line-height: 1.9;
}

.clause-text li::marker {
    color: var(--accent);
}

/* ============================
   FOOTER
   ============================ */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 40px 24px;
    text-align: center;
}

.footer-container {
    max-width: 800px;
    margin: 0 auto;
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 14px;
}

.footer-legal {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 16px;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 11px;
    color: var(--text-dim);
}

.footer-links span::before {
    content: "●";
    margin-inline-end: 8px;
    color: var(--accent-dark);
    font-size: 6px;
    vertical-align: middle;
}

/* ============================
   LEGAL TABLE (Data Types)
   ============================ */
.legal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.legal-table th {
    background: var(--accent-dark);
    color: var(--bg-primary);
    padding: 12px 16px;
    text-align: start;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.legal-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    line-height: 1.7;
    vertical-align: top;
}

.legal-table tr:hover td {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.legal-table th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

[dir="ltr"] .legal-table th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.legal-table th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

[dir="ltr"] .legal-table th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

/* ============================
   BACK TO TOP
   ============================ */
.back-to-top {
    position: fixed;
    bottom: 32px;
    inset-inline-end: 32px;
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-border);
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: all var(--transition);
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--accent);
    color: var(--bg-primary);
    box-shadow: var(--shadow-glow);
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .content {
        padding: 32px 24px 80px;
    }
}

@media (max-width: 640px) {
    .hero {
        padding: 48px 16px 40px;
    }

    .hero-title {
        font-size: 22px;
    }

    .hero-meta {
        gap: 16px;
    }

    .meta-divider {
        display: none;
    }

    .article-block {
        padding: 20px 16px;
    }

    .clause {
        padding: 16px;
    }

    .content {
        padding: 24px 16px 60px;
    }
}

/* ============================
   PRINT STYLES
   ============================ */
@media print {

    .site-header,
    .sidebar,
    .site-footer,
    .back-to-top,
    .btn-print,
    .lang-toggle {
        display: none !important;
    }

    body {
        background: white;
        color: #000;
        font-size: 14pt;
    }

    .hero-title,
    .hero-eyebrow,
    .hero-subtitle,
    .meta-label,
    .meta-value,
    .article-intro,
    .clause-text,
    p,
    li,
    span,
    div {
        color: #000 !important;
    }

    .section-title,
    .article-title,
    .clause-id {
        color: #c5a021 !important;
    }

    .hero {
        margin-top: 0;
        background: none;
        border: none;
        padding: 20px 0;
    }

    .main-layout {
        display: block;
    }

    .content {
        max-width: 100%;
        padding: 0;
    }

    .doc-section {
        break-before: page !important;
        page-break-before: always !important;
    }

    #sec-preamble {
        break-before: auto !important;
        page-break-before: auto !important;
    }

    .article-block,
    .clause {
        background: none;
        border: 1px solid #ccc;
        break-inside: auto;
        page-break-inside: auto;
    }

    .article-block {
        margin: 0px 0 !important;
        padding: 6px !important;
    }

    .clause {
        margin: 4px 0 !important;
        padding: 4px 6px !important;
    }

    .clause-id {
        margin: 1px !important;
    }

    .clause-text {
        margin: 1px !important;
    }

    .article-intro {
        margin: 2px 0 !important;
    }

    .article-title {
        margin: 4px 0 2px !important;
    }

    .section-header {
        margin: 4px !important;
        padding: 4px !important;
    }

    p {
        margin: 1px 0 !important;
    }

    li {
        margin: 1px 0 !important;
    }

    #sec-appendix .article-block {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .section-header,
    .section-title,
    .article-title,
    .clause-id {
        break-after: avoid;
        page-break-after: avoid;
    }
}