:root {
    color-scheme: dark;

    --bg: #09090b;
    --surface: #111114;
    --surface-2: #17171b;
    --line: rgba(255, 255, 255, 0.075);
    --line-strong: rgba(255, 255, 255, 0.14);

    --text: #ededf0;
    --muted: #9a9aa6;
    --faint: #63636e;

    --accent: #6f9bff;
    --accent-bright: #a9c4ff;
    --accent-deep: #3f6dff;
    --accent-glow: rgba(111, 155, 255, 0.35);

    --radius: 16px;
    --radius-sm: 10px;

    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

::selection {
    background: var(--accent-deep);
    color: #fff;
}

a {
    color: inherit;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 8px;
}

img,
svg {
    display: block;
}

/* --------------------------------------------------------------------------
   Background: circuit dot grid + cursor light
   -------------------------------------------------------------------------- */

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    --dot: radial-gradient(circle at center, rgba(255, 255, 255, 0.11) 1px, transparent 1.5px);
}

.bg-grid::before,
.bg-grid::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--dot);
    background-size: 24px 24px;
    background-position: center;
}

/* Static grid fades out toward the edges */
.bg-grid::before {
    -webkit-mask-image: radial-gradient(ellipse 80% 70% at 30% 20%, #000 10%, transparent 75%);
    mask-image: radial-gradient(ellipse 80% 70% at 30% 20%, #000 10%, transparent 75%);
}

/* Brighter blue dots that follow the cursor */
.bg-grid::after {
    background-image: radial-gradient(circle at center, var(--accent) 1px, transparent 1.6px);
    opacity: 0;
    transition: opacity 0.4s ease;
    -webkit-mask-image: radial-gradient(180px circle at var(--px, 50%) var(--py, 50%), #000, transparent 100%);
    mask-image: radial-gradient(180px circle at var(--px, 50%) var(--py, 50%), #000, transparent 100%);
}

.bg-grid.is-lit::after {
    opacity: 0.55;
}

.bg-glow {
    position: fixed;
    z-index: -2;
    pointer-events: none;
    width: 60rem;
    height: 40rem;
    left: -20rem;
    top: -22rem;
    background: radial-gradient(closest-side, rgba(63, 109, 255, 0.16), transparent);
    filter: blur(10px);
}

/* --------------------------------------------------------------------------
   Card with cursor-following border light
   -------------------------------------------------------------------------- */

.card,
.info-box,
.intro-box,
.error-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    isolation: isolate;
    transition:
        border-color 0.35s ease,
        transform 0.5s var(--ease-out),
        background-color 0.35s ease;
}

.card::before,
.info-box::before,
.intro-box::before,
.error-box::before {
    /* Border highlight */
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), var(--accent), transparent 70%);
    mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.card::after,
.info-box::after,
.intro-box::after,
.error-box::after {
    /* Soft inner glow */
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(111, 155, 255, 0.07), transparent 60%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.card:hover::before,
.card:hover::after,
.info-box:hover::before,
.info-box:hover::after,
.intro-box:hover::before,
.intro-box:hover::after,
.error-box:hover::before,
.error-box:hover::after {
    opacity: 1;
}

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

.btn,
.back-button,
.email-link,
.pgp-link,
.chat-room-link,
.chat-room-link-se,
.chat-room-link-so {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.75rem;
    padding: 0 1.15rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--text);
    font: 500 0.92rem/1 var(--font-sans);
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    transition:
        color 0.3s ease,
        border-color 0.3s ease,
        transform 0.4s var(--ease-spring);
}

/* Fill that sweeps up from the bottom on hover */
.btn::before,
.back-button::before,
.email-link::before,
.pgp-link::before,
.chat-room-link::before,
.chat-room-link-se::before,
.chat-room-link-so::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--text);
    transform: translateY(101%);
    border-radius: inherit;
    transition: transform 0.45s var(--ease-out);
}

.btn:hover,
.back-button:hover,
.email-link:hover,
.pgp-link:hover,
.chat-room-link:hover,
.chat-room-link-se:hover,
.chat-room-link-so:hover {
    color: var(--bg);
    border-color: var(--text);
}

.btn:hover::before,
.back-button:hover::before,
.email-link:hover::before,
.pgp-link:hover::before,
.chat-room-link:hover::before,
.chat-room-link-se:hover::before,
.chat-room-link-so:hover::before {
    transform: translateY(0);
}

.btn:active,
.back-button:active,
.email-link:active,
.pgp-link:active {
    transform: scale(0.97);
}

.btn-primary,
.email-link {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
    color: #fff;
}

.btn-primary::before,
.email-link::before {
    background: #fff;
}

.btn-primary:hover,
.email-link:hover {
    border-color: #fff;
}

.btn .arrow,
.back-button .arrow {
    display: inline-block;
    transition: transform 0.4s var(--ease-spring);
}

.btn:hover .arrow {
    transform: translateX(3px);
}

.back-button:hover .arrow,
.btn:hover .arrow:first-child {
    transform: translateX(-3px);
}

/* Hover tints for the chat-room links */
.chat-room-link-se::before {
    background: #5a9be6;
}

.chat-room-link-so::before {
    background: #f48024;
}

.chat-room-link-se:hover,
.chat-room-link-so:hover {
    color: #0b0b0d;
}

.chat-room-link-se:hover {
    border-color: #5a9be6;
}

.chat-room-link-so:hover {
    border-color: #f48024;
}

/* --------------------------------------------------------------------------
   Labels / small type
   -------------------------------------------------------------------------- */

.eyebrow {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font: 500 0.75rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}

.eyebrow .num {
    color: var(--accent);
}

.eyebrow::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--line-strong), transparent);
}

/* --------------------------------------------------------------------------
   Sub-page layout (contact, zRef, 404, privacy policy)
   -------------------------------------------------------------------------- */

.page {
    width: min(100% - 2.5rem, 760px);
    margin: 0 auto;
    padding: clamp(1.5rem, 5vw, 4rem) 0 4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: clamp(1.5rem, 5vw, 3rem);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand svg {
    width: 28px;
    height: 28px;
    transition: transform 0.5s var(--ease-spring);
}

.brand:hover svg {
    transform: rotate(-8deg) scale(1.08);
}

#mainTitle,
.page-title {
    font-size: clamp(2.25rem, 6vw, 3.5rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.04em;
    margin-bottom: 0.75rem;
    text-wrap: balance;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 1rem;
}

.info-box,
.intro-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    padding: clamp(1.25rem, 3vw, 1.75rem);
}

.info-box h1,
.info-box h2,
.intro-box h1,
.intro-box h2 {
    font: 500 0.75rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.info-box p,
.intro-box p,
.container li {
    color: var(--muted);
    line-height: 1.7;
}

.info-box p strong,
.intro-box p strong {
    color: var(--text);
    font-weight: 500;
}

.info-box p a,
.intro-box p a,
.page > p a {
    color: var(--text);
    background: linear-gradient(var(--accent), var(--accent)) no-repeat left bottom / 100% 1px;
    transition:
        background-size 0.4s var(--ease-out),
        color 0.3s ease;
}

.info-box p a:hover,
.intro-box p a:hover,
.page > p a:hover {
    color: var(--accent-bright);
    background-size: 0% 1px;
    background-position: right bottom;
}

.contact-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.contact-item p {
    flex-basis: 100%;
}

.app-store-badge {
    display: inline-block;
    margin-top: 0.25rem;
    transition: transform 0.4s var(--ease-spring);
}

.app-store-badge:hover {
    transform: translateY(-2px) scale(1.04);
}

.app-store-badge img {
    height: 48px;
    width: auto;
}

/* 404 */
.error-box {
    padding: clamp(2rem, 6vw, 3.5rem);
    text-align: left;
}

.error-number {
    font: 600 clamp(4.5rem, 14vw, 8rem) / 1 var(--font-mono);
    letter-spacing: -0.06em;
    background: linear-gradient(180deg, var(--text), var(--faint));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--muted);
    max-width: 52ch;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.75rem;
}

.btn-secondary {
    background: transparent;
}

/* Long-form text pages (privacy policy) */
.page.prose > strong,
.page.prose > h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.page.prose > p,
.page.prose > ul,
.page.prose > ol {
    color: var(--muted);
    line-height: 1.75;
}

.page.prose > p strong {
    color: var(--text);
    font-weight: 600;
}

/* Bold-only paragraphs act as section headings */
.page.prose > p:has(> strong:only-child) {
    margin-top: 1.25rem;
    font-size: 1.1rem;
}

.page.prose ul,
.page.prose ol {
    padding-left: 1.25rem;
}

.site-footer {
    margin-top: 3rem;
    font: 400 0.75rem/1 var(--font-mono);
    color: var(--faint);
}

/* --------------------------------------------------------------------------
   Page-enter animation for sub-pages
   -------------------------------------------------------------------------- */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.page > * {
    animation: rise 0.7s var(--ease-out) both;
}

.page > *:nth-child(2) {
    animation-delay: 60ms;
}
.page > *:nth-child(3) {
    animation-delay: 120ms;
}
.page > *:nth-child(4) {
    animation-delay: 180ms;
}
.page > *:nth-child(5) {
    animation-delay: 240ms;
}
.page > *:nth-child(6) {
    animation-delay: 300ms;
}
.page > *:nth-child(7) {
    animation-delay: 360ms;
}
.page > *:nth-child(n + 8) {
    animation-delay: 400ms;
}

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