/* ===========================================================
   NexusLink — Field Notes Archive
   Order: reset · variables · base · typography · layout
   · components · utilities · responsive
   =========================================================== */

/* ----- RESET ----- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body,
h1, h2, h3, h4, h5, h6,
p, ul, ol, dl, figure { margin: 0; }

ul, ol { padding-left: 0; }

img, svg { display: block; max-width: 100%; height: auto; }

a { color: inherit; text-decoration: none; }

button { font: inherit; }

/* ----- VARIABLES ----- */
:root {
    --paper: #F5F1E8;
    --paper-deep: #EBE4D1;
    --paper-soft: #FAF7EF;
    --ink: #1B2433;
    --ink-soft: #2C3645;
    --ink-muted: #5C6470;
    --ink-faint: #8C8676;
    --rule: #C9C0AC;
    --rule-soft: rgba(27, 36, 51, 0.10);
    --accent: #B83A2E;
    --accent-deep: #7A1F18;
    --accent-soft: #E8B5AB;

    --font-display: "Fraunces", "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
    --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    --measure: 65ch;
    --column: 860px;
    --frame: 1100px;
}

/* ----- BASE ----- */
html {
    font-family: var(--font-display);
    font-size: 17px;
    font-variation-settings: "opsz" 14, "wght" 400;
    color: var(--ink);
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--paper);
    background-image:
        radial-gradient(ellipse 70% 50% at 85% 0%, rgba(184, 58, 46, 0.08), transparent 60%),
        radial-gradient(ellipse 60% 40% at 0% 100%, rgba(27, 36, 51, 0.05), transparent 60%);
    background-attachment: fixed;
}

::selection { background: var(--accent-soft); color: var(--ink); }

/* ----- TYPOGRAPHY ----- */
h1, h2, h3 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.18;
    letter-spacing: -0.012em;
    text-wrap: balance;
}

h1 {
    font-variation-settings: "opsz" 144, "wght" 500;
    font-size: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);
    margin-bottom: 0.6rem;
}

h2 {
    font-variation-settings: "opsz" 96, "wght" 500;
    font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.95rem);
    margin: 0 0 1rem;
}

h3 {
    font-variation-settings: "opsz" 24, "wght" 600;
    font-size: 1.12rem;
    margin: 1.85rem 0 0.6rem;
    letter-spacing: -0.005em;
}

p {
    margin: 0 0 1.05em;
    max-width: var(--measure);
}

strong { font-variation-settings: "opsz" 14, "wght" 600; color: var(--ink); }
em { font-style: italic; }

article p a,
article li a,
article td a {
    color: var(--accent-deep);
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1px;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
article p a:hover,
article li a:hover,
article td a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(232, 181, 171, 0.35);
}

code, pre, kbd {
    font-family: var(--font-mono);
    font-size: 0.86em;
}

p code,
li code,
td code {
    background: var(--paper-soft);
    border: 1px solid var(--rule-soft);
    padding: 1px 5px;
    color: var(--ink-soft);
    word-break: break-all;
    overflow-wrap: anywhere;
}

pre {
    background: var(--ink);
    color: var(--paper);
    padding: 1.15rem 1.25rem;
    border-left: 3px solid var(--accent);
    overflow-x: auto;
    font-size: 0.84rem;
    line-height: 1.55;
    margin: 1.5rem 0 1.75rem;
    max-width: 100%;
}
pre code {
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
}

/* lists */
article ul,
article ol {
    padding-left: 1.5rem;
    margin: 0 0 1.25rem;
    max-width: var(--measure);
}
article ul { list-style: square; }
article ol { list-style: decimal; }
article li { margin-bottom: 0.5rem; padding-left: 0.25rem; }
article ul li::marker { color: var(--accent); }
article ol li::marker { color: var(--accent); font-variation-settings: "wght" 600; }

/* tables */
table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0 2rem;
    font-size: 0.94rem;
}
thead { border-bottom: 2px solid var(--ink); }
th {
    text-align: left;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-muted);
    font-weight: 400;
}
td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: top;
}
tr:last-child td { border-bottom: 0; }
td code { font-size: 0.74rem; padding: 0; background: transparent; border: 0; color: var(--ink-soft); }

/* ----- LAYOUT ----- */
.frame {
    max-width: var(--frame);
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--ink);
    color: var(--paper);
    padding: 0.55rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    z-index: 999;
}
.skip-link:focus { top: 0; outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- HEADER ----- */
body > header {
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    position: relative;
}
body > header::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    bottom: -4px;
    height: 1px;
    background: var(--rule-soft);
}
body > header > .frame {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem 2.5rem;
    padding-top: 1.4rem;
    padding-bottom: 1.4rem;
    flex-wrap: wrap;
}

.site-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-variation-settings: "opsz" 48, "wght" 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1;
    transition: color 0.18s ease;
}
.site-logo:hover { color: var(--accent-deep); }
.site-logo__mark {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 3px;
    box-shadow: 0 1px 0 var(--rule-soft);
}
.site-logo__text { position: relative; top: 0.02em; }

body > header nav[aria-label="Primary"] ul {
    list-style: none;
    display: flex;
    gap: 1.75rem;
    flex-wrap: wrap;
}
body > header nav[aria-label="Primary"] a {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    position: relative;
    padding: 0.25rem 0 0.4rem;
    display: inline-block;
}
body > header nav[aria-label="Primary"] a:hover,
body > header nav[aria-label="Primary"] a[aria-current="page"] {
    color: var(--ink);
}
body > header nav[aria-label="Primary"] a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.25s ease;
}
body > header nav[aria-label="Primary"] a:hover::after,
body > header nav[aria-label="Primary"] a[aria-current="page"]::after {
    width: 100%;
}

/* ----- BREADCRUMB ----- */
nav[aria-label="Breadcrumb"] {
    padding-top: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
nav[aria-label="Breadcrumb"] ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
nav[aria-label="Breadcrumb"] li {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
nav[aria-label="Breadcrumb"] li + li::before {
    content: "/";
    color: var(--rule);
}
nav[aria-label="Breadcrumb"] a {
    color: var(--ink-muted);
    border-bottom: 1px solid transparent;
    padding-bottom: 1px;
    transition: color 0.18s ease, border-color 0.18s ease;
}
nav[aria-label="Breadcrumb"] a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ----- MAIN / ARTICLE ----- */
main {
    flex: 1;
    width: 100%;
    max-width: var(--column);
    margin-left: auto;
    margin-right: auto;
    padding: 2.5rem 1.5rem 5rem;
}

article {
    counter-reset: section;
    animation: enter 0.55s ease both;
}

@keyframes enter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    article { animation: none; }
}

/* article hero (status and similar) */
.article-hero {
    margin: 0 0 2rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--rule-soft);
}
.article-hero h1 { margin-bottom: 0.6rem; }
.article-hero .article-byline {
    margin-bottom: 1.35rem;
    padding-bottom: 0;
    border-bottom: 0;
}
.status-hero__link-line {
    margin: 0 0 0.55rem;
    max-width: 100%;
    line-height: 1.4;
}
.status-hero__link {
    font-family: var(--font-mono);
    font-size: clamp(1rem, 0.85rem + 0.65vw, 1.22rem);
    font-weight: 500;
    color: var(--accent-deep);
    border-bottom: 0;
    padding-bottom: 0;
    background: transparent;
    word-break: break-all;
    overflow-wrap: anywhere;
    transition: color 0.18s ease;
}
a.status-hero__link:hover,
a.status-hero__link:focus-visible {
    color: var(--accent);
    outline: 2px solid var(--accent-soft);
    outline-offset: 3px;
}
code.status-hero__link.endpoint-primary {
    font-size: clamp(1rem, 0.85rem + 0.65vw, 1.22rem);
    padding: 0;
}
.status-hero__note {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    margin: 0;
    max-width: var(--measure);
}

/* byline / page date */
.article-byline,
.page-date {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-muted);
    margin: 0 0 2.2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--rule-soft);
    max-width: none;
}
.article-byline time,
.page-date time {
    color: var(--ink);
    font-variation-settings: "wght" 500;
}

/* drop-cap on lede paragraph */
article > .article-byline + p::first-letter,
article > .article-hero + p::first-letter,
article > .page-date + p::first-letter {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "wght" 500;
    float: left;
    font-size: 4em;
    line-height: 0.82;
    padding: 0.4rem 0.55rem 0 0;
    color: var(--accent-deep);
}

/* primary endpoint in body copy — red mono, no chrome */
.endpoint-primary:not(.status-hero__link) {
    font-family: var(--font-mono);
    font-size: 1.05em;
    font-variation-settings: "wght" 500;
    color: var(--accent-deep);
    background: transparent;
    border: 0;
    padding: 0;
    word-break: break-all;
    overflow-wrap: anywhere;
}

@media (max-width: 720px) {
    .endpoint-primary:not(.status-hero__link) { font-size: 1em; }
}

/* disclaimer aside */
.disclaimer {
    border-left: 3px solid var(--accent);
    background: var(--paper-deep);
    padding: 1rem 1.25rem 1rem 1.15rem;
    margin: 1.75rem 0 2.5rem;
    font-size: 0.92rem;
    color: var(--ink-soft);
    max-width: var(--measure);
}
.disclaimer p { margin: 0; max-width: none; }
.disclaimer strong {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-deep);
    margin-bottom: 0.4rem;
    font-variation-settings: "wght" 400;
}

/* documentary screenshots */
.figure {
    margin: 1.5rem 0 2rem;
    border: 1px solid var(--rule-soft);
    background: var(--paper-soft);
    padding: 0.5rem;
    max-width: 100%;
}
.figure img {
    width: 100%;
    height: auto;
    border-radius: 2px;
}
.figure--wide { max-width: 100%; }
.figure--narrow { max-width: var(--measure); }
.figure figcaption {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--ink-muted);
    margin-top: 0.65rem;
    padding: 0 0.25rem 0.15rem;
    letter-spacing: 0.04em;
    max-width: none;
}

/* sections */
article > section {
    counter-increment: section;
    margin: 0 0 2.25rem;
}

article > section > h2 {
    position: relative;
    padding-top: 2.5rem;
    margin-top: 2.75rem;
    border-top: 1px solid var(--rule);
}

article > section > h2::before {
    content: "§ " counter(section, decimal-leading-zero);
    display: block;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-bottom: 0.65rem;
}

/* ----- FOOTER ----- */
body > footer {
    background: var(--ink);
    color: var(--paper);
    margin-top: auto;
    padding: 3rem 0 2rem;
    position: relative;
}
body > footer::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

body > footer > .frame {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5rem 2rem;
    align-items: end;
}

body > footer .footer-mark {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-variation-settings: "wght" 500;
    color: var(--paper);
}
body > footer .footer-mark::before {
    content: "§ ";
    font-family: var(--font-mono);
    color: var(--accent-soft);
    font-size: 0.85em;
}

body > footer .footer-tagline {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(245, 241, 232, 0.55);
    margin: 0.4rem 0 0;
    max-width: 38ch;
}

body > footer nav[aria-label="Footer"] {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
body > footer nav[aria-label="Footer"] a {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--paper);
    border-bottom: 1px solid rgba(245, 241, 232, 0.18);
    padding-bottom: 2px;
    transition: color 0.18s ease, border-color 0.18s ease;
}
body > footer nav[aria-label="Footer"] a:hover {
    color: var(--accent-soft);
    border-bottom-color: var(--accent-soft);
}

body > footer .copyright {
    grid-column: 1 / -1;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: rgba(245, 241, 232, 0.45);
    margin: 1.75rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(245, 241, 232, 0.08);
    letter-spacing: 0.05em;
}

/* ----- RESPONSIVE ----- */
@media (max-width: 720px) {
    html { font-size: 16px; }

    body > header > .frame {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
        padding-top: 1.15rem;
        padding-bottom: 1.15rem;
    }
    body > header nav[aria-label="Primary"] ul { gap: 1.15rem; }

    main { padding: 1.75rem 1.25rem 3.5rem; }

    article > .article-byline + p::first-letter,
    article > .article-hero + p::first-letter,
    article > .page-date + p::first-letter {
        font-size: 3.2em;
        padding-right: 0.4rem;
    }

    article > section > h2 {
        padding-top: 1.85rem;
        margin-top: 2rem;
    }

    table { font-size: 0.85rem; display: block; overflow-x: auto; }
    th, td { padding: 0.5rem 0.55rem; white-space: normal; }
    td code { font-size: 0.7rem; }

    body > footer > .frame {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    body > footer nav[aria-label="Footer"] { justify-content: flex-start; }
}

@media (max-width: 420px) {
    article > .article-byline + p::first-letter,
    article > .article-hero + p::first-letter,
    article > .page-date + p::first-letter {
        font-size: 2.6em;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
