* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background-color: #111111;
    color: #ffffff;
    line-height: 1.5;
    overflow-x: clip;
    max-width: 100%;
    position: relative;
    letter-spacing: -0.02em;
}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background-color: rgba(17, 17, 17, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-content {
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.back-button {
    color: #666666;
    text-decoration: none;
    font-size: 1.04rem;
    font-weight: 500;
    letter-spacing: normal;
    transition: color 0.3s ease;
}

.back-button:hover { color: #ffffff; }

.contact-info a {
    color: #666666;
    text-decoration: none;
    font-size: 1.04rem;
    font-weight: 500;
    letter-spacing: normal;
    transition: color 0.3s ease;
}

.contact-info a:hover { color: #ffffff; }

/* Cover */
.cover-image {
    width: 100%;
    display: block;
}

/* Project Meta Cards */
.project-meta-item {
    display: inline-flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px 28px;
    background-color: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    flex: 1 1 0;
    min-width: 0;
    --mouse-x: 50%;
    --mouse-y: 50%;
}

.project-meta-item::before {
    content: '';
    position: absolute;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 65%);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    left: var(--mouse-x);
    top: var(--mouse-y);
    transform: translate(-50%, -50%);
}

.project-meta-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 1px;
    background: radial-gradient(280px circle at var(--mouse-x) var(--mouse-y),
        rgba(255, 255, 255, 1) 0%,
        rgba(255, 255, 255, 0.6) 20%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.05) 70%,
        transparent 85%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.project-meta-item:hover::before,
.project-meta-item:hover::after { opacity: 1; }

.project-meta-item:hover {
    background-color: #222222;
    border-color: rgba(255, 255, 255, 0.2);
}

.meta-label {
    color: #555555;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.meta-value {
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.6;
}

/* Overview nav thumbnails */
.overview-nav {
    display: flex;
    gap: 8px;
    margin-top: 40px;
    justify-content: center;
}

.overview-nav-item {
    flex: 0 0 220px;
    text-decoration: none;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.overview-nav-item:hover {
    transform: translateY(-6px);
    opacity: 0.85;
}

.overview-nav-item img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}

.overview-nav-item span {
    display: block;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #888888;
    text-align: center;
    letter-spacing: 0.02em;
}

/* Section Meta (inside each section) */
.section-meta {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    margin-bottom: 24px;
    flex-wrap: nowrap;
}

/* Content Sections */
.content-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 40px;
}

.content-section h2 {
    font-size: 2.625rem;
    font-weight: 500;
    line-height: 1.15;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
    color: #ffffff;
    text-align: center;
}

.section-description {
    font-size: 1rem;
    line-height: 1.8;
    color: #888888;
    margin-bottom: 0;
    letter-spacing: 0.02em;
    word-break: keep-all;
    text-align: center;
}

.content-header {
    display: flex;
    align-items: flex-start;
    gap: 40px;
    margin-top: 64px;
    margin-bottom: 24px;
}

.content-title {
    font-size: 1.4rem;
    font-weight: 500;
    color: #ffffff;
    letter-spacing: -0.01em;
    flex: 0 0 420px;
    text-align: left;
    padding-top: 2px;
}

.content-header .section-description {
    flex: 1;
    text-align: left;
    margin-bottom: 0;
}

/* Spacing between content blocks */
.section-description + .section-image-wrap,
.section-description + .side-two-col {
    margin-top: 32px;
}

.section-image-wrap + .section-image-wrap,
.section-image-wrap + .side-two-col,
.side-two-col + .section-image-wrap,
.side-two-col + .side-two-col {
    margin-top: 16px;
}

/* Section Images */
.section-image-wrap {
    border-radius: 8px;
}

.section-image-wrap.no-scale {
    will-change: auto;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.65s ease, transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-image-wrap.no-scale.img-visible {
    opacity: 1;
    transform: translateY(0);
}

.section-image-wrap img,
.section-image-wrap .section-video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.img-bordered {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* Side-by-side two column layout */
.side-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.side-col-img {
    margin-top: 0 !important;
}

.side-two-col .side-col-img {
    height: 100%;
}

.side-two-col .side-col-img img {
    height: 100%;
    object-fit: cover;
}

/* Scroll fade-in for sections */
.animate-target {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-target.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Footer */
footer {
    padding: 48px 40px;
    border-top: 1px solid #222222;
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.footer-nav {
    display: flex;
    gap: 40px;
    align-items: center;
}

.footer-nav-link,
.footer-home {
    color: #555555;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer-nav-link:hover,
.footer-home:hover { color: #ffffff; }

.footer-home {
    color: #ffffff;
    font-weight: 600;
}

.footer-copy {
    color: #444444;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .section-meta {
        flex-wrap: wrap;
    }

    .project-meta-item {
        flex: 1 1 calc(50% - 8px);
    }

    .content-section {
        padding: 56px 20px;
    }

    .content-section h2 {
        font-size: 2rem;
    }

    /* Overview thumbnails: shrink to fit the row instead of overflowing */
    .overview-nav {
        gap: 6px;
    }

    .overview-nav-item {
        flex: 1 1 0;
        min-width: 0;
    }

    .overview-nav-item img {
        height: 96px;
    }

    .overview-nav-item span {
        font-size: 0.72rem;
    }

    /* Section header: stack title above description */
    .content-header {
        flex-direction: column;
        gap: 12px;
        margin-top: 40px;
    }

    .content-title {
        flex: none;
        width: 100%;
    }

    .side-two-col {
        grid-template-columns: 1fr;
    }

    footer {
        padding: 40px 20px;
    }

    .footer-nav {
        gap: 24px;
    }
}

@media (max-width: 480px) {
    .project-meta-item {
        flex: 1 1 100%;
    }
}

/* Video marquee */
.video-marquee {
    overflow: hidden;
    margin-top: 24px;
    margin-bottom: 64px;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding: 0 40px;
}

.video-marquee-track {
    display: flex;
    will-change: transform;
}

.video-marquee-item {
    flex: 0 0 auto;
    margin-right: 8px;
    display: flex;
    flex-direction: column;
}

.video-marquee-video {
    height: 494px;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 12px;
    background-color: #1a1a1a;
}

.video-marquee-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-marquee-caption {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.02em;
}

/* Screen row grids */
.screen-rows-wrap {
    --item-w: calc((100% - 4 * 12px) / 5);
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 56px;
}

.screen-row {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.screen-item {
    flex: 0 0 var(--item-w);
    width: var(--item-w);
    display: flex;
    flex-direction: column;
}

.screen-item .section-image-wrap {
    margin-top: 0 !important;
    flex: 1;
}

.screen-desc {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #888888;
    margin-bottom: 10px;
    letter-spacing: 0.02em;
    word-break: keep-all;
}

/* Stagger per row */
.screen-row .screen-item:nth-child(1) .section-image-wrap.no-scale { transition-delay: 0ms; }
.screen-row .screen-item:nth-child(2) .section-image-wrap.no-scale { transition-delay: 80ms; }
.screen-row .screen-item:nth-child(3) .section-image-wrap.no-scale { transition-delay: 160ms; }
.screen-row .screen-item:nth-child(4) .section-image-wrap.no-scale { transition-delay: 240ms; }

/* Alfrado screen grid (2 rows × 6 cols) */
.alfrado-screen-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.alfrado-screen-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.alfrado-screen-item {
    flex: 0 0 calc((100% - 5 * 12px) / 6);
    width: calc((100% - 5 * 12px) / 6);
    margin-top: 0 !important;
}

/* Video Player */
.video-player-wrap {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.video-player-wrap .section-video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0;
}

.video-scrubber-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 32px 20px 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.video-player-wrap:hover .video-scrubber-overlay {
    opacity: 1;
    pointer-events: auto;
}

.video-scrubber-track {
    position: relative;
    height: 3px;
    background-color: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
}

.video-scrubber-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background-color: #ffffff;
    border-radius: 2px;
    pointer-events: none;
    will-change: width;
}

.video-scrubber-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background-color: #ffffff;
    border-radius: 50%;
    pointer-events: none;
    will-change: left;
    transition: transform 0.1s ease;
}

.video-scrubber-track:hover .video-scrubber-thumb {
    transform: translate(-50%, -50%) scale(1.3);
}

/* ==========================================================================
   Mobile overrides — placed AFTER base rules so they win on equal specificity
   (the .video-marquee/.screen/.alfrado base rules are defined below the
   earlier @media block, so overrides there were being ignored)
   ========================================================================== */
@media (max-width: 768px) {
    /* Header: hide the email on mobile (matches the other project pages) */
    header {
        padding: 12px 16px;
    }

    .contact-info {
        display: none;
    }

    /* Marquee videos: shrink so several are visible at once */
    .video-marquee {
        padding: 0 20px;
    }

    .video-marquee-video {
        height: 250px;
    }

    .video-marquee-caption {
        font-size: 0.75rem;
    }

    /* UX flow screenshots: 2-column grid, every cell the SAME size.
       Ignore the 3/4/3 row grouping so all items flow 1,2 / 3,4 / 5,6 … */
    .screen-rows-wrap {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px 12px;
    }

    .screen-row {
        display: contents;
    }

    .screen-item {
        width: auto;
        min-width: 0; /* let 1fr columns be truly equal width, not sized to
                         each image's intrinsic width */
    }

    /* Fixed phone aspect-ratio box so differing source ratios all render
       at identical size (fills via cover, keeps the top of each screen) */
    .screen-item .section-image-wrap {
        aspect-ratio: 9 / 19;
        overflow: hidden;
        min-width: 0;
    }

    .screen-item .section-image-wrap img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top;
    }

    /* One-line captions (…) so images stay aligned across the row */
    .screen-desc {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Alfrado UI grid: 6-across → 3-across on mobile */
    .alfrado-screen-grid {
        gap: 8px;
    }

    .alfrado-screen-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .alfrado-screen-item {
        flex: 0 0 calc((100% - 2 * 8px) / 3);
        width: calc((100% - 2 * 8px) / 3);
    }
}
