/* =========================================================================
   Reset, primitives and shared components.
   Mobile first: unprefixed rules are the small screen, media queries add.
   ========================================================================= */

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

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

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: -0.015em;
}

p, ul, ol, figure, blockquote, table {
    margin: 0;
}

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

/* Reserve the box before the file arrives, so nothing shifts. */
img[width][height] {
    height: auto;
}

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

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

input, select, textarea {
    font: inherit;
    color: inherit;
}

/* One focus treatment everywhere, always visible, never removed. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

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

/* ---------- Layout primitives ------------------------------------------ */

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--space-3);
}

@media (min-width: 768px) {
    .container {
        padding-inline: var(--space-4);
    }
}

.stack > * + * {
    margin-block-start: var(--space-3);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* First tab stop on every page. */
.skip-link {
    position: absolute;
    inset-inline-start: var(--space-3);
    inset-block-start: -100%;
    z-index: var(--z-toast);
    padding: var(--space-2) var(--space-3);
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.skip-link:focus {
    inset-block-start: var(--space-2);
}

/* ---------- The signature -----------------------------------------------
   One memorable detail, applied consistently: a thin accent rule above every
   section heading that extends on hover. Everything else stays disciplined.
   ----------------------------------------------------------------------- */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-end: var(--space-3);
    padding-block-start: var(--space-2);
    border-block-start: 1px solid var(--border);
    position: relative;
}

.section-head::before {
    content: '';
    position: absolute;
    inset-block-start: -1px;
    inset-inline-start: 0;
    width: 48px;
    height: 3px;
    background: var(--accent);
    transition: width var(--transition);
}

.section-head:hover::before,
.section-head:focus-within::before {
    width: 96px;
}

.section-head h2 {
    font-size: var(--fs-md);
    letter-spacing: -0.02em;
}

.section-head .more {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--accent);
}

.section-head .more:hover {
    text-decoration: underline;
}

/* ---------- Category chip ---------------------------------------------- */

.chip {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--accent);
}

.chip::before {
    content: '';
    width: 6px;
    height: 6px;
    margin-inline-end: var(--space-2);
    background: currentColor;
    border-radius: 1px;
    transform: rotate(45deg);
}

.chip--plain {
    color: var(--text-muted);
}

/* ---------- Meta row --------------------------------------------------- */

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.meta > * + *::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-inline-end: var(--space-2);
    background: currentColor;
    border-radius: 50%;
    vertical-align: middle;
    opacity: 0.6;
}

/* ---------- Buttons ---------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;              /* tap target floor */
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: background var(--transition), border-color var(--transition);
}

.btn:hover {
    background: var(--surface);
    border-color: var(--text-muted);
}

.btn--accent {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn--accent:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn--ghost {
    border-color: transparent;
    background: transparent;
}

.btn--icon {
    width: 44px;
    min-height: 44px;
    padding: 0;
}

/* ---------- Thumbnails ------------------------------------------------- */

.thumb {
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

/* The attribute selector is deliberate. `img[width][height]` above scores
   higher than a plain `.thumb img`, so without matching those attributes here
   the height:auto rule wins and the picture stops short of the bottom of its
   box, leaving a grey band under every card. */
.thumb img,
.thumb img[width][height] {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

a:hover > .thumb img,
a:hover .thumb img {
    transform: scale(1.03);
}

.thumb--16x9 { aspect-ratio: 16 / 9; }
.thumb--3x2  { aspect-ratio: 3 / 2; }
.thumb--1x1  { aspect-ratio: 1 / 1; }

/* ---------- Empty state ------------------------------------------------ */

.empty {
    padding: var(--space-7) var(--space-3);
    text-align: center;
    color: var(--text-muted);
}

.empty h2 {
    font-size: var(--fs-md);
    margin-block-end: var(--space-2);
    color: var(--text);
}
