/*
======================================
    Brand mark — cursor blink, splash
    screen, language toggle
======================================
*/

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@500;700&display=swap');

.logo-cursor {
    animation: logo-blink 1.4s steps(1, end) infinite;
}

@keyframes logo-blink {
    0%, 60%, 100% {
        opacity: 1;
    }
    61%, 88% {
        opacity: 0.15;
    }
}

/* Arabic label on the language toggle is always Tajawal, even on the EN page */
.lang-toggle {
    font-family: "Tajawal", "Poppins", sans-serif;
}

/*
======================================
    Splash screen — the Circuit E
    draws itself, then the cursor
    lands and blinks
======================================
*/

.splash-mark {
    width: 110px;
    height: 110px;
    color: #fff;
}

.splash-mark .draw {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: splash-draw 1s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.splash-mark .draw-mid {
    animation-delay: 0.5s;
}

.splash-cursor {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation:
        splash-cursor-in 0.35s cubic-bezier(0.34, 1.3, 0.64, 1) 0.95s forwards,
        logo-blink 1.4s steps(1, end) 1.5s infinite;
}

@keyframes splash-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes splash-cursor-in {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.splash-percent {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0.25em;
    opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
    .logo-cursor,
    .splash-cursor {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .splash-mark .draw {
        animation: none;
        stroke-dashoffset: 0;
    }
}

/*
======================================
    Footer giant name — size against
    the container, not the viewport.
    The heading's cqw units otherwise
    keep growing on wide screens while
    the container is capped, wrapping
    the brand period onto its own line.
======================================
*/

.footer-bottom {
    container-type: inline-size;
}

.porthe-large-text {
    font-size: 33cqw;
    white-space: nowrap;
}

/*
======================================
    Selected Work — interactive index
======================================
*/

.works-list {
    position: relative;
}

.work-row {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2.4rem 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.14);
    text-decoration: none;
    color: inherit;
}

html.dark .work-row {
    border-color: rgba(255, 255, 255, 0.14);
}

.work-row:first-of-type {
    border-top: 1px solid rgba(0, 0, 0, 0.14);
}

html.dark .work-row:first-of-type {
    border-top-color: rgba(255, 255, 255, 0.14);
}

.work-index {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.95rem;
    opacity: 0.45;
    min-width: 2.6rem;
}

.work-name {
    flex: 1;
    font-size: clamp(2rem, 4.6vw, 4.2rem);
    line-height: 1.08;
    text-transform: uppercase;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.work-meta {
    display: flex;
    align-items: center;
    gap: 1.6rem;
}

.work-cat {
    font-size: 0.95rem;
    opacity: 0.55;
    white-space: nowrap;
}

.work-cta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid currentColor;
    border-radius: 999px;
    padding: 0.55rem 1.15rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.work-cta i {
    font-size: 0.8em;
    transform: rotate(-45deg);
}

[dir="rtl"] .work-cta i {
    transform: scaleX(-1) rotate(-45deg);
}

.work-row:hover .work-cta {
    opacity: 1;
    transform: translateY(0);
}

.work-row:hover .work-name {
    transform: translateX(14px);
}

[dir="rtl"] .work-row:hover .work-name {
    transform: translateX(-14px);
}

/* Hovering the list dims the other rows (children only — GSAP owns row opacity) */
@media (pointer: fine) {
    .works-list:hover .work-row:not(:hover) .work-name,
    .works-list:hover .work-row:not(:hover) .work-index,
    .works-list:hover .work-row:not(:hover) .work-meta {
        opacity: 0.3;
    }
    .work-name,
    .work-index,
    .work-meta {
        transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    }
}

/* Cursor-following preview card */
.work-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: clamp(20rem, 30vw, 28rem);
    aspect-ratio: 16 / 10;
    border-radius: 1rem;
    overflow: hidden;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.work-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    opacity: 0;
}

/* Inline thumbnails for touch devices and small screens */
.work-thumb {
    display: none;
}

@media (pointer: coarse), (max-width: 1023px) {
    .work-preview {
        display: none;
    }

    /* Each project becomes a self-contained card that reveals and the image
       parallaxes as it scrolls past — a vertical, scroll-driven "slider". */
    .works-list {
        display: flex;
        flex-direction: column;
        gap: 1.6rem;
    }
    .work-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0 0 1.3rem;
        margin: 0;
        border: none;
        border-radius: 1.15rem;
        overflow: hidden;
        background: rgba(0, 0, 0, 0.035);
        box-shadow: 0 14px 36px rgba(0, 0, 0, 0.10);
    }
    html.dark .work-row {
        background: rgba(255, 255, 255, 0.045);
        box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
    }
    .work-row:first-of-type {
        border-top: none;
    }

    .work-thumb {
        display: block;
        order: -1;
        width: 100%;
        aspect-ratio: 16 / 10;
        border-radius: 0;
        overflow: hidden;
        margin-bottom: 1.15rem;
    }
    .work-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top;
        transform: scale(1.18);   /* headroom so the parallax never reveals an edge */
        will-change: transform;
    }

    .work-index {
        padding: 0 1.2rem;
        font-size: 0.88rem;
        opacity: 0.5;
        min-width: 0;
    }
    .work-name {
        flex-basis: auto;
        padding: 0.15rem 1.2rem 0;
        font-size: clamp(1.9rem, 8.5vw, 2.8rem);
        line-height: 1.05;
    }
    .work-meta {
        width: auto;
        padding: 0.95rem 1.2rem 0;
        justify-content: space-between;
        align-items: center;
    }
    .work-cta {
        opacity: 1;
        transform: none;
    }
}

/*
======================================
    Approach glyphs — animated, theme-aware
======================================
*/

.ag-wrap, .ag-svg { width: 100%; height: 100%; display: block; }
.ag-svg { overflow: visible; }
.ag-svg [class^="ag-"] { transform-box: fill-box; transform-origin: center; }

.ag-blink { animation: ag-blink 1.4s steps(1, end) infinite; }
@keyframes ag-blink { 0%, 60%, 100% { opacity: 1; } 61%, 88% { opacity: 0.15; } }

.ag-pulse { animation: ag-pulse 2.4s ease-in-out infinite; }
@keyframes ag-pulse { 0%, 100% { opacity: 0.6; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.05); } }

.ag-ping { animation: ag-ping 2.6s ease-out infinite; opacity: 0; }
@keyframes ag-ping { 0% { opacity: 0.55; transform: scale(0.5); } 70%, 100% { opacity: 0; transform: scale(1.7); } }

.ag-flow { animation: ag-flow 1.1s linear infinite; }
@keyframes ag-flow { to { stroke-dashoffset: -26; } }

.ag-rise { animation: ag-rise 2.6s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
@keyframes ag-rise {
    0% { transform: translateY(5px); opacity: 0; }
    22% { opacity: 1; }
    62% { transform: translateY(-5px); opacity: 1; }
    100% { transform: translateY(-13px); opacity: 0; }
}

/* cube top face glow */
.ag-glow { animation: ag-glow 2.6s ease-in-out infinite; }
@keyframes ag-glow { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.95; } }

/* rocket hover + flickering exhaust */
.ag-hover { animation: ag-hover 3.2s ease-in-out infinite; }
@keyframes ag-hover { 0%, 100% { transform: translateY(2px); } 50% { transform: translateY(-3px); } }

.ag-flame { animation: ag-flame 0.42s ease-in-out infinite alternate; }
.ag-svg .ag-flame { transform-origin: top center; }
@keyframes ag-flame { from { transform: scaleY(0.72); opacity: 0.6; } to { transform: scaleY(1.18); opacity: 1; } }

/* Smaller footprint inside the dashed ring, and a softer light-mode palette:
   strokes use a deep indigo (not pure black) so they harmonize with the
   #6366F1 accents on the cream circle. White in dark mode reads as before. */
.single-design-process .ag-wrap { width: 80%; height: 80%; }
.single-design-process .ag-svg { color: #272252; }
html.dark .single-design-process .ag-svg { color: #ffffff; }

/* Step number — optical centering inside its pill (mobile browsers render the
   default line box slightly high) */
.step-num { line-height: 1; padding-top: 1px; }

/* About copy reflows naturally and avoids stranded single-word lines */
.about-copy { text-wrap: pretty; }

/*
======================================
    Architecture band — scroll-driven story,
    INVERTED theme for section separation
    (dark band on light page, light on dark)
======================================
*/

.arch-band {
    /* light page -> dark band */
    background: #0E0C22;
    color: #ffffff;
}

html.dark .arch-band {
    /* dark page -> light band */
    background: #F5EFE6;
    color: #15140F;
}

.arch-pin {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(0.75rem, 1.6vw, 1.5rem);
    overflow: hidden;
    padding: clamp(2rem, 4vw, 3rem) 0;
}

.arch-head {
    text-align: center;
    max-width: 760px;
    padding: 0 1.25rem;
    z-index: 2;
}

.arch-heading {
    font-size: clamp(1.7rem, 3.6vw, 2.8rem);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.arch-subtitle {
    margin-top: 0.7rem;
    font-size: clamp(0.88rem, 1.3vw, 1.05rem);
    font-weight: 300;
    line-height: 1.55;
    opacity: 0.72;
}

.arch-stage {
    position: relative;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1.25rem, 2.4vw, 2rem);
}

.arch-glow {
    position: absolute;
    left: 26%;
    top: 50%;
    width: 42vw;
    height: 42vw;
    max-width: 560px;
    max-height: 560px;
    transform: translateY(-50%);
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18), transparent 62%);
    pointer-events: none;
}

.arch-scroll { width: 100%; display: flex; justify-content: center; }

.arch-svg {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    /* keep the whole composition inside the pinned viewport */
    max-height: clamp(240px, calc(100vh - 430px), 500px);
    z-index: 1;
}

.arch-label { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 19px; opacity: 0.78; }
.arch-label-sm { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; opacity: 0.62; }
.arch-zone { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; font-weight: 600; letter-spacing: 0.22em; opacity: 0.7; }

/* edges: marching-ants flow once active (opacity driven by the scroll timeline) */
.arch-edge {
    stroke-dasharray: 6 8;
    animation: arch-march 1s linear infinite;
}
.arch-edge-dim {
    stroke-dasharray: 2 7;
    animation: arch-march 2.4s linear infinite;
}
@keyframes arch-march { to { stroke-dashoffset: -28; } }

.arch-accent { transform-box: fill-box; transform-origin: center; animation: ag-pulse 2.6s ease-in-out infinite; }

/* Terminal card — sits above the diagram (in flow) with clear spacing, so it
   never overlaps the zones. Always a dark code surface, separated on either band. */
.arch-term {
    align-self: center;
    z-index: 2;
    direction: ltr;
    text-align: left;
    max-width: 360px;
    background: #14122e;
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

/* Mobile: vertical zone-flow instead of the wide diagram */
.arch-mobile { display: none; }

@media (max-width: 1023px) {
    .arch-pin { min-height: auto; padding: 3.5rem 0; gap: 1.75rem; }
    .arch-stage { gap: 1.75rem; }
    .arch-term { margin: 0 1.25rem; width: max-content; max-width: calc(100% - 2.5rem); }
    .arch-glow { display: none; }
    .arch-scroll { display: none; }

    .arch-mobile {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        padding: 0 1.25rem;
    }
    .arch-m-zone {
        width: 100%;
        max-width: 440px;
        border: 1px dashed rgba(99, 102, 241, 0.4);
        border-radius: 16px;
        background: rgba(99, 102, 241, 0.05);
        padding: 1.1rem 1.2rem 1.25rem;
    }
    .arch-m-zone-label { display: block; margin-bottom: 0.95rem; }
    .arch-m-chips { display: flex; flex-wrap: wrap; gap: 8px; }
    .arch-m-chip {
        border: 1.5px solid #6366F1;
        border-radius: 9px;
        padding: 7px 13px;
        font-family: 'JetBrains Mono', 'Tajawal', ui-monospace, monospace;
        font-size: 12.5px;
        line-height: 1.2;
        color: inherit;
    }
    .arch-m-arrow {
        color: #6366F1;
        font-size: 20px;
        line-height: 1;
        padding: 11px 0;
    }
}

.arch-term-dots { display: flex; gap: 7px; margin-bottom: 12px; }
.arch-term-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.arch-term-body { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; line-height: 1.7; color: rgba(255, 255, 255, 0.85); }
.arch-term-body .p { color: rgba(255, 255, 255, 0.32); }
.arch-term-body .ok { color: #34D399; }
.arch-final { color: #8B8DF5; margin-top: 4px; }

.arch-cmd-wrap { display: inline-block; overflow: hidden; white-space: nowrap; vertical-align: bottom; }
.arch-cmd { display: inline-block; white-space: nowrap; }
.arch-cursor { display: inline-block; width: 8px; height: 14px; background: #6366F1; vertical-align: -2px; margin-left: 2px; animation: ag-blink 1.1s steps(1, end) infinite; }

@media (prefers-reduced-motion: reduce) {
    .ag-blink, .ag-pulse, .ag-ping, .ag-flow, .ag-rise, .ag-glow, .ag-hover, .ag-flame,
    .arch-edge, .arch-accent, .arch-cursor {
        animation: none;
    }
    .ag-ping { opacity: 0; }
    .ag-pulse, .ag-rise, .ag-hover, .ag-flame { opacity: 1; transform: none; }
    .ag-glow { opacity: 0.85; }
}
