:root {
    --bg: #111111;
    --bg-deep: #0C0C0C;
    --fg: #ECEAE6;
    --muted: #7E7C77;
    --meta: #8A8883;
    --story: #B9B7B2;
    --line: #2A2A28;
    --btn-line: #2E2E2B;
    --tile: #1E1E1C;
    --gap: 8px;
    --pad: clamp(16px, 3vw, 40px);
    --serif: 'Instrument Serif', Georgia, serif;
    --sans: 'Geist', 'Helvetica Neue', system-ui, sans-serif;
    --mono: 'Geist Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); }

body {
    color: var(--fg);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body.locked { overflow: hidden; }

a { color: #9A9893; text-decoration: none; transition: color .2s; }
a:hover { color: var(--fg); }

.bar, .bar-width {
    max-width: 1600px;
    margin: 0 auto;
    padding-left: var(--pad);
    padding-right: var(--pad);
}

header.bar {
    padding-top: 20px;
    padding-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 32px;
}

.name {
    font-family: var(--serif);
    font-size: 26px;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--fg);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0 24px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.chip {
    background: none;
    border: 0;
    padding: 12px 0;
    min-height: 44px;
    font: inherit;
    color: var(--muted);
    cursor: pointer;
    transition: color .2s;
}
.chip:hover, .chip[aria-pressed="true"] { color: var(--fg); }

/* Grid */
.grid {
    columns: 3 300px;
    column-gap: var(--gap);
}

.tile {
    break-inside: avoid;
    margin-bottom: var(--gap);
}

.ph {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: var(--tile);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    color: inherit;
}
.ph img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: transform 1s cubic-bezier(.2, .7, .2, 1), opacity .4s;
}
.ph img.ready { opacity: 1; }
.ph:hover img { transform: scale(1.02); }
.ph::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--bg);
    opacity: 0;
    transition: opacity .4s;
    pointer-events: none;
}
.ph:hover::after { opacity: .12; }
.ph:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

.empty {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 80px 0;
    text-align: center;
}

footer.foot {
    padding-top: 40px;
    padding-bottom: 32px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }

/* Viewer */
.icon-btn {
    background: none;
    border: 1px solid var(--btn-line);
    color: var(--fg);
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: none;
    transition: border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--fg); background: #1A1A19; }
.icon-btn:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

.viewer {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg-deep);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.viewer[hidden] { display: none; }

.viewer-inner {
    min-height: 100%;
    padding: var(--pad);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(24px, 4vw, 64px);
}

.viewer-image {
    flex: 999 1 min(560px, 100%);
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.viewer-image img {
    display: block;
    max-width: 100%;
    max-height: 86vh;
    width: auto;
    height: auto;
}

.viewer-side {
    flex: 1 1 300px;
    max-width: 400px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
}

.viewer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.counter {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.story { display: flex; flex-direction: column; gap: 20px; }

.story h2 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(30px, 3vw, 40px);
    line-height: 1.08;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

.meta {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--meta);
}

.tags {
    list-style: none;
    margin: -8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}
.tags li::before { content: "#"; }

.story-text {
    margin: 0;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--story);
    font-size: 17px;
    line-height: 1.7;
    white-space: pre-line;
    text-wrap: pretty;
}

.viewer-nav { display: flex; gap: 12px; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
    /* Close button above the photo, story below it */
    .viewer-inner { flex-direction: column; align-items: stretch; gap: 24px; }
    .viewer-side { display: contents; }
    .viewer-top { order: 0; }
    .viewer-image { order: 1; flex: none; }
    .story { order: 2; }
    .viewer-nav { order: 3; padding-bottom: 8px; }
    .viewer-image img { max-height: 70vh; }
}
