@font-face {
    font-family: "Fraunces";
    src: url("../fonts/fraunces-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Fraunces";
    src: url("../fonts/fraunces-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Source Sans 3";
    src: url("../fonts/source-sans-3-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Source Sans 3";
    src: url("../fonts/source-sans-3-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

:root {
    --paper: #f3ecdf;
    --sheet: #fbf7f0;
    --plate: #f7f3ea;
    --ink: #241c14;
    --muted: #5c5146;
    --line: #e0d3bf;
    --indigo: #1e3f86;
    --indigo-deep: #163472;
    --marigold: #e0a31a;
    --clay: #9a3f2c;
    --sans: "Source Sans 3", "Segoe UI", sans-serif;
    --serif: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
}

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

html {
    background: var(--paper);
    color: var(--ink);
    color-scheme: light;
}

body {
    margin: 0 auto;
    max-width: 1120px;
    padding: 1.25rem 1.15rem 2.5rem;
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.5;
    background: var(--paper);
}

body::before {
    content: "";
    position: fixed;
    z-index: 20;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--indigo) 0 72%, var(--marigold) 72% 100%);
}

img {
    max-width: 100%;
    height: auto;
}

h1, h2, p {
    overflow-wrap: break-word;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

a {
    color: var(--indigo);
}

a:hover {
    color: var(--indigo-deep);
}

:focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 3px;
}

::selection {
    background: var(--indigo);
    color: #fff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 30;
    background: var(--sheet);
    color: var(--ink);
    padding: 0.6rem 0.8rem;
}

.skip:focus {
    top: 0.8rem;
}

.site-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    align-items: center;
    padding: 0.4rem 0 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.brand-mark {
    width: 2.6rem;
    height: 2.6rem;
    flex: none;
}

.brand-mark circle {
    fill: none;
    stroke: var(--indigo);
    stroke-width: 2.2;
}

.brand-mark circle:last-child {
    stroke: var(--marigold);
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    font-family: var(--serif);
    font-size: 1.2rem;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.brand-place {
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.search {
    display: flex;
    gap: 0.5rem;
    min-width: 0;
}

.search input,
.admin-filter input,
.product-form input[type="text"],
.product-form textarea,
.login-card input {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cbbba4;
    background: var(--sheet);
    color: var(--ink);
    padding: 0.55rem 0.75rem;
    font: inherit;
}

.product-form textarea {
    min-height: 14rem;
    resize: vertical;
    line-height: 1.5;
}

.search input {
    min-width: 0;
    flex: 1;
}

.search button,
.button,
.text-button {
    font: inherit;
    cursor: pointer;
}

.search button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.55rem 1rem;
    border: 1px solid var(--indigo);
    background: var(--indigo);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.search button:hover,
.button:hover {
    background: var(--indigo-deep);
    color: #fff;
}

.button.secondary {
    background: transparent;
    color: var(--indigo);
}

.button.secondary:hover {
    background: rgba(30, 63, 134, 0.06);
    color: var(--indigo-deep);
}

.button.danger {
    background: transparent;
    color: var(--clay);
    border-color: var(--clay);
}

.button.danger:hover {
    background: rgba(154, 63, 44, 0.08);
    color: var(--clay);
}

.button.danger.solid {
    background: var(--clay);
    color: #fff;
}

.button.danger.solid:hover {
    background: #7e3122;
    color: #fff;
}

.text-button {
    border: 0;
    background: none;
    color: var(--indigo);
    font-weight: 600;
    min-height: 44px;
    padding: 0 0.2rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.header-actions a {
    font-weight: 600;
    text-decoration: none;
}

.header-actions a:hover {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.header-actions form {
    margin: 0;
}

.flash {
    margin: 1rem 0 0;
    padding: 0.75rem 0.9rem;
    background: var(--sheet);
    border: 1px solid var(--line);
    border-left: 4px solid var(--indigo);
}

.flash-ok {
    border-left-color: #2d6a4f;
}

.flash-error {
    border-left-color: var(--clay);
}

.masthead {
    display: grid;
    gap: 1.25rem;
    padding: 1.6rem 0 1.4rem;
}

.eyebrow {
    margin: 0 0 0.45rem;
    color: var(--indigo);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow a {
    color: inherit;
    text-decoration: none;
}

.eyebrow a:hover {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.masthead h1,
.admin-head h1,
.empty h1,
.product-copy h1,
.login-card h1 {
    margin: 0;
    font-size: clamp(2.2rem, 1.15rem + 3.5vw, 4.5rem);
}

.lede,
.site-footer p {
    white-space: pre-line;
}

.lede {
    max-width: 40rem;
    margin: 0.8rem 0 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.piece-count {
    margin: 0;
}

.piece-count strong {
    display: block;
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(3rem, 8vw, 4.6rem);
    line-height: 0.85;
    letter-spacing: -0.04em;
    color: var(--indigo);
}

.piece-count span {
    color: var(--muted);
}

.results-title {
    margin: 0 0 1rem;
    color: var(--muted);
}

.catalog {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.35rem;
}

.card,
.card a,
.gallery,
.product-copy,
.admin-row {
    min-width: 0;
}

.card a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.card-photo,
.admin-thumb,
.photo-tile img,
.delete-photo {
    background: var(--plate);
    border: 1px solid var(--line);
}

.card-photo {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.card-photo img,
.admin-thumb img,
.photo-tile img,
.delete-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card h2 {
    margin: 0.7rem 0 0.25rem;
    font-size: 1.45rem;
}

.card a:hover h2,
.admin-row h2 a:hover {
    text-decoration: underline;
    text-underline-offset: 0.16em;
}

.card-meta {
    display: flex;
    gap: 0.75rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.card-meta span:first-child {
    flex: none;
    color: var(--indigo);
    font-weight: 600;
}

.card-meta span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-missing {
    color: var(--muted);
    font-size: 0.9rem;
}

.crumb {
    margin: 1rem 0 0.8rem;
    font-size: 0.92rem;
}

.crumb a {
    text-decoration: none;
    font-weight: 600;
}

.product {
    display: grid;
    gap: 1.25rem;
}

.stage-photo {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: var(--plate);
    border: 1px solid var(--line);
    margin-bottom: 0.55rem;
}

.js .stage-photo {
    display: none;
    margin-bottom: 0;
}

.js .stage-photo.is-current {
    display: block;
}

.photo-counter {
    display: none;
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
}

.js .photo-counter {
    display: block;
}

.thumbs {
    display: none;
    gap: 0.5rem;
    margin-top: 0.55rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.35rem;
}

.js .thumbs {
    display: flex;
}

.thumbs button {
    flex: 0 0 4.6rem;
    scroll-snap-align: start;
    padding: 0;
    border: 1px solid var(--line);
    background: var(--plate);
    cursor: pointer;
    aspect-ratio: 4 / 3;
}

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

.thumbs button[aria-pressed="true"] {
    border-color: var(--indigo);
    box-shadow: inset 0 0 0 1px var(--indigo);
}

.product-copy h1 {
    font-size: clamp(2rem, 1rem + 3vw, 3.4rem);
}

.product-copy h2 {
    margin: 1.4rem 0 0.45rem;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--indigo);
}

.description {
    margin: 0;
    max-width: 38rem;
    white-space: pre-line;
    line-height: 1.55;
}

.muted {
    color: var(--muted);
}

.neighbors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
    margin-top: 2rem;
}

.neighbor {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 44px;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
}

.neighbor span {
    color: var(--indigo);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.neighbor strong {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.12rem;
    letter-spacing: -0.02em;
}

.neighbor.next {
    text-align: right;
}

.empty {
    padding: 2.5rem 0 1rem;
}

.empty h1,
.empty h2 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.95rem;
}

.site-footer p {
    margin: 0;
    max-width: 40rem;
}

.site-footer a {
    font-weight: 600;
}

.is-admin .search {
    display: none;
}

.admin-head {
    display: grid;
    gap: 1rem;
    padding: 1.4rem 0 0.4rem;
}

.admin-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-head h1 {
    font-size: clamp(2rem, 1rem + 3vw, 3.3rem);
}

.admin-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 1rem 0 0.4rem;
}

.admin-filter input {
    flex: 1 1 14rem;
    width: auto;
}

.admin-list {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0;
}

.admin-row {
    display: grid;
    grid-template-columns: 4.75rem minmax(0, 1fr);
    gap: 0.75rem 1rem;
    align-items: center;
    padding: 0.95rem 0;
    border-bottom: 1px solid var(--line);
}

.admin-thumb {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.admin-row h2 {
    margin: 0;
    font-size: 1.35rem;
}

.admin-row h2 a {
    color: inherit;
    text-decoration: none;
}

.row-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
}

.row-actions .button {
    flex: 1;
}

.panel {
    background: var(--sheet);
    border: 1px solid var(--line);
    padding: 1.1rem;
}

.login-wrap {
    display: grid;
    place-items: center;
    padding: 1.5rem 0 1rem;
}

.login-card {
    width: min(100%, 28rem);
}

.login-card h1 {
    font-size: clamp(2.2rem, 6vw, 3rem);
}

.product-form {
    max-width: 46rem;
    margin-top: 1rem;
}

.product-form label,
.login-card label {
    display: block;
    margin: 1rem 0 0.35rem;
    font-weight: 600;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.2rem;
}

.form-errors {
    margin: 0 0 0.5rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #e4c2b8;
    background: #fbf1ee;
    color: #6e2c1e;
}

.form-errors ul {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
}

.hint {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

fieldset.current-photos {
    border: 0;
    margin: 1.2rem 0 0;
    padding: 0;
}

.current-photos legend {
    padding: 0;
    font-weight: 600;
}

.photo-grid,
.upload-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.75rem;
    margin-top: 0.7rem;
}

.photo-tile {
    display: grid;
    gap: 0.25rem;
}

.photo-tile img,
.upload-preview img {
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: var(--plate);
    border: 1px solid var(--line);
}

.photo-tile label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.92rem;
    font-weight: 400;
    min-height: 32px;
}

.upload-preview:empty {
    display: none;
}

.delete-panel {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    max-width: 46rem;
}

.delete-photo {
    aspect-ratio: 4 / 3;
}

@media (min-width: 700px) {
    body {
        padding-inline: 1.75rem;
    }

    .catalog {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.6rem 1.25rem;
    }

    .masthead {
        grid-template-columns: minmax(0, 1.5fr) auto;
        align-items: end;
        padding-top: 2.2rem;
    }

    .piece-count {
        text-align: right;
    }

    .product {
        grid-template-columns: minmax(0, 1.15fr) minmax(16rem, 0.85fr);
        gap: 2.25rem;
        align-items: start;
    }

    .gallery {
        position: sticky;
        top: 1rem;
    }

    .delete-panel {
        grid-template-columns: 16rem minmax(0, 1fr);
        align-items: center;
    }

    .form-actions .button {
        flex: none;
    }
}

@media (min-width: 800px) {
    .site-header {
        grid-template-columns: auto minmax(16rem, 26rem);
    }

    .is-admin .site-header {
        grid-template-columns: 1fr auto;
    }

    .admin-row {
        grid-template-columns: 5.5rem minmax(0, 1fr) auto;
    }

    .row-actions {
        grid-column: auto;
    }

    .row-actions .button {
        flex: none;
    }
}

@media (min-width: 1080px) {
    .catalog {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 699px) {
    .form-actions .button,
    .search button {
        min-width: 44px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .button,
    .admin-head-actions .button {
        width: 100%;
    }

    .admin-head-actions {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

@media print {
    body::before,
    .search,
    .header-actions,
    .site-footer a,
    .neighbors,
    .thumbs,
    .photo-counter,
    .crumb {
        display: none !important;
    }

    body {
        max-width: none;
        background: #fff;
    }

    .stage-photo {
        display: block !important;
    }
}
