/*
  site.css: the few things the Swift theme can't say.

  Raptor's theme (Sources/Theme) sets three colors per scheme: the page, the text and the
  accent. This file builds the rest from them: a second accent, the glow behind the top
  of each page, the grain, the glass panels and the gradient buttons. It also holds the
  display typeface and the styling of post bodies, which arrive as rendered Markdown and
  so can't carry Swift modifiers.
*/

/* Hanken Grotesk, one variable file for every weight. SIL OFL 1.1. */
@font-face {
    font-family: "Hanken Grotesk";
    src: url("/typefaces/HankenGrotesk.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ---------- Color ---------- */

:root {
    --sans-fallback: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --serif: "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    --grain-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/*
  The palette, Lake Effect: Chicago at night. The theme's page, text and accent colors
  are in Palette.swift; these add the rest:
    --accent-2   where gradients end: the red of the flag's stars
    --on-accent  text on anything filled with the gradient
    --panel      the glass panels' tint
    --glow-1/2   the two lights behind the top of the page
    --grain      how much texture shows
    --star       the four stars in the footer
*/
:root,
[data-color-scheme="light"] {
    --accent-2: #d90f3a;
    --on-accent: #ffffff;
    --panel: #ffffff;
    --glow-1: rgb(40 150 255 / 0.20);
    --glow-2: rgb(255 50 90 / 0.10);
    --grain: 0.045;
    --star: #d90f3a;
}

[data-color-scheme="dark"] {
    color-scheme: dark;
    --accent-2: #ff4d6a;
    --on-accent: #04101f;
    --panel: #0b1426;
    --glow-1: rgb(30 140 255 / 0.30);
    --glow-2: rgb(255 40 90 / 0.12);
    --grain: 0.07;
    --star: #ff4d6a;
}

/* Text a step back from the page, tinted by the palette rather than a neutral gray. */
:root,
[data-color-scheme] {
    --fg-secondary: color-mix(in srgb, var(--fg) 64%, var(--bg-page));
    --divider: color-mix(in srgb, var(--fg) 12%, transparent);
    --hairline: color-mix(in srgb, var(--fg) 14%, transparent);
}

html {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

::selection {
    background: color-mix(in srgb, var(--accent) 24%, transparent);
}

/* The theme names the typeface; these add what to show while it loads or if it can't. */
body {
    font-family: var(--font-family), var(--sans-fallback);
}

/* Headings: set tight and broken into even lines. */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--heading-font-family), var(--sans-fallback);
    letter-spacing: -0.03em;
    text-wrap: balance;
}

/* The navigation bar lines up with the page's edges, with room between its links. */
.nav-inner {
    padding-inline: 0;
    gap: 1.75rem;
}

p {
    text-wrap: pretty;
}

/* ---------- Atmosphere ---------- */

/* Light pooled behind the top of every page. */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: min(1200px, 150vh);
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(52% 58% at 84% 4%, var(--glow-1), transparent 72%),
        radial-gradient(42% 48% at 2% 40%, var(--glow-2), transparent 72%);
}

/* A fine grain under everything, so the dark has texture instead of flat pixels. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: var(--grain);
    background-image: var(--grain-image);
}

/* The phrase in the headline that carries the gradient. */
.glow-text {
    background-image: linear-gradient(100deg in oklch, var(--accent) 5%, var(--accent-2) 95%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

[data-color-scheme="dark"] .glow-text {
    filter: drop-shadow(0 0 26px color-mix(in srgb, var(--accent) 38%, transparent));
}

/* Section titles fade from the text color into the accent. */
.sheen {
    background-image: linear-gradient(180deg, var(--fg) 35%, color-mix(in oklch, var(--fg) 45%, var(--accent)));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Section labels get a small lit dot. */
.eyebrow::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 10px;
    border-radius: 50%;
    vertical-align: 0.08em;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 60%, transparent);
}

.portrait {
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--fg) 14%, transparent),
        0 40px 110px -36px color-mix(in srgb, var(--accent) 70%, transparent),
        0 10px 50px -20px color-mix(in srgb, var(--accent-2) 50%, transparent);
}

/* Buttons: the gradient, lit from below; the outlined one is glass. */
a.btn.btn-prominent {
    --btn-fg: var(--on-accent);
    --fg: var(--on-accent);
    font-weight: 600;
    background-image: linear-gradient(120deg in oklch, var(--accent), var(--accent-2));
    box-shadow:
        inset 0 1px 0 rgb(255 255 255 / 0.28),
        0 14px 36px -14px color-mix(in srgb, var(--accent) 80%, transparent);
}

a.btn.btn-prominent:hover {
    filter: brightness(1.07) saturate(1.05);
    box-shadow:
        inset 0 1px 0 rgb(255 255 255 / 0.32),
        0 18px 48px -12px color-mix(in srgb, var(--accent) 90%, transparent);
}

a.btn.btn-bordered {
    --btn-bg: color-mix(in srgb, var(--panel) 45%, transparent);
    --btn-border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Glass panels with an edge that catches the light. */
.panel {
    position: relative;
    border-radius: 24px;
    background: color-mix(in srgb, var(--panel) 74%, transparent);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--fg) 7%, transparent),
        0 50px 100px -50px color-mix(in srgb, var(--accent) 45%, transparent);
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(150deg,
        color-mix(in srgb, var(--fg) 26%, transparent),
        color-mix(in srgb, var(--fg) 6%, transparent) 40%,
        color-mix(in srgb, var(--accent) 45%, transparent));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* Inside the chat panel: the fan's bubbles and the card's button take the gradient. */
.accent-fill {
    color: var(--on-accent);
    background-image: linear-gradient(120deg in oklch, var(--accent), var(--accent-2));
}

.reply-bubble {
    background: color-mix(in srgb, var(--fg) 9%, transparent);
}

.stars {
    color: var(--star);
}

[data-color-scheme="dark"] .stars {
    text-shadow: 0 0 12px color-mix(in srgb, var(--star) 70%, transparent);
}

.nav-inner a:hover {
    color: var(--accent);
}

/* ---------- Post bodies ---------- */

.prose {
    font-family: var(--serif);
    font-size: 1.2rem;
    line-height: 1.65;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
    margin-block: 0 1.25em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-block: 2em 0.6em;
}

.prose h1,
.prose h2 { font-size: 1.6em; }
.prose h3 { font-size: 1.3em; }
.prose h4 { font-size: 1.1em; }

.prose a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
    transition: color 0.15s ease;
}

.prose a:hover {
    color: var(--accent);
}

.prose ul,
.prose ol {
    padding-inline-start: 1.3em;
}

.prose li {
    margin-block: 0.3em;
}

.prose li > ul,
.prose li > ol {
    margin-block: 0.3em 0;
}

.prose blockquote {
    margin-inline: 0;
    padding: 0.1em 0 0.1em 1.1em;
    border-inline-start: 3px solid var(--accent);
    font-style: italic;
    color: color-mix(in srgb, var(--fg) 82%, transparent);
}

.prose blockquote p:last-child {
    margin-bottom: 0;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
}

/* Two or more pictures in one paragraph sit side by side. */
.prose p:has(> a > img + *),
.prose p:has(> a:nth-of-type(2) > img) {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.prose p:has(> a:nth-of-type(2) > img) > a {
    flex: 1 1 220px;
    max-width: 320px;
}

.prose sup {
    font-family: var(--mono);
    font-size: 0.7em;
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--hairline);
    margin-block: 2.5em;
}

.prose code {
    font-family: var(--mono);
    font-size: 0.85em;
}

.prose > :last-child {
    margin-bottom: 0;
}
