/* Christopher Disher — one stylesheet for every page.
   Dark by default, light when the visitor's system asks for it. */

:root {
    color-scheme: dark light;
    --ground: #0b0b0a;
    --ink: #e8e6e1;
    --mute: #a3a19b;
    --rule: rgba(232, 230, 225, 0.16);
    --rule-strong: rgba(232, 230, 225, 0.32);
    --overlay: rgba(11, 11, 10, 0.97);
    --grain: 0.07;
    --photo-ink: #f2f0eb;
    --photo-mute: rgba(242, 240, 235, 0.78);

    --display: "Bodoni Moda", Didot, "Bodoni 72", serif;
    --reading: "Cormorant Garamond", Garamond, serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: light) {
    :root {
        --ground: #f2f1ed;
        --ink: #161614;
        --mute: #5e5c57;
        --rule: rgba(22, 22, 20, 0.16);
        --rule-strong: rgba(22, 22, 20, 0.3);
        --overlay: rgba(242, 241, 237, 0.97);
        --grain: 0.09;
    }
}

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

html {
    background: var(--ground);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--mono);
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.04em;
    -webkit-font-smoothing: antialiased;
    transition: color 600ms ease;
}

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}
a:hover {
    opacity: 0.7;
}

button {
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: 6px;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Film grain over everything ──────────────────────────────── */

.grain {
    position: fixed;
    inset: -128px;
    z-index: 50;
    pointer-events: none;
    opacity: var(--grain);
    background: url(../assets/img/grain.png) 0 0 / 256px 256px;
    animation: grain 0.5s steps(4) infinite;
}
@keyframes grain {
    0% { background-position: 0 0; }
    25% { background-position: -97px 41px; }
    50% { background-position: 53px -118px; }
    75% { background-position: -31px -67px; }
    100% { background-position: 0 0; }
}

/* ── Header ──────────────────────────────────────────────────── */

.site-header {
    position: relative;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 36px clamp(20px, 4vw, 56px);
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}
.site-header .name {
    font-weight: 400;
    text-decoration: none;
}
.site-header button {
    padding: 14px 0;
    margin: -14px 0;
    text-transform: inherit;
}

.label {
    font-size: 9px;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: var(--mute);
}

/* ── Contact ─────────────────────────────────────────────────── */

.contact {
    width: 100vw;
    height: 100vh;
    height: 100svh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 24px;
    border: 0;
    background: var(--overlay);
    color: var(--ink);
}
.contact[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}
.contact::backdrop {
    background: transparent;
}
.contact .close {
    position: absolute;
    top: 22px;
    right: clamp(8px, 4vw, 44px);
    padding: 14px;
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}
.contact form,
.contact .done {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.contact h2,
.contact .done p {
    margin: 0 0 8px;
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: 36px;
    line-height: 1;
    letter-spacing: 0;
    text-align: center;
}
.contact label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--mute);
}
.contact input,
.contact textarea {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--rule-strong);
    border-radius: 0;
    padding: 10px 0;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: 0.02em;
    resize: vertical;
}
.contact input:focus,
.contact textarea:focus {
    outline: none;
    border-bottom-color: var(--ink);
}
.contact .send {
    align-self: center;
    min-height: 44px;
    margin-top: 8px;
    padding: 12px 34px;
    border: 1px solid var(--rule-strong);
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}
.contact .send[disabled] {
    opacity: 0.5;
    cursor: default;
}
.contact .note {
    min-height: 16px;
    margin: -8px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--mute);
}
.contact .done {
    align-items: center;
    text-align: center;
}
.contact .done span {
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--mute);
}
.contact .honey {
    display: none;
}

/* ── Home: three rows ────────────────────────────────────────── */

.home {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.home .bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 900ms ease;
    pointer-events: none;
}
.home .bg-music { object-position: 50% 0%; }
.home.night .bg-music { object-position: 50% 60%; }
.home .bg-home { object-position: 50% 55%; }
.home .scrim {
    position: fixed;
    inset: 0;
    background: rgb(8, 10, 14);
    opacity: 0;
    transition: opacity 900ms ease;
    pointer-events: none;
}

.home main {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px 96px;
    text-align: center;
}
.rows {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 60px;
}
.row {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: opacity 500ms ease;
}
.row .title {
    padding: 4px 10px;
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(26px, 2.3vw, 32px);
    line-height: 1.1;
    letter-spacing: 0;
    text-decoration: none;
}
.row .sub {
    min-height: 18px;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 400ms ease;
}

/* Hovering one row dims the others and shows its line. */
.home[data-active] .row { opacity: 0.22; }
.home[data-active="1"] .row[data-row="1"],
.home[data-active="2"] .row[data-row="2"],
.home[data-active="3"] .row[data-row="3"] { opacity: 1; }
.home[data-active="1"] .row[data-row="1"] .sub,
.home[data-active="2"] .row[data-row="2"] .sub,
.home[data-active="3"] .row[data-row="3"] .sub { opacity: 1; }

.home[data-active="2"] .bg-music,
.home[data-active="3"] .bg-home { opacity: 1; }
.home[data-active="2"] .scrim { opacity: 0.2; }
.home.night[data-active="2"] .scrim { opacity: 0.1; }
.home[data-active="3"] .scrim { opacity: 0.42; }
.home[data-active="2"],
.home[data-active="3"] {
    --ink: var(--photo-ink);
    --mute: var(--photo-mute);
}
.home[data-active="2"] .site-header,
.home[data-active="2"] .row,
.home[data-active="3"] .site-header,
.home[data-active="3"] .row {
    text-shadow: 0 0 18px rgba(0, 0, 0, 0.6), 0 0 4px rgba(0, 0, 0, 0.45);
}

/* A hidden line can't be tapped, so a phone tap never lands on a link it can't see. */
.row .sub { pointer-events: none; }
.home[data-active="1"] .row[data-row="1"] .sub,
.home[data-active="2"] .row[data-row="2"] .sub,
.home[data-active="3"] .row[data-row="3"] .sub { pointer-events: auto; }

/* ── The viewfinder behind Ghostwriting ──────────────────────── */

.viewfinder {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(1040px, 92vw);
    aspect-ratio: 2.39 / 1;
    min-height: calc(100% + 150px);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 700ms ease;
    pointer-events: none;
}
.home[data-active="1"] .viewfinder { opacity: 1; }

.viewfinder .screen {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #111110;
}
.viewfinder .screen > div {
    position: absolute;
    inset: 0;
}
.viewfinder .static {
    opacity: 0.55;
    background: url(../assets/img/grain.png) 0 0 / 180px 180px;
    filter: grayscale(1) contrast(2.6) brightness(0.85);
    animation: snow 0.32s steps(8) infinite;
}
@keyframes snow {
    0% { background-position: 0 0; }
    12% { background-position: -61px 23px; }
    25% { background-position: 47px -88px; }
    37% { background-position: -112px -41px; }
    50% { background-position: 79px 64px; }
    62% { background-position: -23px 117px; }
    75% { background-position: 131px -9px; }
    87% { background-position: -97px 71px; }
    100% { background-position: 0 0; }
}
.viewfinder .scan {
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.42) 0 1px, transparent 1px 3px);
}
.viewfinder .screen > .roll {
    bottom: auto;
    height: 28%;
    background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.16) 45%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0.16) 55%, transparent 100%);
    animation: roll 3.6s linear infinite;
}
@keyframes roll {
    0% { transform: translateY(-110%); }
    100% { transform: translateY(470%); }
}
.viewfinder .tube {
    background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.65) 100%);
}

.viewfinder .corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 0 solid currentColor;
}
.viewfinder .tl { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.viewfinder .tr { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.viewfinder .bl { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.viewfinder .br { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }
.viewfinder .slate,
.viewfinder .timecode {
    position: absolute;
    top: 6px;
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--mute);
    font-variant-numeric: tabular-nums;
}
.viewfinder .slate { left: 28px; }
.viewfinder .timecode { right: 28px; }
.viewfinder .subtitle {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 26px;
    margin: 0;
    text-align: center;
    font-family: var(--display);
    font-style: italic;
    font-size: 17px;
    line-height: 1.35;
    color: var(--photo-ink);
    text-shadow: 0 0 12px rgba(0, 0, 0, 0.9), 0 0 3px rgba(0, 0, 0, 0.9);
    transition: opacity 500ms ease;
}
.viewfinder .subtitle.out { opacity: 0; }

/* Light mode: a blank viewfinder. The static only makes sense as a lit screen in a dark room. */
@media (prefers-color-scheme: light) {
    .viewfinder .screen { display: none; }
    .viewfinder .subtitle {
        color: var(--ink);
        text-shadow: none;
    }
}

/* ── Ghostwriting archive ────────────────────────────────────── */

.archive {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
    padding: 72px clamp(20px, 4vw, 40px) 160px;
    display: flex;
    flex-direction: column;
    gap: 64px;
}
.archive .intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.archive h1 {
    margin: 0;
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: 32px;
    line-height: 1.1;
    letter-spacing: 0;
}
.archive .intro p {
    margin: 0;
    line-height: 1.6;
    color: var(--mute);
}

.filters .group {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px 0;
    padding: 22px 0;
    border-top: 1px solid var(--rule);
}
.filters .group > .label {
    flex: 0 0 140px;
}
.filters .chips {
    flex: 1 1 480px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 26px;
}
.chip {
    padding: 8px 0;
    font-family: var(--reading);
    font-style: italic;
    font-size: 20px;
    letter-spacing: 0;
    color: var(--mute);
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
}
.chip[aria-pressed="true"] {
    color: var(--ink);
    text-decoration-line: underline;
}
.filters .bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--mute);
}
.filters .bar div {
    display: flex;
    gap: 26px;
}
.filters .bar button {
    padding: 12px 0;
    text-transform: inherit;
}
.filters .bar button:hover {
    opacity: 0.7;
}
.filters .redraw {
    color: var(--ink);
}

.results {
    display: flex;
    flex-direction: column;
    gap: 112px;
}
.results .empty {
    margin: 0;
    text-align: center;
    font-family: var(--reading);
    font-style: italic;
    font-size: 22px;
    color: var(--mute);
}
.excerpt {
    display: flex;
    flex-wrap: wrap;
    gap: 32px 72px;
    font-family: var(--reading);
    letter-spacing: 0;
    animation: arrive 700ms ease both;
}
@keyframes arrive {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
.excerpt .text {
    flex: 999 1 540px;
    min-width: 0;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.excerpt h2 {
    margin: 0;
    font-weight: 300;
    font-size: 36px;
    line-height: 1.12;
}
.excerpt .source {
    font-style: italic;
    font-size: 18px;
    color: var(--mute);
}
.excerpt .body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 20px;
}
.excerpt .body p {
    margin: 0;
    font-size: 21px;
    line-height: 1.6;
}
.excerpt .body b {
    font-weight: 500;
}
.excerpt .meta {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 12px;
    font-size: 18px;
    line-height: 1.4;
    color: var(--mute);
}
.excerpt .meta .category {
    color: var(--ink);
}
.excerpt .meta em {
    font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
    .grain,
    .viewfinder .static,
    .viewfinder .screen > .roll,
    .excerpt {
        animation: none;
    }
}
