/* =====================================================================
   Margin brand system  --  shared primitives (base, buttons, headers,
   marginalia). The design TOKENS live in brand-tokens.css and are pulled
   in below, so this file holds only the genuinely common CSS that depends
   on them. Page-specific layout stays in each page's own <style>.

   Surfaces that want the tokens but NOT the button/base paradigm (popup,
   side panel) import brand-tokens.css directly instead of this file.
   ===================================================================== */

@import url('brand-tokens.css');

/* "Needs action" tier: italic ink, no colour shift (the no-green law).
   Shared so every surface flags a recoverable state the same way. */
.is-attention { color: var(--ink); font-style: italic; }
.is-error     { color: var(--state-error); font-style: normal; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--cream);
    color: var(--ink);
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* The margin line. Brand-defining. Always visible. Each surface sets its
   x-position + width via the custom properties above; the page's <body>
   must be position:relative for this to anchor. */
body::before {
    content: '';
    position: absolute;
    left: var(--margin-line-x);
    top: 0;
    bottom: 0;
    width: var(--margin-line-w);
    background: var(--red);
}

/* ---------------------------------------------------------------------
   Wordmark + tagline. Sizes are set per-surface (the popup wordmark is
   smaller than the settings one); this fixes only family/weight/colour.
   --------------------------------------------------------------------- */
.wordmark {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1;
}
.tagline {
    color: var(--pencil);
    line-height: 1;
}

/* ---------------------------------------------------------------------
   Buttons -- flat, hairline border, no radius. Identical across surfaces.
   --------------------------------------------------------------------- */
button {
    background: transparent;
    border: 1px solid var(--ink);
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
    position: relative;
}
button:hover:not(:disabled) {
    background: var(--ink);
    color: var(--cream);
}
button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Primary action gets a tiny red leader on its left edge. */
button.primary::before {
    content: '';
    position: absolute;
    left: -1px;
    top: -1px;
    bottom: -1px;
    width: 3px;
    background: var(--red);
}

/* Ghost variant -- lighter weight border, italic until hover. */
button.ghost {
    border-color: var(--rule-strong);
    color: var(--pencil);
    font-style: italic;
}
button.ghost:hover:not(:disabled) {
    border-color: var(--ink);
    background: transparent;
    color: var(--ink);
    font-style: normal;
}

/* Danger intent -- red wash on hover (pair with .ghost for a quiet rest
   state that only reddens on intent). */
button.danger:hover:not(:disabled) {
    background: var(--red);
    border-color: var(--red);
    color: var(--cream);
}

/* ---------------------------------------------------------------------
   Section chapter headers -- the editorial "01 Canvas" signature.
       <div class="section-num"><span>01</span> Canvas</div>
       <h2>...</h2>
       <p class="section-sub">...</p>
   --------------------------------------------------------------------- */
.section-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pencil);
    margin: 56px 0 8px;
}
.section-num span {
    color: var(--red);
    margin-right: 0.6em;
}
.section-num:first-of-type { margin-top: 0; }

h2 {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -0.015em;
    margin: 0 0 6px;
    line-height: 1.15;
}

/* Italic subhead under a heading -- used only when the heading alone
   doesn't carry the section. */
.section-sub {
    font-family: 'Crimson Pro', Georgia, serif;
    font-style: italic;
    font-size: 17px;
    color: var(--pencil);
    margin: 0 0 24px;
    max-width: 56ch;
}

.section-rule {
    border-top: 1px solid var(--rule-strong);
    margin: 56px 0 0;
}

/* ---------------------------------------------------------------------
   Editorial marginalia -- short handwritten asides in the gutter voice.
   --------------------------------------------------------------------- */
.marginalia {
    font-family: 'Caveat', cursive;
    font-style: normal;
    font-size: 18px;
    color: var(--pencil);
    display: inline-block;
    transform: rotate(-1deg);
    transform-origin: 0 50%;
}
.marginalia.red { color: var(--red); }

/* Visually hidden but kept in the accessibility tree -- offscreen, NOT
   display:none, so a polite live region stays announceable to screen
   readers. Shared primitive for status nodes across surfaces. */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}

/* Honor a reduced-motion request across every surface that imports this
   sheet (popup, welcome, preview) -- transitions + animations off (T2-6).
   side-panel.html and options.html already carry their own guard. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
