/* ============================================================
   Morgan Wilkinson — brand design system
   Canonical source: morganwilkinson.com repo → public/brand.css
   Vendored copies live in other repos (e.g. workshop docs/) —
   keep them in sync when this file changes.

   Theming: :root holds the light tokens; dark applies via
   prefers-color-scheme unless overridden by [data-theme] on
   <html>. brand.js persists the choice in localStorage
   (key: mw-theme) — restore it in <head> to avoid a flash.
   ============================================================ */

/* ---------- Design tokens ---------- */

:root {
    --bg: #f2f2f7;
    --grid-line: rgba(23, 23, 60, 0.055);

    --text: #17171f;
    --muted: #5a5a70;
    --faint: #8b8ba0;
    --footer: #a3a3b8;

    --red: #dc2626;
    --orange: #f97316;
    --cyan: #0e93b4;

    --card-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.42));
    --card-border: rgba(23, 23, 44, 0.1);
    --card-shadow:
        0 24px 80px rgba(30, 30, 70, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
    --edge-glow: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.5), rgba(220, 38, 38, 0.5), rgba(14, 147, 180, 0.5), transparent);

    --surface: rgba(255, 255, 255, 0.55);
    --surface-strong: rgba(255, 255, 255, 0.85);
    --line: rgba(23, 23, 44, 0.1);

    --title-gradient: linear-gradient(115deg, #17171f 30%, #6b3f1d 60%, #ea580c 90%);
    --divider: linear-gradient(90deg, transparent, rgba(23, 23, 44, 0.22), transparent);

    --blob-opacity-a: 0.2;
    --blob-opacity-b: 0.14;
    --blob-opacity-c: 0.12;

    --font-head: 'Space Grotesk', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --radius-card: 24px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #06060b;
        --grid-line: rgba(255, 255, 255, 0.025);

        --text: #e7e7ee;
        --muted: #9a9ab0;
        --faint: #6d6d85;
        --footer: #55556b;

        --cyan: #22d3ee;

        --card-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
        --card-border: rgba(255, 255, 255, 0.09);
        --card-shadow:
            0 24px 80px rgba(0, 0, 0, 0.55),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);
        --edge-glow: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.7), rgba(220, 38, 38, 0.7), rgba(34, 211, 238, 0.7), transparent);

        --surface: rgba(255, 255, 255, 0.05);
        --surface-strong: rgba(255, 255, 255, 0.1);
        --line: rgba(255, 255, 255, 0.09);

        --title-gradient: linear-gradient(115deg, #ffffff 25%, #e8d9c9 55%, #fb923c 90%);
        --divider: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);

        --blob-opacity-a: 0.5;
        --blob-opacity-b: 0.35;
        --blob-opacity-c: 0.3;
    }
}

:root[data-theme="dark"] {
    --bg: #06060b;
    --grid-line: rgba(255, 255, 255, 0.025);

    --text: #e7e7ee;
    --muted: #9a9ab0;
    --faint: #6d6d85;
    --footer: #55556b;

    --cyan: #22d3ee;

    --card-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    --card-border: rgba(255, 255, 255, 0.09);
    --card-shadow:
        0 24px 80px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --edge-glow: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.7), rgba(220, 38, 38, 0.7), rgba(34, 211, 238, 0.7), transparent);

    --surface: rgba(255, 255, 255, 0.05);
    --surface-strong: rgba(255, 255, 255, 0.1);
    --line: rgba(255, 255, 255, 0.09);

    --title-gradient: linear-gradient(115deg, #ffffff 25%, #e8d9c9 55%, #fb923c 90%);
    --divider: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);

    --blob-opacity-a: 0.5;
    --blob-opacity-b: 0.35;
    --blob-opacity-c: 0.3;
}

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

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: inherit;
}

button {
    font-family: inherit;
}

/* ---------- Background scene ---------- */

.scene {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.scene .grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 45%, black 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 45%, black 30%, transparent 75%);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    will-change: transform;
}

.blob-a {
    width: 480px;
    height: 480px;
    background: var(--red);
    top: -10%;
    left: -8%;
    opacity: var(--blob-opacity-a);
    animation: drift-a 26s ease-in-out infinite alternate;
}

.blob-b {
    width: 420px;
    height: 420px;
    background: var(--cyan);
    bottom: -15%;
    right: -6%;
    opacity: var(--blob-opacity-b);
    animation: drift-b 32s ease-in-out infinite alternate;
}

.blob-c {
    width: 320px;
    height: 320px;
    background: var(--orange);
    top: 55%;
    left: 60%;
    opacity: var(--blob-opacity-c);
    animation: drift-c 24s ease-in-out infinite alternate;
}

@keyframes drift-a {
    to { transform: translate(140px, 90px) scale(1.15); }
}

@keyframes drift-b {
    to { transform: translate(-120px, -110px) scale(1.1); }
}

@keyframes drift-c {
    to { transform: translate(-140px, -60px) scale(0.85); }
}

/* ---------- Glass card ---------- */

.card {
    position: relative;
    padding: 56px 48px;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    backdrop-filter: blur(28px) saturate(140%);
    -webkit-backdrop-filter: blur(28px) saturate(140%);
    box-shadow: var(--card-shadow);
    animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
}

/* Top gradient edge glow */
.card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: var(--edge-glow);
}

/* ---------- Typography ---------- */

.brand-title {
    font-family: var(--font-head);
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 20px;
    background: var(--title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tagline {
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--muted);
}

.divider {
    width: 56px;
    height: 1px;
    margin: 32px auto;
    background: var(--divider);
}

.note {
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    color: var(--faint);
}

/* ---------- Pill ---------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
    animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
    50% { opacity: 0.35; }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn:hover {
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.btn:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* ---------- Top bar (back link left, actions right) ---------- */

.topbar {
    position: fixed;
    top: 20px;
    left: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 10;
}

.topbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-group:last-child {
    margin-left: auto;
}

.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 24px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.theme-toggle svg {
    width: 17px;
    height: 17px;
}

/* Effective dark theme → show sun icon, hide moon */
.icon-sun { display: none; }

:root[data-theme="dark"] .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun { display: inline; }
    :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Nav menu (app hub) ---------- */

.nav {
    text-align: left;
    width: 100%;
}

[hidden] {
    display: none !important;
}

.nav-section + .nav-section {
    margin-top: 28px;
}

.nav-heading {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-item:hover {
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.nav-item:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.nav-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.nav-item-name {
    font-family: var(--font-head);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nav-item-desc {
    font-size: 0.78rem;
    color: var(--muted);
}

.nav-item-arrow {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--faint);
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-item:hover .nav-item-arrow {
    color: var(--orange);
    transform: translateX(3px);
}

/* ---------- Accessibility / responsive ---------- */

@media (prefers-reduced-motion: reduce) {
    .blob, .pill-dot, .card {
        animation: none;
    }
}

@media (max-width: 520px) {
    .card {
        padding: 44px 28px;
    }

    .topbar {
        top: 14px;
        right: 14px;
    }
}
