/* ===== Portfolio — Editorial Design System ===== */

/* ── Reset & Base ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Light Theme (default) ── */
:root {
    --bg: #f8f6f3;
    --text: #0a0a0a;
    --body-color: #5a5652;
    --muted: #8a8580;
    --accent: #c4553a;
    --border: rgba(0, 0, 0, .06);
    --radius: 4px;
    --radius-sm: 2px;
    --font-display: 'Playfair Display', serif;
    --font-body: 'DM Sans', sans-serif;
    --sidebar-w: 200px;
}

/* ── Dark Theme ── */
body.dark {
    --bg: #1a1917;
    --text: #f0ede8;
    --body-color: #b0aaa4;
    --muted: #7a7570;
    --accent: #d4694f;
    --border: rgba(255, 255, 255, .08);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: -webkit-fill-available;
    min-height: 100vh;
    overflow: hidden;
    transition: background .35s ease, color .25s ease;
}

/* Grain / noise texture overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.035;
    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)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    border: none;
    cursor: pointer;
}

/* ── Focus-visible for keyboard accessibility ── */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Top Utility Bar (PRESERVED) ── */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: 36px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.topbar__left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar__link {
    color: var(--muted);
    font-weight: 400;
    letter-spacing: .3px;
    transition: color .2s ease;
}

.topbar__link:hover {
    color: var(--text);
}

.topbar__right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar__social {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar__cta {
    color: var(--text);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: color .2s ease, border-color .2s ease;
}

.topbar__cta:hover {
    color: var(--text);
    border-color: var(--text);
}

/* ── Sidebar (PRESERVED) ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding: 36px 28px 28px;
    z-index: 100;
    border-right: 1px solid var(--border);
}

.sidebar__top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 48px;
}

.sidebar__logo-mark {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.sidebar__logo-mark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    transform: translate(-50%, -50%);
}

.sidebar__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: default;
}

.brand__text {
    font-family: var(--font-body);
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
    letter-spacing: 3px;
}

.brand__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

/* Navigation */
.sidebar__nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow-y: auto;
}

.nav-group__label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 10px;
    padding-left: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    cursor: pointer;
    margin-bottom: 4px;
    position: relative;
    border: 1px solid transparent;
}

.nav-item__num {
    display: none;
}

/* Icons hidden on desktop — shown on mobile only */
.nav-item__icon {
    display: none;
}

/* Hover — subtle glass hint */
.nav-item:hover {
    color: var(--text);
    background: rgba(196, 85, 58, 0.04);
    border-color: rgba(196, 85, 58, 0.06);
}

/* Active — full glassmorphism pill */
.nav-item.active {
    color: var(--text);
    font-weight: 500;
    background: linear-gradient(135deg,
            rgba(196, 85, 58, 0.10) 0%,
            rgba(196, 85, 58, 0.05) 50%,
            rgba(215, 170, 140, 0.08) 100%);
    border-color: rgba(196, 85, 58, 0.15);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        inset 0 -1px 0 rgba(196, 85, 58, 0.05),
        0 2px 8px rgba(196, 85, 58, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
}

.nav-item.active .nav-item__num {
    color: var(--accent);
}

/* Dark mode glass variants */
body.dark .nav-item:hover {
    background: rgba(212, 105, 79, 0.06);
    border-color: rgba(212, 105, 79, 0.08);
}

body.dark .nav-item.active {
    background: linear-gradient(135deg,
            rgba(212, 105, 79, 0.12) 0%,
            rgba(212, 105, 79, 0.06) 50%,
            rgba(180, 120, 90, 0.08) 100%);
    border-color: rgba(212, 105, 79, 0.18);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(212, 105, 79, 0.05),
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* Sidebar Bottom */
.sidebar__bottom {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar__resume {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    padding: 8px 4px;
    transition: color .2s ease;
}

.sidebar__resume:hover {
    color: var(--text);
}

/* Social Links (in topbar) */
.social-link {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color .2s ease;
}

.social-link:hover {
    color: var(--text);
}

/* ── Main Content ── */
.main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    height: 100vh;
    height: 100dvh;
    /* dynamic viewport height — Safari 15.4+ */
    overflow-y: auto;
    padding: 36px 0 0;
    scroll-behavior: smooth;
}

/* ── Theme Toggle Button (inside topbar) ── */
.theme-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer;
    transition: color .2s ease, border-color .2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--text);
}

.theme-toggle__icon--sun {
    display: none;
}

.theme-toggle__icon--moon {
    display: block;
}

body.dark .theme-toggle__icon--sun {
    display: block;
}

body.dark .theme-toggle__icon--moon {
    display: none;
}

/* ════════════════════════════════════════════ */
/* HERO SECTION                                */
/* ════════════════════════════════════════════ */
.hero {
    min-height: calc(100vh - 36px);
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    padding: 60px 56px 60px 56px;
    position: relative;
    overflow: hidden;
}

.hero__content {
    animation: heroFadeIn 0.8s ease both;
    max-width: 60%;
    position: relative;
    z-index: 1;
}

@keyframes heroFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero__headline {
    font-family: var(--font-body);
    font-size: clamp(52px, 7vw, 110px);
    font-weight: 300;
    line-height: 1.02;
    letter-spacing: -3px;
    color: var(--text);
    margin-bottom: 28px;
}

.hero__headline em {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
}

.hero__subline {
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--body-color);
    line-height: 1.65;
    max-width: 480px;
    margin-bottom: 2rem;
}

/* Hero Stats */
.hero__stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(12px);
    animation: statsFadeIn .6s ease forwards;
    animation-delay: .4s;
}

@keyframes statsFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero__stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hero__stat-num,
.hero__stat-suffix {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 500;
}

.hero__stat-num {
    color: var(--text);
}

.hero__stat-suffix {
    color: var(--accent);
}

.hero__stat-label {
    font-size: .75rem;
    color: var(--muted);
    letter-spacing: .4px;
    text-transform: uppercase;
}

.hero__stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
}

.hero__cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent);
    padding: 14px 0;
    border-bottom: 1.5px solid var(--accent);
    transition: gap .25s ease;
    letter-spacing: .3px;
}

.hero__cta:hover {
    gap: 14px;
}

.hero__cta-arrow {
    transition: transform .25s ease;
}

.hero__cta:hover .hero__cta-arrow {
    transform: translateX(4px);
}

/* Hero Visual — positioned to align with headline baseline */
.hero__visual {
    position: absolute;
    right: 12%;
    z-index: 2;
}

.hero__still {
    width: 180px;
    height: 240px;
    aspect-ratio: auto;
    background: linear-gradient(145deg, #e8e3dc, #d5cfc7);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    transition: width 0.3s ease, height 0.3s ease;
}

.hero__still::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(248, 246, 243, 0.15) 100%);
    pointer-events: none;
    z-index: 1;
}

body.dark .hero__still {
    background: linear-gradient(145deg, #2a2825, #1f1e1b);
}

body.dark .hero__still::after {
    background: linear-gradient(180deg, transparent 60%, rgba(26, 25, 23, 0.2) 100%);
}

.hero__still-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    opacity: 0.6;
}

.hero__photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    filter: grayscale(0.08) contrast(1.02);
    pointer-events: none;
}

.hero__still-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    opacity: 0;
    transition: opacity .2s ease;
}

.hero__still:hover .hero__still-resize {
    opacity: 0.5;
}


/* ════════════════════════════════════════════ */
/* SECTION LABEL                               */
/* ════════════════════════════════════════════ */
.section-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 40px;
}


/* ════════════════════════════════════════════ */
/* WORK / CASE STUDIES                         */
/* ════════════════════════════════════════════ */
.work {
    padding: 80px 56px 100px;
    border-top: 1px solid var(--border);
}

.case-studies {
    display: grid;
    grid-template-columns: 1fr;
    gap: 64px;
}

.case-card {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 40px;
    align-items: center;
}

.case-card:nth-child(even) {
    grid-template-columns: 1fr 1.2fr;
}

.case-card:nth-child(even) .case-card__img-link,
.case-card:nth-child(even) .case-card__img {
    order: 2;
}

.case-card:nth-child(even) .case-card__body {
    order: 1;
}

.case-card__img-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.case-card__img {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(145deg, #e0dbd4, #cdc7be);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s ease;
}

body.dark .case-card__img {
    background: linear-gradient(145deg, #2a2825, #1f1e1b);
}

.case-card:hover .case-card__img {
    transform: scale(1.03);
}

.case-card__img-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    opacity: 0.5;
}

.case-card__body {
    padding: 8px 0;
}

.case-card__title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.2;
}

.case-card__desc {
    font-size: 1rem;
    color: var(--body-color);
    line-height: 1.65;
    margin-bottom: 20px;
    max-width: 400px;
}

.case-card__link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: .3px;
    transition: gap .2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.case-card__arrow {
    display: inline-block;
    transition: transform .25s ease;
}

.case-card__link:hover .case-card__arrow {
    transform: translateX(4px);
}


/* Keep Subaru card layout matching first card (image left, text right) */
#case-subaru {
    grid-template-columns: 1.2fr 1fr;
}

#case-subaru .case-card__img,
#case-subaru .case-card__body {
    order: 0;
}

@media (max-width: 1100px) {
    #case-subaru {
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════ */
/* ABOUT SECTION                               */
/* ════════════════════════════════════════════ */
.about {
    padding: 80px 56px 100px;
    border-top: 1px solid var(--border);
}

.about__grid {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 56px;
    align-items: center;
}

.about__photo {
    width: 100%;
    max-width: 380px;
    aspect-ratio: 3 / 4;
    border-radius: 24px 4px 24px 4px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .08);
    transition: border-radius .4s ease, box-shadow .3s ease;
}

.about__photo:hover {
    border-radius: 4px 24px 4px 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .12);
}

body.dark .about__photo {
    box-shadow: 0 8px 32px rgba(0, 0, 0, .25);
}

.about__photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    display: block;
}

.about__text {
    padding-top: 12px;
}

.about__text p {
    font-size: 1.05rem;
    color: var(--body-color);
    line-height: 1.65;
    margin-bottom: 18px;
    max-width: 520px;
}

.about__text p:last-child {
    margin-bottom: 0;
}

.about__contact-link {
    color: var(--accent);
    font-weight: 500;
    transition: opacity .2s ease;
}

.about__contact-link:hover {
    opacity: 0.75;
}


/* ════════════════════════════════════════════ */
/* FOOTER                                      */
/* ════════════════════════════════════════════ */
.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 56px;
    border-top: 1px solid var(--border);
}

.footer__email {
    font-size: 0.875rem;
    color: var(--muted);
    transition: color .2s ease;
    letter-spacing: .2px;
}

.footer__email:hover {
    color: var(--text);
}

.footer__social {
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer__social a {
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s ease;
}

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


/* ════════════════════════════════════════════ */
/* FILM OVERLAY (dark mode transition)         */
/* ════════════════════════════════════════════ */
#film-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    display: none;
}


/* ════════════════════════════════════════════ */
/* REVEAL ANIMATION (Intersection Observer)    */
/* ════════════════════════════════════════════ */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

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


/* ════════════════════════════════════════════ */
/* RESPONSIVE                                  */
/* ════════════════════════════════════════════ */

@media (max-width: 1100px) {
    .hero {
        padding: 48px 40px 60px;
    }

    .hero__content {
        max-width: 55%;
    }

    .hero__visual {
        right: 8%;
    }

    .hero__still {
        width: 160px;
        height: 210px;
    }

    .case-card {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .case-card:nth-child(even) {
        grid-template-columns: 1fr;
    }

    .case-card:nth-child(even) .case-card__img-link,
    .case-card:nth-child(even) .case-card__img {
        order: 0;
    }

    .case-card:nth-child(even) .case-card__body {
        order: 0;
    }

    .work,
    .about {
        padding: 60px 40px 80px;
    }

    .about__grid {
        grid-template-columns: 1fr 2fr;
        gap: 40px;
    }

    .footer {
        padding: 28px 40px;
    }
}

@media (max-width: 820px) {
    .sidebar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 6px 8px;
        /* Safari home indicator safe zone */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 200;
        background: var(--bg);
        transition: transform 0.3s ease;
    }

    /* Scroll-hide: slide nav bar below the viewport */
    .sidebar--hidden {
        transform: translateY(110%);
    }


    .sidebar__top,
    .sidebar__bottom,
    .nav-group__label {
        display: none;
    }

    .sidebar__nav {
        flex-direction: row;
        gap: 0;
        overflow-x: auto;
        width: 100%;
        justify-content: space-around;
    }

    .hide-mobile {
        display: none !important;
    }

    .nav-group {
        display: flex;
        gap: 0;
    }

    /* Icon-only nav items */
    .nav-item {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 10px;
        font-size: 13px;
        white-space: nowrap;
        border-radius: 10px;
        border: 1px solid transparent;
        margin-bottom: 0;
    }

    .nav-item__icon {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--muted);
        transition: color 0.2s ease;
    }

    .nav-item__icon svg {
        width: 20px;
        height: 20px;
    }

    .nav-item__text {
        font-size: 9px;
        font-weight: 500;
        letter-spacing: 0.3px;
        color: var(--muted);
        transition: color 0.2s ease;
    }

    .nav-item__num {
        display: none;
    }

    /* Active state on mobile */
    .nav-item.active {
        background: rgba(196, 85, 58, 0.08);
        border-color: rgba(196, 85, 58, 0.10);
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .nav-item.active .nav-item__icon {
        color: var(--accent);
    }

    .nav-item.active .nav-item__text {
        color: var(--accent);
    }

    /* Hover on mobile */
    .nav-item:hover .nav-item__icon {
        color: var(--text);
    }

    .nav-item:hover .nav-item__text {
        color: var(--text);
    }

    .topbar {
        left: 0;
        padding: 0 16px;
    }

    .topbar__left {
        display: none;
    }

    .topbar__right {
        width: 100%;
        justify-content: space-between;
    }

    .topbar__cta {
        padding: 5px 10px;
        font-size: 10px;
        white-space: nowrap;
    }

    .main {
        margin-left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        /* Bottom padding = nav bar height + safe area + extra breathe room */
        padding: 36px 0 calc(90px + env(safe-area-inset-bottom, 16px));
    }

    .hero {
        min-height: auto;
        padding: 48px 24px 60px;
    }

    .hero__content {
        max-width: 100%;
    }

    .hero__visual {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        margin-top: 24px;
    }

    .hero__still {
        width: 140px;
        height: 180px;
    }

    .work,
    .about {
        padding: 48px 24px 64px;
    }

    .about__grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .about__photo {
        max-width: 220px;
    }

    .footer {
        padding: 24px;
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .theme-toggle {
        width: 24px;
        height: 24px;
    }

    .case-studies {
        gap: 48px;
    }
}