/* ========================================================================
   base.css -- ScribeHold modern reset + base element styles

   Layer 2 of the modular CSS bundle. Consumes tokens from tokens.css.
   Provides:
     - Modern CSS reset (box-sizing, margin/padding, inherited font, media)
     - Root typography (font stack, size, line-height, color)
     - Link defaults with :focus-visible ring (keyboard-only)
     - Heading scale and prose rhythm
     - Skip-link primitive (visually hidden, revealed on :focus)

   All color, type, spacing, radius, and shadow values come from tokens.css
   via var(...). No hard-coded hex values in this file.

   No @import directives -- bundle assembly is Task 20's concern.

   Bundle order: tokens -> base -> layout -> components/* -> pages/*
   ======================================================================== */

/* ------------------------------------------------------------------------
   1. Modern CSS reset
   ------------------------------------------------------------------------ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body,
h1, h2, h3, h4, h5, h6,
p,
figure,
blockquote,
dl, dd,
ol, ul {
    margin: 0;
    padding: 0;
}

ol, ul {
    list-style: none;
}

/* Inherit font on form controls so the page's typography choices apply. */
input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

/* Responsive media defaults. */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Honor reduced-motion preference at the element level so component CSS
   inherits sane animation defaults. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ------------------------------------------------------------------------
   2. Root + body typography
   ------------------------------------------------------------------------ */

html {
    font-size: 16px;                          /* 1rem == 16px baseline */
    -webkit-text-size-adjust: 100%;           /* prevent iOS rotation zoom */
    text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-family-base);
    font-size: var(--font-size-md);
    line-height: var(--line-height-normal);
    font-weight: var(--font-weight-regular);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ------------------------------------------------------------------------
   3. Links + global focus ring
   ------------------------------------------------------------------------ */

a {
    color: var(--color-link);
    text-decoration: none;
}

a:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

a:visited {
    color: var(--color-link-visited);
}

/* WCAG 1.4.1 — inline links inside prose must not rely on color alone.
   Anchors directly inside paragraphs (and lists / footnotes treated as
   prose) get an underline so they remain distinguishable from surrounding
   text when color is unavailable. Buttons (.btn), navigation (.nav-*),
   footer chrome, and other non-prose anchors are unaffected because they
   are not direct children of <p>/<li>. */
p > a,
li > a {
    text-decoration: underline;
}

/* Keyboard-only focus ring (mouse clicks do not trigger :focus-visible).
   Applied globally so every interactive element gets the same treatment. */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------------
   4. Headings + prose rhythm
   ------------------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--color-ink);
}

h1 {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--space-4);
}

h2 {
    font-size: var(--font-size-3xl);
    margin-top: var(--space-10);
    margin-bottom: var(--space-3);
}

h3 {
    font-size: var(--font-size-xl);
    margin-top: var(--space-8);
    margin-bottom: var(--space-2);
}

h4 {
    font-size: var(--font-size-lg);
    margin-top: var(--space-6);
    margin-bottom: var(--space-2);
}

h5,
h6 {
    font-size: var(--font-size-base);
    margin-top: var(--space-5);
    margin-bottom: var(--space-2);
}

/* The first heading inside any container should not push itself away from
   the container's top edge. Component layout owns block spacing. */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
    margin-top: 0;
}

p {
    margin-bottom: var(--space-4);
}

p:last-child {
    margin-bottom: 0;
}

ul, ol {
    margin-bottom: var(--space-4);
}

li + li {
    margin-top: var(--space-1);
}

blockquote {
    margin: var(--space-6) 0;
    padding-left: var(--space-4);
    border-left: 3px solid var(--color-border);
    color: var(--color-muted);
}

hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-8) 0;
}

code, kbd, samp, pre {
    font-family: var(--font-family-mono);
    font-size: 0.95em;
}

pre {
    overflow: auto;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-manila);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

small {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
}

strong, b {
    font-weight: var(--font-weight-semibold);
}

/* ------------------------------------------------------------------------
   5. Skip-link (visually hidden until focused via keyboard)

   Place as the first focusable element in <body>:
       <a href="#main" class="skip-link">Skip to content</a>
   ------------------------------------------------------------------------ */

.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-modal);
    padding: var(--space-2) var(--space-4);
    background: var(--color-ink-navy);
    color: var(--color-bg-cream);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    border-radius: var(--radius-md);
    transform: translateY(-150%);
    transition: transform var(--duration-fast) var(--easing-standard);
}

.skip-link:focus,
.skip-link:focus-visible {
    transform: translateY(0);
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
    color: var(--color-bg-cream);
    text-decoration: none;
}
