/*  ========================================================================
    takun.org — "field notebook / riso" redesign
    Paper & ink, one oxblood accent, mono utility labels, physarum decoration.
    ======================================================================== */

:root {
    --paper: #f4f0f0;
    --paper-2: #efebe7;
    --ink: #1f1d1a;
    --ink-soft: #4a463f;
    --rule: #d8d1bf;
    --accent: #8a2f24;
    --accent-soft: #b5695f;
    --slate: #3a4a52;
    --accent-rgb: 138, 47, 36;
    --art-filter: none;
    --hero-opacity: 0.92;
    --thumb-opacity: 1;
    --icon-filter: none;
    --toggle-moon: block;  /* icon shows the theme a click switches to */
    --toggle-sun: none;
    color-scheme: light;

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
        Georgia, serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "DejaVu Sans Mono",
        Menlo, Consolas, monospace;

    --measure: 44rem;  /* publication column */
    --rail: 15rem;     /* sticky identity column */
    --page: 64rem;
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
}

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

/* dark tokens: follow the system unless the toggle pinned light; keep the
   two blocks in sync */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #17161b;
        --paper-2: #201f26;
        --ink: #e8e3d6;
        --ink-soft: #b3ad9f;
        --rule: #33313b;
        --accent: #d98a7e;
        --accent-soft: #e0a89e;
        --slate: #9fb4bd;
        --accent-rgb: 217, 138, 126;
        --art-filter: invert(1) hue-rotate(180deg);
        --hero-opacity: 0.85;
        --thumb-opacity: 0.85;
        --icon-filter: invert(0.9);
        --toggle-moon: none;
        --toggle-sun: block;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #17161b;
    --paper-2: #201f26;
    --ink: #e8e3d6;
    --ink-soft: #b3ad9f;
    --rule: #33313b;
    --accent: #d98a7e;
    --accent-soft: #e0a89e;
    --slate: #9fb4bd;
    --accent-rgb: 217, 138, 126;
    --art-filter: invert(1) hue-rotate(180deg);
    --hero-opacity: 0.85;
    --thumb-opacity: 0.85;
    --icon-filter: invert(0.9);
    --toggle-moon: none;
    --toggle-sun: block;
    color-scheme: dark;
}

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

body {
    margin: 0;
    padding: 0 1.5rem;
    font: 1.12rem/1.62 var(--serif);
    color: var(--ink);
    background: var(--paper);
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    background-image:
        radial-gradient(rgba(var(--accent-rgb), 0.015) 1px, transparent 1px);
    background-size: 4px 4px;
}

/* two columns: identity rail on the left, publications on the right */
.content {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--page);
    margin: 0 auto;
    padding-top: 3.5rem;
    display: grid;
    grid-template-columns: var(--rail) minmax(0, var(--measure));
    gap: 0 4rem;
    justify-content: center;
    align-items: start;
}

::selection {
    background: rgba(var(--accent-rgb), 0.16);
    color: var(--accent);
}

/* header / identity rail */
.masthead {
    position: sticky;
    top: 3.5rem;
}

.hero-band {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 0 1.3rem;
    opacity: var(--hero-opacity);
    -webkit-user-select: none;
    user-select: none;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 22%, #000 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 22%, #000 100%);
}

.hero-band,
.paper-thumb img {
    filter: var(--art-filter);
}

.masthead h1 {
    grid-area: name;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1.1;
}

.masthead .role {
    grid-area: role;
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    color: var(--ink-soft);
    margin: 0.55rem 0 1rem;
}

/* .masthead .role::before {
    content: "// ";
    color: var(--accent);
} */

.socials {
    grid-area: socials;
    display: flex;
    gap: 1.05rem;
    align-items: center;
}

.socials a {
    display: inline-flex;
    opacity: 0.72;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.socials a:hover {
    opacity: 1;
    transform: translateY(-1px);
    text-decoration: none;
}

.socials img {
    width: 22px;
    height: 22px;
    display: block;
    filter: var(--icon-filter);
}



/* publications */
h2 {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    margin: 2.6rem 0 1.1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--rule);
}

main > h2:first-child {
    margin-top: 0;
}

h2::before {
    content: "# ";
    color: var(--accent);
}

h3,
h4,
h5,
h6 {
    font-family: var(--mono);
    line-height: 1.25;
    margin-top: 2rem;
}

h3::before {
    content: "## ";
    color: var(--accent);
}

h4::before {
    content: "### ";
    color: var(--accent);
}

h5::before {
    content: "#### ";
    color: var(--accent);
}

h6::before {
    content: "##### ";
    color: var(--accent);
}

/* year in a left gutter, sticking while its papers scroll past */
.year-group {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: 0 1rem;
    align-items: start;
}

.year-group + .year-group {
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
}

.year {
    position: sticky;
    top: 3.5rem;
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.7;
    color: var(--accent);
}

.year::before {
    content: none;
}

.paper {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 0 1rem;
    align-items: start;
    margin: 0 0 1.35rem;
}

.paper-thumb {
    width: 3.25rem;
    height: 3.25rem;
    display: grid;
    place-items: center;
}

.paper-thumb img {
    width: 2.75rem;
    height: 2.75rem;
    display: block;
    opacity: var(--thumb-opacity);
}

.paper-body {
    min-width: 0;
    line-height: 1.32;
}

.paper .title {
    display: block;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.04rem;
    line-height: 1.3;
    color: var(--ink);
}

.paper .title:hover {
    color: var(--accent);
    text-decoration: none;
}

/* authors: quieter than the title, co-author links are not "actions" */
.paper .authors {
    display: block;
    font-size: 0.84rem;
    line-height: 1.42;
    color: var(--ink-soft);
    margin-top: 0.3rem;
}

.paper .authors b {
    font-weight: 600;
    color: var(--ink);
}

.paper .authors a {
    color: inherit;
    text-decoration: underline dotted;
    text-decoration-color: var(--accent-soft);
    text-underline-offset: 0.18em;
}

.paper .authors a:hover {
    color: var(--accent);
}

/* venue + links share one line, split by a thin rule */
.paper .meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem 0.8rem;
    margin-top: 0.45rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    line-height: 1.5;
}

.paper .venue {
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--slate);
}

.paper .links {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.8rem;
    padding-left: 0.8rem;
    border-left: 1px solid var(--rule);
}

.paper .links a {
    color: var(--accent);
    white-space: nowrap;
}

.paper .links a::before {
    content: "\203A ";
    color: var(--accent-soft);
}

/* links */
a {
    color: var(--accent);
    text-decoration: none;
    text-underline-offset: 0.12em;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 1px;
}

/* prose */
blockquote {
    background: var(--paper-2);
    margin: 1.4rem 0;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--accent);
}

hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 2rem 0;
}

code {
    font-family: var(--mono);
    font-size: 0.86em;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 0.08rem 0.28rem;
}

pre {
    padding: 0.9rem;
    overflow: auto;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-left: 3px solid rgba(var(--accent-rgb), 0.5);
}

pre>code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9rem;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.4rem 0;
    font-size: 0.95rem;
}

th,
td {
    border: 1px solid var(--rule);
    padding: 0.5rem 0.7rem;
    text-align: left;
}

thead th {
    background: var(--paper-2);
    font-family: var(--mono);
    font-size: 0.85rem;
}

/* taxonomy */
.taxonomy-container {
    margin-top: 1.4rem;
}

.term {
    margin: 0.4rem 0;
    font-family: var(--mono);
    font-size: 0.95rem;
}

/* footer */
footer {
    flex-shrink: 0;
    width: 100%;
    max-width: var(--page);
    margin: 3rem auto 1.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: center;
    align-items: center;  /* keeps the theme icon on the text's centre line */
    gap: 0.5rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
}

footer a {
    color: var(--ink-soft);
}

footer .accent {
    color: var(--accent);
}

.theme-toggle {
    display: inline-flex;
    position: relative;
    top: -0.05em;  /* line-box centre sits slightly below cap centre */
    padding: 0.2rem;
    border: 0;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    opacity: 0.72;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.theme-toggle[hidden] {
    display: none;  /* stays hidden without JS */
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    opacity: 1;
    color: var(--accent);
}

.theme-toggle svg {
    width: 15px;
    height: 15px;
}

.theme-toggle .moon {
    display: var(--toggle-moon);
}

.theme-toggle .sun {
    display: var(--toggle-sun);
}

/* narrow screens: single column, compact header */
@media (max-width: 52rem) {
    body {
        padding: 0 1rem;
    }

    .content {
        display: block;
        padding-top: 0;
    }

    .masthead {
        position: static;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "band band"
            "name socials"
            "role socials";
        align-items: center;
        column-gap: 1rem;
        margin-bottom: 2rem;
    }

    .hero-band {
        grid-area: band;
        width: calc(100% + 2rem);
        height: 4rem;
        margin: 0 -1rem 1.1rem;
        object-fit: cover;
        object-position: center bottom;
    }

    .masthead .role {
        margin: 0.35rem 0 0;
    }
}

@media (max-width: 34rem) {
    body {
        font-size: 1.05rem;
    }

    .masthead h1 {
        font-size: 1.4rem;
    }

    .masthead .role {
        font-size: 0.72rem;
    }

    .year-group {
        display: block;
    }

    .year {
        position: static;
        margin-bottom: 0.6rem;
    }

    .paper {
        grid-template-columns: 2.75rem minmax(0, 1fr);
        gap: 0 0.8rem;
    }

    /* links often wrap under the venue here; a divider would dangle */
    .paper .links {
        padding-left: 0;
        border-left: none;
    }

    .paper-thumb {
        width: 2.75rem;
        height: 2.75rem;
    }

    .paper-thumb img {
        width: 2.25rem;
        height: 2.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

@media print {
    body {
        max-width: 100%;
        color: #000;
        background: #fff;
    }

    .paper-thumb img {
        filter: none;
        opacity: 1;
    }

    .theme-toggle {
        display: none;
    }

    .content {
        display: block;
    }

    .masthead {
        position: static;
    }

    .hero-band,
    .socials {
        display: none;
    }
}