/* Base - @font-face, reset, element defaults, shared keyframes. */

/* Metric-matched fallback: occupies the same box as the pixel font so the
   swap (font-display: swap) causes ~0px layout shift. Overrides are tuned via
   fonttools to 8bitoperator metrics. */
@font-face {
    font-family: "8bitoperator-fallback";
    src: local("Courier New"), local("Courier"), local("monospace");
    ascent-override: 224.54%;
    descent-override: 51.82%;
    line-gap-override: 0%;
    size-adjust: 64.41%;
}

@font-face {
    font-family: "8bitoperator JVE";
    src: url("/fonts/8bitoperatorJVE.woff2") format("woff2"),
         url("/fonts/8bitoperatorJVE.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
    /* 8bitoperator has a small cap-height (0.56em). Scale it up to match the
       previous pixel font (Press Start 2P, 1.0em) so pixel text renders the
       same visual size. */
    size-adjust: 178%;
}

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

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

p {
    max-width: var(--text-measure);
    color: var(--text-secondary);
}

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

a {
    color: var(--accent-dark);
    text-underline-offset: 0.2em;
}
a:hover {
    color: var(--accent);
}

input,
button,
textarea,
select {
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input,
textarea,
select {
    background: var(--bg-alt);
    border: var(--border-width-thin) solid var(--border);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    outline: none;
}

button {
    background: none;
    cursor: pointer;
    line-height: inherit;
}

code {
    font-family: var(--font-pixel);
    font-size: var(--font-size-2xs);
    color: var(--accent);
}

hr {
    border: none;
    border-top: var(--border-width) solid var(--border-light);
}

h1,
h2 {
    font-family: var(--font-pixel);
    font-size: clamp(var(--font-size-base), 0.7rem + 1.2vw, var(--font-size-2xl));
    line-height: var(--line-height-snug);
    text-wrap: balance;
    color: var(--text-primary);
}

h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    font-weight: 700;
    color: var(--text-primary);
}

html {
    scroll-behavior: smooth;
}

dialog::backdrop {
    background: color-mix(in srgb, var(--accent-light) 15%, transparent);
}

dialog:not([open]):not([popover]) {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

dialog[open],
dialog:popover-open {
    animation: fadeIn 0.15s ease-out;
}
