/*
 * Public-site additions: portfolio filtering, pagination and project detail.
 *
 * Written as plain CSS with its own class prefix rather than Tailwind utilities,
 * because the Vite/Tailwind bundle cannot be rebuilt in the deploy environment.
 * Palette values mirror the @theme tokens in resources/css/app.css.
 */

/* Token names are distinct from Tailwind's --color-* vars, so there is no clash. */
:root {
    --cream-50: #fdfbf6;
    --cream-100: #faf7f2;
    --cream-200: #f3ede2;
    --cream-300: #e8dfcc;
    --ink-300: #7a6e60;
    --ink-500: #5a4f44;
    --ink-700: #3a322a;
    --ink-900: #2a2520;
    --bronze-300: #d6b886;
    --bronze-500: #c39c5f;
    --bronze-700: #8b6f47;
    --serif: 'Cormorant Garamond', ui-serif, Georgia, serif;
}

/* --------------------------------------------------------------- filters */

.sm-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    /* Breathing room under the page heading, which sits tight above it. */
    margin-top: 2rem;
    margin-bottom: 2.75rem;
    max-width: 64rem;
}

@media (min-width: 1024px) {
    .sm-toolbar { margin-top: 2.75rem; }
}

.sm-chip {
    display: inline-block;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid rgba(139, 111, 71, 0.25);
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink-500);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sm-chip:hover { border-color: var(--bronze-500); color: var(--ink-900); }
.sm-chip.is-active {
    background: var(--ink-900);
    border-color: var(--ink-900);
    color: var(--cream-100);
}
.sm-chip .sm-chip-count { opacity: 0.55; margin-left: 5px; font-size: 12px; }

.sm-search {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}
.sm-search input {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(139, 111, 71, 0.25);
    background: rgba(255, 255, 255, 0.7);
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-900);
    width: 210px;
    max-width: 46vw;
}
.sm-search input::placeholder { color: var(--ink-300); }
.sm-search input:focus {
    outline: none;
    border-color: var(--bronze-500);
    box-shadow: 0 0 0 3px rgba(195, 156, 95, 0.16);
}
.sm-search button {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--ink-900);
    background: var(--ink-900);
    color: var(--cream-100);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.25s ease;
}
.sm-search button:hover { opacity: 0.85; }

.sm-result-note {
    font-size: 14px;
    color: var(--ink-300);
    margin: -20px 0 30px;
    max-width: 64rem;
}
.sm-result-note a { color: var(--bronze-700); }

/* ------------------------------------------------------------ pagination */

.sm-pagination {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 48px;
    max-width: 64rem;
}
.sm-pagination a,
.sm-pagination span {
    min-width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(139, 111, 71, 0.22);
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink-500);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.25s ease;
}
.sm-pagination a:hover { border-color: var(--bronze-500); color: var(--ink-900); }
.sm-pagination .is-current span {
    background: var(--ink-900);
    border-color: var(--ink-900);
    color: var(--cream-100);
}
.sm-pagination .is-disabled span { opacity: 0.35; }
.sm-pagination li { list-style: none; }
.sm-pagination { padding-left: 0; }

/* --------------------------------------------------------- project card */

.sm-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}
.sm-card-link:hover .sm-card-title { color: var(--bronze-700); }
.sm-card-media { overflow: hidden; }
.sm-card-media img {
    /* Natural proportions — no fixed ratio, no cropping. */
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.sm-card-link:hover .sm-card-media img { transform: scale(1.04); }

/* Home page statistics ---------------------------------------------------
   The markup is `grid-cols-3` with no responsive variant, so on a phone three
   columns of ~100px have to hold a 3rem number like "60,000" and a label like
   "Million+ Emails / Quarter". Stack them instead, number beside label. */

@media (max-width: 639px) {
    .sm-stats {
        grid-template-columns: 1fr;
        gap: 1.15rem;
        margin-top: 3.5rem;
        padding-top: 2rem;
    }
    .sm-stats > div {
        display: flex;
        align-items: baseline;
        gap: 0.9rem;
    }
    .sm-stats .stat-number {
        font-size: 2.25rem;
        flex: 0 0 auto;
        /* Keeps the labels aligned in a tidy second column. */
        min-width: 4.5ch;
    }
    .sm-stats .eyebrow {
        margin-top: 0;
        letter-spacing: 0.12em;
        font-size: 0.68rem;
        line-height: 1.5;
    }
}

/* Small tablets: three across still fits, but not at the full 3rem. */
@media (min-width: 640px) and (max-width: 900px) {
    .sm-stats { gap: 1.25rem; }
    .sm-stats .stat-number { font-size: 2.1rem; }
    .sm-stats .eyebrow { letter-spacing: 0.1em; font-size: 0.66rem; }
}

/* Masonry card grid, used by /projects and the home page featured row. */
.sm-cards {
    max-width: 64rem;
    column-count: 1;
    column-gap: 2rem;
}
.sm-card-item {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin: 0 0 2rem;
    display: block;
    width: 100%;
}

@media (min-width: 768px) {
    .sm-cards { column-count: 2; }
}
@media (min-width: 1400px) {
    .sm-cards { column-count: 3; }
}

/* The home page shows three featured items, so it goes wide sooner. */
.sm-cards-featured { column-gap: 1.75rem; }
@media (min-width: 640px) {
    .sm-cards-featured { column-count: 2; }
}
@media (min-width: 1024px) {
    .sm-cards-featured { column-count: 3; }
}

/* -------------------------------------------------------- project detail */

.sm-breadcrumb {
    font-size: 13px;
    color: var(--ink-300);
    margin-bottom: 28px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.sm-breadcrumb a { color: var(--bronze-700); text-decoration: none; }
.sm-breadcrumb a:hover { color: var(--ink-900); }

.sm-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    padding: 22px 0;
    margin: 32px 0;
    border-top: 1px solid rgba(139, 111, 71, 0.16);
    border-bottom: 1px solid rgba(139, 111, 71, 0.16);
    max-width: 64rem;
}
.sm-detail-meta div { min-width: 120px; }
.sm-detail-meta dt {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-300);
    margin-bottom: 6px;
}
.sm-detail-meta dd {
    margin: 0;
    font-family: var(--serif);
    font-size: 21px;
    color: var(--ink-900);
}

/* Cover + gallery side by side ------------------------------------------ */

.sm-showcase {
    max-width: 80rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

@media (min-width: 1024px) {
    .sm-showcase {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
        gap: 40px;
        align-items: start;
    }
    /* With only one of the two present, let it use the full width. */
    .sm-showcase.is-gallery-only,
    .sm-showcase.is-cover-only {
        grid-template-columns: 1fr;
    }
}

.sm-showcase-cover { min-width: 0; }
.sm-showcase-gallery { min-width: 0; }

/* Beside the cover there is room for two columns, not three. */
.sm-showcase .sm-gallery { max-width: none; }

@media (min-width: 1024px) {
    .sm-showcase .sm-gallery { column-count: 2; }
    .sm-showcase.is-gallery-only .sm-gallery { column-count: 3; }
}

.sm-hero {
    /* Shrink to the image so a small cover is not framed in dead space. */
    width: fit-content;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: var(--cream-200);
    border: 1px solid rgba(139, 111, 71, 0.12);
}
/* Scoped past `.sm-tile > img`, which sets width:100% and is declared later. */
.sm-hero .sm-tile { width: auto; }
.sm-hero .sm-tile > img {
    /* Never upscale past the file's own resolution. */
    width: auto;
    max-width: 100%;
    height: auto;
    display: block;
}

.sm-prose {
    max-width: 44rem;
    color: var(--ink-500);
    font-size: 17px;
    line-height: 1.8;
    white-space: pre-line;
}

/* Masonry via CSS columns: items keep their natural aspect ratio and stack
   with no cropping. Real `grid-template-rows: masonry` is not shipping widely
   enough to rely on, and columns need no JavaScript. */
.sm-gallery {
    max-width: 64rem;
    column-count: 1;
    column-gap: 18px;
}

@media (min-width: 640px) {
    .sm-gallery { column-count: 2; }
}
@media (min-width: 1280px) {
    .sm-gallery { column-count: 3; }
}

.sm-gallery-item {
    /* Stop a tile being split across two columns. */
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin: 0 0 18px;
    display: block;
    width: 100%;
}

.sm-gallery button {
    padding: 0;
    border: 1px solid rgba(139, 111, 71, 0.12);
    border-radius: 10px;
    overflow: hidden;
    background: var(--cream-200);
    cursor: zoom-in;
    display: block;
    width: 100%;
}
.sm-gallery img {
    width: 100%;
    height: auto;          /* respect the file's own proportions */
    display: block;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.sm-gallery button:hover img { transform: scale(1.03); }

/* `auto 16/9` means: use the video's own ratio once metadata arrives, and only
   fall back to 16/9 before then — so the column reserves space without ever
   overriding the real proportions. */
.sm-video {
    border: 1px solid rgba(139, 111, 71, 0.12);
    border-radius: 10px;
    overflow: hidden;
    background: var(--ink-900);
}
.sm-video video {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: auto 16 / 9;
    background: var(--ink-900);
}

/* Gallery / hero tiles are buttons that open the modal. */
.sm-tile {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
    position: relative;
    font: inherit;
    color: inherit;
}
.sm-tile-video { cursor: pointer; }
.sm-tile > img,
.sm-tile > video {
    width: 100%;
    height: auto;
    display: block;
    /* The tile is the click target, so the media itself must not swallow it. */
    pointer-events: none;
}
/* Poster-less video thumbnails: real ratio once metadata lands, 16/9 until then. */
.sm-tile > video {
    aspect-ratio: auto 16 / 9;
    background: var(--ink-900);
}
.sm-tile:focus-visible {
    outline: 2px solid var(--bronze-700);
    outline-offset: 3px;
}

.sm-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 62px;
    height: 62px;
    border-radius: 999px;
    background: rgba(42, 37, 32, 0.62);
    color: #fff;
    display: grid;
    place-items: center;
    pointer-events: none;
    transition: background 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(2px);
}
.sm-tile-video:hover .sm-play {
    background: var(--bronze-700);
    transform: scale(1.06);
}

/* Native modal ---------------------------------------------------------- */

.sm-modal {
    /* Tailwind's preflight sets `margin: 0` on every element, which wipes out
       the `margin: auto` the UA stylesheet uses to centre a modal <dialog>.
       Re-centre explicitly rather than relying on the browser default. */
    position: fixed;
    inset: 0;
    margin: auto;
    width: fit-content;
    height: fit-content;
    max-width: 94vw;
    max-height: 94vh;
    border: none;
    padding: 0;
    background: transparent;
    overflow: visible;
    color: var(--cream-100);
}
.sm-modal::backdrop {
    background: rgba(28, 24, 20, 0.88);
    backdrop-filter: blur(3px);
}
.sm-modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
}
.sm-modal-body img,
.sm-modal-body video {
    display: block;
    max-width: 94vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    border-radius: 6px;
    background: #000;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}
.sm-modal-body p { color: var(--cream-200); padding: 24px; }
.sm-modal-body p a { color: var(--bronze-300); }

/* Anchored to the modal's own top-right corner, not the viewport's. */
.sm-modal-close {
    position: absolute;
    top: -16px;
    right: -16px;
    background: var(--ink-900);
    border: 1px solid rgba(250, 247, 242, 0.25);
    color: var(--cream-100);
    font-size: 26px;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    cursor: pointer;
    z-index: 2;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}
.sm-modal-close:hover { background: var(--bronze-700); transform: scale(1.06); }
.sm-modal-close:focus-visible { outline: 2px solid var(--bronze-300); outline-offset: 2px; }

/* On small screens the corner would sit off-screen, so tuck it inside. */
@media (max-width: 640px) {
    .sm-modal { max-width: 92vw; }
    .sm-modal-close { top: 6px; right: 6px; }
}

/* The related-work block follows the gallery with no top padding of its own,
   so give the "— More …" heading room to breathe. */
.sm-related { padding-top: 2.5rem; }

@media (min-width: 1024px) {
    .sm-related { padding-top: 4rem; }
}

/* Prev / next */
.sm-neighbours {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid rgba(139, 111, 71, 0.16);
    max-width: 64rem;
}
.sm-neighbour {
    text-decoration: none;
    max-width: 46%;
    color: var(--ink-500);
}
.sm-neighbour.is-next { text-align: right; margin-left: auto; }
.sm-neighbour span {
    display: block;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-300);
    margin-bottom: 6px;
}
.sm-neighbour strong {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 500;
    color: var(--ink-900);
    transition: color 0.25s ease;
}
.sm-neighbour:hover strong { color: var(--bronze-700); }

@media (max-width: 640px) {
    .sm-search { margin-left: 0; width: 100%; }
    .sm-search input { flex: 1; max-width: none; }
    .sm-detail-meta { gap: 20px; }
    .sm-neighbour { max-width: 100%; }
    .sm-neighbour.is-next { text-align: left; margin-left: 0; }
}
