/* Reset, typography and the fixed background */

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

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

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: transparent;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img, video, iframe { max-width: 100%; }
img { height: auto; display: block; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0;
}

a { color: inherit; }

:focus-visible {
    outline: 2px solid var(--hl);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Background: a fixed element, not background-attachment (iOS ignores that) */
/* Sized to the LARGEST viewport (100lvh): on iPhone, Safari's toolbars shrink as you
   scroll, and an inset:0 background would leave a growing strip of page colour. */
.site-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100vh;
    height: 100lvh;
    z-index: -1;
    background: var(--bg);
    background-size: cover;
    background-position: center;
}
.has-bg-image .site-bg { background-color: #1a1c24; }

/* Fades pinned to the VISIBLE top and bottom edges (they move with Safari's toolbar) */
.site-fade {
    position: fixed;
    left: 0;
    right: 0;
    z-index: -1;
    pointer-events: none;
}
.site-fade-top {
    top: 0;
    height: calc(70px + env(safe-area-inset-top));
    background: linear-gradient(var(--edge), transparent);
}
.site-fade-bottom {
    bottom: 0;
    height: calc(90px + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, var(--edge));
}

.site-vignette {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(0, 0, 0, 0.26), rgba(0, 0, 0, 0.2) 30%, rgba(0, 0, 0, 0.3)),
        radial-gradient(90% 70% at 50% 0, transparent 40%, rgba(0, 0, 0, 0.45));
}
/* Photos can be very bright: a flat scrim plus a floor in the vignette keep text >= 4.5:1 at every height (see tests/contrast_model.py) */
.has-bg-image .site-vignette {
    background:
        linear-gradient(rgba(0, 0, 0, 0.24), rgba(0, 0, 0, 0.24)),
        linear-gradient(rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0.26) 30%, rgba(0, 0, 0, 0.4)),
        radial-gradient(90% 70% at 50% 0, transparent 40%, rgba(0, 0, 0, 0.5));
}

.site-grain {
    position: absolute;
    inset: 0;
    display: none;
    background-image: radial-gradient(rgba(0, 0, 0, 0.3) 1px, transparent 1px);
    background-size: 3px 3px;
    opacity: 0.5;
}
.has-grain .site-grain { display: block; }

/* viewport-fit=cover lets the background run under the iPhone status bar and home bar;
   keep the content itself clear of them */
.site {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: clip;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.site-main { flex: 1; }
