/* ===========================
    CSS VARIABLES
=========================== */
:root {
    --font-heading: "Faculty Glyphic", serif;
    --font-subheading: "Hurricane", cursive;
    --font-body: "Poiret One", sans-serif;
    --color-dark: #333;
    --color-light: #fff;
    --color-accent: #6b9080;
    --color-bg: #f8f5f1;
    --color-banner: #f7ecd9;
    --color-tap-highlight: transparent;
}

/* ===========================
   GLOBAL STYLES
=========================== */
html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-dark);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden;
    box-sizing: border-box;
    background-image: url('images/site-background.webp');
    background-image: image-set(
        url('images/site-background.avif') type("image/avif"),
        url('images/site-background.webp') type("image/webp")
    );
    background-attachment: fixed;
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
}

p {
    font-size: clamp(1.08rem, 0.35vw + 1.01rem, 1.16rem);
    font-weight: 600;
    line-height: 1.7;
}

@media screen and (orientation: portrait) and (max-width: 1024px) {
    body {
        background-size: cover;
        background-position: center;
    }
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(248, 245, 241, 0.5);
    z-index: -1;
}

.gallery-item {
    -webkit-tap-highlight-color: var(--color-tap-highlight);
}

nav a,
.modal-nav,
.close {
    -webkit-tap-highlight-color: var(--color-tap-highlight);
}

.gallery-item img {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

@media (hover: none) and (pointer: coarse) {
    .gallery-item {
        transition: transform 0.06s ease;
        touch-action: manipulation;
    }

    nav a,
    .modal-nav,
    .close {
        transition: transform 0.06s ease;
        touch-action: manipulation;
    }

    .gallery-item:active {
        transform: translateY(3px) scale(0.96);
    }

    nav a:active {
        transform: translateY(3px) scale(0.96);
    }

    .modal-nav:active,
    .close:active {
        transform: translateY(3px) scale(0.96);
    }
}

/* ===========================
    HEADER & NAVIGATION
=========================== */
header {
    background-color: var(--color-dark);
    color: var(--color-light);
    padding: 0.5rem;
    text-align: left;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-sizing: border-box;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    height: 50px;
}

header.fade-out {
    opacity: 0;
    visibility: hidden;
}

header.fade-out:focus-within {
    opacity: 1;
    visibility: visible;
}

header h1 {
    font-size: 1.2rem;
    margin: 0;
    font-family: var(--font-heading);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 1rem;
    text-decoration: none;
    color: inherit;
}

.header-logo {
    height: 32px;
    width: auto;
    border-radius: 4px;
    object-fit: cover;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    width: 30px;
    height: 30px;
    justify-content: center;
    align-items: center;
    margin-left: auto;
    margin-right: 1rem;
    z-index: 1100;
    padding: 0;
    border: 0;
    background: transparent;
}

.hamburger span {
    height: 3px;
    width: 100%;
    background: var(--color-light);
    margin: 4px 0;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

nav {
    margin-left: auto;
    margin-right: 1rem;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
}

nav li {
    margin: 0 1rem;
}

nav a {
    color: var(--color-light);
    text-decoration: none;
    transition: color 0.3s;
    font-size: 0.9rem;
}

nav a:hover {
    color: var(--color-accent);
}

nav a[aria-current="page"] {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 0.35rem;
}

/* ===========================
   HERO BANNER SECTION
=========================== */
.hero-banner {
    position: relative;
    width: 100vw;
    height: clamp(400px, 70vh, 900px);
    min-height: 400px;
    overflow: hidden;
    margin: 0;
    margin-left: calc(-50vw + 50%);
    margin-top: 50px;
    border-radius: 0;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Show more of banner images on wider displays by increasing hero height */
@media screen and (min-width: 1400px) {
    .hero-banner {
        height: min(78vh, 980px);
    }
}

@media screen and (min-width: 1800px) and (min-aspect-ratio: 2/1) {
    .hero-banner {
        height: min(74vh, 940px);
    }
}

/* The van in Jessica's photography hero sits right of centre; shift the crop so it stays centred */
body[data-artist="jessica"][data-category="photography"] .hero-image {
    object-position: 80% center;
}

.photo-poetry-page .hero-image {
    background-color: transparent;
}

.hero-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--color-light);
    padding: 2rem;
    border-radius: 8px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.hero-overlay h2 {
    font-family: var(--font-heading);
    font-size: 3rem;
    margin: 0 0 0.4rem 0;
    letter-spacing: 0.04em;
}

.hero-overlay h3 {
    font-family: var(--font-subheading);
    font-size: 3.2rem;
    margin: 0 0 1rem 0;
    color: rgba(255,255,255,0.85);
    text-align: center;
}

.hero-overlay p {
    font-size: 1.05rem;
    margin: 0;
    line-height: 1.5;
    opacity: 0.9;
}

.hero-logo {
    max-height: 140px;
    max-width: min(40vw, 260px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}

.hero-overlay-text {
    display: flex;
    flex-direction: column;
}

.gallery-page .hero-overlay {
    justify-content: center;
}

.gallery-page .hero-overlay-text {
    align-items: center;
    text-align: center;
}

.gallery-page .hero-overlay h2 {
    text-align: center;
}

/* ===========================
   MAIN CONTENT AREAS
=========================== */
main {
    padding: 2rem;
    max-width: 1300px;
    margin: 0 auto;
}

.artist-page main {
    padding-top: 5rem;
}

/* ===========================
   CATEGORY TILES
=========================== */
#categories {
    padding: 2.5rem 0;
    max-width: 1200px;
    margin: 0 auto;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.category-tile {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 4 / 3;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.category-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.45s ease;
    display: block;
}

.category-tile:hover img {
    transform: scale(1.06);
}

.category-tile__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3rem 1.5rem 1.5rem;
    background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 100%);
}

.category-tile__overlay h3 {
    margin: 0;
    color: var(--color-light);
    font-family: var(--font-heading);
    font-size: 2rem;
    letter-spacing: 0.03em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ===========================
   DUO ARTIST SECTION
=========================== */
#artists-duo {
    max-width: 1000px;
    margin: 3rem auto;
    padding: 2rem;
    background-color: var(--color-banner);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    box-sizing: border-box;
}

.duo-image {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.duo-image img {
    width: 100%;
    height: 380px;
    object-fit: cover;
    object-position: center;
    display: block;
}

.duo-text h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-dark);
    margin: 0 0 0.3rem 0;
}

.duo-text h3 {
    font-family: var(--font-subheading);
    font-size: 1.8rem;
    color: var(--color-accent);
    margin: 0 0 1rem 0;
}

.duo-text p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #555;
    max-width: 680px;
    margin: 0 auto;
}

#welcome {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6rem minmax(0, 1fr);
    align-items: stretch;
    background-color: var(--color-banner) !important;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 3rem;
    width: 100%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.welcome-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1 1 0;
    min-width: 0;
}

.welcome-photo {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.welcome-gap {
    width: 6rem;
    display: flex;
    align-self: stretch;
    align-items: center;
    justify-content: center;
}

.welcome-gap::before {
    content: "";
    width: 2px;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(
        to bottom,
        rgba(107, 144, 128, 0),
        rgba(107, 144, 128, 0.9) 25%,
        rgba(51, 51, 51, 0.85) 50%,
        rgba(107, 144, 128, 0.9) 75%,
        rgba(107, 144, 128, 0)
    );
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.welcome-bio {
    display: flex;
    flex-direction: column;
    min-height: 24rem;
}

.welcome-bio h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-dark);
    margin: 0 0 1rem 0;
}

/* Keep artist names on a single line in index bio boxes on wider screens */
@media screen and (min-width: 901px) {
    #welcome .welcome-bio h2 {
        white-space: nowrap;
        font-size: clamp(1.45rem, 1.7vw, 2rem);
    }
}

.welcome-bio p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #555;
    margin: 0;
    flex: 1;
}

.artist-link {
    align-self: flex-start;
    display: inline-block;
    margin-top: 1.25rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--color-dark);
    border-radius: 4px;
    color: var(--color-dark);
    font-family: var(--font-heading);
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.artist-link:hover {
    background-color: var(--color-dark);
    color: var(--color-light);
}

.artist-profile {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: center;
    max-width: 1000px;
    margin: 2rem auto 3rem;
    padding: 2rem;
    background-color: var(--color-banner);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.artist-profile img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    object-fit: cover;
}

.artist-profile h2 {
    margin: 0 0 0.75rem;
    font-family: var(--font-heading);
    font-size: 2rem;
}

.artist-profile__introduction {
    color: var(--color-accent);
    font-family: var(--font-heading);
}

#artist-biography {
    white-space: pre-line;
}

.artist-eyebrow {
    margin: 0 0 0.25rem;
    color: var(--color-light);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.welcome-column .portrait {
    width: 200px;
    height: 200px;
    max-width: 100%;
    object-fit: cover;
    object-position: center;
}

@media screen and (max-width: 768px) {
    .welcome-column {
        width: 100%;
    }
}

/* ===========================
   GALLERY STYLES - MASONRY LAYOUT
=========================== */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-auto-rows: minmax(50px, auto); /* Smaller minimum for tighter packing */
    gap: 4px; /* Reduce gap for tighter spacing */
    width: 100%;
    grid-auto-flow: row dense;
    align-items: start;
}

body[data-page-type="gallery"] .gallery {
    position: relative;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    break-inside: avoid;
    display: flex;
    flex-direction: column;
    width: 100%;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    cursor: pointer;
}

/* Reserve space for unsized static thumbnails so lazy loading defers offscreen images. */
.gallery-item:not(.portrait):not(.landscape) img {
    height: 280px;
    object-fit: cover;
}

.gallery-item .item-desc {
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    background-color: #f7ecd9;
    border-radius: 8px;
}

.gallery-item .item-desc p {
    display: none;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gallery-item:hover img {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.hamburger:focus-visible,
.gallery-item:focus-visible,
.modal button:focus-visible {
    outline: 3px solid #f3bb48;
    outline-offset: -3px;
}

.gallery-empty {
    grid-column: 1 / -1;
    padding: 3rem 1rem;
    text-align: center;
}

/* Masonry Item Size Variations */
.gallery-item.tall {
    grid-row-end: span 2;
}

.gallery-item.extra-tall {
    grid-row-end: span 3;
}

.gallery-item.wide {
    grid-column-end: span 2;
}

/* Portrait and Landscape thumbnail adjustments - unified height system */
.gallery-item.portrait,
.gallery-item.landscape {
    grid-row-end: span 2;
    min-height: 380px; /* Fixed height for all items */
    height: 380px; /* Exact height to ensure alignment */
    display: flex;
    flex-direction: column;
}

.gallery-item.portrait img,
.gallery-item.landscape img {
    width: 100% !important;
    height: 280px !important; /* Same image height for both types */
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    flex: 0 0 280px; /* Fixed flex basis */
}

.gallery-item.portrait .item-desc,
.gallery-item.landscape .item-desc {
    flex: 1; /* Take remaining space */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content in available space */
}

.gallery-item.portrait .item-desc {
    min-height: 80px; /* More space for portraits */
    padding: 0.5rem;
}

.gallery-item.landscape .item-desc {
    min-height: 20px; /* Ultra-compact height for landscapes */
    padding: 0.1rem 0.4rem; /* Minimal vertical padding, keep horizontal */
}

/* ===========================
    MODAL STYLES
=========================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: flex-start;
    padding-top: calc(24px + env(safe-area-inset-top));
    box-sizing: border-box;
}

.modal-content {
    display: flex;
    flex-direction: column; /* Default to vertical stacking */
    justify-content: flex-start;
    align-items: center;
    max-width: 95vw;
    width: 95vw;
    margin: 20px auto;
    height: auto;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

.modal-loading-indicator {
    position: sticky;
    top: 8px;
    display: none;
    align-items: center;
    gap: 10px;
    align-self: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    z-index: 2;
}

.modal-loading-indicator.visible {
    display: inline-flex;
}

.modal-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: modal-spin 0.7s linear infinite;
}

.modal-image.is-loading {
    opacity: 1;
}

@keyframes modal-spin {
    to {
        transform: rotate(360deg);
    }
}

.modal-image {
    max-width: 80vw;
    width: auto;
    max-height: 60vh;
    height: auto;
    object-fit: contain;
    flex: none;
    margin: 0 auto 20px auto;
    display: block;
    transition: opacity 0.12s linear, filter 0.16s ease;
}

.modal-image.is-thumbnail {
    filter: none;
}

.modal-image.landscape {
    width: auto;
    max-width: 65vw; /* More conservative width to prevent cropping */
    height: auto;
    max-height: 70vh;
    flex-shrink: 1; /* Allow shrinking if needed */
}

.modal-image.portrait {
    height: auto;
    max-height: 80vh;
    width: auto;
}

.modal-description {
    flex: none;
    width: 100%;
    max-width: none;
    min-width: auto;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    word-break: break-word;
    hyphens: auto;
    color: var(--color-light);
    background-color: rgba(0,0,0,0.7);
    border-radius: 8px;
    margin-left: 0;
    margin-top: 0;
    text-align: center;
}

.modal-description p {
    margin: 0 0 15px;
    white-space: pre-wrap;
}

/* Modal Navigation Arrows */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 1001;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-nav:hover {
    background-color: rgba(255, 255, 255, 0.95);
}

.modal-nav.prev {
    left: 20px;
}

.modal-nav.next {
    right: 20px;
}

.modal-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile and Tablet: Move arrows to bottom */
@media screen and (max-width: 1024px) {
    .modal-nav {
        position: fixed;
        top: auto;
        bottom: 15px;
        transform: none;
        width: 60px;
        height: 60px;
        font-size: 22px;
    }
    
    .modal-nav.prev {
        left: 10px;
    }
    
    .modal-nav.next {
        right: 10px;
    }
}

/* Very small screens: Even smaller arrows */
@media screen and (max-width: 480px) {
    .modal-nav {
        position: fixed;
        width: 52px;
        height: 52px;
        font-size: 20px;
        bottom: 10px;
    }
    
    .modal-nav.prev {
        left: 8px;
    }
    
    .modal-nav.next {
        right: 8px;
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1002;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s ease;
    border: 0;
    padding: 0;
    font-family: inherit;
    line-height: inherit;
}

.close:hover {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
}

/* Larger close button for wide and tablet screens */
@media screen and (min-width: 481px) {
    .close {
        font-size: 32px;
        width: 50px;
        height: 50px;
        top: 20px;
        right: 40px;
    }
}

/* ===========================
    ADDITIONAL COMPONENTS
=========================== */
.curated-bio {
    background-color: #f7ecd9;
    padding: 0.5rem 2rem 1.2rem 2rem;
    margin: 0 2rem 2rem 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 1300px;
    margin-left: auto;
    margin-right: auto;
    min-height: 120px;
}

.curated-bio h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.curated-bio p {
    font-size: 1.1rem;
    line-height: 1.8;
}

.item-desc {
    background-color: rgba(255,255,255,0.9);
    padding: 1rem;
    border-radius: 0 0 8px 8px;
    text-align: center;
}

.item-desc h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin: 0 0 0.5rem;
}

.item-desc p {
    font-size: 0.9rem;
    margin: 0 0 0.5rem;
    color: #666;
}

footer {
    background-color: var(--color-dark);
    color: var(--color-light);
    text-align: left;
    padding: 1rem 0 1rem 1rem;
    margin-top: 3rem;
    width: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 1rem;
}

.footer-contact {
    max-width: 360px;
    width: 100%;
    margin: 0;
    text-align: right;
    justify-self: end;
}

.footer-contact h3 {
    margin: 0 0 0.4rem 0;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--color-light);
}

.footer-contact p {
    margin: 0 0 0.5rem 0;
}

.footer-contact a {
    color: var(--color-light);
}

.footer-contact a:hover {
    color: var(--color-accent);
}

.footer-contact-form {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

/* Labels stay available to assistive technology; the placeholders remain the visible text. */
.footer-contact-form label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.footer-contact-form input,
.footer-contact-form textarea {
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--color-light);
}

.footer-contact-form input::placeholder,
.footer-contact-form textarea::placeholder {
    color: rgba(255, 255, 255, 0.75);
}

.footer-contact-form textarea {
    resize: vertical;
    min-height: 80px;
}

.footer-contact-form button {
    align-self: flex-end;
    padding: 0.45rem 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.18);
    color: var(--color-light);
    cursor: pointer;
    font-family: var(--font-body);
}

.footer-contact-form button:hover {
    background-color: rgba(255, 255, 255, 0.28);
}

.footer-form-message {
    display: none;
    margin: 0.45rem 0 0;
    font-size: 0.85rem;
}

footer > p {
    margin: 0;
    grid-column: 1 / -1;
    justify-self: center;
    text-align: center;
}

/* ===========================
    RESPONSIVE DESIGN
=========================== */

/* Large Screens */
@media (min-width: 1200px) {
    main {
        padding: 2rem 1.5rem;
        max-width: none;
    }
    .gallery {
        padding: 0 0.5rem;
    }
    #gallery h3 {
        padding: 0 0.5rem;
    }
}

/* Ultra-wide Screens */
@media (min-width: 3840px) {
    main {
        padding: 4rem;
    }
}

/* Tablet */
@media (max-width: 1024px) {
    main {
        padding: 1.5rem;
    }
    #welcome {
        padding: 1.2rem;
    }
    .welcome-bio h2 {
        font-size: 1.8rem;
    }
    .welcome-bio p {
        font-size: 1rem;
    }
    .gallery-item.landscape .item-desc {
        min-height: 20px; /* Same as desktop for consistency */
        padding: 0.1rem 0.35rem; /* Match desktop vertical padding */
    }
    .gallery-item .item-desc h4 {
        font-size: 0.95rem; /* Slightly smaller on tablet */
    }
    .gallery-item .item-desc p {
        font-size: 0.8rem; /* Smaller paragraph text */
        line-height: 1.2; /* Tighter line height */
    }
    .modal-content {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        max-width: 95vw !important;
        width: 95vw !important;
        height: auto !important;
        margin: 20px auto !important;
        padding: 20px !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    .modal-image,
    .modal-image.landscape,
    .modal-image.portrait {
        width: auto !important;
        max-width: 85vw !important;
        height: auto !important;
        max-height: 60vh !important;
        object-fit: contain !important;
        margin: 0 auto 20px auto !important;
        display: block !important;
        flex: none !important;
    }
    .modal-description {
        width: 100%;
        max-width: 100%;
        min-width: auto;
        margin-left: 0;
        margin-top: 0;
        padding: 16px;
        word-break: break-word;
        overflow-wrap: break-word;
        display: block;
    }
    .modal {
        overflow-x: hidden !important;
    }
}

/* Small Tablet */
@media (max-width: 900px) {
    nav a {
        font-size: 0.8rem;
    }
    nav li {
        margin: 0 0.5rem;
    }
    #welcome {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    .welcome-gap {
        height: 0.5rem;
        width: 100%;
    }

    .welcome-gap::before {
        width: 60%;
        height: 2px;
        background: linear-gradient(
            to right,
            rgba(107, 144, 128, 0),
            rgba(107, 144, 128, 0.9) 25%,
            rgba(51, 51, 51, 0.85) 50%,
            rgba(107, 144, 128, 0.9) 75%,
            rgba(107, 144, 128, 0)
        );
    }
    .welcome-bio h2 {
        font-size: 1.7rem;
    }
    .welcome-bio {
        min-height: 0;
    }
    .hero-banner {
        height: 35vh;
        min-height: 200px;
    }
    .hero-overlay {
        padding: 1rem;
        gap: 1rem;
        flex-direction: column;
        text-align: center;
    }
    .hero-logo {
        max-height: 80px;
        max-width: min(55vw, 220px);
    }
    .hero-overlay h2 {
        font-size: 1.8rem;
    }
    .hero-overlay h3 {
        font-size: 1.4rem;
    }
    .hero-overlay p {
        font-size: 0.95rem;
    }
    .category-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .category-tile {
        aspect-ratio: 16 / 7;
    }
    #artists-duo {
        margin: 1.5rem auto;
        padding: 1.2rem;
    }
    .duo-image img {
        height: 220px;
    }
    .duo-text h2 {
        font-size: 1.5rem;
    }
    .duo-text h3 {
        font-size: 1.3rem;
    }
    .header-brand h1 {
        font-size: 1rem;
    }
    .header-logo {
        height: 26px;
    }
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        grid-auto-rows: minmax(50px, auto); /* Smaller minimum for tighter packing */
        gap: 3px; /* Smaller gap */
    }
    .gallery-item.landscape .item-desc {
        min-height: 20px; /* Same as desktop for consistency */
        padding: 0.1rem 0.3rem; /* Match desktop vertical padding */
    }
    .gallery-item .item-desc h4 {
        font-size: 0.9rem; /* Smaller on medium mobile */
    }
    .gallery-item .item-desc p {
        font-size: 0.75rem; /* Smaller paragraph text */
        line-height: 1.15; /* Tighter line height */
    }
}

/* Mobile */
@media (max-width: 768px) {
    nav li {
        display: block;
        margin: 0.5rem 0;
    }
    header {
        height: 60px;
    }
    header h1 {
        font-size: 1rem;
    }
    #welcome {
        padding: 0.8rem;
        gap: 0.8rem;
    }
    .welcome-gap {
        height: 0.4rem;
    }

    .welcome-gap::before {
        width: 55%;
        height: 2px;
        background: linear-gradient(
            to right,
            rgba(107, 144, 128, 0),
            rgba(107, 144, 128, 0.9) 25%,
            rgba(51, 51, 51, 0.85) 50%,
            rgba(107, 144, 128, 0.9) 75%,
            rgba(107, 144, 128, 0)
        );
    }
    .welcome-bio h2 {
        font-size: 1.5rem;
    }
    .welcome-bio p {
        font-size: 0.9rem;
    }
    main {
        padding: 1rem;
    }
    .artist-profile {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding: 1rem;
    }
    .artist-profile img {
        width: min(100%, 320px);
        margin: 0 auto;
    }
    .modal-description {
        max-width: 100%;
        margin-left: 0;
        margin-top: 20px;
    }
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        grid-auto-rows: minmax(50px, auto); /* Smaller minimum for tighter packing */
        gap: 3px; /* Smaller gap */
    }
    .gallery-item.landscape .item-desc {
        min-height: 20px; /* Same as desktop for consistency */
        padding: 0.1rem 0.25rem; /* Match desktop vertical padding */
    }
    .gallery-item .item-desc h4 {
        font-size: 0.85rem; /* Smaller on mobile */
    }
    .gallery-item .item-desc p {
        font-size: 0.7rem; /* Much smaller paragraph text */
        line-height: 1.1; /* Very tight line height */
    }
}

/* Small Mobile */
@media (max-width: 1100px) {
    .nav-links {
        position: absolute;
        top: 40px;
        right: 0;
        background: var(--color-dark);
        flex-direction: column;
        width: 100vw;
        max-width: 280px;
        height: auto;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        display: none;
        padding: 1rem 0;
        border-radius: 0 0 8px 8px;
    }
    .nav-links.active {
        display: flex;
    }
    .nav-links li {
        margin: 0.5rem 1rem;
        text-align: right;
    }
    .hamburger {
        display: flex;
    }
    nav ul {
        flex-direction: column;
    }
    nav {
        margin-right: 0;
    }
}

/* Small Mobile */
@media (max-width: 600px) {
    .nav-links {
        max-width: 250px;
    }
    .nav-links li {
        margin: 0.5rem 0;
    }
    #welcome {
        padding: 0.6rem;
        flex-direction: column;
        text-align: center;
    }
    .hero-banner {
        height: 30vh;
        min-height: 150px;
    }
    .hero-overlay {
        padding: 0.75rem;
        border-radius: 6px;
        width: 90vw;
        max-width: 95vw;
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    .hero-logo {
        max-height: 60px;
        max-width: min(60vw, 180px);
    }
    .hero-overlay h2 {
        font-size: 1.4rem;
        margin-bottom: 0.2rem;
    }
    .hero-overlay h3 {
        font-size: 1.1rem;
        margin-bottom: 0.4rem;
    }
    .hero-overlay p {
        font-size: 0.8rem;
    }
    .category-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .category-tile {
        aspect-ratio: 16 / 7;
    }
    .category-tile__overlay h3 {
        font-size: 1.4rem;
    }
    #artists-duo {
        margin: 1rem auto;
        padding: 1rem;
    }
    .duo-image img {
        height: 180px;
    }
    .duo-text h2 {
        font-size: 1.3rem;
    }
    .duo-text h3 {
        font-size: 1.1rem;
    }
    .duo-text p {
        font-size: 0.9rem;
    }
    .header-brand h1 {
        font-size: 0.95rem;
    }
    .header-logo {
        height: 24px;
    }
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        grid-auto-rows: minmax(50px, auto); /* Smaller minimum for tighter packing */
        gap: 2px; /* Even smaller gap on mobile */
    }
    .gallery-item.portrait img,
    .gallery-item.landscape img {
        width: 100%;
        object-fit: cover;
        object-position: center;
    }
    .gallery-item p {
        font-size: 0.75rem;
        padding: 0.2rem;
        line-height: 1.2;
        margin: 0 0 0.3rem 0; /* Reduce margin to save space */
    }
    .gallery-item.portrait .item-desc {
        min-height: 60px; /* Keep minimum for portraits */
        padding: 0.3rem;
    }
    .gallery-item.landscape .item-desc {
        min-height: 20px; /* Same as desktop for consistency */
        padding: 0.1rem 0.2rem; /* Match desktop vertical padding */
    }
    .gallery-item .item-desc h4 {
        font-size: 0.9rem; /* Smaller heading on mobile */
        margin: 0 0 0.3rem 0;
    }
    .modal-content {
        padding: 15px !important;
    }

    .modal-image.portrait {
        margin-top: 10px;   /* Reduced margin to prevent cropping */
    }
    .modal-image.landscape {
        margin-top: 8px;    /* Minimal margin for landscapes */
    }
    .modal-description {
        margin-top: 12px;
        width: 100%;
        text-align: center;
    }

    .close {
        top: 10px;
        right: 10px;
        font-size: 32px;
        padding: 2px 8px;
        z-index: 1100;
        background: rgba(0,0,0,0.3);
        border-radius: 50%;
    }
}

/* Portrait nav breakpoint to prevent crowded links on medium-width phones */
@media screen and (max-width: 712px) and (orientation: portrait) {
    .nav-links {
        max-width: 250px;
        z-index: 1000;
    }

    .nav-links li {
        margin: 0.5rem 0;
    }
}

/* Portrait mode: keep homepage category tiles closer to square */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    .category-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        justify-items: center;
    }

    .category-tile {
        aspect-ratio: 1 / 1;
        width: min(74vw, 400px);
    }
}

/* ===========================
   TABLET LANDSCAPE HERO TUNING
=========================== */
@media screen and (min-width: 901px) and (max-width: 1440px) and (orientation: landscape) {
    .hero-overlay {
        padding: 1rem 1.25rem;
        gap: 1.2rem;
        max-width: min(92vw, 900px);
    }

    .hero-logo {
        max-height: 105px;
        max-width: min(32vw, 280px);
    }

    .hero-overlay h2 {
        font-size: 2.2rem;
        line-height: 1.1;
        white-space: nowrap;
    }

    .hero-overlay h3 {
        font-size: 2rem;
        line-height: 1.1;
        margin-bottom: 0.6rem;
    }

    .hero-overlay p {
        font-size: 0.95rem;
        line-height: 1.45;
    }
}

/* Keep homepage hero title on one line on tablet/square viewports */
@media screen and (min-width: 901px) and (max-width: 1200px) {
    body:not(.gallery-page) .hero-overlay {
        gap: 1rem;
        padding: 1.25rem;
        max-width: min(94vw, 900px);
    }

    body:not(.gallery-page) .hero-overlay-text {
        min-width: 0;
        writing-mode: horizontal-tb;
    }

    body:not(.gallery-page) .hero-overlay h2 {
        font-size: clamp(1.9rem, 3.1vw, 2.4rem);
        line-height: 1.1;
        white-space: nowrap;
        word-break: normal;
        overflow-wrap: normal;
        writing-mode: horizontal-tb;
    }

    body:not(.gallery-page) .hero-overlay h3,
    body:not(.gallery-page) .hero-overlay p {
        writing-mode: horizontal-tb;
        word-break: normal;
        overflow-wrap: normal;
    }

    body:not(.gallery-page) .hero-overlay h3 {
        font-size: clamp(1.65rem, 2.7vw, 2.2rem);
        line-height: 1.1;
    }

    body:not(.gallery-page) .hero-overlay p {
        font-size: clamp(0.9rem, 1.4vw, 1rem);
        line-height: 1.45;
    }
}

/* Keep homepage category links side-by-side on near-square portrait tablets */
@media screen and (min-width: 901px) and (max-width: 1024px) and (orientation: portrait) {
    #categories .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.75rem;
    }

    #categories .category-tile {
        width: 100%;
        aspect-ratio: 4 / 3;
    }
}

/* Keep homepage category links side-by-side on smaller portrait tablets */
@media screen and (min-width: 800px) and (max-width: 900px) and (orientation: portrait) {
    #categories .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem;
        justify-items: stretch;
    }

    #categories .category-tile {
        width: 100%;
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.85rem 0.5rem 0.45rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 1rem;
        line-height: 1.1;
    }
}

/* Keep category links horizontal on near-square small tablets (e.g. 840x814) */
@media screen and (min-width: 800px) and (max-width: 900px) and (min-height: 700px) {
    #categories .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem;
        justify-items: stretch;
    }

    #categories .category-tile {
        width: 100%;
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.8rem 0.5rem 0.45rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 0.98rem;
        line-height: 1.1;
    }
}

/* Use hamburger navigation on near-square tablets */
@media screen and (min-width: 700px) and (max-width: 900px) and (min-height: 700px) {
    .nav-links {
        max-width: 220px;
        z-index: 1000;
        padding: 0.6rem 0;
    }

    .nav-links li {
        display: block;
        margin: 0.35rem 0;
        padding-right: 1rem;
    }
}

/* Make hero banners taller on near-square tablet/desktop windows (e.g. 900x829) */
@media screen and (min-width: 850px) and (max-width: 930px) and (min-height: 780px) {
    .hero-banner {
        height: 48vh;
        min-height: 370px;
    }
}

/* Improve hero layout and height on near-square tablet widths (e.g. 812x796) */
@media screen and (min-width: 800px) and (max-width: 849px) and (min-height: 740px) {
    .hero-banner {
        height: 50vh;
        min-height: 390px;
    }

    body:not(.gallery-page) .hero-overlay {
        flex-direction: row;
        text-align: left;
        gap: 0.9rem;
        padding: 0.95rem 1rem;
        width: auto;
        max-width: min(92vw, 760px);
    }

    body:not(.gallery-page) .hero-logo {
        max-height: 70px;
        max-width: 160px;
    }

    body:not(.gallery-page) .hero-overlay h2 {
        font-size: 1.65rem;
        white-space: nowrap;
    }

    body:not(.gallery-page) .hero-overlay h3 {
        font-size: 1.3rem;
        margin-bottom: 0.35rem;
    }

    body:not(.gallery-page) .hero-overlay p {
        font-size: 0.9rem;
    }
}

/* Keep category links horizontal on narrower near-square screens (e.g. 756x800) */
@media screen and (min-width: 700px) and (max-width: 799px) and (min-height: 700px) {
    #categories .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.45rem;
        justify-items: stretch;
    }

    #categories .category-tile {
        width: 100%;
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.75rem 0.45rem 0.4rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 0.9rem;
        line-height: 1.1;
    }
}

/* Keep homepage hero overlay stable on near-square small tablets */
@media screen and (min-width: 700px) and (max-width: 799px) and (min-height: 700px) {
    body:not(.gallery-page) .hero-overlay {
        flex-direction: row;
        text-align: left;
        gap: 0.9rem;
        padding: 0.9rem 1rem;
        width: auto;
        max-width: min(92vw, 700px);
    }

    body:not(.gallery-page) .hero-logo {
        max-height: 65px;
        max-width: 150px;
    }

    body:not(.gallery-page) .hero-overlay h2 {
        font-size: 1.5rem;
        white-space: nowrap;
    }

    body:not(.gallery-page) .hero-overlay h3 {
        font-size: 1.2rem;
        margin-bottom: 0.35rem;
    }

    body:not(.gallery-page) .hero-overlay p {
        font-size: 0.85rem;
    }
}

/* Fix hero and category sizing on mid-small near-square screens (e.g. 544x647, 608x681) */
@media screen and (min-width: 520px) and (max-width: 680px) and (min-height: 620px) {
    .hero-banner {
        height: 42vh;
        min-height: 280px;
    }

    body:not(.gallery-page) .hero-overlay {
        flex-direction: row;
        text-align: left;
        gap: 0.7rem;
        padding: 0.75rem 0.85rem;
        width: auto;
        max-width: min(94vw, 560px);
    }

    body:not(.gallery-page) .hero-logo {
        max-height: 56px;
        max-width: 120px;
    }

    body:not(.gallery-page) .hero-overlay h2 {
        font-size: 1.25rem;
        white-space: nowrap;
    }

    body:not(.gallery-page) .hero-overlay h3 {
        font-size: 1.05rem;
        margin-bottom: 0.25rem;
    }

    body:not(.gallery-page) .hero-overlay p {
        font-size: 0.78rem;
        line-height: 1.35;
    }

    #categories .category-grid {
        grid-template-columns: 1fr;
        gap: 0.45rem;
        justify-items: center;
    }

    #categories .category-tile {
        width: min(46vw, 280px);
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.7rem 0.4rem 0.35rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 0.88rem;
        line-height: 1.1;
    }
}

/* Fix hero and category sizing on compact near-square screens (e.g. 469x609) */
@media screen and (min-width: 430px) and (max-width: 519px) and (min-height: 560px) {
    .hero-banner {
        height: 40vh;
        min-height: 260px;
    }

    .hero-overlay {
        padding: 0.6rem 0.7rem;
        gap: 0.55rem;
        max-width: 92vw;
    }

    .hero-logo {
        max-height: 50px;
        max-width: 110px;
    }

    .hero-overlay h2 {
        font-size: 1.2rem;
    }

    .hero-overlay h3 {
        font-size: 1rem;
        margin-bottom: 0.3rem;
    }

    .hero-overlay p {
        font-size: 0.72rem;
        line-height: 1.3;
    }

    #categories .category-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        justify-items: center;
    }

    #categories .category-tile {
        width: min(70vw, 250px);
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.55rem 0.35rem 0.3rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 0.9rem;
        line-height: 1.1;
    }
}

/* Keep category boxes compact on tall mobile portraits (e.g. 414x846) */
@media screen and (min-width: 390px) and (max-width: 429px) and (min-height: 760px) {
    #categories .category-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        justify-items: center;
    }

    #categories .category-tile {
        width: min(70vw, 240px);
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.6rem 0.35rem 0.3rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 0.9rem;
        line-height: 1.1;
    }
}

/* ===========================
   MOBILE PORTRAIT ORIENTATION
=========================== */
@media screen and (max-width: 768px) and (orientation: portrait) {
    .modal-content {
        max-height: 95vh !important;
        margin: 5px auto !important;
        padding: 5px !important;
        overflow-y: auto !important;
    }
    
    .modal-image.portrait {
        margin-top: 10px !important;
        max-height: 65vh !important;
        width: auto !important;
        max-width: 90vw !important;
    }
    
    .modal-image.landscape {
        margin-top: 5px !important;
        max-height: 50vh !important;
    }
    
    .close {
        top: 5px !important;
        right: 5px !important;
        font-size: 24px !important;
        width: 30px !important;
        height: 30px !important;
    }
}

/* ===========================
   MOBILE LANDSCAPE ORIENTATION
   Covers devices up to 960px width (includes Galaxy Note 20: 915x412)
=========================== */
@media screen and (max-width: 960px) and (max-height: 600px) and (orientation: landscape) {
    .hero-banner {
        margin-top: 50px;
    }
    .hero-overlay {
        flex-direction: row;
        text-align: left;
        gap: 1rem;
        padding: 0.6rem 1rem;
    }
    .hero-logo {
        max-height: 50px;
        max-width: min(30vw, 160px);
    }
    .hero-overlay h2 {
        font-size: 1.05rem;
        margin-bottom: 0.1rem;
        line-height: 1.1;
        white-space: nowrap;
    }
    .hero-overlay h3 {
        font-size: 1rem;
        margin-bottom: 0.2rem;
    }
    .hero-overlay p {
        font-size: 0.75rem;
    }
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .category-tile {
        aspect-ratio: 4 / 3;
    }
    .category-tile__overlay h3 {
        font-size: 1.2rem;
    }
    .category-tile__overlay {
        padding: 1.5rem 1rem 0.75rem;
    }
    /* Ensure modal doesn't use flex centering that causes cropping - only when open */
    .modal.modal-open {
        display: block !important; /* Override flex display when modal is open */
        padding: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    .nav-links {
        max-width: 200px;
        z-index: 1000;
        padding: 0.5rem 0;
    }
    
    .nav-links li {
        display: block;
        margin: 0.3rem 0;
        padding-right: 1rem;
    }

    /* Compact text sections to reduce extra whitespace on short landscape screens */
    #welcome {
        padding: 0.8rem;
        gap: 0.6rem;
    }

    .welcome-photo {
        margin-bottom: 0.5rem;
    }

    .welcome-bio h2 {
        margin-bottom: 0.45rem;
    }

    .welcome-bio p {
        line-height: 1.45;
    }

    #artists-duo {
        margin: 1rem auto;
        padding: 0.9rem;
    }

    .duo-image {
        margin-bottom: 0.9rem;
    }

    .duo-text p {
        line-height: 1.5;
    }

    .curated-bio {
        padding: 0.6rem 1rem 0.9rem 1rem;
        margin: 0 auto 1rem auto;
        min-height: 0;
    }

    /* Modal content positioned at top to prevent cropping */
    .modal-content {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        max-width: 95vw !important;
        width: 95vw !important;
        height: auto !important;
        margin: 0 auto !important; /* No top margin */
        padding: 40px 10px 10px 10px !important; /* Top padding for close button space */
        box-sizing: border-box !important;
    }
    
    .modal-image,
    .modal-image.landscape,
    .modal-image.portrait {
        width: auto;
        max-width: 90%;
        height: auto;
        max-height: 50vh; /* Reduced to leave room for description */
        object-fit: contain;
        margin: 0 auto 10px auto; /* No top margin to prevent cropping */
        display: block;
        flex-shrink: 0;
    }
    
    .modal-description {
        width: 100%;
        max-height: none; /* Remove max-height so text flows naturally */
        overflow-y: visible; /* No scrolling in description box */
        padding: 10px;
        flex-shrink: 0;
    }
    
    .close {
        position: fixed; /* Fixed positioning to ensure it's always visible */
        top: 5px;
        right: 5px;
        font-size: 28px;
        padding: 4px 8px;
        z-index: 1200; /* Higher z-index */
        background: rgba(0,0,0,0.7); /* More visible background */
        color: white;
        border-radius: 50%;
        cursor: pointer;
        line-height: 1;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Make hero banners taller on 846x414-style landscape screens */
@media screen and (min-width: 820px) and (max-width: 870px) and (max-height: 430px) and (orientation: landscape) {
    .hero-banner {
        height: 70vh;
        min-height: 290px;
    }
}

/* ===========================
   WIDER MOBILE LANDSCAPE (800px+ width)
   Includes Galaxy Note 20 (915px) and similar devices
=========================== */
@media screen and (min-width: 800px) and (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {
    /* Ensure modal doesn't use flex centering that causes cropping - only when open */
    .modal.modal-open {
        display: block !important;
        padding: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    /* Modal content positioned at top */
    .modal-content {
        margin: 0 auto !important;
        padding: 40px 10px 10px 10px !important;
        justify-content: flex-start !important;
    }
    
    .modal-image,
    .modal-image.portrait,
    .modal-image.landscape {
        margin-top: 0 !important;
        max-height: 50vh !important;
    }
}

/* ===========================
   MEDIUM TO LARGE SCREENS - Force vertical stacking to prevent cropping
   Using more specific selectors to override any conflicting rules
   Handles split-screen mode on Windows 11 (1/4 screen windows)
=========================== */
@media screen and (min-width: 1025px) and (max-width: 1799px) {
    .modal .modal-content,
    .modal-content {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        max-width: 95vw !important;
        width: 95vw !important;
        height: auto !important;
        margin: 10px auto !important; /* Reduced margin for split-screen */
        padding: 15px !important; /* Reduced padding */
        overflow-y: visible !important; /* Allow modal to scroll */
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        display: flex !important;
    }
    
    .modal .modal-image,
    .modal .modal-image.landscape,
    .modal .modal-image.portrait,
    .modal-image,
    .modal-image.landscape,
    .modal-image.portrait {
        max-width: 85vw !important;
        width: auto !important;
        height: auto !important;
        max-height: 60vh !important;
        margin: 5px auto 15px auto !important; /* Reduced top margin */
        object-fit: contain !important;
        flex: none !important;
        display: block !important;
    }
    
    .modal .modal-description,
    .modal-description {
        flex: none !important;
        width: 100% !important;
        max-width: none !important;
        min-width: auto !important;
        margin-left: 0 !important;
        margin-top: 0 !important;
        text-align: center !important;
    }
}

/* ===========================
   VERY WIDE SCREENS - Side by side layout
=========================== */
@media screen and (min-width: 1800px) {
    .modal-content {
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        height: 85% !important;
    }
    
    .modal-image {
        max-width: 60% !important;
        margin: 0 20px 0 0 !important;
        flex: 1 !important;
    }
    
    .modal-description {
        flex: 0 0 40% !important;
        min-width: 250px !important;
        margin-left: 20px !important;
        margin-top: 0 !important;
        text-align: left !important;
    }
}

/* ===========================
   FIXED THUMBNAIL SIZES - Override responsive scaling
=========================== */
@media (max-width: 1024px) {
    .gallery-item.portrait,
    .gallery-item.landscape {
        min-height: 380px !important;
        height: 380px !important;
    }
    .gallery-item.portrait img,
    .gallery-item.landscape img {
        height: 280px !important;
        flex: 0 0 280px !important;
    }
}

/* Compact homepage category boxes on tall small phones (e.g. 360x760, 360x780) */
@media screen and (min-width: 340px) and (max-width: 389px) and (min-height: 740px) {
    #categories .category-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        justify-items: center;
    }

    #categories .category-tile {
        width: min(70vw, 220px);
        aspect-ratio: 16 / 10;
    }

    #categories .category-tile__overlay {
        padding: 0.55rem 0.35rem 0.3rem;
    }

    #categories .category-tile__overlay h3 {
        font-size: 0.88rem;
        line-height: 1.1;
    }
}

/* Match Hurricane's subtitle width and vertical metrics using local Arial Bold. */
@font-face {
    font-family: "Hurricane Fallback";
    src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold");
    font-weight: 700;
    size-adjust: 58.5065%;
    ascent-override: 162.3751%;
    descent-override: 73.4961%;
    line-gap-override: 0%;
}

/* Larger homepage branding, with room for the overlay to grow on small screens. */
body[data-page-type="home"] .hero-banner {
    display: grid;
    align-items: center;
    height: auto;
    min-height: clamp(400px, 70vh, 980px);
}

body[data-page-type="home"] .hero-picture,
body[data-page-type="home"] .hero-image {
    position: absolute;
    inset: 0;
}

body[data-page-type="home"] .hero-overlay {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    box-sizing: border-box;
    width: calc(100% - 2rem);
    max-width: 1600px;
    margin: 2rem auto;
    padding: 4rem;
    gap: 4rem;
}

body[data-page-type="home"] .hero-logo {
    width: 520px;
    max-height: 280px;
    max-width: min(80vw, 520px);
}

body[data-page-type="home"] .hero-overlay h2 {
    font-size: 6rem;
    line-height: 1.15;
    white-space: normal;
}

body[data-page-type="home"] .hero-overlay h3 {
    font-family: "Hurricane", "Hurricane Fallback", cursive;
    font-size: 6.4rem;
    line-height: 1.1;
    min-block-size: 1.1em;
}

body[data-page-type="home"] .hero-overlay p {
    font-size: 2.1rem;
}

@media screen and (max-width: 1440px) {
    body[data-page-type="home"] .hero-overlay {
        flex-direction: column;
        text-align: center;
        padding: 2rem;
        gap: 2rem;
    }

    body[data-page-type="home"] .hero-logo {
        max-height: 210px;
    }

    body[data-page-type="home"] .hero-overlay h2 {
        font-size: 4.4rem;
    }

    body[data-page-type="home"] .hero-overlay h3 {
        font-size: 4rem;
    }

    body[data-page-type="home"] .hero-overlay p {
        font-size: 1.9rem;
    }
}

@media screen and (max-width: 900px) {
    body[data-page-type="home"] .hero-logo {
        max-height: 160px;
    }

    body[data-page-type="home"] .hero-overlay h2 {
        font-size: 3.6rem;
    }

    body[data-page-type="home"] .hero-overlay h3 {
        font-size: 2.8rem;
    }
}

@media screen and (max-width: 600px) {
    body[data-page-type="home"] .hero-overlay {
        padding: 1.5rem;
        gap: 1.5rem;
    }

    body[data-page-type="home"] .hero-logo {
        max-height: 120px;
    }

    body[data-page-type="home"] .hero-overlay h2 {
        font-size: 2.8rem;
    }

    body[data-page-type="home"] .hero-overlay h3 {
        font-size: 2.2rem;
    }

    body[data-page-type="home"] .hero-overlay p {
        font-size: 1.6rem;
    }
}

@media (hover: none) and (pointer: coarse) {
    .modal {
        padding-left: 8px;
        padding-right: 8px;
    }

    .modal-content {
        width: min(96vw, 900px);
    }

    .modal-nav {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }
}