/* ==========================================================================
   Main CSS - Consolidated
   ========================================================================== */

/* ==========================================================================
   Variables
   ========================================================================== */

:root {
    /* Palette */
    --color-bg-paper: #F5F3EE;
    --color-text-ink: #2C2D30;
    --color-text-light: #595A5D;
    --color-accent: #B3202A;   /* cinnabar, from the seal paste */
    --color-line: rgba(44, 45, 48, 0.15);

    /* Typography */
    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'Newsreader', serif;

    /* Spacing */
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
}

/* ==========================================================================
   Reset & Base Body Styles
   ========================================================================== */

body {
    background-color: var(--color-bg-paper);
    color: var(--color-text-ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-variant-numeric: oldstyle-nums;
    line-height: 1.7;
    margin: 0;
    padding: 0;

    /* Parchment: faint strands and veins, warm blotches where the sheet is thicker, and a fine grain. The
       layers repeat at different sizes, so the pattern never visibly tiles */
    background-image:
        url("/images/paper/paper-fibres.webp?v=1"),
        url("/images/paper/paper-clouds.webp?v=1"),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 700px, 1100px, auto;
}

/* The sheet darkens a little toward its edges, as old parchment does */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(140, 105, 60, 0.09) 100%);
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--color-text-ink);
    margin-top: 0;
}

a {
    color: var(--color-text-ink);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

::selection {
    background: color-mix(in srgb, var(--color-accent) 22%, transparent);
}

a:hover {
    color: var(--color-accent);
    border-bottom: 1px solid var(--color-accent);
}

/* ==========================================================================
   Layout - Container & Grid
   ========================================================================== */

.l-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem var(--space-md);
}

.l-grid-sidebar {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .l-grid-sidebar {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
}

/* ==========================================================================
   Header Component
   ========================================================================== */

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0;
    border-bottom: none !important;
    padding-bottom: 0;
    position: relative;
}

.site-header__branding {
    max-width: 60%;
}

.site-header__branding h1 {
    font-size: 3rem;
    margin-bottom: 0.2rem;
    font-weight: 700;
}

.site-header__title-link {
    border-bottom: none;
}

.site-header__title-link:hover {
    border-bottom: none;
}

.site-header__tagline {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--color-text-light);
    margin: 0;
}

.site-header__logo {
    width: 300px;
    height: auto;
    display: block;
    border-radius: 2px;
    position: absolute;
    top: -50px;
    right: -20px;
    z-index: 10;
    pointer-events: none;
}

/* Kea: the painting, replaced by a bird-free plate plus a live 3D bird on a canvas (static/js/kea3d.js) */
.c-kea__painting {
    display: block;
    width: 100%;
    height: auto;
}

/* Narrow screens: every page opens with one row, short text on the left (the name, or a post's date and
   author) and the bird on the right. The row is as tall as the bird, so the bird holds still between pages
   and page titles start below it */
@media (max-width: 960px) {
    .l-container {
        padding-top: 1rem;
    }

    .site-header {
        min-height: 120px;
        align-items: flex-end;
        padding-right: 130px;
    }

    .site-header__logo {
        top: 0;
        right: 0;
        width: 120px;
    }

    .site-header__branding {
        max-width: none;
    }

    .site-header__branding h1 {
        font-size: 2.25rem;
        margin-bottom: 0;
    }

    .l-grid-sidebar,
    .l-page {
        margin-top: var(--space-md);
    }
}

/* ==========================================================================
   Footer Component
   ========================================================================== */

.site-footer {
    margin-top: 5rem;
    padding-bottom: var(--space-md);
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* ==========================================================================
   Post List & Post Preview Components
   ========================================================================== */

/* Section Title (reusable) */
.c-section-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--color-text-light);
    margin: 0 0 1.5rem;
}

/* Bio Component */
.c-bio p {
    margin-bottom: 1.5rem;
    font-family: var(--font-body);
    font-size: 1.2rem;
}

/* Post List */
.c-post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Post Preview */
.c-post-preview {
    margin-bottom: var(--space-md);
}

.c-post-preview__title a {
    border-bottom: none;
}

.c-post-preview__title a:hover {
    border-bottom: none;
    color: var(--color-accent);
    text-decoration: underline 1px;
    text-underline-offset: 0.2em;
}

.c-post-preview__date {
    font-size: 0.8rem;
    color: var(--color-text-light);
    display: block;
    margin-bottom: 0.3rem;
}

.c-post-preview__title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    display: block;
}

.c-post-preview__excerpt {
    font-size: 0.95rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
    display: block;
}

/* ==========================================================================
   Single Column Layout
   ========================================================================== */

.l-single-column {
    max-width: 65ch;
}

/* Single-column pages under the full header (post list, 404) */
.l-page {
    margin-top: var(--space-lg);
}

/* ==========================================================================
   Article Component (Single Posts)
   ========================================================================== */

/* Date and author sit above the title, sized to stay legible in a zoomed-out screenshot */
.c-article__date {
    font-size: 0.85rem;
    color: var(--color-text-light);
    display: block;
}

.c-article__byline {
    font-size: 1.15rem;
    border-bottom: none;
}

.c-article__byline:hover {
    border-bottom: none;
}

.c-article__title {
    font-size: 2.5rem;
    margin: 0.75rem 0 1.5rem;
    line-height: 1.2;
}

.c-article__excerpt {
    font-size: 1.05rem;
    color: var(--color-text-light);
    margin: -1rem 0 1.5rem;
}

.c-article__content {
    font-family: var(--font-body);
    font-size: 1.25rem;
    line-height: 1.65;
}

.c-article__content a {
    border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 50%, transparent);
}

/* Alex's seal, stamped in cinnabar: the end mark after a post's last word, and after the name in the
   homepage footer. It links home */
.c-seal,
.c-seal:hover,
.c-article__content .c-seal {
    border-bottom: none;
}

.c-seal img {
    display: inline-block;
    width: 1.05em;
    height: 1.05em;
    margin-left: 0.45em;
    vertical-align: -0.18em;
    mix-blend-mode: multiply;
    transition: opacity 0.2s ease;
}

.c-seal:hover img {
    opacity: 0.7;
}

.c-article__content p {
    margin-bottom: 1.5rem;
}

/* Other posts to read next, between the end of the essay and the citation */
.c-more {
    margin-top: var(--space-lg);
}

.c-article__content h2 {
    margin-top: var(--space-md);
    margin-bottom: 1rem;
}

/* ==========================================================================
   Footnotes / Sidenotes (sidenotes on wide screens, bottom list otherwise)
   ========================================================================== */

.footnotes {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* Plain muted numbers instead of the default underlined-link look */
.c-article__content sup {
    line-height: 0;
}

.footnote-ref,
.footnote-backref,
.sidenote sup {
    color: var(--color-text-light);
    border-bottom: none;
    font-size: 0.75em;
}

.footnote-ref:hover,
.footnote-backref:hover {
    border-bottom: none;
    opacity: 0.7;
}

.sidenote {
    display: none;
}

@media (min-width: 1000px) {
    .sidenote {
        display: block;
        float: right;
        clear: right;
        width: 220px;
        margin: 0.3rem -260px 1rem 0;
        font-size: 0.8rem;
        line-height: 1.5;
        color: var(--color-text-light);
    }

    .footnotes {
        display: none;
    }
}

/* ==========================================================================
   Citation
   ========================================================================== */

.c-citation {
    margin-top: var(--space-md);
    padding-top: 1rem;
    border-top: 1px solid var(--color-line);
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.c-citation summary {
    cursor: pointer;
}

.c-citation pre {
    overflow-x: auto;
    padding: 1rem;
    background: rgba(44, 45, 48, 0.04);
    border-radius: 2px;
}

.c-citation__box {
    position: relative;
}

.c-citation__copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.15rem 0.55rem;
    font: inherit;
    font-size: 0.75rem;
    color: var(--color-text-light);
    background: var(--color-bg-paper);
    border: 1px solid var(--color-line);
    border-radius: 2px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.c-citation__copy:hover,
.c-citation__copy:focus-visible {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* ==========================================================================
   Page transitions: an ink flick
   Clicking a link on the site flicks a brush stroke of ink across it, then the page follows
   (layouts/partials/ink-splash.html). Where the browser supports cross-document view transitions, the
   old page, ink and all, fades into the new one. The painting never moves.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }
}

.c-kea {
    view-transition-name: kea;
}

::view-transition {
    background: var(--color-bg-paper);
}

::view-transition-group(kea),
::view-transition-new(kea),
::view-transition-new(root) {
    animation: none;
}

::view-transition-old(kea) {
    display: none;
}

::view-transition-old(root) {
    animation: ink-lift 180ms ease-in both;
}

@keyframes ink-lift {
    to {
        opacity: 0;
        filter: blur(.6px);
    }
}

.c-ink-splash {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}
