/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
    --bg: #07090c;
    --surface: rgba(14, 18, 24, 0.90);
    --surface-hover: rgba(18, 23, 31, 0.94);
    --surface-solid: #0c1015;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --border-active: rgba(127, 196, 216, 0.45);

    --heading: #f3f5f7;
    --text: #b4bcc8;
    --text-dim: #8b96a5;

    --accent: #7fc4d8;
    --accent-glow: rgba(127, 196, 216, 0.55);
    --dna-silver: #c9d1dc;

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

    --radius: 12px;
    --gutter: clamp(20px, 5vw, 48px);
    --nav-height: 68px;
    --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

    color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-height) + 16px);
    /* Reserved up front: the static pre-boot hero has no scrollbar yet, the full page does. */
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
}

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

h1,
h2,
h3 {
    text-wrap: balance;
}

/* Both only receive programmatic focus (FocusOnNavigate, skip link). */
h1:focus,
.page:focus {
    outline: none;
}

p {
    margin: 0 0 1em;
}

a {
    color: inherit;
}

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

::selection {
    background: rgba(127, 196, 216, 0.3);
    color: var(--heading);
}

.icon {
    flex: none;
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.container {
    width: min(1280px, 100% - 2 * var(--gutter));
    margin-inline: auto;
}

/* The WebGL canvas is fixed at z-index 0, the page scrolls above it. */
.page {
    position: relative;
    z-index: 1;
}

.section {
    padding: clamp(96px, 12vh, 144px) 0;
}

/* Desktop keeps the right side of the viewport free for the DNA. */
.section__content {
    width: calc(58.3333% - 10px);
    min-width: 0;
}

@media (min-width: 821px) and (max-width: 1180px) {
    :root {
        --gutter: 32px;
    }

    .section__content {
        width: 70%;
    }
}

.section-header {
    margin-bottom: 48px;
}

.section-eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 18px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.section-eyebrow__index {
    color: var(--accent);
}

.section-eyebrow__index::after {
    content: "";
    display: inline-block;
    width: 28px;
    height: 1px;
    margin-left: 12px;
    background: var(--border-strong);
    vertical-align: middle;
}

.section-title {
    margin: 0;
    color: var(--heading);
    font-size: clamp(2.25rem, 3.2vw, 2.875rem);
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: -0.03em;
}

/* ==========================================================================
   Shared components
   ========================================================================== */

.tag {
    display: inline-block;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.4;
    letter-spacing: 0.01em;
    /* Short tags stay on one line anyway; long ones may wrap instead of leaving a narrow screen. */
    max-width: 100%;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.btn .icon {
    transition: transform 160ms var(--ease-out);
}

.btn:hover .icon,
.btn:focus-visible .icon {
    transform: translateX(3px);
}

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

.btn--primary:hover,
.btn--primary:focus-visible {
    background: var(--accent);
}

.btn--ghost {
    border-color: var(--border-strong);
    background: rgba(7, 9, 12, 0.4);
    color: var(--heading);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
}

.text-link {
    color: var(--accent);
    text-underline-offset: 4px;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--heading);
    color: var(--bg);
    font-size: 0.9rem;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* ==========================================================================
   Hero
   Global (not scoped) on purpose: index.html renders the same block statically
   while the .NET runtime downloads, so the first paint already shows the name.
   ========================================================================== */

.hero {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: calc(var(--nav-height) + 24px) 0 96px;
}

.hero__copy {
    width: min(660px, 58.3333%);
}

.hero__visual {
    display: none;
}

.hero__name {
    margin: 0;
    color: var(--heading);
    font-size: clamp(4.5rem, 7.2vw, 6.5rem);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -0.035em;
}

.hero__title {
    margin: 18px 0 0;
    color: var(--heading);
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.hero__focus {
    margin: 16px 0 0;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: clamp(0.74rem, 1.6vw, 0.86rem);
    letter-spacing: 0.06em;
}

.hero__intro {
    margin: 30px 0 0;
    max-width: 58ch;
    font-size: clamp(1rem, 1.6vw, 1.12rem);
    line-height: 1.7;
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 38px 0 0;
}

.hero__scroll {
    position: absolute;
    bottom: 30px;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 44px;
    min-height: 44px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.2em;
    text-decoration: none;
    text-transform: uppercase;
    transform: translateX(-50%);
}

.hero__scroll-line {
    position: relative;
    width: 1px;
    height: 38px;
    background: var(--border);
    overflow: hidden;
}

.hero__scroll-line::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--accent);
    animation: scroll-hint 2.4s cubic-bezier(0.6, 0, 0.3, 1) 2 both;
}

@keyframes scroll-hint {
    0% {
        transform: translateY(-100%);
    }

    60%,
    100% {
        transform: translateY(100%);
    }
}

@media (max-height: 640px) {
    .hero__scroll {
        display: none;
    }
}

@media (min-width: 821px) and (max-width: 1180px) {
    .hero__copy {
        width: 70%;
    }
}

@media (max-width: 820px) {
    :root {
        --gutter: 24px;
    }

    .section {
        padding: clamp(64px, 10svh, 88px) 0;
    }

    .section__content,
    .hero__copy {
        width: 100%;
    }

    .section-header {
        margin-bottom: 32px;
    }

    .section-title {
        font-size: clamp(1.875rem, 4.4vw, 2.25rem);
        line-height: 1.16;
    }

    .hero {
        padding-bottom: 72px;
    }

    .hero__name {
        font-size: clamp(3rem, 8vw, 4rem);
    }

    .hero__title {
        font-size: clamp(1.3125rem, 3.3vw, 1.625rem);
    }

    .hero__intro {
        margin-top: 24px;
        font-size: 1rem;
    }

    .hero__actions {
        margin-top: 28px;
    }

    .hero__visual {
        display: block;
        height: clamp(160px, 24svh, 240px);
        margin-top: 24px;
        pointer-events: none;
    }

    .hero__scroll {
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    :root {
        --gutter: 20px;
    }

    .hero__focus {
        max-width: 38ch;
        line-height: 1.8;
        letter-spacing: 0.025em;
    }
}

@media (max-width: 820px) and (max-height: 640px) {
    .hero {
        min-height: 0;
        padding-bottom: 48px;
    }

    .hero__visual {
        display: none;
    }
}

/* Pre-boot only: the button keeps its space but stays hidden until Blazor takes over. */
.hero--boot .hero__actions {
    visibility: hidden;
}

.boot-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
    width: var(--blazor-load-percentage, 0%);
    height: 2px;
    background: var(--accent);
    transition: width 0.2s ease;
}

/* ==========================================================================
   Reveal on scroll (enabled by js/site.js, see observeReveals)
   ========================================================================== */

.reveal-ready [data-reveal]:not([data-revealed]) {
    opacity: 0;
}

.reveal-ready [data-reveal][data-revealed] {
    animation: reveal-in 500ms var(--ease-out) both;
}

.reveal-ready .section-header[data-revealed],
.reveal-ready .closing__title[data-revealed] {
    animation: title-in 360ms var(--ease-out) both;
}

@keyframes title-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes reveal-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ==========================================================================
   DNA node labels (elements are created by js/scene/labels.js)
   ========================================================================== */

.dna-label {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--heading);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 140ms ease;
    will-change: transform, opacity;
}

.dna-label::before {
    content: "";
    width: 20px;
    height: 1px;
    background: var(--accent);
    opacity: 0.7;
}

/* Left of its node: the leader line moves to the end, the text keeps its reading order. */
.dna-label--left::before {
    order: 1;
}

/* Hex "address" in front of the node name, e.g. 0x03 .NET */
.dna-label__address {
    color: var(--accent);
    opacity: 0.75;
}

/* Medium screens have no free room beside the helix: the label sits centred above its node. */
.dna-label--above::before {
    display: none;
}

/* Same breakpoint as LAYOUTS.narrow in js/scene/config.js: the helix is behind the text there. */
@media (max-width: 820px) {
    .dna-label {
        display: none;
    }
}

/* ==========================================================================
   Blazor error UI
   ========================================================================== */

#blazor-error-ui {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: none;
    padding: 12px var(--gutter);
    border-top: 1px solid var(--border-strong);
    background: var(--surface-solid);
    color: var(--heading);
    font-size: 0.85rem;
}

#blazor-error-ui .reload {
    margin-left: 8px;
    color: var(--accent);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: var(--gutter);
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }

    /* Without its animation the hint would rest as a solid accent bar. */
    .hero__scroll-line::after {
        animation: none !important;
        transform: translateY(100%);
    }

    .btn:hover .icon,
    .btn:focus-visible .icon {
        transform: none;
    }
}

/* ==========================================================================
   Print (a recruiter may print the page): light, fully revealed, no chrome
   ========================================================================== */

@media print {
    :root {
        --bg: #fff;
        --surface: transparent;
        --surface-hover: transparent;
        --surface-solid: transparent;
        --border: #bbb;
        --border-strong: #888;
        --heading: #000;
        --text: #1a1a1a;
        --text-dim: #444;
        --accent: #0b4a5c;
        color-scheme: light;
    }

    /* The reveal gate is more specific than this selector, hence !important. */
    [data-reveal] {
        opacity: 1 !important;
        animation: none !important;
    }

    .dna-scene,
    .nav,
    .hud,
    .skip-link,
    .hero__scroll,
    .hero__actions,
    .hero__visual,
    .project__light,
    .boot-progress,
    #blazor-error-ui {
        display: none !important;
    }

    .hero {
        min-height: 0;
        padding: 0 0 24px;
    }

    /* !important: the scoped .closing rule (full viewport height) is more specific. */
    .section {
        min-height: 0 !important;
        padding: 28px 0;
    }

    .section__content,
    .hero__copy {
        width: 100% !important;
    }

    .btn--primary {
        border-color: var(--border-strong);
        background: none;
        color: var(--heading);
    }
}
