:root,
body {
    --fg: #f2f2f2;
    --bg: #030305;
    --vignette: rgba(0, 0, 0, 0.34);
    --hair: rgba(127, 127, 127, 0.28);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
    font-family: 'Space Mono', 'Courier New', Courier, monospace;
    transition: background-color 0.4s ease, color 0.4s ease;
}

canvas {
    display: block;
    opacity: 0;
    transition: opacity 1.1s ease;
}

body.loaded canvas {
    opacity: 1;
}

::selection {
    background: var(--fg);
    color: var(--bg);
}

button {
    font-family: inherit;
}

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

/* ---------------------------------------------------------------- chrome */

.identity {
    position: fixed;
    top: 42px;
    left: 48px;
    z-index: 10;
    pointer-events: none;
    max-width: 320px;
}

.name {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.24em;
}

.tagline {
    margin: 11px 0 0;
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    opacity: 0.55;
}

/* ----------------------------------------------------------------- links */

.links {
    position: fixed;
    bottom: 48px;
    right: 48px;
    z-index: 10;
    display: flex;
    align-items: baseline;
    gap: 20px;
}

.link {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    color: var(--fg);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-decoration: none;
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.25s ease;
}

.link:hover,
.link:focus-visible {
    opacity: 1;
    text-decoration: underline;
    text-underline-offset: 5px;
    text-decoration-thickness: 1px;
}

/* ---------------------------------------------------------------- panels */

.panel {
    position: fixed;
    top: 138px;
    left: 48px;
    z-index: 20;
    width: min(360px, calc(100vw - 96px));
    padding: 22px 24px 24px;
    border: 1px solid var(--hair);
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    visibility: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(.2, .7, .2, 1), visibility 0.28s;
}

/* ascii corner ticks, opposing corners only */
.panel::before,
.panel::after {
    position: absolute;
    font-size: 12px;
    line-height: 1;
    opacity: 0.5;
    content: '+';
}

.panel::before {
    top: -6px;
    left: -4px;
}

.panel::after {
    bottom: -6px;
    right: -4px;
}

.panel.open {
    visibility: visible;
    opacity: 1;
    transform: none;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-title {
    margin: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    opacity: 0.55;
}

.panel-close {
    appearance: none;
    background: none;
    border: 0;
    padding: 2px 6px;
    margin: -2px -6px 0 0;
    color: var(--fg);
    font-size: 11px;
    line-height: 1;
    opacity: 0.45;
    cursor: pointer;
    transition: opacity 0.25s ease;
}

.panel-close:hover {
    opacity: 1;
}

.panel-body {
    font-size: 12px;
    line-height: 1.8;
}

.panel-body p {
    margin: 0 0 10px;
    opacity: 0.8;
}

.panel-body p:last-child {
    margin-bottom: 0;
}

.panel-body a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
    opacity: 0.7;
    transition: opacity 0.25s ease;
}

.panel-body a:hover {
    opacity: 1;
}

.projects {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.projects li {
    margin: 0 0 12px;
    padding-left: 16px;
    position: relative;
}

.projects li::before {
    content: '>';
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0.4;
}

.projects li:last-child {
    margin-bottom: 0;
}

.project-name {
    display: block;
    font-weight: 700;
    font-size: 12px;
}

.project-desc {
    display: block;
    font-size: 11px;
    line-height: 1.6;
    opacity: 0.55;
}

/* section subheads inside the resume panel */
.resume-head {
    font-size: 9px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    opacity: 0.45 !important;
    margin: 0 0 8px !important;
}

.panel-foot {
    margin: 0;
    font-size: 11px;
}

/* -------------------------------------------------------------- vignette */

.vignette {
    position: fixed;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 56%, var(--vignette) 100%);
    transition: background 0.4s ease;
}

/* ----------------------------------------------------------------- grain */

.grain {
    position: fixed;
    inset: -64px;
    z-index: 5;
    pointer-events: none;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: grain-shift 0.7s steps(4) infinite;
}

@keyframes grain-shift {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-18px, 24px);
    }

    50% {
        transform: translate(26px, -14px);
    }

    75% {
        transform: translate(-12px, -22px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* --------------------------------------------------------------- reticle */

@media (pointer: fine) {
    body.on-canvas canvas {
        cursor: none;
    }
}

.reticle {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

body.on-canvas .reticle {
    opacity: 1;
}

@media (pointer: coarse) {
    .reticle {
        display: none;
    }
}

.reticle::before,
.reticle::after {
    content: '';
    position: absolute;
    background: var(--fg);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--bg) 70%, transparent);
    transition: transform 0.3s cubic-bezier(.2, .7, .2, 1);
}

/* crosshair: rotates into an × and swells over a nav word */
.reticle::before {
    width: 15px;
    height: 1px;
    left: -7px;
    top: 0;
}

.reticle::after {
    width: 1px;
    height: 15px;
    left: 0;
    top: -7px;
}

body.nav-hover .reticle::before {
    transform: rotate(45deg);
}

body.nav-hover .reticle::after {
    transform: rotate(45deg);
}

.reticle-label {
    position: absolute;
    left: 16px;
    top: 10px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: lowercase;
    white-space: nowrap;
    color: var(--fg);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    padding: 3px 7px;
    border: 1px solid var(--hair);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

body.nav-hover .reticle-label {
    opacity: 1;
    transform: translateX(0);
}

/* --------------------------------------------------------------- reveals */

.name,
.tagline,
.links {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2, .7, .2, 1);
}

body.loaded .name,
body.loaded .tagline,
body.loaded .links {
    opacity: 1;
    transform: translateY(0);
}

body.loaded .name {
    transition-delay: 0.14s;
}

body.loaded .tagline {
    transition-delay: 0.22s;
    opacity: 0.55;
}

body.loaded .links {
    transition-delay: 0.34s;
}
/* ------------------------------------------------------------- drag hint */

/* A shell-prompt whisper tucked above the theme toggle: the text types in
   left-to-right, a block caret blinks beside it. Stays ultra-dim. */
.drag-hint {
    position: fixed;
    left: 48px;
    bottom: 48px;
    z-index: 25;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5em;
    white-space: nowrap;
    font-size: 9px;
    letter-spacing: 0.22em;
    color: var(--fg);
    opacity: 0;
    transition: opacity 1.2s ease;
}

body.loaded .drag-hint {
    transition-delay: 1.4s;
    opacity: 0.3;
}

.drag-hint-text {
    clip-path: inset(0 100% 0 0);
    animation: drag-hint-type 1s steps(12, end) forwards;
    animation-delay: 1.7s;
}

@keyframes drag-hint-type {
    to { clip-path: inset(0 0 0 0); }
}

/* fade out for good once the user has dragged */
body.dragged .drag-hint {
    opacity: 0 !important;
    transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
    .drag-hint-text { animation: none; clip-path: none; }
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 640px) {
    .identity {
        top: 24px;
        left: 24px;
    }

    .links {
        left: 24px;
        right: 24px;
        bottom: calc(28px + env(safe-area-inset-bottom, 0px));
        gap: 8px 14px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .panel {
        top: auto;
        left: 18px;
        right: 18px;
        bottom: calc(94px + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-height: 52vh;
        overflow-y: auto;
    }
}

/* -------------------------------------------------------- reduced motion */

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

    .name,
    .tagline,
    .links,
    .panel,
    canvas {
        transition: none;
        transform: none;
    }

    .grain {
        animation: none;
    }

    .reticle::before,
    .reticle::after,
    .reticle-label {
        transition: none;
    }
}
