/*
 * SweetBookmark design system ("quiet utility").
 *
 * Tokens first, then base elements, then shared components. Light and dark
 * follow the visitor's system setting via prefers-color-scheme. Page-specific
 * styles live in their own files (e.g. landing.css) and only use these tokens.
 */

/* ---------- Fonts (self-hosted: the CSP only allows fonts from 'self') ---------- */

@font-face {
    font-family: "Geist";
    src: url("../fonts/Geist-Variable.f208f1ceee9d.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist Mono";
    src: url("../fonts/GeistMono-Variable.6aaa5f578bc1.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
    color-scheme: light dark;

    /* Colour: neutral greys, one green accent */
    --bg: #ffffff;
    --bg-subtle: #fafafa;
    --surface: #ffffff;
    --border: #e6e6e6;
    --border-strong: #d4d4d4;
    --text: #0a0a0a;
    --text-muted: #5f5f5f;      /* 6.4:1 on --bg */
    --text-faint: #8a8a8a;      /* decorative / large text only */
    --accent: #15803d;          /* 5.0:1 on --bg */
    --accent-hover: #166534;
    --accent-soft: #f0fdf4;
    --on-accent: #ffffff;
    --focus: #15803d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -8px rgba(0, 0, 0, 0.12);

    /* Type */
    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.875rem;
    --text-display: clamp(2.5rem, 6.2vw, 4.25rem);

    /* Space (4px grid) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4.5rem;
    --space-9: 7rem;

    /* Shape */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;

    --container: 1080px;
    --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0b0c;
        --bg-subtle: #111113;
        --surface: #151518;
        --border: #26262b;
        --border-strong: #34343a;
        --text: #ededef;
        --text-muted: #a1a1a8;  /* 7.6:1 on --bg */
        --text-faint: #6e6e76;
        --accent: #4ade80;
        --accent-hover: #86efac;
        --accent-soft: rgba(74, 222, 128, 0.1);
        --on-accent: #052e16;
        --focus: #4ade80;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
    }
}

@media (max-width: 640px) {
    :root {
        --gutter: 1rem;
    }
}

/* ---------- Base ---------- */

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

p {
    margin: 0;
    text-wrap: pretty;
}

a {
    color: inherit;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 0.2em;
}

a:hover {
    text-decoration-color: currentColor;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

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

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

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -3rem;
    z-index: 100;
    padding: var(--space-2) var(--space-3);
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius);
    text-decoration: none;
    font-size: var(--text-sm);
}

.skip-link:focus {
    top: var(--space-3);
}

.container {
    width: 100%;
    max-width: calc(var(--container) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
    letter-spacing: -0.01em;
}

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

/* ---------- Components ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 2.5rem;
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn-sm {
    height: 2rem;
    padding: 0 var(--space-3);
}

.btn-lg {
    height: 2.875rem;
    padding: 0 var(--space-5);
    font-size: var(--text-base);
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--text) 82%, var(--bg));
}

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

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

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

.btn-secondary:hover {
    border-color: var(--border-strong);
    background: var(--bg-subtle);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--bg-subtle);
}

kbd,
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    height: 1.5em;
    padding: 0 0.35em;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78em;
    line-height: 1;
}

/* Wordmark: ribbon mark + lowercase name */
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text);
    font-weight: 600;
    font-size: var(--text-base);
    letter-spacing: -0.02em;
    text-decoration: none;
}

.wordmark-mark {
    width: 18px;
    height: 18px;
    color: var(--accent);
    flex: none;
}

/* Public site header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: 3.5rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.site-nav-link {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-decoration: none;
}

.site-nav-link:hover {
    color: var(--text);
}

@media (max-width: 640px) {
    .site-nav-link.optional {
        display: none;
    }
}

/* Public site footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-6) 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.site-footer-links {
    display: flex;
    gap: var(--space-5);
}

.site-footer-links a {
    text-decoration: none;
}

.site-footer-links a:hover {
    color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
