/*
 * PuccioTech CMS — public theme foundation (increment A4, ADR-0012 §G).
 *
 * A small, self-contained stylesheet for the anonymous public surface. It defines its own tokens and
 * does not import or depend on admin.css (SOP §6): the public theme and the admin shell are
 * deliberately separate. Goals — a readable measure, curated typography (a serif display title over
 * a system-sans body), a sensible content width, and a responsive layout that needs no JavaScript.
 * This is a foundation the future Themes context replaces additively, not a configurable theme engine.
 */

:root {
    --ink: #1c1d21;
    --ink-soft: #5a5e68;
    --paper: #fbfbf8;
    --rule: #e7e6e0;
    --accent: #1f5fd0;

    --measure: 44rem;
    --step: 1.5rem;

    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body.public-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.container {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
    padding-inline: 1.5rem;
}

/* Keyboard-first skip link: off-screen until focused. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 0.6rem 1rem;
    background: var(--ink);
    color: #fff;
    border-radius: 0 0 0.5rem 0;
    text-decoration: none;
    z-index: 10;
}

.skip-link:focus {
    left: 0;
}

/* --- Header ------------------------------------------------------------- */

.site-header {
    border-bottom: 1px solid var(--rule);
    padding-block: 1.25rem;
}

.site-brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
    color: var(--ink);
}

/*
 * The configured site logo, when present, replaces the brand text inside the same link. Capped to a
 * sensible header height with the width kept proportional (`width: auto`); the intrinsic width/height
 * attributes on the <img> reserve layout so it does not reflow as it loads (ADR-0016 §K point 12).
 * `display: block` drops the inline-image baseline gap.
 */
.site-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 3rem;
}

/*
 * Primary navigation (B3, ADR-0015 §F). A horizontal, wrap-friendly list of the site's menu links,
 * rendered only when the menu has at least one published link. No JavaScript: it is a plain list
 * that reflows to multiple rows on narrow viewports rather than collapsing behind a toggle.
 */
.site-nav {
    margin-top: 0.85rem;
}

.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
}

.site-nav a {
    display: inline-block;
    padding: 0.15rem 0;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a:focus-visible {
    color: var(--ink);
}

/* The page currently being viewed: emphasised and rule-marked, not merely coloured. */
.site-nav a[aria-current="page"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* --- Main --------------------------------------------------------------- */

.site-main {
    flex: 1 0 auto;
    padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

/* --- Article ------------------------------------------------------------ */

.page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 2.9rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 1.5rem;
}

/*
 * The body is now a structured block document (ADR-0017 §H): the page-content wrapper holds fixed,
 * autoescaped block markup (headings, paragraphs, lists, quotes, images, and the legacy carrier), not
 * raw pre-wrap text. `pre-wrap` therefore moves off this wrapper — where it would render the template's
 * own inter-block whitespace — and onto `.block-legacy-text` alone (below), which must stay byte-for-byte
 * identical to the pre-B5 plain-text rendering (§K). `overflow-wrap` still guards long unbroken tokens.
 */
.page-content {
    overflow-wrap: break-word;
    color: var(--ink);
}

/* --- Structured content blocks (ADR-0017 §H) --------------------------- */

/*
 * Vertical rhythm for the block flow. The first block sits flush under the page title; subsequent
 * blocks are separated by one --step so the document reads as an ordered flow, not a wall of text.
 */
.page-content > * {
    margin: 0 0 var(--step);
}

.page-content > *:last-child {
    margin-bottom: 0;
}

.block-heading {
    font-family: var(--font-display);
    line-height: 1.2;
    color: var(--ink);
    margin-top: calc(var(--step) * 1.25);
}

h2.block-heading {
    font-size: 1.7rem;
}

h3.block-heading {
    font-size: 1.35rem;
}

h4.block-heading {
    font-size: 1.1rem;
}

.block-list {
    padding-left: 1.5rem;
}

.block-list li {
    margin-bottom: 0.35rem;
}

/*
 * A pulled-in quotation with an accent rule; the optional <cite> reads as a muted attribution and is
 * given a leading em-dash presentationally (never stored in the citation text).
 */
.block-quote {
    margin-left: 0;
    padding-left: var(--step);
    border-left: 3px solid var(--accent);
    color: var(--ink-soft);
    font-style: italic;
}

.block-quote > p {
    margin: 0;
}

.block-quote cite {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-style: normal;
    color: var(--ink-soft);
}

.block-quote cite::before {
    content: "\2014\00a0"; /* em dash + non-breaking space */
}

/*
 * An embedded image never overflows the measure; intrinsic width/height are emitted on the <img> so the
 * browser reserves layout and avoids a reflow. The caption reads as a muted, smaller line beneath it.
 */
.block-image {
    margin-left: 0;
    margin-right: 0;
}

.block-image img {
    display: block;
    max-width: 100%;
    height: auto;
}

.block-image figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

/*
 * The legacy body carrier (§K): the exact migrated bytes, autoescaped and presented pre-wrap exactly as
 * the pre-B5 `.page-content` was, so an existing Alpha page is byte-for-byte visually identical after the
 * migration. HTML-looking characters stay escaped (they were before).
 */
.block-legacy-text {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    color: var(--ink);
}

/* --- Footer ------------------------------------------------------------- */

.site-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--rule);
    padding-block: 1.5rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.site-footer p {
    margin: 0;
}

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

.notice {
    text-align: center;
    padding-block: clamp(2rem, 8vw, 5rem);
}

.notice-code {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(3rem, 12vw, 5rem);
    line-height: 1;
    color: var(--accent);
}

.notice-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0.5rem 0 0.75rem;
}

.notice-text {
    margin: 0 auto;
    max-width: 34rem;
    color: var(--ink-soft);
}
