/* ==========================================================================
   base.css
   Reset, element typography, containers, accessibility helpers.
   All values reference tokens.css. Nothing is hardcoded.
   Load order is base -> chrome -> components -> responsive and must not
   change: responsive.css contains the overrides that depend on coming last.
   ========================================================================== */

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* Sticky header is 64px. Without this every fragment anchor lands with
       its target heading hidden underneath the header. */
    scroll-padding-top: calc(64px + var(--space-4));
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    font-weight: var(--fw-regular);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur-mid) var(--ease-brand),
        color var(--dur-mid) var(--ease-brand);
}

img,
svg,
video {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

/* ---------- Typography ---------- */
h1, h2 {
    margin: 0 0 var(--space-md);
    line-height: var(--lh-heading);
    color: var(--color-text-primary);
    text-wrap: balance;
}

h3, h4 {
    margin: 0 0 var(--space-md);
    font-family: var(--font-sans);
    font-weight: var(--fw-bold);
    line-height: var(--lh-heading);
    letter-spacing: -0.015em;
    color: var(--color-text-primary);
    text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
h4 { font-size: var(--fs-h4); font-weight: var(--fw-semibold); }

/* Editorial serif: major page titles */
.hero__title,
.blog-head__title,
.post__title,
.research-head-title,
.research-title,
.reading > h1,
.section.container > .reveal > h1 {
    font-family: var(--font-serif);
    font-weight: var(--fw-display);
    letter-spacing: -0.015em;
}

/* Editorial serif: section headings and card titles */
.section__head > h2,
.belief__inner > h2,
.card__title,
.cta__title,
.prose h2,
.research-prose > h2,
.landing > h2 {
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 var(--paragraph-gap);
}

/* Headings already balance above. Paragraphs need pretty, which matters more
   here than usual because body copy justifies from 768px up and a justified
   line with an orphaned last word is the worst case. */
p, li {
    text-wrap: pretty;
}

/* Body justification: tablet/desktop only. Direct-child paragraphs so
   nested callout / blockquote copy stays left. Mobile stays left.
   Structured UI (.step, cards, tables, lists) is never justified. */
@media (min-width: 768px) {
    .prose > p,
    .research-prose > p,
    .landing > p,
    .about-strip__bio > p {
        text-align: justify;
        hyphens: auto;
        -webkit-hyphens: auto;
    }
}

.prose blockquote p,
.prose .callout p,
.research-prose blockquote p,
.research-prose .callout p,
.step,
.step-grid,
.split-2,
.session-list,
.card {
    text-align: left;
    hyphens: manual;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

/* Body links: underlined. */
.prose a {
    text-decoration: underline;
    text-underline-offset: 0.15em;
    text-decoration-thickness: 1px;
}

.prose a:hover,
a:hover {
    color: var(--color-accent-hover);
}

strong { font-weight: var(--fw-semibold); }

code, pre, kbd, samp {
    font-family: var(--font-mono);
    font-size: var(--fs-code);
}

::selection {
    background: var(--color-accent);
    color: var(--color-selection-fg);
}

/* One transition declaration for every interactive element, so hover states
   stop being transitioned ad hoc wherever someone remembered. */
a,
button,
[role="button"],
input,
textarea,
select,
summary {
    transition: var(--transition-interactive);
}

/* ---------- Layout ---------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--space-md);
    min-width: 0;
}

/* Deliberate exception, not a pattern to reach for casually: content that is
   dense/tabular rather than prose (case embeds today) may need more than the
   editorial 1200px container. Any future content type can opt in the same way. */
.container--wide {
    max-width: var(--container-max-wide);
}

.site-main {
    flex: 1 0 auto;
    min-width: 0;
    /* Catch any remaining wide child (tables, pre, SVG) so the page never
       scrolls horizontally as a whole. Scroll stays inside .table-wrap / pre. */
    overflow-x: clip;
}

.reading {
    max-width: var(--measure-prose);
    margin-inline: auto;
}

/* Landing / service pages: full container width (default for new static pages) */
.landing {
    min-width: 0;
}

/* Running copy is capped. Structured children (tables, .step-grid, grids)
   deliberately escape the cap and use the full container width. */
.landing > p,
.landing > ul,
.landing > ol {
    max-width: var(--measure-wide);
}

.landing > h2 {
    display: inline-block;
    max-width: 100%;
    margin-top: var(--space-12);
    padding-top: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-accent-line);
}

.landing > h2:first-child {
    margin-top: 0;
    padding-top: 0;
}

/* A .label sitting above an H2 owns the section opening; the H2 itself then
   sheds its top margin so the pair does not double-space. */
.landing > .label--block {
    margin-top: var(--space-12);
    padding-top: var(--space-4);
}

.landing > .label--block:first-child {
    margin-top: 0;
    padding-top: 0;
}

.landing > .label--block + h2 {
    margin-top: 0;
    padding-top: 0;
}

.landing .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-block: var(--space-xl);
}

.landing table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-small);
}

.landing th,
.landing td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    vertical-align: top;
    border-bottom: var(--border);
    white-space: normal;
}

.landing thead th {
    font-weight: var(--fw-semibold);
    background: var(--color-surface-tint);
    border-bottom: var(--border-width) solid var(--color-text-secondary);
    vertical-align: bottom;
}

.landing tbody tr:nth-child(even) {
    background: var(--color-surface-tint);
}

.landing ul,
.landing ol {
    margin: 0 0 var(--paragraph-gap);
    padding-left: 1.25rem;
}

.landing li + li {
    margin-top: var(--space-xs);
}

.split-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
}

.section {
    padding-block: var(--space-section);
}

.section--tight {
    padding-block: var(--space-section-tight);
}

/* A section boundary is drawn, not implied by whitespace alone. The last
   section before the footer opts out so it does not double-rule. */
.section + .section,
.section--tight + .section,
.section + .section--tight {
    border-top: var(--border);
}

.section--flush {
    border-top: 0;
}

.section__head {
    margin-bottom: var(--space-10);
}

/* The heading is inline-block so its accent rule ends with the text rather
   than the container. That means the eyebrow above it has to be a block,
   or the two inline-blocks share a line. */
.section__head > .eyebrow {
    display: block;
}

.section__head > h2 {
    display: inline-block;
    max-width: 100%;
    margin-top: 0;
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-accent-line);
}

.section__sub {
    max-width: var(--measure-lede);
    margin: var(--space-sm) 0 0;
    color: var(--color-text-secondary);
    font-size: var(--fs-lede);
    line-height: var(--lh-lede);
}

.eyebrow {
    display: inline-block;
    margin-bottom: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

/* Opt-in pill. The flat .eyebrow reads as a caption; on a page head it needs
   to read as a marker. Applied page by page, not as a redefinition. */
.eyebrow--pill {
    padding: var(--space-1) var(--space-3);
    background: var(--color-accent-wash);
    color: var(--color-accent-hover);
    /* The wash alone is 1.14:1 against the page. The border is what makes the
       pill read as an object rather than tinted text. */
    border: var(--border-width) solid var(--color-accent-line);
    border-radius: var(--radius-pill);
    font-weight: var(--fw-semibold);
}

.lede {
    max-width: var(--measure-lede);
    color: var(--color-text-secondary);
    font-size: var(--fs-lede);
    line-height: var(--lh-lede);
}

.section__more {
    margin-top: var(--space-xl);
}

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--space-4);
    /* Parked one full link height above the viewport until focused. */
    top: calc(-1 * var(--space-12));
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface-raised);
    color: var(--color-text-primary);
    border: var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-overlay);
    transition: top var(--dur-fast) var(--ease-brand);
}

.skip-link:focus {
    top: var(--space-md);
}

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-base);
}
