:root {
    /* Color System: True Deep Charcoal */
    --bg-base: #141416;
    --bg-surface: #1c1c1e;
    --bg-surface-alt: #18181a;
    --bg-surface-elevated: #242426;

    /* Override Bootstrap Defaults */
    --bs-primary: #ffffff;
    --bs-primary-rgb: 255, 255, 255;

    /* Typography Colors */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.55);

    /* Borders & Accents */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.15);
    --accent: #eaeaec;

    /* Typography System */
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Poppins', sans-serif;

    /* Spacing */
    --space-huge: clamp(4rem, 15vh, 12rem);
    --space-lg: clamp(2rem, 8vh, 6rem);
}

[dir="rtl"] {
    --font-heading: 'IBM Plex Sans Arabic', sans-serif;
    --font-body: 'IBM Plex Sans Arabic', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Background Motif - Subtle architectural noise */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: 
        radial-gradient(circle at 15% 30%, rgba(255, 255, 255, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 85% 70%, rgba(255, 255, 255, 0.02) 0%, transparent 40%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    line-height: 1.1;
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.display-1 { font-size: clamp(3rem, 8vw, 7rem); font-weight: 200; letter-spacing: -0.04em; line-height: 1.05; }
.display-2 { font-size: clamp(2.5rem, 6vw, 5rem); font-weight: 300; letter-spacing: -0.03em; }
.display-3 { font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 300; letter-spacing: -0.02em; }

.text-eyebrow {
    font-family: var(--font-body);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    font-weight: 500;
    display: block;
    margin-bottom: 1rem;
}

.lead {
    font-size: clamp(1.125rem, 2vw, 1.35rem);
    color: var(--text-secondary);
    font-weight: 300;
    max-width: 70ch;
}

.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

/* Typography Utilities */
.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.tracking-wider { letter-spacing: 0.05em; }

/* Structural Utilities */
.py-huge { padding-top: var(--space-huge); padding-bottom: var(--space-huge); }
.py-lg { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }

@media (min-width: 992px) {
    .mb-lg-huge { margin-bottom: var(--space-huge) !important; }
}
/* Architectural Grid System */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
}

/* Direction-aware structural borders (logical properties keep RTL correct) */
.border-grid-x { border-inline-start: 1px solid var(--border-subtle); border-inline-end: 1px solid var(--border-subtle); }
.border-grid-y { border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.border-grid-all { border: 1px solid var(--border-subtle); }

.bg-surface { background-color: var(--bg-surface); }
.bg-surface-alt { background-color: var(--bg-surface-alt); }
.border-subtle { border-color: var(--border-subtle) !important; }
.border-top-subtle { border-top: 1px solid var(--border-subtle) !important; }
.border-bottom-subtle { border-bottom: 1px solid var(--border-subtle) !important; }
.border-start-subtle { border-inline-start: 1px solid var(--border-subtle) !important; }
.border-end-subtle { border-inline-end: 1px solid var(--border-subtle) !important; }

/* Refined Components */

/* Buttons */
.btn {
    font-family: var(--font-body);
    border-radius: 0 !important;
    padding: 0.8rem 2rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 400;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background-color: var(--text-primary);
    color: var(--bg-base);
    border: 1px solid var(--text-primary);
}

.btn-primary:hover {
    background-color: transparent;
    color: var(--text-primary);
}

.btn svg {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:hover svg {
    transform: translateX(5px);
}

.btn-outline-light {
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-outline-light:hover {
    background-color: rgba(255,255,255,0.05);
    border-color: var(--border-medium);
}

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

a:hover {
    color: var(--text-secondary);
}

.link-animated {
    position: relative;
    display: inline-block;
}

.link-animated::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: currentColor;
    transform-origin: bottom right;
    transition: transform 0.4s cubic-bezier(0.86, 0, 0.07, 1);
}

.link-animated:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Custom Cards / Containers */
.architectural-box {
    border: 1px solid var(--border-subtle);
    padding: 2.5rem;
    background-color: rgba(255, 255, 255, 0.01);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.architectural-box:hover {
    background-color: rgba(255, 255, 255, 0.02);
    border-color: var(--border-medium);
}

/* Forms */
.form-control, .form-select {
    border-radius: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;
    padding: 1rem 1.25rem;
    background-color: rgba(255, 255, 255, 0.02) !important;
    color: var(--text-primary) !important;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    box-shadow: none !important;
    border-bottom-color: var(--text-primary) !important;
    outline: none;
}

/* Fix dropdown options visibility on certain OS/browsers */
.form-select option {
    background-color: var(--bg-base);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-family: var(--font-body);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Aspect Ratios */
.aspect-16x9 { aspect-ratio: 16 / 9; }
.aspect-1x1 { aspect-ratio: 1 / 1; }
.aspect-4x3 { aspect-ratio: 4 / 3; }
.aspect-3x4 { aspect-ratio: 3 / 4; }

.img-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Animation Classes (Controlled by JS) */
.reveal-up {
    opacity: 0;
    transform: translateY(30px);
    transition: all 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Markdown Content Styling for Legal Pages */
.markdown-content h1, .markdown-content h2, .markdown-content h3 {
    color: var(--bs-primary);
    font-family: var(--font-heading);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 400;
}
.markdown-content h2 {
    font-size: 1.5rem;
}
.markdown-content p {
    margin-bottom: 1.2rem;
}
.markdown-content ul {
    margin-bottom: 1.5rem;
    padding-inline-start: 1.5rem;
}
.markdown-content li {
    margin-bottom: 0.5rem;
}

/* Premium SVG Hover Animations */
.hover-trigger {
    cursor: pointer;
}

.hover-trigger svg {
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center;
}

.hover-trigger:hover svg,
.hover-trigger.is-active svg {
    transform: scale(1.03) translateZ(0);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.15));
}

.hover-trigger:hover .text-primary,
.hover-trigger.is-active .text-primary {
    color: #ffffff !important;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Scroll to Top Geometric Shape */
.scroll-top-shape {
    position: fixed;
    bottom: 2rem;
    inset-inline-end: 2rem;
    width: 48px;
    height: 48px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(10px);
}

.scroll-top-shape.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-shape:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.scroll-track {
    position: absolute;
    bottom: -1px;
    left: -1px;
    right: -1px;
    height: 1px;
    background-color: transparent;
}

.scroll-progress {
    height: 100%;
    width: 0%;
    background-color: var(--text-primary);
    transition: width 0.1s linear;
}

/* Internal SVG Animations */
.anim-node, .anim-path, .anim-ring, .anim-shape {
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center;
}

.hover-trigger:hover svg .anim-node,
.hover-trigger.is-active svg .anim-node {
    fill: var(--text-primary);
    stroke: var(--text-primary);
    transform: scale(1.5);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

.hover-trigger:hover svg .anim-ring,
.hover-trigger.is-active svg .anim-ring {
    transform: scale(1.05);
    stroke: rgba(255, 255, 255, 0.5);
    stroke-width: 1.5;
}

.hover-trigger:hover svg .anim-shape,
.hover-trigger.is-active svg .anim-shape {
    stroke: var(--text-primary);
    stroke-width: 1.2;
    fill: rgba(255, 255, 255, 0.05);
}

.hover-trigger:hover svg .anim-path,
.hover-trigger.is-active svg .anim-path {
    stroke: var(--text-primary);
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawInternalPath 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes drawInternalPath {
    to { stroke-dashoffset: 0; }
}

/* Technology Grid (Professional Stack Motif) */
.tech-logo {
    height: 35px;
    max-width: 120px;
    opacity: 0.3;
    filter: grayscale(100%);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), filter 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tech-logo svg {
    height: 35px !important;
    max-width: 100% !important;
    width: auto;
}

.tech-logo:hover,
.tech-logo.is-active {
    opacity: 1;
    filter: grayscale(0%);
    transform: scale(1.05);
}

/* Accessibility: Reduced Motion */
@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;
    }

    .reveal-up {
        opacity: 1;
        transform: none;
    }
}
