/* ==========================================================================
   RESET
   ========================================================================== */

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

html {
    font-size: 16px;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page-level scrollbar: tokenized, tinted toward the brand hue. */
html {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in oklch, var(--rule) 80%, transparent) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: color-mix(in oklch, var(--rule) 70%, transparent);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
    transition: background-color 180ms var(--ease-out);
}

::-webkit-scrollbar-thumb:hover {
    background: color-mix(in oklch, var(--rule-strong) 90%, transparent);
    background-clip: padding-box;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

ol,
ul {
    list-style: none;
}

/* The `hidden` HTML attribute must beat class rules that set `display`
   (e.g. .list/.empty/.pagination/.filters all set display: flex).
   Without this, JS toggling `element.hidden` has no visible effect. */
[hidden] {
    display: none !important;
}

img,
svg {
    display: block;
}

/* ==========================================================================
   BASE
   ========================================================================== */

body {
    font-family: var(--f-sans);
    font-size: var(--t-base);
    font-weight: 400;
    line-height: 1.55;
    background: var(--surface);
    color: var(--ink);
    min-height: 100vh;
    /* Broadly-supported OpenType: kern always on, ligatures on for body
       sans, and contextual alternates when the family supplies them. */
    font-feature-settings: "kern", "liga", "calt";
    transition: background-color 220ms var(--ease-out), color 220ms var(--ease-out);
}

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

.tabular {
    font-variant-numeric: tabular-nums;
}

/* Visually hide content while keeping it in the accessibility tree. Used
   for the main-content <h1> so screen-reader users get a clean "you're on
   the index" anchor without disturbing the editorial layout. */
.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 — first focusable element on the page. Hidden off-screen until
   focused, then slides into the top-left so keyboard users can bypass the
   rail (brand, theme toggle, search, ~6 filter chips) and land on the list. */
.skip-link {
    position: absolute;
    top: var(--s-2);
    left: var(--s-2);
    z-index: 100;
    padding: var(--s-2) var(--s-3);
    font-family: var(--f-mono);
    font-size: var(--t-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-text);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    transform: translateY(calc(-100% - var(--s-3)));
    transition: transform 180ms var(--ease-out);
}

.skip-link:focus {
    transform: translateY(0);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Skip target landed via fragment — tabindex="-1" lets it receive focus
   without being in the tab order; suppress the focus ring since it's a
   transient anchor, not an interactive control. */
#main-content:focus {
    outline: none;
}

/* ==========================================================================
   FOCUS
   ========================================================================== */

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--r-sm);
}

.item-row:focus-visible {
    outline-offset: 4px;
}

/* ==========================================================================
   ANIMATIONS
   Shared keyframes used across components. Animation declarations live on
   the components themselves.
   ========================================================================== */

@keyframes item-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.001ms !important;
    }

    /* Loading states are status messages, not decorative motion. Opacity-only
       pulses are vestibular-safe — keep them running. Each rule re-asserts
       the full animation with !important so the universal nuke above doesn't
       collapse it back to 0s. */
    .skel {
        animation: pulse 1.6s ease-in-out infinite !important;
    }

    .item-ai-btn[data-loading="true"] svg {
        animation: ai-pulse 1.4s ease-in-out infinite !important;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */

@media print {

    .rail-section-theme,
    .rail-section-search,
    .pagination,
    .filters {
        display: none;
    }

    .page {
        display: block;
        padding: 0;
    }

    .main {
        max-width: 100%;
    }

    body {
        background: var(--print-bg);
        color: var(--print-ink);
    }

    .item,
    .item:last-child {
        border-color: var(--print-rule);
    }

    .item-row {
        padding: 12px 0;
    }
}
