:root {
    --bg: #f4efe8;
    --ink: #16120f;
    --muted: #756b61;
    --line: rgba(22, 18, 15, .16);
    --card: rgba(255, 252, 247, .82);
    --radius: 28px;
    --gap: 24px;
    --serif: Georgia, serif
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden
}

body {
    font-family: system-ui, sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 15% 10%, rgba(181, 74, 48, .2), transparent 30vw), var(--bg)
}

button {
    font: inherit;
    cursor: pointer
}

.app {
    position: fixed;
    inset: 28px
}

.screen {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(360px, .58fr) 1fr;
    gap: var(--gap)
}

.copy-card,
.content-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 24px 70px rgba(22, 18, 15, .16);
    overflow: hidden
}

.copy-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.copy-content {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 46px 46px 24px;
}

.copy-nav {
    position: absolute;
    left: 50%;
    bottom: 24px;
    translate: -50% 0;
    display: flex;
    gap: 10px;
    padding: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .55)
}

.round-button,
.home-button,
.image-arrow,
.lightbox-arrow,
.submit-button {
    border: 0;
    background: #16120f;
    color: #fff
}

.round-button {
    width: 46px;
    height: 46px;
    border-radius: 999px
}

.home-button {
    height: 46px;
    border-radius: 999px;
    padding: 0 18px
}

h1 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(38px, 5vw, 74px);
    line-height: .94;
    margin: 0;
    letter-spacing: -.05em
}

.lede,
.support {
    color: var(--muted);
    line-height: 1.45
}

.content-card {
    padding: 20px
}

.content-card.is-home .focus-carousel,
.content-card.is-home .contact-form {
    display: none
}

.content-card.is-gallery .category-grid,
.content-card.is-gallery .contact-form {
    display: none
}

.content-card.is-contact .category-grid,
.content-card.is-contact .focus-carousel {
    display: none
}

.category-grid {
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px
}

.category-tile {
    position: relative;
    border: 0;
    border-radius: 22px;
    padding: 16px;
    color: #fff;
    background: var(--tile-colour, #333);
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    text-align: left
}

.category-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0
}

.category-tile:after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, .7));
    z-index: 1
}

.category-tile strong {
    position: relative;
    z-index: 2;
    font-family: var(--serif);
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 400
}

.focus-carousel {
    position: relative;
    height: 100%
}

.image-track {
    height: 100%;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    overflow: hidden;
    border-radius: 22px
}

.image-item {
    position: relative;
    border: 0;
    padding: 0;
    background: #FFF;
    opacity: .2
}

.image-item.is-active {
    opacity: 1
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: contain
}

.image-caption {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    padding: 14px;
    border-radius: 18px;
    color: #fff;
    background: rgba(0, 0, 0, .58)
}

.image-caption p {
    margin: .25rem 0 0
}

.empty-gallery {
    height: 100%;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 22px
}

.image-arrow {
    position: absolute;
    z-index: 3;
    top: 50%;
    translate: 0 -50%;
    width: 48px;
    height: 48px;
    border-radius: 999px
}

.image-arrow-left {
    left: 12px
}

.image-arrow-right {
    right: 12px
}

.contact-form {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: 24px
}

.form-row.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px
}

input,
textarea {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    background: #fffaf4
}

textarea {
    min-height: 150px
}

.hidden-field {
    position: absolute;
    left: -9999px
}

.submit-button {
    border-radius: 999px;
    padding: 12px 18px;
    align-self: flex-start
}

.lightbox {
    width: min(1180px, calc(100vw - 28px));
    height: min(820px, calc(100vh - 28px));
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: #111;
    color: #fff
}

.lightbox::backdrop {
    background: rgba(0, 0, 0, .7)
}

.lightbox figure {
    margin: 0;
    width: 100%;
    height: 100%;
    position: relative
}

.lightbox img {
    width: 100%;
    height: 100%;
    object-fit: contain
}

.lightbox figcaption {
    position: absolute;
    left: 14px;
    bottom: 14px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(0, 0, 0, .55)
}

.close {
    position: absolute;
    z-index: 5;
    top: 12px;
    right: 12px;
    border: 0;
    border-radius: 999px;
    width: 42px;
    height: 42px;
    background: rgba(255, 252, 247, 0.92);
    color: #16120f
}

.lightbox-arrow {
    position: absolute;
    z-index: 5;
    top: 50%;
    width: 48px;
    height: 48px;
    border-radius: 999px
}

.lightbox-arrow-left {
    left: 14px
}

.lightbox-arrow-right {
    right: 14px
}

@media(max-width:760px) {
    .app {
        inset: 12px
    }

    .screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr
    }

    .copy-card {
        min-height: 300px;
        padding: 10px 10px 90px
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr)
    }
}


/* ─── Caption: single image description inside the image card ─────────────── */

.image-caption,
.image-caption-single {
    overflow: hidden;
    scrollbar-width: none;
}

.image-caption::-webkit-scrollbar,
.image-caption-single::-webkit-scrollbar {
    display: none;
}

.image-caption-single {
    display: block;
    left: clamp(8px, 1.2vw, 14px);
    right: clamp(8px, 1.2vw, 14px);
    bottom: clamp(8px, 1.2vw, 14px);
    padding: clamp(9px, 1.2vw, 14px);
    line-height: 1.2;
}

.image-caption-single strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: clamp(15px, 1.6vw, 23px);
    line-height: 1.12;
}

.image-item {
    min-height: 0;
}

.image-item img {
    display: block;
}

@media (max-height: 720px) {
    .image-caption-single {
        padding: 8px 10px;
    }

    .image-caption-single strong {
        font-size: clamp(13px, 1.25vw, 17px);
    }
}

@media (max-width: 760px) {
    .image-caption-single strong {
        -webkit-line-clamp: 3;
    }
}

/* ─── Lightbox fixes ──────────────────────────────────────────────────────── */

.lightbox {
    overflow: hidden !important;
}

.lightbox figure {
    overflow: hidden;
}

.lightbox figcaption {
    overflow: hidden !important;
    scrollbar-width: none;
    max-width: min(680px, calc(100% - 28px));
}

.lightbox figcaption::-webkit-scrollbar {
    display: none;
}

.lightbox figcaption strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.12;
}

/* Description panel intentionally hidden — remove p element if not needed */
.lightbox figcaption p,
.lightbox figcaption p[hidden] {
    display: none !important;
}

@media (max-height: 720px) {
    .lightbox figcaption {
        left: 10px;
        right: 10px;
        bottom: 10px;
        max-width: calc(100% - 20px);
    }

    .lightbox figcaption strong {
        font-size: clamp(13px, 1.25vw, 17px);
    }
}

@media (max-width: 760px) {
    .lightbox figcaption strong {
        -webkit-line-clamp: 3;
    }
}

/* ─── Lightbox close button ───────────────────────────────────────────────── */

#closeLightbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    line-height: 1;
    font-size: 30px;
    font-weight: 300;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#closeLightbox::before,
#closeLightbox::after {
    content: none !important;
}

@media (max-width: 430px), (max-height: 680px) {
    #closeLightbox {
        width: 38px;
        height: 38px;
        font-size: 27px;
    }
}

/* ─── Form field font inheritance ─────────────────────────────────────────── */

input,
textarea,
button {
    font: inherit;
    color: inherit;
}

.contact-form {
    min-height: 0;
}

.contact-form label,
.contact-form input,
.contact-form textarea,
.contact-form button {
    max-width: 100%;
}

.contact-form textarea {
    min-height: clamp(110px, 24vh, 180px);
}

/* ─── Navigation bar (copy-nav) — static flex child, never scrolls ───────── */

/* Shared nav bar style on all layouts */
.copy-nav {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px 12px;
    border-top: 1px solid var(--line);
    background: rgba(255, 252, 247, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Mobile portrait: stacked layout */
@media (max-width: 760px) and (min-height: 501px) {
    .app {
        position: fixed !important;
        inset: 12px;
        min-height: 0;
        height: auto;
        padding: 0;
    }

    .screen {
        position: absolute;
        inset: 0;
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        gap: 12px;
    }

    /* copy-card: tighter on mobile, text scrolls, nav stays put */
    .copy-card {
        max-height: 44vh;
    }

    .copy-content {
        padding: 16px 16px 8px;
    }

    .content-card {
        min-height: 0;
        height: auto;
        overflow: hidden;
        padding: 12px;
    }

    .category-grid,
    .focus-carousel,
    .image-track {
        min-height: 0;
        height: 100%;
    }

    .image-item,
    .image-item img {
        min-height: 0;
    }

    .copy-nav {
        padding: 5px 16px 6px;
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .copy-nav .round-button {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .copy-nav .home-button {
        height: 32px;
        padding-inline: 12px;
        font-size: 13px;
    }
}

@media (max-width: 380px) and (min-height: 501px) {
    .copy-nav {
        gap: 7px;
    }

    .copy-nav .round-button {
        width: 39px;
        height: 39px;
    }

    .copy-nav .home-button {
        height: 39px;
        padding-inline: 13px;
    }
}

/* ─── Contact / About page: allow vertical scrolling on mobile ────────────── */

@media (max-width: 760px) {
    body:has(.content-card.is-contact) {
        height: auto !important;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
    }

    body:has(.content-card.is-contact) .app {
        position: relative !important;
        inset: auto;
        min-height: calc(100dvh - 82px);
        padding: 12px;
    }

    body:has(.content-card.is-contact) .screen {
        position: relative !important;
        inset: auto;
        height: auto;
        min-height: 0;
        grid-template-rows: auto auto;
    }

    body:has(.content-card.is-contact) .copy-card {
        max-height: none;
        overflow: visible;
    }

    body:has(.content-card.is-contact) .content-card.is-contact {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .content-card.is-contact .contact-form {
        display: flex !important;
        height: auto;
        min-height: 0;
        max-height: none;
        overflow: visible;
        justify-content: flex-start;
        padding: 8px;
        gap: 10px;
    }

    .content-card.is-contact .form-row,
    .content-card.is-contact .form-row.two {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .content-card.is-contact input,
    .content-card.is-contact textarea {
        width: 100%;
        min-width: 0;
    }

    .content-card.is-contact textarea {
        min-height: 120px;
        max-height: 220px;
    }

    .content-card.is-contact .submit-button {
        width: 100%;
        text-align: center;
    }

    /* Fallback for older browsers without :has() */
    body.contact-scroll {
        height: auto !important;
        min-height: 100%;
        overflow-y: auto;
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 430px), (max-height: 680px) {
    .content-card.is-contact .contact-form {
        padding: 4px;
    }

    .content-card.is-contact textarea {
        min-height: 96px;
    }
}

/* ─── Landscape mobile: revert to desktop side-by-side layout ──────────────
   When the screen is too short to stack text above image usefully
   (phone held sideways), switch back to the two-column desktop layout.
   Threshold: viewport height ≤ 500px (covers all phones in landscape).
   We also re-show the copy-nav inside the card rather than fixed at bottom. */

@media (max-height: 500px) and (max-width: 1024px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    body {
        padding-bottom: 0;
    }

    .app {
        position: fixed !important;
        inset: 10px !important;
        height: auto !important;
        padding: 0 !important;
    }

    /* Two-column side by side */
    .screen {
        position: absolute !important;
        inset: 0 !important;
        height: 100% !important;
        display: grid !important;
        grid-template-columns: minmax(220px, 0.48fr) 1fr !important;
        grid-template-rows: 1fr !important;
        gap: 10px !important;
    }

    /* Copy card: full height, flex column already — just remove the portrait cap */
    .copy-card {
        max-height: none !important;
        height: 100% !important;
    }

    .copy-content {
        padding: 14px 16px 8px !important;
    }

    /* Content card: full height */
    .content-card {
        height: 100% !important;
        overflow: hidden !important;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .category-grid,
    .focus-carousel,
    .image-track {
        height: 100% !important;
    }

    .copy-nav .round-button {
        width: 34px !important;
        height: 34px !important;
    }

    .copy-nav .home-button {
        height: 34px !important;
        padding-inline: 12px !important;
        font-size: 13px;
    }

    h1 {
        font-size: clamp(22px, 4vw, 42px);
    }
}

@media (max-width: 760px) {
    .copy-content {
        background:
            linear-gradient(#fffcf7 30%, #fffcf700) top,
            linear-gradient(#fffcf700, #fffcf7 70%) bottom,
            radial-gradient(farthest-side at 50% 0, rgba(22,18,15,.24), transparent) top,
            radial-gradient(farthest-side at 50% 100%, rgba(22,18,15,.24), transparent) bottom;
        background-repeat: no-repeat;
        background-size: 100% 34px, 100% 34px, 100% 14px, 100% 14px;
        background-attachment: local, local, scroll, scroll;
    }
}