:root {
    color-scheme: light;
    --paper: #f8f3ea;
    --card: #fffaf3;
    --forest: #172f25;
    --ink: #222e25;
    --muted: #5d6054;
    --line: #e2d9ca;
    --berry: #8e362f;
    --gold: #e6bd8b;
    --display: "Playfair Display", Georgia, serif;
    --body: "DM Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1rem/1.6 var(--body); }
.catalog--birthday {
    --forest: #453052;
    --berry: #783e64;
    --gold: #f5c7ce;
    --ink: #302839;
    --muted: #635a65;
    --line: #e5d9dd;
}
img { display: block; max-width: 100%; }
h1, h2, h3, h4, p, figure { margin: 0; }
a { color: inherit; text-underline-offset: .22em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

.shell { width: min(100% - 4rem, 80rem); margin-inline: auto; }
.skip-link { position: fixed; z-index: 2; top: .6rem; left: .6rem; padding: .7rem 1rem; background: var(--card); transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.masthead { border-bottom: 1px solid var(--line); }
.masthead__inner { min-height: 4.6rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; font-weight: 700; line-height: 1.1; letter-spacing: .08em; }
.brand svg { flex: none; width: 2.45rem; height: 2.45rem; }
.brand small { display: block; margin-top: .18rem; color: var(--muted); font-size: .72rem; font-weight: 500; letter-spacing: 0; }
.masthead__back { color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none; }
.masthead__back:hover { text-decoration: underline; }
.masthead__back span { margin-right: .22rem; }

.cover {
    display: grid;
    grid-template-columns: minmax(0, .91fr) minmax(0, 1.1fr);
    align-items: center;
    gap: clamp(1.75rem, 4vw, 4rem);
    padding: clamp(1.3rem, 3.1vw, 2.8rem);
    margin-block: clamp(1.15rem, 3vw, 2.5rem) clamp(3rem, 7.1vw, 6.5rem);
    background: var(--forest);
    color: var(--paper);
    border-radius: .45rem;
}
.cover__copy { padding: 2rem 0 2rem clamp(.7rem, 2.5vw, 2.4rem); }
.cover h1 {
    font: 500 clamp(3.1rem, 7.1vw, 7.2rem)/.98 var(--display);
    letter-spacing: -.065em;
    text-wrap: balance;
}
.cover h1 em { display: block; color: var(--gold); font-weight: 500; }
.catalog--birthday .cover h1 { font-size: clamp(2.5rem, 5.8vw, 5.8rem); }
.cover__copy p { max-width: 23rem; margin-block: 1.6rem 1.75rem; color: #eee5d6; font-size: clamp(1rem, 1.3vw, 1.15rem); }
.cover__action {
    display: inline-flex;
    align-items: center;
    gap: 1.35rem;
    padding: .7rem 1.1rem;
    border: 1px solid #f5e0b88c;
    border-radius: .25rem;
    color: #fff4e6;
    font-size: .91rem;
    font-weight: 700;
    text-decoration: none;
}
.cover__action:hover { background: var(--paper); color: var(--forest); }
.cover__figure img { width: 100%; height: auto; aspect-ratio: 1.25; object-fit: cover; object-position: center 53%; border-radius: .2rem; background: #355042; }
.cover__figure figcaption { display: flex; flex-wrap: wrap; gap: 0 .65rem; margin-top: .65rem; color: #e1d0b8; font-size: .78rem; }
.cover__figure a { color: var(--paper); }

.catalog { padding-bottom: clamp(3rem, 8vw, 6.5rem); scroll-margin-top: 1rem; }
.catalog__header { display: flex; justify-content: space-between; align-items: end; gap: 1.2rem; }
.catalog__header h2 { font: 500 clamp(2rem, 4.2vw, 3.9rem)/1.05 var(--display); letter-spacing: -.04em; }
.search { display: grid; gap: .2rem; width: min(100%, 17rem); }
.search label { color: var(--muted); font-size: .8rem; font-weight: 700; }
.search input {
    min-width: 0;
    width: 100%;
    padding: .65rem .8rem;
    border: 1px solid #aca796;
    border-radius: .25rem;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
}
.search input::placeholder { color: #68665c; opacity: 1; }
.chapter-index { display: flex; flex-wrap: wrap; gap: .6rem; margin-block: 1.35rem 0; padding-bottom: 1.35rem; border-bottom: 1px solid var(--line); }
.chapter-index a { padding: .42rem .85rem; border: 1px solid #cfc5b5; border-radius: 1.5rem; color: var(--forest); font-size: .84rem; font-weight: 600; text-decoration: none; }
.chapter-index a:hover { background: var(--forest); border-color: var(--forest); color: var(--paper); }
.results, .empty { margin-top: 1.1rem; color: var(--muted); font-size: .95rem; }

.chapter { margin-top: clamp(2.15rem, 4.7vw, 4.25rem); scroll-margin-top: 1.2rem; }
.chapter__header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.chapter__header::after { content: ""; display: block; flex: 1 0 1rem; height: 1px; background: var(--line); }
.chapter h3 { font: 500 clamp(1.7rem, 3.1vw, 2.65rem)/1.12 var(--display); letter-spacing: -.035em; }
.pieces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(.9rem, 2vw, 1.65rem); }
.piece {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: .35rem;
    background: var(--card);
    scroll-margin-top: 1.3rem;
}
.piece:target { outline: 2px solid var(--berry); outline-offset: 4px; }
.piece__image { display: block; overflow: hidden; background: #e9e0d3; border-radius: .3rem .3rem 0 0; cursor: zoom-in; }
.piece__image img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .28s ease; }
.piece__image .piece__portrait { object-fit: contain; }
.piece__image:hover img { transform: scale(1.035); }
.piece__copy { flex: 1; padding: 1.05rem .95rem .85rem; }
.piece h4 { color: var(--forest); font: 600 clamp(1.2rem, 1.6vw, 1.5rem)/1.17 var(--display); letter-spacing: -.025em; }
.piece p { margin-top: .5rem; color: var(--muted); font-size: .92rem; line-height: 1.54; overflow-wrap: anywhere; }
.piece__credit {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .35rem .7rem;
    margin: 0 .95rem;
    padding-block: .65rem .75rem;
    border-top: 1px solid var(--line);
    font-size: .8rem;
}
.piece__credit a { color: var(--berry); font-weight: 700; text-decoration: none; }
.piece__credit a:hover { text-decoration: underline; }
.piece__author { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }

.footer { background: var(--forest); color: var(--paper); }
.footer__inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1.2rem 2rem; padding-block: 1.55rem; }
.brand--footer small, .footer p { color: #e1d0b8; }
.footer p { font-size: .86rem; }
.footer__top { font-size: .86rem; font-weight: 700; }

.viewer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #101714;
    color: var(--paper);
}
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.viewer::backdrop { background: #101714; }
body:has(.viewer[open]) { overflow: hidden; }
.viewer__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap-reverse;
    gap: .6rem 1.2rem;
    padding: .8rem clamp(1rem, 3vw, 2rem);
    padding-top: max(.8rem, env(safe-area-inset-top));
    border-bottom: 1px solid #ffffff30;
}
.viewer__toolbar h2 { font: 500 clamp(1.1rem, 2.6vw, 1.7rem)/1.2 var(--display); }
.viewer__controls { display: flex; flex: none; gap: .5rem; }
.viewer__controls button {
    min-height: 2.75rem;
    padding: .35rem .72rem;
    border: 1px solid #e6bd8b80;
    border-radius: .25rem;
    background: transparent;
    color: inherit;
    font: 700 .9rem var(--body);
    cursor: pointer;
}
.viewer__controls button:hover, .viewer__controls button[aria-pressed="true"] { background: var(--paper); color: var(--forest); }
.viewer__viewport { overflow: auto; overscroll-behavior: contain; }
.viewer__viewport:focus-visible { outline-offset: -3px; }
.viewer__stage { display: grid; place-items: center; width: 100%; height: 100%; }
.viewer__photo { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.viewer__viewport.is-zoomed .viewer__stage { width: max(100%, var(--zoom-width)); height: max(100%, var(--zoom-height)); }
.viewer__viewport.is-zoomed .viewer__photo { width: var(--zoom-width); height: var(--zoom-height); max-width: none; }

@media (max-width: 56rem) {
    .shell { width: calc(100% - 2.5rem); }
    .pieces { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 39rem) {
    .shell { width: calc(100% - 2rem); }
    .masthead__inner { min-height: 3.75rem; }
    .cover { grid-template-columns: minmax(0, 1fr); gap: 1.55rem; }
    .cover__copy { padding: .65rem .15rem 0; }
    .cover h1 { font-size: clamp(3.25rem, 12vw, 4.6rem); }
    .cover__copy p { margin-block: 1.05rem 1.15rem; }
    .cover__figure img { aspect-ratio: 1.4; }
    .catalog__header { display: grid; grid-template-columns: minmax(0, 1fr); }
    .search { width: 100%; }
    .piece__copy { padding: .85rem .72rem .7rem; }
    .piece__credit { margin-inline: .72rem; }
}

@media (max-width: 26rem) {
    .pieces { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .piece__image img { transition: none; }
}
