/* ==========================================================================
   Portfolio page styles
   Extracted from portfolio.php for browser caching and maintainability.
   Only rules actually used by portfolio.php are kept here.
   ========================================================================== */

:root {
    --brand-teal: #2dd4bf;
    --brand-teal-glow: rgba(45, 212, 191, 0.25);
    --bg-dark-os: #080c14;
}

body {
    background-color: var(--bg-dark-os);
    color: #f8fafc;
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
}

html.rtl body,
html[lang="ar"] body {
    font-family: 'Cairo', sans-serif;
}

/* Ambient OS Backdrop Wall */
.os-ambient-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 900px;
    background:
        radial-gradient(circle at 50% 10%, rgba(99, 102, 241, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 80% 30%, rgba(45, 212, 191, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 20% 40%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Search Launcher Pill */
.os-search-container {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(25px) saturate(190%);
    -webkit-backdrop-filter: blur(25px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9999px;
    padding: 8px 10px 8px 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.os-search-container:focus-within {
    border-color: rgba(45, 212, 191, 0.5);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(45, 212, 191, 0.2);
}

.os-search-btn {
    background: #ffffff;
    color: #070b12;
    font-weight: 800;
    border-radius: 9999px;
    padding: 10px 28px;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    cursor: pointer;
}

.os-search-btn:hover {
    background: #2dd4bf;
    color: #070b12;
    box-shadow: 0 0 20px rgba(45, 212, 191, 0.6);
    transform: scale(1.03);
}

/* Latest-work layout */
.td-work-shell {
    width: min(100% - 3rem, 86rem);
    margin-inline: auto;
}

.td-latest {
    padding: clamp(3rem, 5.8vw, 5rem) 0 2.65rem;
}

.td-latest-layout {
    display: grid;
    grid-template-columns: minmax(15rem, .5fr) minmax(0, 1.6fr);
    align-items: center;
    gap: clamp(2.4rem, 5.5vw, 5.7rem);
}

.td-eyebrow {
    margin: 0 0 .8rem;
    color: #5eead4;
    font-size: .71rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.td-latest-copy h1 {
    max-width: 11ch;
    margin: 0;
    color: #f8fafc;
    font-family: 'Syne', 'Outfit', sans-serif;
    font-size: clamp(2.18rem, 3.65vw, 3.7rem);
    line-height: 1.05;
    letter-spacing: -.055em;
    text-wrap: balance;
}

.td-latest-copy>p:not(.td-eyebrow) {
    max-width: 30rem;
    margin: 1.1rem 0 1.5rem;
    color: #aebdce;
    font-size: .95rem;
    line-height: 1.7;
}

.td-inline-link {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    color: #b9fff4;
    border: 1px solid rgba(45, 212, 191, .36);
    border-radius: .8rem;
    padding: .72rem 1rem;
    font-size: .84rem;
    font-weight: 800;
    text-decoration: none !important;
    transition: color .2s ease, background .2s ease, transform .2s ease;
}

.td-inline-link:hover {
    color: #06201e;
    background: #5eead4;
    transform: translateY(-1px);
}

/* Rails / carousels */
.td-latest-rail,
.td-category-rail {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scroll-padding-inline: 1px;
    scrollbar-width: none;
    padding: 1px 0 .8rem;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    cursor: grab;
}

.td-latest-rail:active,
.td-category-rail:active {
    cursor: grabbing;
}

.td-latest-rail {
    padding-bottom: 1rem;
    padding-inline-end: 2rem;
}

.td-latest-rail::-webkit-scrollbar,
.td-category-rail::-webkit-scrollbar,
.td-category-nav::-webkit-scrollbar {
    display: none;
}

/* Rail cards */
.td-rail-card {
    flex: 0 0 clamp(16rem, 22vw, 19rem);
    scroll-snap-align: start;
    min-width: 0;
}

.td-rail-card--latest {
    flex-basis: clamp(17rem, 24vw, 21.5rem);
}

.td-rail-card--lead {
    flex-basis: clamp(19.5rem, 28.5vw, 25rem);
}

.td-rail-card-link {
    display: block;
    height: 100%;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 1rem;
    background: rgba(10, 24, 39, .52);
    color: inherit;
    text-decoration: none !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
    transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}

.td-rail-card-link:hover {
    border-color: rgba(94, 234, 212, .56);
    transform: translateY(-2px);
    box-shadow: 0 18px 32px rgba(2, 8, 23, .32);
}

.td-rail-card-link:focus-visible,
.td-carousel-button:focus-visible,
.td-category-button:focus-visible {
    outline: 3px solid #5eead4;
    outline-offset: 4px;
}

.td-rail-media {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #0b1726;
}

.td-rail-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .55s cubic-bezier(.16, 1, .3, 1);
}

.td-rail-card-link:hover .td-rail-media img {
    transform: scale(1.03);
    filter: brightness(1.06) saturate(1.04);
}

.td-rail-media-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(2, 10, 20, .08), rgba(2, 10, 20, .7));
}

.td-rail-badge {
    position: absolute;
    top: .7rem;
    inset-inline-start: .7rem;
    max-width: calc(100% - 1.4rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid rgba(94, 234, 212, .38);
    border-radius: 999px;
    background: rgba(5, 22, 34, .76);
    color: #cafff7;
    padding: .28rem .52rem;
    font-size: .61rem;
    font-weight: 800;
    letter-spacing: .055em;
    text-transform: uppercase;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.td-rail-copy {
    display: flex;
    min-height: 7.9rem;
    flex-direction: column;
    padding: .85rem .9rem .8rem;
}

.td-rail-copy h3 {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    color: #f1f5f9;
    font-size: .94rem;
    font-weight: 800;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-wrap: pretty;
}

.td-rail-copy p {
    display: -webkit-box;
    min-height: 2.4em;
    overflow: hidden;
    margin: .42rem 0 .65rem;
    color: #aab9c9;
    font-size: .76rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.td-rail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    margin-top: auto;
    color: #94a3b8;
    font-size: .68rem;
    font-weight: 600;
}

.td-rail-meta>span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-rail-meta i {
    color: #5eead4;
    margin-inline-end: .32rem;
}

.td-rail-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex: 0 0 1.65rem;
    width: 1.65rem;
    height: 1.65rem;
    border: 1px solid rgba(94, 234, 212, .3);
    border-radius: 50%;
    color: #5eead4;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.td-rail-arrow i {
    display: block;
    margin: 0 !important;
    line-height: 1 !important;
    transform: translateY(-.5px);
}

.td-rail-card-link:hover .td-rail-arrow {
    background: #5eead4;
    color: #04201d;
    transform: translateX(3px);
}

.td-rail-card-link:hover .td-rail-arrow i,
.td-rail-card-link:focus-visible .td-rail-arrow i {
    color: #04201d;
}

/* Category browser */
.td-category-browser {
    padding: 1.2rem 0 3.6rem;
}

.td-category-nav {
    display: flex;
    gap: .72rem;
    overflow-x: auto;
    padding: .25rem 0 1rem;
    scrollbar-width: none;
}

.td-category-button {
    display: inline-flex;
    min-width: 8.15rem;
    min-height: 4.9rem;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    gap: .38rem;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: .9rem;
    background: rgba(15, 29, 45, .44);
    color: #b7c4d3;
    padding: .7rem .85rem;
    text-align: start;
    transition: border-color .22s ease, background .22s ease, color .22s ease, transform .22s ease;
}

.td-category-button i {
    color: #5eead4;
    font-size: 1rem;
}

.td-category-button span {
    font-size: .73rem;
    font-weight: 800;
}

.td-category-button small {
    color: #7e8da0;
    font-size: .64rem;
}

.td-category-button:hover,
.td-category-button.is-active {
    border-color: rgba(45, 212, 191, .48);
    background: rgba(13, 148, 136, .14);
    color: #d9fffa;
    transform: translateY(-1px);
}

.td-category-section {
    scroll-margin-top: 7.5rem;
    padding: 2.05rem 0 1.1rem;
    border-top: 1px solid rgba(148, 163, 184, .12);
    border-image: linear-gradient(90deg, transparent, rgba(94, 234, 212, .24), rgba(148, 163, 184, .1), transparent) 1;
}

.td-category-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .9rem;
}

.td-category-title {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    min-width: 0;
    margin: 0;
    color: #f1f5f9;
    font-size: clamp(1.05rem, 1.45vw, 1.28rem);
    font-weight: 800;
    letter-spacing: -.025em;
}

.td-category-title::before {
    content: '';
    width: .18rem;
    height: 1.1em;
    border-radius: 99px;
    background: #2dd4bf;
    box-shadow: 0 0 12px rgba(45, 212, 191, .25);
}

.td-category-title span {
    color: #8190a1;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: 0;
}

.td-category-actions {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.td-category-view {
    color: #5eead4;
    font-size: .72rem;
    font-weight: 800;
    text-decoration: none !important;
    white-space: nowrap;
}

.td-carousel-button {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border: 1px solid rgba(94, 234, 212, .26);
    border-radius: 50%;
    background: rgba(7, 21, 34, .55);
    color: #a8fff4;
    transition: background .2s ease, color .2s ease, opacity .2s ease;
}

.td-carousel-button:hover:not(:disabled) {
    background: #5eead4;
    color: #06201e;
}

.td-carousel-button:disabled {
    cursor: not-allowed;
    opacity: .35;
    border-color: rgba(148, 163, 184, .12);
    background: rgba(15, 23, 42, .28);
    color: #718096;
}

/* Search state / empty state */
.td-search-shell {
    width: min(100% - 3rem, 64rem);
    margin-inline: auto;
}

.td-search-shell .os-search-container {
    background: rgba(15, 23, 42, .57);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .09);
}

.td-search-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.2rem 0 -.2rem;
    color: #cbd5e1;
    font-size: .88rem;
}

.td-search-state strong {
    color: #5eead4;
}

body.td-search-active #portfolio-latest,
body.td-search-active #portfolio-category-nav {
    display: none;
}

body.td-search-active .td-category-browser {
    padding-top: 1.4rem;
}

.td-empty-search {
    padding: 3.5rem 1.2rem;
    text-align: center;
    border: 1px solid rgba(148, 163, 184, .14);
    border-radius: 1rem;
    color: #9eafc0;
}

.td-empty-search h2 {
    color: #f1f5f9;
    font-size: 1.25rem;
    margin: 0 0 .5rem;
}

/* Keep content visible even if entrance scripts are delayed or unavailable. */
#page-content .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
}

/* Footer micro-polish */
#page-content footer .text-xs {
    font-size: .8125rem;
    line-height: 1.55;
}

/* Rail edge fade masks */
.td-latest-rail {
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 2.5rem), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 2.5rem), transparent 100%);
}

html[dir="rtl"] .td-latest-rail {
    mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 2.5rem), transparent 100%);
    -webkit-mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 2.5rem), transparent 100%);
}

/* Light theme */
body.tt-light-style-on {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

body.tt-light-style-on .os-ambient-bg {
    opacity: 0.2;
}

body.tt-light-style-on .os-search-container {
    background: rgba(255, 255, 255, .8) !important;
    border-color: rgba(226, 232, 240, .9) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .06) !important;
}

body.tt-light-style-on .os-search-btn {
    background: #0f172a !important;
    color: #ffffff !important;
}

body.tt-light-style-on .td-latest {
    background: radial-gradient(circle at 72% 35%, rgba(45, 212, 191, .10), transparent 35%), linear-gradient(180deg, rgba(255, 255, 255, .4), transparent);
}

body.tt-light-style-on .td-eyebrow,
body.tt-light-style-on .td-category-view {
    color: #0f8f82;
}

body.tt-light-style-on .td-inline-link {
    color: #0f766e;
    border-color: rgba(13, 148, 136, .42);
    background: rgba(255, 255, 255, .55);
}

body.tt-light-style-on .td-inline-link:hover {
    color: #fff;
    background: #0f9488;
}

body.tt-light-style-on .td-search-shell .os-search-container {
    background: rgba(255, 255, 255, .92) !important;
    border-color: rgba(148, 163, 184, .3) !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .08) !important;
}

body.tt-light-style-on .td-search-shell input {
    color: #172554 !important;
}

body.tt-light-style-on .td-search-shell input::placeholder {
    color: #64748b !important;
}

body.tt-light-style-on .td-rail-card-link {
    background: rgba(255, 255, 255, .94);
    border-color: rgba(148, 163, 184, .3);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .055);
}

body.tt-light-style-on .td-rail-card-link:hover {
    border-color: rgba(13, 148, 136, .58);
    box-shadow: 0 14px 26px rgba(15, 23, 42, .1);
}

body.tt-light-style-on .td-rail-copy h3 {
    color: #0f172a !important;
}

body.tt-light-style-on .td-rail-copy p {
    color: #475569 !important;
}

body.tt-light-style-on .td-rail-meta {
    color: #526277 !important;
}

body.tt-light-style-on .td-rail-badge {
    color: #0f766e;
    background: rgba(255, 255, 255, .84);
    border-color: rgba(13, 148, 136, .42);
}

body.tt-light-style-on .td-rail-arrow {
    color: #0f9488;
    border-color: rgba(13, 148, 136, .28);
    background: #f0fdfa;
}

body.tt-light-style-on .td-rail-card-link:hover .td-rail-arrow {
    background: #0f9488;
}

body.tt-light-style-on .td-rail-card-link:hover .td-rail-arrow i {
    color: #fff;
}

body.tt-light-style-on .td-category-button {
    color: #1e293b;
    background: rgba(255, 255, 255, .9);
    border-color: rgba(148, 163, 184, .28);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
}

body.tt-light-style-on .td-category-button small {
    color: #64748b;
}

body.tt-light-style-on .td-category-button:hover,
body.tt-light-style-on .td-category-button.is-active {
    color: #0f766e;
    background: #f0fdfa;
    border-color: rgba(13, 148, 136, .52);
}

body.tt-light-style-on .td-category-title {
    color: #0f172a !important;
}

body.tt-light-style-on .td-category-title span {
    color: #64748b;
}

body.tt-light-style-on .td-category-section {
    border-image: linear-gradient(90deg, transparent, rgba(13, 148, 136, .24), rgba(100, 116, 139, .18), transparent) 1;
}

body.tt-light-style-on .td-carousel-button {
    color: #0f766e;
    background: #fff;
    border-color: rgba(13, 148, 136, .3);
}

body.tt-light-style-on .td-carousel-button:disabled {
    color: #94a3b8;
    background: #f8fafc;
    border-color: rgba(148, 163, 184, .22);
}

/* Responsive */
@media (max-width: 767px) {
    #content-wrap.pt-28 {
        padding-top: 5rem;
    }

    .td-work-shell {
        width: min(100% - 1.25rem, 86rem);
    }

    .td-latest {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .td-latest-layout {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }

    .td-latest-copy h1 {
        max-width: 13ch;
        font-size: 1.85rem;
    }

    .td-latest-copy>p:not(.td-eyebrow) {
        font-size: .88rem;
        margin-bottom: 1rem;
    }

    .td-eyebrow {
        font-size: .65rem;
        margin-bottom: .5rem;
    }

    .td-inline-link {
        padding: .6rem .85rem;
        font-size: .78rem;
        gap: .5rem;
    }

    .td-latest-rail {
        margin-inline-end: -1rem;
        padding-inline-end: 1rem;
        padding-bottom: .5rem;
    }

    .td-rail-card--latest,
    .td-rail-card--lead {
        flex-basis: 72vw;
    }

    .td-rail-card {
        flex-basis: 66vw;
    }

    .td-rail-copy {
        min-height: 6.5rem;
        padding: .7rem .75rem .65rem;
    }

    .td-rail-copy h3 {
        font-size: .88rem;
    }

    .td-rail-copy p {
        font-size: .72rem;
        margin: .35rem 0 .5rem;
    }

    .td-rail-meta {
        font-size: .65rem;
    }

    .td-rail-badge {
        font-size: .58rem;
        padding: .22rem .44rem;
    }

    .td-rail-arrow {
        width: 1.5rem;
        height: 1.5rem;
    }

    .td-search-shell {
        width: min(100% - 1.25rem, 64rem);
    }

    .td-search-state {
        align-items: flex-start;
        flex-direction: column;
        gap: .5rem;
    }

    .td-category-browser {
        padding-bottom: 2.5rem;
    }

    .td-category-nav {
        margin-inline-end: -1rem;
        padding-inline-end: 1rem;
        gap: .55rem;
        padding-bottom: .65rem;
    }

    .td-category-button {
        min-width: 6.5rem;
        min-height: auto;
        padding: .55rem .75rem;
    }

    .td-category-button i {
        font-size: .88rem;
    }

    .td-category-button span {
        font-size: .7rem;
    }

    .td-category-button small {
        font-size: .6rem;
    }

    .td-category-section {
        padding-top: 1.15rem;
    }

    .td-category-section-head {
        margin-bottom: .55rem;
    }

    .td-category-actions .td-carousel-button {
        display: none;
    }

    .td-category-title {
        font-size: 1rem;
    }

    .td-category-title span {
        font-size: .68rem;
    }

    .td-category-rail {
        gap: .75rem;
    }

    .os-search-container {
        padding: 6px 8px 6px 16px;
        gap: 8px;
    }

    .os-search-btn {
        padding: 8px 18px;
        font-size: .8rem;
    }

    .td-latest-rail {
        padding-inline-end: 1rem;
        mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1.25rem), transparent 100%);
        -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1.25rem), transparent 100%);
    }

    html[dir="rtl"] .td-latest-rail {
        mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 1.25rem), transparent 100%);
        -webkit-mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 1.25rem), transparent 100%);
    }

    .td-category-rail {
        mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1.5rem), transparent 100%);
        -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1.5rem), transparent 100%);
    }

    html[dir="rtl"] .td-category-rail {
        mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 1.5rem), transparent 100%);
        -webkit-mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 1.5rem), transparent 100%);
    }
}

@media (prefers-reduced-motion: reduce) {

    .td-rail-card-link,
    .td-rail-media img,
    .td-category-button,
    .td-carousel-button,
    .td-inline-link,
    .td-rail-arrow,
    .os-search-btn {
        transition: none !important;
    }
}