/* =========================================================
   Tokens
   ========================================================= */
:root {
    --bg: #fafafa;
    --fg: #111111;
    --muted: #7a7a7a;
    --line: rgba(0, 0, 0, 0.08);
    --dot: rgba(0, 0, 0, 0.18);
    --glow: rgba(0, 0, 0, 0.06);
    --cursor: #111111;
    --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --ease: cubic-bezier(0.65, 0, 0.35, 1);
}

html[data-theme="dark"] {
    --bg: #0b0b0c;
    --fg: #f2f2f2;
    --muted: #8a8a8a;
    --line: rgba(255, 255, 255, 0.08);
    --dot: rgba(255, 255, 255, 0.16);
    --glow: rgba(255, 255, 255, 0.07);
    --cursor: #f2f2f2;
}

/* =========================================================
   Reset / base
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    height: auto;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
    cursor: none;
}

body.page {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

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

/* Sliding underline — reused by nav links, footer links, back link */
.underline {
    position: relative;
}

.underline::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 100%;
    height: 1px;
    background: var(--fg);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.35s var(--ease);
}

.underline:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* =========================================================
   Background: dot grid + spotlight
   ========================================================= */
.grid {
    position: fixed;
    inset: 0;
    background-image: radial-gradient(var(--dot) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 100%);
    mask-image: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.glow {
    position: fixed;
    inset: 0;
    background: radial-gradient(500px circle at var(--mx, 50%) var(--my, 50%), var(--glow), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* =========================================================
   Custom cursor
   ========================================================= */
.cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cursor);
    pointer-events: none;
    z-index: 100;
    transform: translate(-50%, -50%);
    transition: width 0.25s ease, height 0.25s ease, background var(--transition);
}

.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    border: 1px solid var(--cursor);
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    transform: translate(-50%, -50%);
    opacity: 0.5;
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease, border-color var(--transition);
}

body.hovering .cursor {
    width: 4px;
    height: 4px;
}

body.hovering .cursor-ring {
    width: 56px;
    height: 56px;
    opacity: 0.9;
}

/* =========================================================
   Header
   ========================================================= */
header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2rem 3rem;
    animation: fadeDown 1s ease both;
}

.logo {
    font-size: 0.85rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    font-weight: 500;
}

nav {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

nav a {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    transition: color 0.3s ease;
}

nav a:hover {
    color: var(--fg);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--line);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--fg);
    cursor: none;
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--fg);
    transform: rotate(20deg);
}

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

.theme-toggle .moon {
    display: none;
}

html[data-theme="dark"] .theme-toggle .sun {
    display: none;
}

html[data-theme="dark"] .theme-toggle .moon {
    display: block;
}

/* =========================================================
   Main 
   ========================================================= */
main {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 1.5rem;
}

/* Small uppercase line under the title (tagline / "Page not found") */
.tagline {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--muted);
    animation: fadeUp 1.2s ease both 0.45s;
}

/* --- Home: name --- */
.name {
    font-size: clamp(2.8rem, 9vw, 7.5rem);
    font-weight: 300;
    letter-spacing: -0.04em;
    line-height: 1;
    animation: fadeUp 1.2s ease both 0.2s;
}

.name strong {
    font-weight: 600;
}


.divider {
    width: 40px;
    height: 1px;
    background: var(--fg);
    margin-top: 2.5rem;
    opacity: 0.3;
    animation: grow 1.2s ease both 0.7s;
}

/* --- 404: ghost code --- */
.code {
    font-size: clamp(5rem, 22vw, 16rem);
    font-weight: 200;
    letter-spacing: -0.06em;
    line-height: 0.9;
    color: transparent;
    -webkit-text-stroke: 1px var(--fg);
    opacity: 0.35;
    user-select: none;
    animation: fadeUp 1.2s ease both 0.2s;
}

.back {
    margin-top: 3rem;
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    animation: fadeUp 1.2s ease both 0.7s;
}

.back svg {
    width: 14px;
    height: 14px;
    transition: transform 0.35s var(--ease);
}

.back:hover svg {
    transform: translateX(-4px);
}

/* =========================================================
   Footer
   ========================================================= */
footer {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-top: 1px solid var(--line);
    animation: fadeUp 1s ease both 0.9s;
}

footer a {
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--fg);
}

.socials {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.socials a {
    display: grid;
    place-items: center;
    color: var(--muted);
    transition: color 0.3s ease, transform 0.3s ease;
}

.socials a:hover {
    color: var(--fg);
    transform: translateY(-2px);
}

.socials svg {
    width: 16px;
    height: 16px;
}


/* =========================================================
   Text pages (legal, etc.)
   ========================================================= */
body.page {
    overflow: auto;
}

.page main {
    justify-content: flex-start;
    align-items: stretch;
    text-align: left;
    padding: 4rem 1.5rem 6rem;
}

.content {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    animation: fadeUp 1.2s ease both 0.2s;
}

.content h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 300;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.content .tagline {
    margin-top: 1rem;
    margin-bottom: 4rem;
    animation: none;
}

.content section+section {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 1px solid var(--line);
}

.content h2 {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.content p {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--fg);
    opacity: 0.85;
}

.content p+p {
    margin-top: 1rem;
}

.content a {
    border-bottom: 1px solid var(--line);
    transition: border-color 0.3s ease;
}

.content a:hover {
    border-color: var(--fg);
}

.content .updated {
    margin-top: 4rem;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 1;
}


/* =========================================================
   Animations
   ========================================================= */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
}

@keyframes fadeDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
}

@keyframes grow {
    from {
        transform: scaleX(0);
    }
}

/* =========================================================
   Responsive / accessibility
   ========================================================= */
@media (max-width: 640px) {

    header,
    footer {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    nav {
        gap: 1.5rem;
    }

    footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (hover: none) {

    body,
    .theme-toggle {
        cursor: auto;
    }

    .cursor,
    .cursor-ring {
        display: none;
    }

    .grid {
        -webkit-mask-image: none;
        mask-image: none;
        opacity: 0.4;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}