/* ==========================================================================
   MARSHALL MCDONALD PORTFOLIO - STYLESHEET
   
   TABLE OF CONTENTS:
   1. GLOBAL & RESET
   2. TYPOGRAPHY ENFORCEMENT
   3. LAYOUT & STRUCTURE (Sticky Footer, Bleeds, Video Stacking)
   4. CUSTOM BLOCK STYLES (Cards, Buttons, Clickable Groups)
   5. SITE HEADER & NAVIGATION
   6. DRAWER MENU
   7. ANIMATIONS & EFFECTS
   8. PORTFOLIO ARCHIVE (Grid & Filters)
   9. SINGLE PROJECT TEMPLATE
   10. RESPONSIVE UTILITIES
   11. GALLERY SLIDER STYLES
   12. PASSWORD PROTECTION
   13. MASSIVE PRIVATE GALLERY GRID
   14. MAGAZINE POPUP GALLERY (BLOCK CLASS: .magazine-gallery)

   ========================================================================== */

/* ==========================================================================
   1. GLOBAL & RESET
   ========================================================================== */
* { 
    box-sizing: border-box; 
}

html{
  scroll-behavior: smooth;
}

body { 
    overflow-x: hidden; 
    margin: 0; 
    padding-top: 0; 
}

body:not(.home) {
    padding-top: 0px;
}

main {
    display: block;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

main > *:first-child {
    margin-top: 0 !important;
}

footer {
    margin-block-start: 0;
    margin-block-end: 0;
}

svg * {
  vector-effect: non-scaling-stroke;
}


/* ==========================================================================
   2. TYPOGRAPHY ENFORCEMENT
   ========================================================================== */
h1, h2, h3, 
.wp-block-navigation.is-style-h1-look .wp-block-navigation-item__content, 
.wp-block-navigation.is-style-h2-look .wp-block-navigation-item__content, 
.wp-block-navigation.is-style-h3-look .wp-block-navigation-item__content { 
    font-family: var(--wp--preset--font-family--eb-garamond); 
    font-weight: 200; 
    text-transform: none; 
    letter-spacing: normal;
}

h4, .h4, 
.wp-block-navigation.is-style-h4-look .wp-block-navigation-item__content { 
    font-family: var(--wp--preset--font-family--montserrat); 
    font-weight: 200; 
    text-transform: uppercase; 

}

h5, h6, .h5, .h6, 
.wp-block-navigation.is-style-h5-look .wp-block-navigation-item__content, 
.wp-block-navigation.is-style-h6-look .wp-block-navigation-item__content { 
    font-family: var(--wp--preset--font-family--neue-kabel); 
    font-weight: 200; 
    text-transform: uppercase; 
}

body, p, .body, .p, 
.wp-block-navigation.is-style-body-look .wp-block-navigation-item__content { 
    font-family: var(--wp--preset--font-family--neue-kabel); 
    font-weight: 200; 
    font-size: var(--wp--preset--font-size--small); 
    line-height: 1.8; 
}

.wp-block-button__link, .nav-link { 
    font-family: var(--wp--preset--font-family--neue-kabel); 
    font-weight: 100; 
    text-transform: uppercase; 
}


/* ==========================================================================
   3. LAYOUT & STRUCTURE
   ========================================================================== */

/* Neutralize old sticky rules and conflicting min-heights */
body, 
.wp-site-blocks {
    min-height: auto !important; 
}

footer,
.site-footer,
.force-bottom-footer {
    position: relative !important;
    top: auto !important;
    margin-top: 0 !important;
}

#dynamic-footer-spacer {
    margin-block: 0;
}

/* --- Full Bleed Utilities --- */
.header-overlap-hero {
    padding-top: 0 !important;
}

.hero-full-bleed { 
    width: 100vw !important; position: relative !important; left: 50% !important; right: 50% !important; 
    margin-left: -50vw !important; margin-right: -50vw !important; max-width: 100vw !important; 
    min-height: 100vh !important; display: flex !important; flex-direction: column !important;
    justify-content: center !important; align-items: center !important; overflow: hidden;
}

.hero-full-bleed > * { max-width: 100vw !important; width: 100% !important; }

.hero-full-width-bleed { 
    width: 100vw !important; position: relative !important; left: 50% !important; right: 50% !important; 
    margin-left: -50vw !important; margin-right: -50vw !important; max-width: 100vw !important; 
    display: flex !important; flex-direction: column !important; justify-content: center !important; 
    align-items: center !important; overflow: hidden; 
}

.hero-full-width-bleed > * { max-width: 100vw !important; width: 100% !important; }

.content-full-bleed { 
    width: 100vw !important; position: relative !important; left: 50% !important; right: 50% !important; 
    margin-left: -50vw !important; margin-right: -50vw !important; max-width: 100vw !important; 
    display: flex !important; flex-direction: column !important; justify-content: center !important; 
    align-items: flex-start !important; overflow: hidden; 
}

.content-full-bleed > * { max-width: 100vw !important; width: 100% !important; }

/* --- Fixed Video Stacking (Layered Approach) --- */
.global-video-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    object-fit: cover;
    z-index: 2; /* Sits above the Hero/Footer backgrounds */
    pointer-events: none !important;
    mix-blend-mode: multiply; 
    opacity: 0.3; 
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

.hide-video-section {
    position: relative;
    z-index: 3 !important; /* Pushes the entire section OVER the video */
}

.reveal-video-section {
    position: relative;
    z-index: auto !important; 
}

.reveal-video-section > * {
    position: relative;
    z-index: 4 !important; /* Pushes text/images OVER the video */
}

#hero_bg {
    position: absolute;
    z-index: 1;
    height: 100vh;
    width: 100vw;
    left: 0;
    top: 0;
    margin-block: 0;
    pointer-events: none;
    overflow: hidden;

    svg {
        position: relative;
        top: 50%;
        transform: translate(-50%, -50%);
        height: 100vh;
        left: 50%;
        overflow: visible;
    }
}

/* 1. Ensure all animated paths are initially invisible */
.anim-fade-up,
.anim-fade-left,
.anim-fade-right {
    opacity: 0;
}

/* 2. Apply animations with timing and delays */
.anim-fade-up {
    /* Runs immediately for 1 second */
    animation: fadeUp 1s ease-out forwards;
}

.anim-fade-left {
    /* Waits 1 second, then runs for 1 second */
    animation: fadeLeft 1s ease-out .5s forwards;
}

.anim-fade-right {
    /* Waits 1 second, then runs for 1 second */
    animation: fadeRight 1s ease-out .5s forwards;
}

/* 3. Define the movement for each direction */
@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(15%); /* Starts 30px lower */
    }
    100% {
        opacity: .25;
        transform: translateY(0); /* Ends in its natural place */
    }
}

@keyframes fadeLeft {
    0% {
        opacity: 0;
        transform: translateX(15%); /* Starts to the right, moves left */
    }
    100% {
        opacity: .25;
        transform: translateX(0); /* Ends in its natural place */
    }
}

@keyframes fadeRight {
    0% {
        opacity: 0;
        transform: translateX(-15%); /* Starts to the left, moves right */
    }
    100% {
        opacity: .25;
        transform: translateX(0); /* Ends in its natural place */
    }
}


/* ==========================================================================
   4. CUSTOM BLOCK STYLES
   ========================================================================== */

/* --- Theme Block Colors --- */
.is-style-theme-dark { background-color: var(--wp--preset--color--dark-body); color: var(--wp--preset--color--dark-body-font); }
.is-style-theme-dark h1, .is-style-theme-dark h2, .is-style-theme-dark h3, .is-style-theme-dark p { color: var(--wp--preset--color--dark-body-font); }
.is-style-theme-brand { background-color: var(--wp--preset--color--light-body); color: var(--wp--preset--color--light-body-font); }
.is-style-theme-muted { background-color: var(--wp--preset--color--footer); color: var(--wp--preset--color--dark-body-font); }

/* --- Separators --- */
.wp-block-separator.is-style-short { width: 60px !important; margin-left: auto !important; margin-right: auto !important; border-top-width: 1px !important; }
.wp-block-separator.is-style-thick { border-top-width: 4px !important; opacity: 1 !important; }

/* --- Nav Defaults --- */
.wp-block-navigation__container.is-vertical { gap: 10px; }

/* --- Buttons --- */
.wp-block-button__link { padding-top: 15px; padding-right: 30px; padding-bottom: 15px; padding-left: 30px; }

/* Outline & Inline Buttons Context */
.is-style-theme-dark .is-style-outline .wp-block-button__link, .is-style-theme-dark .is-style-inline .wp-block-button__link { --border-hover-color: var(--wp--preset--color--light-accents); --border-color: var(--wp--preset--color--dark-accents); --text-color: var(--wp--preset--color--dark-body-font); }
.is-style-theme-brand .is-style-outline .wp-block-button__link, .is-style-theme-brand .is-style-inline .wp-block-button__link { --border-hover-color: var(--wp--preset--color--dark-accents); --border-color: var(--wp--preset--color--light-accents); --text-color: var(--wp--preset--color--light-body-font); }
.is-style-theme-muted .is-style-outline .wp-block-button__link, .is-style-theme-muted .is-style-inline .wp-block-button__link { --border-hover-color: var(--wp--preset--color--dark-accents); --border-color: var(--wp--preset--color--light-accents); --text-color: var(--wp--preset--color--light-body-font); }

.is-style-outline .wp-block-button__link { border: 1px solid var(--border-color, currentColor) !important; color: var(--text-color, currentColor) !important; transition: all 0.2s ease !important; }
.is-style-outline .wp-block-button__link:hover { border-color: var(--border-hover-color, var(--wp--preset--color--dark-accents)) !important; color: var(--text-color, var(--wp--preset--color--dark-accents)) !important; }

.is-style-inline .wp-block-button__link { padding: 0; color: var(--text-color, currentColor) !important; transition: all 0.2s ease !important; }
.is-style-inline .wp-block-button__link:hover { padding: 0; color: var(--border-hover-color, currentColor) !important; }

/* --- Card Wrapper --- */
.is-style-card-wrapper { 
    position: relative !important; cursor: pointer !important; z-index: 1 !important; display: block !important;
    --hover-color: var(--wp--preset--color--light-accents); 
}
.is-style-theme-dark .is-style-card-wrapper { --hover-color: var(--wp--preset--color--light-accents); --pre-hover-color: var(--wp--preset--color--dark-body-font); }
.is-style-theme-brand .is-style-card-wrapper { --hover-color: var(--wp--preset--color--dark-accents); --pre-hover-color: var(--wp--preset--color--dark-light-font); }
.is-style-theme-muted .is-style-card-wrapper { --hover-color: var(--wp--preset--color--dark-accents); --pre-hover-color: var(--wp--preset--color--dark-light-font); }

.is-style-card-wrapper .wp-block-post-title a::after { content: ""; position: absolute !important; inset: 0 !important; z-index: 10 !important; background: transparent !important; }
.is-style-card-wrapper .wp-block-post-title, .is-style-card-wrapper .wp-block-post-excerpt, .is-style-card-wrapper .wp-block-icon, .is-style-card-wrapper .wp-block-post-featured-image, .is-style-card-wrapper .wp-block-group { position: static !important; z-index: 11 !important; pointer-events: none !important; }
.is-style-card-wrapper .wp-block-post-title a { color: var(--pre-hover-color) !important; pointer-events: auto !important; position: static !important; z-index: 12 !important; }

.is-style-card-wrapper img, .portfolio-item-link img { transition: opacity 0.3s ease; }
.is-style-card-wrapper:hover img, .portfolio-item-link:hover img { opacity: 0.5; }
.is-style-card-wrapper:hover .wp-block-post-title a, .is-style-card-wrapper:hover .wp-block-post-excerpt p { color: var(--hover-color) !important; transition: color 0.2s ease !important; }
.is-style-card-wrapper:hover .wp-block-icon svg { fill: var(--hover-color) !important; transition: fill 0.2s ease !important; }

/* --- Button Wrapper & Clickable Group --- */
.is-style-button-wrapper, .is-clickable-group { position: relative !important; cursor: pointer !important; --hover-color: var(--wp--preset--color--light-accents); }
.is-style-theme-dark .is-style-button-wrapper, .is-style-theme-dark .is-clickable-group { --hover-color: var(--wp--preset--color--light-accents); }
.is-style-theme-brand .is-style-button-wrapper, .is-style-theme-brand .is-clickable-group { --hover-color: var(--wp--preset--color--dark-accents); }
.is-style-theme-muted .is-style-button-wrapper, .is-style-theme-muted .is-clickable-group { --hover-color: var(--wp--preset--color--dark-accents); }

.is-style-button-wrapper a.wp-block-button__link::after, .is-clickable-group a.wp-block-button__link::after { content: ""; position: absolute !important; inset: 0 !important; z-index: 10 !important; background: transparent !important;}
.is-style-button-wrapper .wp-block-button__link, .is-clickable-group .wp-block-button__link { background: transparent !important; border: none !important; padding-right: 0 !important; transition: color 0.2s ease !important; }
.is-style-button-wrapper .wp-block-icon, .is-clickable-group .wp-block-icon { pointer-events: none !important; z-index: 5 !important; }
.is-style-button-wrapper .wp-block-icon svg, .is-clickable-group .wp-block-icon svg { transition: fill 0.2s ease !important; }

.is-clickable-group .wp-block-button, .is-clickable-group .wp-block-button__link, .is-clickable-group .wp-block-buttons, .is-clickable-group img, .is-clickable-group .wp-block-image, .is-clickable-group .wp-block-group { position: static !important; }

.is-style-button-wrapper:hover .wp-block-button__link, .is-clickable-group:hover .wp-block-button__link { color: var(--hover-color) !important; }
.is-style-button-wrapper:hover .wp-block-icon svg, .is-clickable-group:hover .wp-block-button__link svg, .is-clickable-group:hover .wp-block-icon svg { fill: var(--hover-color) !important; }
.is-clickable-group img { transition: opacity 0.3s ease; }
.is-clickable-group:hover img { opacity: 0.5; }


/* ==========================================================================
   5. SITE HEADER & NAVIGATION
   ========================================================================== */
.site-header {
    position: fixed !important;
    top: 0; left: 0; width: 100%;
    z-index: 1000;
    min-height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--wp--preset--color--light-header);
    backdrop-filter: blur(10px);
    padding-left: calc((100% - var(--wp--style--global--content-size, 800px)) / 2);
    padding-right: 10px;
    transition: all 0.3s ease;
}

body.admin-bar .site-header { top: 32px; }

@media screen and (max-width: 782px) {
    body.admin-bar .site-header { top: 46px; }
}

@media (max-width: 940px) {
    .site-header {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}

.logo-default, .logo-inverted {
    max-height: 30px;
    width: auto;
    margin: 0 !important;
    display: block;
}

.logo-inverted { display: none !important; }

.site-header.is-inverted {
    background-color: var(--wp--preset--color--dark-header)!important;
    backdrop-filter: blur(10px);
}

.site-header.is-inverted .logo-default { display: none !important; }
.site-header.is-inverted .logo-inverted { display: block !important; }
.site-header.is-inverted .menu-trigger { color: var(--wp--preset--color--dark-body-font) !important; }

.menu-trigger {
    background: none; border: none; cursor: pointer;
    font-family: var(--wp--preset--font-family--neue-kabel);
    text-transform: uppercase; letter-spacing: 0.2em;
    color: var(--wp--preset--color--light-body-font);
}

.menu-trigger svg { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; }


/* ==========================================================================
   6. DRAWER MENU
   ========================================================================== */
body.menu-open-scroll-lock { overflow: hidden !important; height: 100vh !important; }

.slide-menu-wrapper {
    position: fixed !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; 
    width: 100vw !important; z-index: 9999 !important;
    display: flex !important; justify-content: flex-end !important;
    pointer-events: none; visibility: hidden; margin: 0 !important; padding: 0 !important;
}

.menu-backdrop {
    position: absolute; inset: 0; background-color: var(--wp--preset--color--transparent);
    opacity: 0; transition: opacity 0.4s ease; pointer-events: none;
}

.slide-menu-drawer {
    width: 100% !important; max-width: 450px !important; 
    height: 100vh !important; height: 100dvh !important; /* dvh adapts to dynamic mobile address bars */
    margin: 0 !important; margin-left: auto !important;
    background-color: var(--wp--preset--color--dark-header) !important;
    backdrop-filter: blur(10px) !important;
    display: flex !important; flex-direction: column !important; justify-content: space-between !important;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);

    /* --- SCROLL & OVERFLOW FIXES FOR SHORT/LANDSCAPE SCREENS --- */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    
    /* Hide scrollbars for a clean look */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.slide-menu-drawer::-webkit-scrollbar {
    display: none;
}

.slide-menu-wrapper.is-open { pointer-events: auto; visibility: visible; }
.slide-menu-wrapper.is-open .menu-backdrop { opacity: 1; pointer-events: auto; backdrop-filter: blur(10px); }
.slide-menu-wrapper.is-open .slide-menu-drawer { transform: translateX(0); pointer-events: auto; }

.drawer-nav-group .wp-block-navigation.is-style-h1-look .wp-block-navigation-item__content { 
    font-family: var(--wp--preset--font-family--eb-garamond); 
    font-weight: 200; 
    text-transform: none; 
    letter-spacing: 1px;
    transition: all 0.3s ease; /* Fixed typo: changed 'transform' to 'transition' */
}

.drawer-nav-group .wp-block-navigation.is-style-h1-look .wp-block-navigation-item__content:hover { 
    letter-spacing: 2px;
    color: var(--wp--preset--color--light-accents);
}

/* ==========================================================================
   LANDSCAPE / SHORT SCREEN TWO-COLUMN OPTIMIZATION
   ========================================================================== */
@media (max-height: 589px) {
    .drawer-landscape {
        display: flex;
        flex-direction: row-reverse;
        align-items: flex-end;
    }
    .slide-menu-drawer {
        width: 100% !important; max-width: 600px !important; 
    }
    .slider-menu-content {
        display: flex;
        flex-wrap: wrap;
    }
    .stack-switch {
        flex-direction: row-reverse;
        align-items: flex-end;
        align-content: flex-end;
    }
}

/* ==========================================================================
   7. ANIMATIONS & EFFECTS
   ========================================================================== */
.hero-logo-anim { position: absolute !important; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(1); z-index: 2000; transform-origin: center center; will-change: transform; opacity: 1; pointer-events: none; width:100%; max-width: min(calc(100% - 40px), var(--wp--style--global--content-size));}
.hero-logo-anim.is-hidden { opacity: 0 !important; }
.hero-logo-anim.is-resetting { transition: all 0.4s ease !important; }

.home .site-header { background-color: transparent; backdrop-filter: none; transition: background-color 0.4s ease, backdrop-filter 0.4s ease; }
.home .site-header.header-scrolled { background-color: var(--wp--preset--color--light-header); backdrop-filter: blur(10px); }
.home .site-header .logo-default, .home .site-header .logo-inverted { opacity: 0 !important; transition: opacity 0.3s ease; }
.home .site-header.header-scrolled .logo-default, .home .site-header.is-inverted .logo-default { opacity: 1 !important; }
.home .site-header.is-inverted .logo-inverted { opacity: 1 !important; }
.home .site-header.header-scrolled .logo-default { transition: none !important; }


/* ==========================================================================
   8. PORTFOLIO ARCHIVE (GRID & FILTERS)
   ========================================================================== */
.portfolio-ajax-grid {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: 20px;
    row-gap: 40px;
    margin-bottom: 3rem;
}

@media (min-width: 601px) {
    .portfolio-ajax-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.project-image-wrap {
    display: flex;
}

.project-image-wrap img {
    width: 100%; height: auto; aspect-ratio: 3/2; object-fit: cover; border-radius: 0px; 
}

/* --- All Categories Button Engine --- */
#portfolio-all-categories-btn,
.portfolio-all-categories-btn {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font-family: var(--wp--preset--font-family--neue-kabel);
    font-weight: 200;
    font-size: var(--wp--preset--font-size--medium);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--wp--preset--color--light-body-font);
    cursor: pointer;
    transition: color 0.2s ease, opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Checkmark SVG positioned to the right (matches summary alignment) */
#portfolio-all-categories-btn::after,
.portfolio-all-categories-btn::after {
    content: '';
    position: relative;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    opacity: 0;
    transition: opacity 0.2s ease;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z'></path></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z'></path></svg>");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

#portfolio-all-categories-btn:hover,
.portfolio-all-categories-btn:hover {
    color: var(--wp--preset--color--dark-accents);
}

#portfolio-all-categories-btn.is-selected,
.portfolio-all-categories-btn.is-selected {
    color: var(--wp--preset--color--selected, var(--wp--preset--color--dark-accents));
    font-weight: 400;
}

/* Reveals checkmark when active/selected */
#portfolio-all-categories-btn.is-selected::after,
.portfolio-all-categories-btn.is-selected::after {
    opacity: 1;
}

/* --- Filter Checkboxes & Details Block --- */
.filter-checkboxes {
    display: flex; flex-direction: column; gap: 10px; padding-top: 0px; align-items: flex-start;
}

.portfolio-filter-cb,
.portfolio-filter-cb-type,
.portfolio-filter-cb-skill {
  appearance: none; -webkit-appearance: none; width: 15px; height: 15px; border: 0px solid transparent;
  border-radius: 0px; outline: none; background-color: transparent; cursor: pointer; display: grid;
  place-content: center; transition: all 0.2s ease-in-out;
}

.portfolio-filter-cb:checked,
.portfolio-filter-cb-type:checked,
.portfolio-filter-cb-skill:checked {
  background-color: transparent; border-color: transparent;
}

.portfolio-filter-cb::before,
.portfolio-filter-cb-type::before,
.portfolio-filter-cb-skill::before {
    content: ''; position: absolute; margin-top: -3px; width: 20px; height: 20px; opacity: 0;
    background-color: currentColor; 
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z'></path></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z'></path></svg>");
    -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}

.portfolio-filter-cb:checked::before,
.portfolio-filter-cb-type:checked::before,
.portfolio-filter-cb-skill:checked::before { opacity: 1; }

.portfolio-filter-cb:focus-visible,
.portfolio-filter-cb-type:focus-visible,
.portfolio-filter-cb-skill:focus-visible { outline: 2px solid var(--wp--preset--color--highlight); outline-offset: 2px; }

.filter-label:has(.portfolio-filter-cb:checked),
.filter-label:has(.portfolio-filter-cb-type:checked),
.filter-label:has(.portfolio-filter-cb-skill:checked) { color: var(--wp--preset--color--selected); }

.filter-label:hover { color: var(--wp--preset--color--dark-accents); }

.filter-label {
    cursor: pointer;
    font-family: var(--wp--preset--font-family--neue-kabel); font-weight: 200; text-transform: uppercase; font-size: var(--wp--preset--font-size--small); letter-spacing: 1px;
    display: flex; flex-direction: row-reverse; align-items: center; justify-content: flex-end;
}

summary {
    font-family: var(--wp--preset--font-family--neue-kabel); font-weight: 200; text-transform: uppercase; font-size: var(--wp--preset--font-size--medium); letter-spacing: 1px;
    list-style: none; display: flex; justify-content: flex-start; align-items: center; cursor: pointer; gap: 10px;
}

summary::after {
    content: ''; position: relative; margin-top: 0px; width: 20px; height: 20px; transform: rotate(-90deg); background-color: currentColor; 
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m15.99 10.889-3.988 3.418-3.988-3.418.976-1.14 3.012 2.582 3.012-2.581.976 1.139Z'></path></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m15.99 10.889-3.988 3.418-3.988-3.418.976-1.14 3.012 2.582 3.012-2.581.976 1.139Z'></path></svg>");
    -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}

details[open] summary::after { transform: rotate(0deg); }

.project-filter-group { display: flex; flex-direction: column; gap: 10px; padding-top: 0; margin-top: 20px; }
.parent-filter { font-family: var(--wp--preset--font-family--neue-kabel); font-weight: 200; text-transform: uppercase; font-size: var(--wp--preset--font-size--small); letter-spacing: 2px; }
.child-filters { display: flex; flex-direction: column; gap: 10px; margin-left: 0; }

.project-filter-group p:empty {
    display: none;
}

/* --- Card Info Wrapper & Hover States --- */
.card-info-wrapper { padding: 10px; border-bottom: solid 1px var(--wp--preset--color--light-accents); color: var(--wp--preset--color--light-body-font); }
.project-title { margin:0; color: var(--wp--preset--color--light-body-font); }
.card-info-wrapper p, .card-info-wrapper h3 { margin:0; }

.append-link-icon { display: flex; flex-direction: row; align-items: center; justify-content: space-between; }
.append-link-icon svg { width:24px; fill: currentColor; }

.portfolio-item-link:hover .card-info-wrapper p,
.portfolio-item-link:hover .project-title { color: var(--wp--preset--color--dark-accents); }
.portfolio-item-link:hover .append-link-icon svg { fill: var(--wp--preset--color--dark-accents); }

.project-type-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 15px; }
.project-type-list .type-link { text-decoration: none; color: var(--wp--preset--color--light-body-font); font-weight: 600; padding: 8px 16px; border: 1px solid var(--wp--preset--color--light-accents); border-radius: 4px; transition: all 0.3s ease; }
.project-type-list .type-link:hover { background-color: var(--wp--preset--color--highlight); color: var(--wp--preset--color--dark-body-font); }

/* --- Active Filters Display & Pills --- */
#active-filters-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.active-filters-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.active-filter-pill {
    background: var(--wp--preset--color--contrast); /* Adjust color to taste */
    color: var(--wp--preset--color--light-body-font);
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: var(--wp--preset--font-size--small);
    display: flex;
    align-items: center;
}

.active-filter-pill:hover {
    background: var(--wp--preset--color--dark-accents);
}

.active-filter-pill::after {
    content: '×';
    margin-left: 6px;
    font-weight: bold;
}

.clear-all-btn {
    background: none;
    border: none;
    text-decoration: underline;
    text-transform: uppercase;
    cursor: pointer;
    font-family: var(--wp--preset--font-family--neue-kabel);
    font-size: var(--wp--preset--font-size--small);
    color: var(--wp--preset--color--light-body-font);
    letter-spacing: 1px;
    transition: color 0.2s ease;
}

.clear-all-btn:hover {
    color: var(--wp--preset--color--dark-accents);
}

/* --- Portfolio No Results Fallback Notice --- */
.portfolio-no-results-notice {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    margin: 20px 0;
}

.portfolio-no-results-notice .no-results-message {
    font-family: var(--wp--preset--font-family--neue-kabel);
    font-size: var(--wp--preset--font-size--medium);
    color: var(--wp--preset--color--light-body-font);
    margin: 0;
    line-height: 1.6;
}

.clear-filters-link {
    background: none;
    border: none;
    padding: 0;
    margin-left: 6px;
    font-family: inherit;
    font-size: inherit;
    color: var(--wp--preset--color--light-body-font);
    text-decoration: underline;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.clear-filters-link:hover {
    color: var(--wp--preset--color--dark-accents);
}


/* ==========================================================================
   9. SINGLE PROJECT TEMPLATE
   ========================================================================== */
.single-project .wp-site-blocks { margin-top: -24px; }
.project-client-logo { max-width: 150px; }
.project-dates { width:fit-content; }

/* --- Project Template Taxonomy Lists --- */
.project-taxonomy-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 5px 15px; }
.tag-list-vertical.project-taxonomy-list { gap: 10px; padding: 5px 0px; }

.is-style-theme-dark .project-taxonomy-list { --border-color: var(--wp--preset--color--dark-accents); --hover-color: var(--wp--preset--color--light-accents); --link-color: var(--wp--preset--color--dark-body-font);}
.project-taxonomy-list { --border-color: var(--wp--preset--color--light-accents); --hover-color: var(--wp--preset--color--dark-accents); --link-color: var(--wp--preset--color--light-body-font);}

.project-taxonomy-list a {
    text-decoration: none; font-family: var(--wp--preset--font-family--montserrat); font-size: var(--wp--preset--font-size--small);
    color: var(--link-color, var(--wp--preset--color--light-body-font)); text-transform: uppercase; letter-spacing: 2px;
    transition: all 0.2s ease; display: inline-block; padding-right: 20px;
}

.project-taxonomy-list a:hover { color: var(--hover-color, var(--wp--preset--color--dark-accents)); }

.project-taxonomy-list.type-list { display: flex; flex-direction: row; width: 100%; border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;}
.project-taxonomy-list.type-list a { font-size: var(--wp--preset--font-size--small); }
.project-taxonomy-list.tag-list { display: flex; flex-direction: row; }
.project-taxonomy-list.tag-list-vertical { display: flex; flex-direction: column; }
.project-taxonomy-list.tag-list a { font-size: var(--wp--preset--font-size--x-small); }

.project-taxonomy-list.tag-list a::after {
    content: ''; position: absolute; margin-top: -3px; width: 20px; height: 20px; background-color: currentColor; 
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z'></path></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z'></path></svg>");
    -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}

/* --- Project Website Link Custom Style --- */
.project-website-link {
    background: transparent !important; border: none !important; transition: color 0.2s ease !important;
    font-family: var(--wp--preset--font-family--neue-kabel); font-weight: 100; letter-spacing: 2px;
    text-transform: uppercase; padding-top: 15px; padding-right: 25px; padding-bottom: 15px; padding-left: 0px;
    color: var(--wp--preset--color--light-body-font);
}

.project-website-link:hover { color: var(--wp--preset--color--dark-accents); }

.project-website-link::after {
    content: ''; position: absolute; margin-top: -3px; margin-left: 5px; width: 25px; height: 25px; background-color: currentColor; 
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6'></path></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg aria-hidden='true' focusable='false' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6'></path></svg>");
    -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}

.over-size-me {
    max-width:900px;
}

.size-me-buttons {
    display: none;
}

/* --- XL SCREENS ONLY (MIN-width: 1300px) --- */

@media (min-width: 1300px) { 
    .size-me-buttons {
        display: block;
    }
}

    

/* ==========================================================================
   10. RESPONSIVE UTILITIES
   ========================================================================== */

   .add-borders-mobile {
    --border-color: var(--wp--preset--color--light-accents);
   }

   .is-style-theme-dark .add-borders-mobile {
    --border-color: var(--wp--preset--color--dark-accents);
   }

/* --- MOBILE ONLY (max-width: 600px) --- */
@media(max-width: 600px) { 
    .slide-menu-drawer { max-width: 100vw; padding: 40px 20px; } 
    .wp-block-columns.mobile-center-cols { gap: 15px !important; } 
    .wp-block-columns.mobile-center-cols .wp-block-column { text-align: center !important; align-items: center !important; margin-bottom: 0 !important; } 
    .wp-block-columns.mobile-center-cols .wp-block-social-links { justify-content: center !important; } 
    .mobile-center-cols nav.wp-block-navigation.is-content-justification-right { justify-content: center !important; width: 100% !important; } 
    .mobile-center-cols .wp-block-navigation__container, .mobile-center-cols .wp-block-page-list { justify-content: center !important; flex-wrap: wrap !important; } 
    .mobile-center-cols .wp-block-navigation-item { text-align: center !important; }

    /* Force full collapse of hidden elements */
    .hide-for-mobile, .hide-for-mobile * { 
        display: none !important; margin: 0 !important; padding: 0 !important; 
        height: 0 !important; width: 0 !important; overflow: hidden !important;
    }

    /* Column Stacking Utility */
    .reverse-stack { display: flex !important; flex-direction: column-reverse !important; }

    /* Zigzag Offset Grid Utility */
    .is-style-offset-grid .wp-block-post-template li.wp-block-post {
        display: block !important; width: 100% !important; margin-bottom: 20px !important; transition: margin 0.3s ease;
    }
    .is-style-offset-grid .wp-block-post-template li.wp-block-post:nth-child(even) { margin-left: 33.33% !important; width: 66.66% !important; }
    .is-style-offset-grid .wp-block-post-template li.wp-block-post:nth-child(odd) { margin-right: 33.33% !important; width: 66.66% !important; }
    .project-client-logo { max-width: 75px; }
    .project-block-cover { aspect-ratio: unset!important; height: calc((100vw * (2/3)) + 70px) !important;}
}

/* --- TABLET & MOBILE (MAX-width: 781px) --- */

@media (max-width: 781px) { 

    .project-taxonomy-list.type-list { width: 100%;}

    .home-mini-menu {
        z-index: 1001;
    width: 100% !important;
    left: 0;
    position: absolute;
    top: 70px;
    }

    /* Force full collapse of hidden elements */
    .hide-for-mobile--tablet, .hide-for-mobile--tablet * { 
        display: none !important; margin: 0 !important; padding: 0 !important; 
        height: 0 !important; width: 0 !important; overflow: hidden !important;
    }

    /* Column Stacking Utility */
    .reverse-stack { display: flex !important; flex-direction: column-reverse !important; }

    /* Footer Logo */
    .logo-desktop-only { display: none !important; } 

    #hero_bg {
        svg {
            height: auto;
            width:120vw;
        }
    }

    .remove-borders-mobile {
        border: none !important;
        div {
            padding: 0 !important;
        }
    }

    .add-borders-mobile {
        border: solid 1px var(--border-color) !important;
    }
}

/* --- TABLET & DESKTOP (min-width: 782px) --- */
@media (min-width: 782px) { 

    .home-mini-menu {
        z-index: 1001;
    width: calc(100% - 50px) !important;
    left: 0;
    position: absolute;
    top: 0;
    }

    /* Footer Logo */
    .logo-mobile-only { display: none !important; } 

}

/* --- TABLET ONLY (min-width: 782px & max-width: 1000px) --- */
@media (min-width: 782px) and (max-width: 1000px) { 

    /* Force full collapse of hidden elements */
    .hide-for-tablet, .hide-for-tablet * { 
        display: none !important; margin: 0 !important; padding: 0 !important; 
        height: 0 !important; width: 0 !important; overflow: hidden !important;
    }

}



/* --- NOT MOBILE (min-width: 601px) --- */
@media (min-width: 601px) { 

    /* Force full collapse of hidden elements */
    .hide-for-desktop, .hide-for-desktop * { 
        display: none !important; margin: 0 !important; padding: 0 !important; 
        height: 0 !important; width: 0 !important; overflow: hidden !important;
    }
}

/* --- Limit Query Grid to 4 posts on Regular --- */
@media (min-width: 800px) and (max-width: 1099px) {
    .is-style-offset-grid .wp-block-post-template li.wp-block-post:nth-child(n+5) { display: none !important; }
    .is-style-offset-grid .wp-block-post-template.is-layout-grid { grid-template-columns: repeat(4, 1fr) !important; }
}

/* --- Limit Query Grid to 3 posts on Tablet/Mid-range screens --- */
@media (min-width: 601px) and (max-width: 799px) {
    .is-style-offset-grid .wp-block-post-template li.wp-block-post:nth-child(n+4) { display: none !important; }
    .is-style-offset-grid .wp-block-post-template.is-layout-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* --- Ready it for mobile --- */
@media (max-width: 600px) {
    .is-style-offset-grid .wp-block-post-template.is-layout-grid { display: block !important; }
}

/* --- Fix: Neutralize Global Spacing for Hidden Elements --- */
:where(.is-layout-flow) > .hide-for-mobile,
:where(.is-layout-flow) > .hide-for-desktop {
    margin-block-start: 0 !important; margin-block-end: 0 !important;
}

/* ==========================================================================
   11. GALLERY SLIDER STYLES
   ========================================================================== */

/* 1. Master Wrapper Setup */
.gallery-slider-wrapper {
    position: relative;
    width: 100%;
    margin: 0rem 0;
}

/* 2. Overriding default WP Gallery to become a horizontal scroll track */
.wp-block-gallery.is-slider-gallery {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 0px; /* Space between images */
    margin: 0;
    
    /* Hide the scrollbar for a clean look */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.wp-block-gallery.is-slider-gallery::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

/* 3. The Images Inside */
.wp-block-gallery.is-slider-gallery .wp-block-image {
    flex: 0 0 100%; /* Shows 80% of one image, hinting at the next one */
    scroll-snap-align: center;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 4. Arrow Button Styling */
.slider-arrow {
    background: none;
    border: none;
    color: currentColor; /* Adjust to match your exact theme text color */
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    z-index: 10;
    width:24px;
}

/* 5. Custom Class: Keep mobile-style bottom arrows on desktop */
@media (min-width: 1400px) {
    .wp-block-gallery.bottom-arrows + .slider-controls {
        position: static;
        transform: none;
        width: 100%;
        pointer-events: auto;
    }
}
.wp-block-gallery.bottom-arrows + .slider-controls {
    padding: 20px 20px 0;
    max-width: 1240px;
    margin: 0 auto;
}

/* --- SAFARI FIXES --- */
.slider-arrow {
    -webkit-appearance: none; /* Strips Apple's native default button styling */
    appearance: none;
}

.slider-arrow svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0; /* Strictly prevents Safari from collapsing the SVG */
    display: block; /* Removes baseline spacing quirks */
}

.slider-arrow.prev-arrow {
    transform: rotate(180deg);
}

.slider-arrow:hover {
    opacity: 0.6;
}

.slider-controls {
    display: flex;
    justify-content: space-between;
    padding: 20px 0 0 0;
}

/* --- LARGE DESKTOP LAYOUT --- (Like image_e3c809.jpg) */
@media (min-width: 1400px) {
    .gallery-slider-wrapper {
        padding: 0 0px; /* Make room for side arrows */
    }
    
.slider-controls {
        position: absolute;
        top: 50%;
        left: -88px;
        right: 0;
        transform: translateY(-50%);
        display: flex;
        justify-content: space-between;
        pointer-events: none;
        width: calc(100% + 176px);
    
    .slider-arrow {
        pointer-events: auto; /* Re-enable clicks on the arrows themselves */
    }
}
}

/* --- DESKTOP LAYOUT --- (Like image_e3c809.jpg) */
@media (min-width: 782px) {
        .wp-block-gallery.is-slider-gallery .wp-block-image {
        flex: 0 0 50% !important; /* Show one full image per swipe on mobile */
    }
}

/* --- MOBILE LAYOUT --- (Like image_e3c4a6.png) */
@media (max-width: 768px) {
.slider-controls {
        display: flex;
        justify-content: space-between;
        width: 100%;
        margin-top: 0;
        /* Matches the background bar seen in the mobile reference */
        background-color: var(--wp--preset--color--primary, transparent); 
    }
}

/* 6. Drag-to-Scroll States */
.wp-block-gallery.is-slider-gallery {
    cursor: grab;
}

.wp-block-gallery.is-slider-gallery.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto !important;
    scroll-snap-type: none !important;
}




/* ==========================================================================
   12. PASSWORD PROTECTION
   ========================================================================== */

.custom-password-form {
    height: 100vh;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

.password-input-group {
    display: flex;
}

.password-input-group > input {
    background: transparent;
    border: none;
    border-bottom: 1px solid currentColor;
    padding: 20px;
    width: 100%;
    color: currentColor;
}

.password-submit-btn {
background: transparent;
    border: none;
    border: 1px solid currentColor;
    padding: 20px;
    width: auto;
    color: currentColor;
    margin-left: 20px;
}

.password-title {
    font-size: 25px;
}

/* ==========================================================================
   13. MASSIVE PRIVATE GALLERY FLEXBOX (FLUID + FADE-IN ON LOAD)
   ========================================================================== */
.wp-block-gallery.massive-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0; /* Adjust gap space to your preference */
    margin: 0;
}

/* 1. Base Flex Items (Mobile: 2 Columns Across + Stretch) */
.wp-block-gallery.massive-grid .wp-block-image {
    flex: 1 1 calc((100% - 15px) / 2) !important;
    max-width: 100%;
    margin: 0 !important;
    
    /* Memory Saver: Skips rendering off-screen items until scrolled into view */
    content-visibility: auto;
    contain-intrinsic-size: 250px;
}

/* 2. Tablet / Standard Desktop (4 Columns Across + Stretch) */
@media (min-width: 782px) {
    .wp-block-gallery.massive-grid .wp-block-image {
        flex: 1 1 calc((100% - (15px * 3)) / 4) !important;
    }
}

/* 3. Extra Large Desktop (6 Columns Across + Stretch) */
@media (min-width: 1400px) {
    .wp-block-gallery.massive-grid .wp-block-image {
        flex: 1 1 calc((100% - (15px * 5)) / 6) !important;
    }
}

/* 4. Image Styling & Smooth Fade-in Transition (Scoped to direct children) */
.wp-block-gallery.massive-grid > .wp-block-image > img,
.wp-block-gallery.massive-grid > figure > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1 / 1;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* 5. Triggered when the image finishes downloading */
.wp-block-gallery.massive-grid > .wp-block-image > img.is-loaded,
.wp-block-gallery.massive-grid > figure > img.is-loaded {
  opacity: 1;
  transform: scale(1);
}


/* ==========================================================================
   14. MAGAZINE POPUP GALLERY (TRUE 3D FLIP & DYNAMIC SIZING ENGINE)
   ========================================================================== */

/* 14.1 Gutenberg Gallery Thumbnail Cleanup */
.wp-block-gallery.magazine-gallery {
    display: flex;
    width: 50%;
}

.wp-block-gallery.magazine-gallery .wp-block-image:not(:first-child) {
    display: none !important;
}

.wp-block-gallery.magazine-gallery .wp-block-image:first-child {
    display: block !important;
    position: relative;
    cursor: pointer;
    max-width: 100%;
    margin: 0 auto;
    border-radius: 0px;
    overflow: hidden;
}

/* Badge overlay on cover */
.wp-block-gallery.magazine-gallery .magazine-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 15px;
    background: var(--wp--preset--color--dark-body);
    opacity: .75;
    backdrop-filter: blur(8px);
    color: var(--wp--preset--color--dark-body-font);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 2;
}

/* 14.2 Lazy Load Overrides */
.magazine-stage img,
.magazine-stage img[loading="lazy"],
.magazine-stage img.lazyload,
.magazine-stage img.lazyloaded,
.magazine-stage img.entered,
.magazine-stage img.loaded {
    opacity: 1 !important;
    visibility: visible !important;
    filter: none !important;
    transition: none !important; 
    will-change: transform, opacity;
}

/* 14.3 Modal Overlay */
.magazine-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background-color: #435f64eb;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    animation: magFadeIn 0.3s ease forwards;
}

.magazine-modal-overlay.is-closing {
    animation: magFadeOut 0.3s ease forwards;
}

/* 14.4 Close Button */
.magazine-close-btn {
    position: absolute;
    top: 25px;
    right: 25px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--wp--preset--color--dark-body-font);
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    z-index: 100000;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: rotate(45deg);
    display: flex;
}

.magazine-close-btn > svg {
    width: 30px;
}

.magazine-close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ==========================================================================
   14.5 3D Stage & Viewport
   ========================================================================== */
.magazine-stage {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-perspective: 2200px !important;
    perspective: 2200px !important;
    perspective-origin: 50% 50%;
    padding: 40px 0;
    overflow: visible !important;
}

.magazine-book-viewport {
    position: relative;
    width: 100%;
    max-width: 1100px;
    max-height: 75dvh; /* Updated from 80vh to dynamic viewport height */
    aspect-ratio: var(--book-aspect-ratio, 1.414); /* Automatically picks up the JS-calculated ratio per magazine */
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transform-style: preserve-3d !important;
    transform-style: preserve-3d !important;
}

/* Dynamically adjust width/aspect-ratio constraints when viewing single covers */
.magazine-book-viewport.is-single-view {
    aspect-ratio: calc(var(--book-aspect-ratio, 1.414) / 2);
    max-width: 550px; /* Half of the spread max-width */
}

/* Static center spine shadow (visible when book is resting) */
.magazine-book-viewport::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 24px;
    transform: translateX(-50%);
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.125) 45%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0.125) 55%,
        rgba(0, 0, 0, 0) 100%
    );
    pointer-events: none;
    z-index: 200;
}

/* 14.6 Spread Containers & Halves */
.magazine-page-sheet {
    position: absolute;
    inset: 0;
    display: flex;
    width: 100%;
    height: 100%;
}

.magazine-page-sheet.base-spread { z-index: 1; }
.magazine-page-sheet.active-spread { z-index: 2; }

.magazine-page-half {
    width: 50%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.0);
}

/* Left Half Image Split */
.magazine-page-img.is-left-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    object-fit: fill;
}

/* Right Half Image Split */
.magazine-page-img.is-right-img {
    position: absolute;
    top: 0;
    right: 0;
    width: 200%;
    height: 100%;
    object-fit: fill;
}

/* ==========================================================================
   14.7 Single Cover / Back Cover Rules
   ========================================================================== */

/* Hide the center spine shadow when viewing single covers */
.magazine-book-viewport:has(.magazine-page-sheet.is-cover)::after,
.magazine-book-viewport:has(.magazine-page-sheet.is-back-cover)::after {
    display: none !important;
}

/* Restrict the cover sheet to occupy only half of the total spread container width */
.magazine-page-sheet.is-cover,
.magazine-page-sheet.is-back-cover {
    width: 50% !important;
}

/* Position front cover on the right side of the spread */
.magazine-page-sheet.is-cover {
    left: 50% !important;
    right: 0 !important;
}

/* Position back cover on the left side of the spread */
.magazine-page-sheet.is-back-cover {
    left: 0 !important;
    right: 50% !important;
}

/* Handle the inner halves inside the cover sheets */
.magazine-page-sheet.is-cover .magazine-page-half.is-left,
.magazine-page-sheet.is-back-cover .magazine-page-half.is-right {
    display: none !important;
}

.magazine-page-sheet.is-cover .magazine-page-half.is-right,
.magazine-page-sheet.is-back-cover .magazine-page-half.is-left {
    width: 100% !important;
}

/* Fix image stretching on custom-ratio covers */
.magazine-page-sheet.is-cover .magazine-page-half.is-right .magazine-page-img,
.magazine-page-sheet.is-back-cover .magazine-page-half.is-left .magazine-page-img,
.magazine-page-img.is-single-fit {
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    right: auto !important;
    object-fit: contain !important; /* Prevents vertical stretching by respecting image dimensions */
    object-position: center !important;
    background-color: transparent;
}

/* ==========================================================================
   14.8 3D Flipping Leaf Engine & Dynamic Crease Shadow (Safari GPU Fixes)
   ========================================================================== */
.magazine-flip-leaf {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 100;
    -webkit-transform-style: preserve-3d !important;
    transform-style: preserve-3d !important;
    will-change: transform;
}

.magazine-flip-leaf.turn-next {
    left: 50%;
    transform-origin: left center !important;
    -webkit-animation: flipLeafNext 0.65s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
    animation: flipLeafNext 0.65s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

.magazine-flip-leaf.turn-prev {
    left: 0;
    transform-origin: right center !important;
    -webkit-animation: flipLeafPrev 0.65s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
    animation: flipLeafPrev 0.65s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

.leaf-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    background-color: #111;
}

/* Added translateZ(1px) to prevent Safari Z-fighting/flickering */
.leaf-face.leaf-front {
    -webkit-transform: rotateY(0deg) translateZ(1px);
    transform: rotateY(0deg) translateZ(1px);
}

.magazine-flip-leaf.turn-next .leaf-face.leaf-back {
    -webkit-transform: rotateY(180deg) translateZ(1px);
    transform: rotateY(180deg) translateZ(1px);
}

.magazine-flip-leaf.turn-prev .leaf-face.leaf-back {
    -webkit-transform: rotateY(-180deg) translateZ(1px);
    transform: rotateY(-180deg) translateZ(1px);
}

/* Smoothly Fading Dynamic Crease Shadow */
.leaf-face::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 55px;
    pointer-events: none;
    opacity: 0;
    z-index: 5;
}

/* Correct spine edge positioning with smooth keyframe curve */
.magazine-flip-leaf.turn-next .leaf-front::after {
    left: 0;
    width: 12px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.125) 90%, rgba(0, 0, 0, 0.2) 100%);
    opacity: 1;
}

.magazine-flip-leaf.turn-next .leaf-back::after {
    right: 0;
    width: 12px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.125) 90%, rgba(0, 0, 0, 0.2) 100%);
    opacity: 1;
}

.magazine-flip-leaf.turn-prev .leaf-front::after {
    right: 0;
    width: 12px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.125) 90%, rgba(0, 0, 0, 0.2) 100%);
    opacity: 1;
}

.magazine-flip-leaf.turn-prev .leaf-back::after {
    left: 0;
    width: 12px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.125) 90%, rgba(0, 0, 0, 0.2) 100%);
    opacity: 1;
}

/* ==========================================================================
   14.9 Keyframes (Forced Hardware Acceleration)
   ========================================================================== */
@keyframes magFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes magFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Added -webkit- prefixes and translateZ(0) to force GPU rendering */
@-webkit-keyframes flipLeafNext {
    0% { -webkit-transform: rotateY(0deg) translateZ(0); }
    100% { -webkit-transform: rotateY(-180deg) translateZ(0); }
}
@keyframes flipLeafNext {
    0% { transform: rotateY(0deg) translateZ(0); }
    100% { transform: rotateY(-180deg) translateZ(0); }
}

@-webkit-keyframes flipLeafPrev {
    0% { -webkit-transform: rotateY(0deg) translateZ(0); }
    100% { -webkit-transform: rotateY(180deg) translateZ(0); }
}
@keyframes flipLeafPrev {
    0% { transform: rotateY(0deg) translateZ(0); }
    100% { transform: rotateY(180deg) translateZ(0); }
}

/* 14.10 Controls Bar */
.magazine-controls-bar {
    display: flex;
    align-items: center;
    gap: 25px;
    padding: 10px 25px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--wp--preset--color--dark-body-font);
    font-size: var(--wp--preset--font-size--small);
    font-family: var(--wp--preset--font-family--montserrat);
    z-index: 100000;
}

.mag-btn {
    background: none;
    border: none;
    color: var(--wp--preset--color--dark-body-font);
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mag-btn:hover {
    transform: translateY(-1px);
}

.magazine-counter {
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

/* 14.11 Mobile Landscape Adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    .magazine-book-viewport {
        width: auto;
        height: 65dvh;
        max-height: none;
    }

    .magazine-stage {
        padding: 10px 0;
    }

    .magazine-controls-bar {
        padding-bottom: env(safe-area-inset-bottom, 15px);
    }
}