/* ==========================================================================
   1. THEME VARIABLES (LIGHT & DARK MODE)
   ========================================================================== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-video: #f4f4f4;
    --text-primary: #232323;
    --text-secondary: #555555;
    --text-muted: #919191;
    --border-color: #f0f0f0;
    --border-input: rgba(85, 85, 85, 0.3);
    --border-input-focus: rgba(85, 85, 85, 0.8);
    --input-hover-bg: rgba(85, 85, 85, 0.05);
    --skeleton-base: #f7f7f7;
    --skeleton-pulse: #d4d4d4;

    /* Semantic Colors */
    --color-error: #e63946;
    --color-success: #28a745;
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-video: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #757575;
    --border-color: #333333;
    --border-input: rgba(255, 255, 255, 0.2);
    --border-input-focus: rgba(255, 255, 255, 0.6);
    --input-hover-bg: rgba(255, 255, 255, 0.05);
    --skeleton-base: #1c1c1c;
    --skeleton-pulse: #444444;
}

[data-theme="dark"] .dark-icon { display: none !important; }
[data-theme="dark"] .light-icon { display: inline-block !important; }
[data-theme="dark"] .logo-image { filter: invert(1); }

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
@view-transition {
    navigation: auto;
}

html {
    box-sizing: border-box;
    font-family: sans-serif;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: 'Work Sans', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: var(--text-muted);
    text-decoration: underline;
    background-color: transparent;
}

a:hover, a:focus {
    color: var(--text-muted);
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: normal;
    text-rendering: optimizeLegibility;
}

/* Base Images & Protections */
img {
    border: 0;
    max-width: 100%;
    height: auto;
    display: block;
    color: transparent;
    font-size: 0;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.gallery-item-link,
.image-with-placeholder {
    -webkit-touch-callout: none;
    user-select: none;
}

.image-with-placeholder img,
.project-image img {
    pointer-events: none;
}

/* ==========================================================================
   SKELETON LOADING ANIMATION
   ========================================================================== */
@keyframes skeleton-pulse {
    0% { background-color: var(--skeleton-base); }
    100% { background-color: var(--skeleton-pulse); }
}

/* Apply pulse to the WRAPPERS */
.project-image,
.full-width,
.centered-image,
.image-with-placeholder,
.video-wrapper-16-9 {
    background-color: var(--skeleton-base);
    animation: skeleton-pulse 0.8s infinite alternate ease-in-out;
    border-radius: 2px;
}

/* Give standard project wrappers a default minimum height */
.project-image,
.full-width,
.centered-image {
    min-height: 300px;
}

/* Stop the animation and clear the background once loaded */
.is-loaded-wrapper {
    animation: none !important;
    background-color: transparent !important;
}

/* Hide media initially so you don't see the top-to-bottom network paint */
.project-image img,
.full-width img,
.centered-image img,
.image-with-placeholder img,
.image-with-placeholder video,
.video-wrapper-16-9 iframe,
.project-video video {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

/* Class applied by JS once 100% downloaded */
.media-loaded {
    opacity: 1 !important;
}

/* ==========================================================================
   MISSING MEDIA FALLBACK (WIREFRAME)
   ========================================================================== */
.media-failed-wrapper {
    animation: none !important;
    background: repeating-linear-gradient(
        45deg,
        var(--bg-secondary),
        var(--bg-secondary) 10px,
        var(--skeleton-base) 10px,
        var(--skeleton-base) 20px
    ) !important;
    border: 1px solid var(--border-color);
}

/* ==========================================================================
   3. GLOBAL LAYOUT (HEADER & FOOTER)
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Logo */
.logo {
    text-align: center;
    padding: 40px 0 20px 0;
}

.logo .logo-link {
    height: 46px;
    display: inline-block;
}

.logo-link img {
    height: 100%;
    width: auto;
    max-height: 200px;
    margin: 0 auto;
}

/* Desktop Navigation */
.menu {
    text-align: center;
    margin-bottom: 40px;
}

.menu-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    padding: 0 20px;
    margin-bottom: 10px;
}

.item-link {
    color: var(--text-primary);
    font-size: 16px;
    text-decoration: none;
    outline: 0;
    transition: opacity 0.2s ease;
}

.item-link:hover {
    opacity: 0.7;
}

.menu .selected > .item-link {
    text-decoration: underline;
}

/* Desktop Dropdown Styling */
.menu-item.category {
    position: relative;
}

.sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    min-width: 260px;
    padding: 10px 0;
    z-index: 200;
    border-radius: 4px;
    list-style-type: none;
}

@media only screen and (min-width: 768px) {
    .menu-item.category:hover .sub-menu {
        display: block;
    }
}

.sub-menu .item {
    text-align: left;
    white-space: nowrap;
}

.sub-menu .item-link {
    font-size: 14px;
    padding: 10px 20px;
    display: block;
}

.sub-menu .item-link:hover {
    background-color: var(--bg-secondary);
}

/* Mobile Header (Hidden on Desktop) */
.header-mobile {
    display: none;
}

.mobile-menu-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    outline: none;
}

.mobile-menu-trigger svg {
    fill: var(--text-primary);
}

.mobile-menu-trigger .menu-active,
.mobile-menu-trigger.active .menu-inactive {
    display: none;
}

.mobile-menu-trigger.active .menu-active {
    display: inline;
}

/* Mobile Menu Fullscreen Overlay */
.mobile-menu {
    position: fixed;
    background-color: var(--bg-primary);
    top: 64px;
    left: 0;
    right: 0;
    height: calc(100dvh - 64px);
    padding-bottom: 20px;
    transition: all 250ms ease-out;
    visibility: hidden;
    transform: translate3d(0, -1%, 0);
    opacity: 0;
    z-index: 20;
    margin: 0;
}

.mobile-menu.active {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translate3d(0, 0, 0);
    visibility: visible;
    opacity: 1;
}

.mobile-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu .menu-list {
    display: block;
    padding: 10px 0;
}

.mobile-menu .menu-item {
    padding: 0;
    margin-bottom: 0;
    text-align: center;
}

.mobile-menu .item-link {
    display: block;
    padding: 6px 0px;
    color: var(--text-primary);
    font-size: 16px;
    text-decoration: none;
}

.mobile-menu .item-link:hover {
    color: var(--text-primary);
}

.mobile-menu .selected > .item-link,
.mobile-menu .item-link.active {
    text-decoration: underline;
}

.mobile-menu .category {
    margin: 15px 0;
}

.mobile-menu .category .category-link {
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 0;
    text-decoration: none !important;
}

.mobile-menu .category .category-link i {
    font-size: 10px;
    margin-left: 8px;
}

.mobile-menu .sub-menu {
    position: static;
    transform: none;
    box-shadow: none;
    background-color: transparent;
    padding: 0;
    display: none;
    min-width: 100%;
}

.mobile-menu .sub-menu .item {
    margin: 0;
}

.mobile-menu .sub-menu .item-link {
    color: var(--text-primary);
    font-size: 16px;
    padding: 4px 20px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 11px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   4. UI COMPONENTS (BUTTONS & FORMS)
   ========================================================================== */
.action-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
    margin: 0 auto;
}

.action-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Contact Form Scoped Styles */
.contact-row {
    max-width: 800px;
    margin: 40px auto 0 auto;
    padding: 40px 20px;
}

.contact-row .contact-header {
    text-align: center;
    margin-bottom: 40px;
}

.contact-row .contact-header h2 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.contact-row .contact-header p {
    color: var(--text-secondary);
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.contact-form .form-row,
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.contact-form .form-group,
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    text-align: left;
}

.contact-form .form-group label,
.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.contact-form .form-group .required {
    color: var(--color-error);
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea,
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    outline: none;
}

.form-group textarea {
    resize: vertical;
}

.contact-form input:hover,
.contact-form textarea:hover {
    background-color: var(--input-hover-bg);
}

.contact-form input::placeholder,
.contact-form textarea::placeholder {
    color: var(--text-muted);
}

.contact-form input:focus,
.contact-form textarea:focus,
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--border-input-focus);
    box-shadow: 0 0 0 1px var(--border-input-focus);
    background-color: transparent;
}

/* Submit Button Logic */
.contact-form .btn-submit,
.btn-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    background-color: var(--text-primary);
    color: var(--bg-primary);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    align-self: flex-start;
    transition: opacity 0.2s ease, transform 0.1s ease, background 250ms ease, border-color 250ms ease;
}

.contact-form .btn-submit:hover,
.btn-submit:hover {
    opacity: 0.85;
    border-color: var(--border-input-focus);
}

.contact-form .btn-submit:active {
    transform: scale(0.98);
}

.contact-form .btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback Messages */
.contact-form .form-feedback {
    padding: 16px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    border: 1px solid transparent;
}

.contact-form .form-feedback.success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
    border-color: var(--color-success);
}

.contact-form .form-feedback.error {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--color-error);
    border-color: var(--color-error);
}

/* ==========================================================================
   5. PAGE SECTIONS (GALLERY & MASONRY)
   ========================================================================== */
.gallery {
    padding-bottom: 60px;
}

.asset-container {
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
}

.asset {
    width: 33.3333%;
    padding: 1px;
    margin: 0;
}

.asset-grid {
    margin: -2px;
}

.gallery-item-link {
    display: block;
    position: relative;
    overflow: hidden;
    cursor: zoom-in;
}

.image-with-placeholder {
    position: relative;
    width: 100%;
}

.image-placeholder {
    width: 100%;
    height: auto;
    display: block;
    display: none !important;
}

.image-with-placeholder img {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    object-fit: unset !important;
    display: block;
}

.image-with-placeholder video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.asset-grid.masonry {
    column-gap: 0 !important;
    gap: 0 !important;
}

.asset-grid.masonry .asset {
    break-inside: avoid;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

.image-with-placeholder,
.gallery-item-link {
    display: block;
    margin: 1px !important;
    padding: 0 !important;
}

.overlay-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.gallery-item-link:hover .overlay-cover {
    opacity: 0.6;
}

.overlay {
    position: absolute;
    bottom: -100%;
    left: 0;
    width: 100%;
    padding: 20px 15px;
    color: var(--bg-primary);
    z-index: 10;
    background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
    transition: bottom 0.4s cubic-bezier(0.215, 0.61, 0.355, 1), opacity 0.3s;
    opacity: 0;
}

.gallery-item-link:hover .overlay {
    bottom: 0;
    opacity: 1;
}

.caption {
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    text-align: left;
    color: #fff;
}

.caption-top {
    margin-top: 0;
}

.video-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #fff;
    font-size: 20px;
    z-index: 10;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   6. PAGE SECTIONS (SINGLE PROJECTS & ABOUT)
   ========================================================================== */
.project-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 20px;
}

.project-row {
    margin-bottom: 60px;
}

.intro-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 40px;
    margin-bottom: 40px;
}

.intro-row .project-text,
.intro-row .project-video,
.intro-row .project-image {
    flex: 1;
    width: 50%;
}

.intro-row h2 {
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 10px;
}

.grid-3-col-auto {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 60px;
}

.grid-3-col-auto .project-image img {
    width: 100%;
    display: block;
}

.text-grid-3-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 60px;
    margin-bottom: 60px;
}

.row-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 40px;
    align-items: start;
}

.sidebar-right-row {
    grid-template-columns: 3fr 1fr;
}

.full-width img {
    width: 100%;
    height: auto;
    display: block;
}

.centered-image {
    margin: 0 auto 60px auto;
    text-align: center;
}

.centered-image img {
    width: 100%;
    height: auto;
    display: block;
}

.image-caption {
    margin-top: 15px;
    font-size: 14px;
    color: var(--text-muted);
}

.credits {
    text-align: center;
    max-width: 600px;
    margin: 80px auto 0 auto;
}

.square-crop-grid .project-image img {
    aspect-ratio: 1 / 1;
}

/* About / Profile Images */
.profile-image-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.profile-image {
    max-width: 400px;
    width: 100%;
    height: auto;
    border-radius: 50%;
    object-fit: cover;
}

/* ==========================================================================
   7. UTILITIES (VIDEO PLAYERS & SWIPER CAROUSEL)
   ========================================================================== */
.project-video {
    position: relative;
}

.project-video video,
.full-width-video {
    width: 100%;
    height: auto;
    display: block;
    background: var(--bg-video);
}

.video-wrapper-16-9 {
    padding: 56.25% 0 0 0;
    position: relative;
    width: 100%;
}

.video-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.sound-toggle-btn {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 5;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.project-video.has-audio .sound-toggle-btn {
    display: flex;
}

.sound-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.05);
}

.project-video.is-unmuted .sound-toggle-btn {
    opacity: 0;
    pointer-events: none;
}

.project-video.is-unmuted:hover .sound-toggle-btn {
    opacity: 1;
    pointer-events: auto;
}

.inline-video-container .project-video,
.inline-video-container .masonry-inline-video {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    object-fit: cover;
}

.masonry-inline-video {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Swiper Slider */
.project-slider {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

.project-slider .swiper-slide {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
}

.project-slider .swiper-slide img {
    max-width: 100%;
    max-height: 600px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.project-slider .swiper-button-next,
.project-slider .swiper-button-prev {
    color: var(--text-primary);
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.project-slider .swiper-button-next:hover,
.project-slider .swiper-button-prev:hover {
    opacity: 1;
}

.project-slider .swiper-pagination-bullet-active {
    background: var(--text-primary);
}

/* ==========================================================================
   8. CONSOLIDATED MEDIA QUERIES
   ========================================================================== */

/* Asset Grid Steps */
@media only screen and (max-width: 800px) {
    .asset { width: 33.3333%; }
}

@media only screen and (max-width: 520px) {
    .asset { width: 50%; }
}

@media only screen and (max-width: 330px) {
    .asset { width: 100%; }
}

/* Primary Mobile Breakpoint (768px & Below) */
@media only screen and (max-width: 768px) {
    /* Layout & Header */
    main { margin-top: 70px !important; }
    .header { display: none; }
    
    .header-mobile {
        display: block;
        background-color: var(--bg-primary);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        transition: transform 280ms ease-out;
    }
    
    .header-mobile.hidden { transform: translate3d(0, -100%, 0); }
    .header-mobile-logo-trigger { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; }
    .header-mobile .logo { padding: 0; }
    .header-mobile .logo-link img { max-height: 50px; }

    .dark-mode-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 10px;
        font-size: 1.5rem;
        background: transparent;
        border: none;
        color: inherit;
        z-index: 99;
    }

    /* Projects */
    .project-container { padding: 40px 20px; }
    .intro-row { flex-direction: column; gap: 20px; }
    .intro-row .project-text,
    .intro-row .project-video,
    .intro-row .project-image { width: 100%; }
    
    .row-1-2 { grid-template-columns: 1fr; gap: 20px; }
    .sidebar-right-row { grid-template-columns: 1fr; }
    .project-row { margin-bottom: 40px; }

    /* About/Contact Forms (Inherited from original 767px query) */
    .form-row { flex-direction: column; gap: 20px; }
    .profile-image { max-width: 280px; }

    /* Utilities (Fancybox overrides) */
    .fancybox__html5video video {
        object-fit: contain !important;
        height: 100vh !important;
        width: 100vw !important;
    }
}

/* Small Device Overrides */
@media (max-width: 600px) {
    .grid-3-col-auto { grid-template-columns: 1fr; }
    .contact-form .form-row { grid-template-columns: 1fr; }
}
