/* Default theme: tin, the silver of the engraved bunnies with water blue. Other themes are below. */
:root {
    --bg: #e4e4e7;
    --panel: #cfcfd3;
    --fg: #2a282d;
    --mute: #636469;
    --rule: #2a282d;
    --mark: #b6c6d2;   /* highlighter behind the active nav item and hovered links */
    --accent: #215770; /* link underline */
    --hv: #ff4fb0;     /* hi-vis: text selection, active nav number, zoom rects. Nowhere else. */
    --hv-ink: #111;

    --sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, 'Courier New', monospace;

    --photo-max: 1024px; /* natural width of the Details photo */
    --side: 220px;
    --gap: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.8;
    letter-spacing: 0.04em;
    -webkit-font-smoothing: antialiased;
}

body ::selection { background: var(--hv); color: var(--hv-ink); }

a { color: inherit; }

/* ---- Sidebar ---- */
.side {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--side);
    padding: 28px 24px;
    background: var(--panel);
    border-right: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 48px;
}
.wordmark {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
}
nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    counter-reset: nav;
}
nav a {
    counter-increment: nav;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--mute);
    padding: 1px 4px;
    margin-left: -4px;
}
nav a::before {
    content: counter(nav, decimal-leading-zero);
    margin-right: 0.9em;
    font-family: var(--mono);
    letter-spacing: 0;
}
nav a:hover,
nav a.active { color: var(--fg); }
nav a.active::before {
    margin-left: -5px;
    margin-right: calc(0.9em - 5px);
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--hv);
    color: var(--hv-ink);
}

/* Themes: set by the swatches in the sidebar, remembered in localStorage. The default (tin) is :root. */
/* fog: pale sea-fog blue. */
:root[data-theme="fog"] {
    --bg: #e5ecef; --panel: #cbd9e0; --fg: #0f2b38; --rule: #0f2b38;
    --mute: #597983; --mark: #e0cfae; --accent: #215770; --hv: #ff6a3d;
}
/* denim: dark blue, from the jeans and shadowed water. */
:root[data-theme="denim"] {
    --bg: #16313c; --panel: #22404b; --fg: #e5ecef; --rule: #e5ecef;
    --mute: #95a6ad; --mark: #6e7a4e; --accent: #b6c6d2; --hv: #d4ff3a;
}
/* spruce: pale sage with the forest greens. */
:root[data-theme="spruce"] {
    --bg: #e4e8d8; --panel: #cfd8bd; --fg: #1b2614; --rule: #1b2614;
    --mute: #6e7a4e; --mark: #c5b29e; --accent: #3f532b; --hv: #ffd21f;
}
/* sand: warm paper and rock, with the sea-fog blue as the highlighter. */
:root[data-theme="sand"] {
    --bg: #f1eadf; --panel: #dacdc1; --fg: #2a1d10; --rule: #2a1d10;
    --mute: #7c5b43; --mark: #b6c6d2; --accent: #7c5b43; --hv: #4d7cff; --hv-ink: #fff;
}

/* ---- Sidebar: countdown under the wordmark; theme swatches at the foot ---- */
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; flex-direction: column; gap: 4px; }
.count {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mute);
}
.themes { display: flex; gap: 6px; }
.themes button {
    width: 16px;
    height: 16px;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: var(--sw);
    cursor: pointer;
}
.themes button[aria-pressed="true"] { outline: 1px solid var(--rule); outline-offset: 2px; }
.themes [data-set-theme="fog"]    { --sw: #b6c6d2; }
.themes [data-set-theme="denim"]  { --sw: #22404b; }
.themes [data-set-theme="spruce"] { --sw: #6e7a4e; }
.themes [data-set-theme="sand"]   { --sw: #c5b29e; }
.themes [data-set-theme="tin"]    { --sw: #abaaaf; }

/* Key info in the accent color. Used sparingly: a line or two per page. */
.text .key { color: var(--accent); font-weight: 700; }

/* One left-to-right highlighter sweep on load; stays filled afterward. */
.text .wave {
    background: linear-gradient(var(--mark), var(--mark)) no-repeat left / 0 100%;
    animation: wave 1.8s ease-in-out 0.4s forwards;
}
@keyframes wave { to { background-size: 100% 100%; } }
@media (prefers-reduced-motion: reduce) {
    .text .wave { animation: none; background-size: 100% 100%; }
}

/* ---- Foil frame: wrap any photo in the engraved frame ----
   <figure class="framed"><img src="/static/img/photo.jpg" alt=""></figure>
   The photo is cropped to the frame's portrait window. */
.framed {
    position: relative;
    width: 360px;
    max-width: 100%;
    aspect-ratio: 656 / 676;
    margin: 0;
}
figure.framed img {
    position: absolute;
    left: 35%;
    top: 34.2%;
    width: 29%;
    height: 36%;
    object-fit: cover;
}
.framed::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url(/static/img/foil-frame.png) center / 100% 100% no-repeat;
    pointer-events: none;
}

/* Embossed bunnies under the nav. Quietly links to the unlisted gallery. */
.egg { align-self: center; display: block; width: 120px; }
.egg img { display: block; width: 100%; height: auto; }

/* ---- Photos open in a lightbox on click; captions are numbered per page ---- */
.photos { counter-reset: photo; }
.photos img { cursor: zoom-in; }
.photos figure { margin: 0; }
.photos figcaption {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    line-height: 1.4;
    text-transform: uppercase;
}
.photos figcaption::before {
    counter-increment: photo;
    content: counter(photo, decimal-leading-zero);
    color: var(--mute);
}

/* ---- Lightbox and Finder zoom rects ---- */
.lb {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bg) 93%, transparent);
    cursor: zoom-out;
}
.lb[hidden] { display: none; }
.lb img { display: block; height: auto; cursor: zoom-out; }
.zr { position: fixed; z-index: 11; border: 2px solid var(--hv); pointer-events: none; }

/* ---- Main ---- */
main {
    margin-left: var(--side);
    padding: 28px var(--gap) 80px;
}

/* ---- Text ---- */
.text h1 {
    font-weight: 700;
    font-size: clamp(1.6rem, 3.4vw, 2.6rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}
.text h1 + p {
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mute);
}
.text h2 {
    margin-top: 36px;
    padding-top: 8px;
    border-top: 1px solid var(--rule);
    font-family: var(--mono);
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.text h2 + p { margin-top: 8px; }
.text p + p { margin-top: 1em; }
.text li + li { margin-top: 8px; }
.text ul { margin-top: 8px; list-style: none; }
.text hr { margin: 32px 0 16px; border: 0; border-top: 1px solid var(--rule); }
.text hr + * { margin-top: 0; }
.text li { padding: 2px 0; }
.text strong { font-weight: 700; }
/* Links: accent underline, highlighter sweeps in from the left on hover. */
.text a,
nav a {
    background: linear-gradient(var(--mark), var(--mark)) no-repeat 0 100% / 0 100%;
    transition: background-size 0.12s ease-out, color 0.12s;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.text a {
    text-decoration: underline var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}
.text a:hover,
nav a:hover,
nav a.active { background-size: 100% 100%; }
.text a:hover { text-decoration-color: transparent; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Photos: natural aspect ratio, never cropped or stretched ---- */
.photos img { display: block; width: 100%; max-width: var(--photo-max); height: auto; }

/* Content pages: text left, photo right */
body.layout-page main {
    display: grid;
    grid-template-columns: minmax(0, 30rem) minmax(0, 1fr);
    gap: 56px;
    align-items: start;
}
body.layout-page .text { padding-top: 0; }
body.layout-page .photos {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}
/* A lone photo stays in view beside the text; several photos scroll with the page. */
body.layout-page .photos:has(> figure:only-child) {
    position: sticky;
    top: 28px;
}
body.layout-page .photos > figure:only-child {
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
}
body.layout-page .photos > figure:only-child img {
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 56px - 30px);
}

/* Home: date and framed photo, centered in the window */
body.layout-center main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    text-align: center;
}

/* Gallery layout (parked, no page uses it yet): title, then a three-column gallery */
body.layout-gallery .text { margin-bottom: 40px; }
body.layout-gallery .photos {
    columns: 3;
    column-gap: var(--gap);
}
body.layout-gallery .photos > figure {
    margin-bottom: 32px;
    break-inside: avoid;
}

/* ---- Narrow screens: sidebar becomes a top bar ---- */
@media (max-width: 900px) {
    body.layout-gallery .photos { columns: 2; }
}
@media (max-width: 760px) {
    .side {
        position: static;
        width: auto;
        padding: 16px var(--gap);
        gap: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--rule);
    }
    nav { flex-direction: row; flex-wrap: wrap; gap: 2px 18px; }
    main { margin-left: 0; padding: 24px var(--gap) 56px; }
    body.layout-center main { min-height: 0; }
    body.layout-page main { display: block; }
    body.layout-page .photos { margin-top: 32px; }
    body.layout-page .photos:has(> figure:only-child) { position: static; }
    body.layout-page .photos > figure:only-child { width: auto; }
    body.layout-page .photos > figure:only-child img { max-height: none; width: 100%; }
    .egg { display: none; }
    .side-foot { margin-top: 0; flex-direction: row; align-items: center; gap: 16px; }
}
@media (max-width: 480px) {
    body.layout-gallery .photos { columns: 1; }
}
