/* fic.us — shared styles */

:root {
    color-scheme: light dark;

    --bg: #fdfdfd;
    --text: #222;
    --link: #1c1c1c;
    --link-underline: #c4c4c4;
    --link-underline-hover: #777;
    --brace: #9c9c9c;
    --teaser: #8a8a8a;
    --next-title: #c0c0c0;
    --back: #777;
    --back-hover: #222;
    --fn: #33526e;
    --fn-hover: #1f3650;
    --fn-pop-text: #333;
    --fn-pop-bg: #fff;
    --fn-pop-border: #e3e3e3;
    --fn-pop-shadow: rgba(0, 0, 0, 0.1);
}

/* Cool, crisp dark — soft slate ink, not a harsh terminal black. */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #15171b;
        --text: #d7d9dd;
        --link: #e6e8ec;
        --link-underline: #4a4e56;
        --link-underline-hover: #8a8f98;
        --brace: #5a5f68;
        --teaser: #7c818b;
        --next-title: #4e535b;
        --back: #8a8f98;
        --back-hover: #d7d9dd;
        --fn: #8ab0d8;
        --fn-hover: #a8c6e6;
        --fn-pop-text: #cfd2d7;
        --fn-pop-bg: #1d2026;
        --fn-pop-border: #34383f;
        --fn-pop-shadow: rgba(0, 0, 0, 0.45);
    }
}

html {
    font-family: Georgia, "Times New Roman", serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

body {
    max-width: 600px;
    margin: 4rem auto;
    padding: 0 1.25rem;
    line-height: 1.6;
}

a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-color: var(--link-underline-hover);
}

h1 {
    font-size: 1.5rem;
    font-weight: normal;
    margin: 0 0 1.75rem;
}

p {
    margin: 0 0 1.25rem;
}

/* ---------- home ---------- */

.bio a {
    white-space: nowrap;
}

.essays {
    position: relative;
    margin-top: 2.5rem;
}

/* A curly brace hung in the left gutter, so the list aligns with the body text. */
.brace {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1.5rem;
    width: 0.85rem;
    height: 100%;
    color: var(--brace);
    pointer-events: none;
}

.essay-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.essay-list .row {
    min-height: 1.85rem;
    line-height: 1.85rem;
    white-space: nowrap;
    overflow: hidden;
    /* Long rows stay on one line and fade out at the right edge rather than
       wrapping or hard-truncating — gentler than an ellipsis, and it leaves a
       hint of the teaser to invite a tap. Fades only when text reaches the edge. */
    -webkit-mask-image: linear-gradient(
        to right,
        #000 calc(100% - 2.5rem),
        transparent
    );
    mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
}

.essay-list .teaser {
    color: var(--teaser);
}

.essay-list .next .title {
    color: var(--next-title);
}

.essay-list .blank {
    color: transparent;
}

/* ---------- essay ---------- */

.back {
    display: inline-block;
    margin-bottom: 2.25rem;
    font-size: 0.95rem;
    color: var(--back);
    text-decoration: none;
}

.back:hover {
    color: var(--back-hover);
}

article h1 {
    margin-bottom: 2rem;
}

/* prev/next within the series — understated, mirrors the back link */
.essay-nav {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 4rem;
    font-size: 0.95rem;
}

.essay-nav a {
    color: var(--back);
    text-decoration: none;
}

.essay-nav a:hover {
    color: var(--back-hover);
}

.essay-nav .nav-next {
    margin-left: auto;
    text-align: right;
}

/* the not-yet-published next essay: just a greyed title, no link */
.essay-nav .upcoming {
    cursor: default;
    color: var(--next-title);
}

/* ---------- footnotes as popovers ---------- */

.fn {
    cursor: pointer;
    font-size: 0.72em;
    vertical-align: super;
    line-height: 0;
    color: var(--fn);
    padding: 0 0.15em;
    user-select: none;
}

.fn:hover {
    color: var(--fn-hover);
}

.fn-pop {
    position: fixed;
    display: none;
    left: 0;
    top: 0;
    width: max-content;
    max-width: min(22rem, 86vw);
    font-size: 0.82rem;
    line-height: 1.45;
    font-style: normal;
    color: var(--fn-pop-text);
    background: var(--fn-pop-bg);
    border: 1px solid var(--fn-pop-border);
    border-radius: 7px;
    box-shadow: 0 6px 22px var(--fn-pop-shadow);
    padding: 0.6rem 0.75rem;
    text-align: left;
    white-space: normal;
    z-index: 50;
}

.fn-pop a {
    color: var(--fn);
}

.fn.open .fn-pop {
    display: block;
}

/* ---------- 404 ---------- */

.lost {
    margin-bottom: 1.75rem;
}

.video {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
}

@media (max-width: 480px) {
    body {
        margin: 2.5rem auto;
        /* nudge body copy up for comfortable serif reading on phones;
           headings/nav stay in rem, so the hierarchy holds */
        font-size: 1.0625rem;
    }

    .brace {
        left: -1.05rem;
    }

    .essay-nav {
        flex-direction: column;
        gap: 0.6rem;
    }

    /* stacked, but keep the "next" pointer hugging the right edge */
    .essay-nav .nav-next {
        align-self: flex-end;
        text-align: right;
    }
}
