/* Main CSS */

/* reset.css, fonts.css and variables.css are linked from index.html (parallel, not chained @imports) */

/* Single-screen layout: the page never scrolls, panels swap in place */
html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

html {
    background-color: var(--color-background);
    transition: background-color 0.4s ease;
}

body {
    font-family: var(--font-family-base);
    /* No background here: it would paint over the fixed grid canvas */
    color: var(--color-text);
    transition: color 0.4s ease;
}

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

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

[hidden] {
    display: none !important;
}

[tabindex="-1"]:focus {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Background layers ---------- */

.bg-grid {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
}

/* Fine film grain to remove the flat-digital look */
.bg-grain {
    position: fixed;
    inset: -50%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: grain 8s steps(6) infinite;
}

:root[data-theme="light"] .bg-grain {
    opacity: 0.05;
}

.panel-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 1px;
    width: 100%;
    z-index: 200;
    background: var(--color-accent);
    transform-origin: 0 50%;
    transform: scaleX(0);
    transition: transform 0.9s var(--ease-out);
}

/* ---------- Header & Nav ---------- */

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 22px var(--frame);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.logo {
    color: var(--color-text);
    display: flex;
    align-items: center;
}

.logo svg {
    width: 28px;
    height: 28px;
    transition: transform 0.6s var(--ease-out), color 0.3s ease;
}

.logo:hover svg {
    transform: rotate(90deg);
    color: var(--color-accent);
}

.nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.nav-list {
    display: flex;
    gap: var(--spacing-lg);
    list-style: none;
}

.nav-link {
    position: relative;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 6px 0;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.nav-index {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-accent);
    opacity: 0.8;
}

.nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background: var(--color-accent);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s var(--ease-out);
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-text);
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
    transform-origin: left;
}

.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.6s var(--ease-out);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* The Half-Filled Circle Icon */
.theme-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    background: linear-gradient(to right, currentColor 50%, transparent 50%);
}

:root[data-theme="light"] .theme-toggle {
    transform: rotate(180deg);
}

:root[data-theme="light"] .theme-toggle:hover {
    transform: rotate(180deg) scale(1.1);
}

.lang-toggle {
    display: flex;
    gap: 2px;
    padding: 6px 4px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
    background: none;
    border: none;
    cursor: pointer;
}

.lang-toggle span {
    padding: 2px 5px;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

:root[lang="en"] .lang-toggle [data-lang="en"],
:root[lang="fr"] .lang-toggle [data-lang="fr"] {
    color: var(--color-background);
    background: var(--color-text);
}

.lang-toggle:hover span {
    color: var(--color-accent);
}

:root[lang="en"] .lang-toggle:hover [data-lang="en"],
:root[lang="fr"] .lang-toggle:hover [data-lang="fr"] {
    color: var(--color-background);
}

.menu-toggle {
    display: none;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
}

.menu-toggle span {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 1.5px;
    background: var(--color-text);
    transition: transform 0.35s var(--ease-out), top 0.35s var(--ease-out);
}

.menu-toggle span:nth-child(1) { top: 13px; }
.menu-toggle span:nth-child(2) { top: 21px; }

.menu-open .menu-toggle span:nth-child(1) { top: 17px; transform: rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { top: 17px; transform: rotate(-45deg); }

/* ---------- Stage & panels ---------- */

.stage {
    position: fixed;
    inset: 0;
}

.panel {
    --y: 30px;
    position: absolute;
    inset: 0;
    display: flex;
    padding: var(--anchor) var(--frame) var(--bar-h) var(--content-x);
    overflow-y: auto;
    scrollbar-width: none;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(var(--y));
    filter: blur(6px);
    transition:
        opacity 0.5s ease,
        transform 0.8s var(--ease-out),
        filter 0.5s ease,
        visibility 0s linear 0.8s;
}

.panel::-webkit-scrollbar {
    display: none;
}

.panel.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    filter: none;
    transition:
        opacity 0.6s ease 0.2s,
        transform 0.9s var(--ease-out) 0.2s,
        filter 0.6s ease 0.2s,
        visibility 0s;
}

/* Used to place an incoming panel at its start position without animating */
.panel.no-transition {
    transition: none;
}

.panel-inner {
    width: 100%;
    max-width: 980px;
}

/* The hero is the only panel centered vertically (margin:auto still lets tall content start at the top) */
.panel--hero {
    padding-top: 80px;
}

.panel--hero .panel-inner {
    margin: auto 0;
}

/* ---------- Hero ---------- */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-family-mono);
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 28px;
    padding: 6px 12px 6px 10px;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-surface) 60%, transparent);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 0 0 var(--color-accent-glow);
    animation: pulse 2.4s ease-out infinite;
}

.hero-name {
    font-size: clamp(42px, 7.2vw, 84px);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.035em;
    margin-bottom: 28px;
    max-width: 680px;
}

/* "Matteo SCARINGELLA": the capitals need a little less negative tracking */
.hero-name [data-scramble] {
    letter-spacing: -0.025em;
}

.hero-hello {
    display: block;
    font-size: 0.42em;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--color-text-muted);
    margin-bottom: 0.25em;
}

[data-scramble] {
    display: inline-block;
}

[data-scramble] .glyph,
.log-msg .glyph {
    color: var(--color-accent);
    opacity: 0.7;
}

.hero-desc {
    max-width: 540px;
    font-size: clamp(16px, 1.6vw, 18px);
    color: var(--color-text-muted);
    line-height: 1.7;
    margin-bottom: 40px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

/* ---------- Vault dial ---------- */

.dial {
    position: fixed;
    right: -6vw;
    top: 50%;
    width: min(62vw, 720px);
    aspect-ratio: 1;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%);
    transition: transform 1.4s var(--ease-out), opacity 1s ease;
}

.dial.ready {
    opacity: 1;
}

/* Off the hero, the dial steps back so it never fights with the content */
body:not([data-panel="top"]) .dial.ready {
    opacity: 0.3;
    transform: translate(22%, -50%) scale(1.15);
}

.dial svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.dial-stroke {
    fill: none;
    stroke: var(--color-line-strong);
    stroke-width: 0.6;
}

.dial-dashed {
    stroke-dasharray: 2 6;
}

.dial-arc {
    stroke: var(--color-accent);
    stroke-opacity: 0.5;
    stroke-dasharray: 120 571;
    stroke-linecap: round;
}

.dial-ticks line {
    stroke: var(--color-text-faint);
    stroke-width: 0.6;
}

.dial-ticks line.major {
    stroke: var(--color-text-muted);
    stroke-width: 0.9;
}

.dial-marker,
.dial-core {
    fill: var(--color-accent);
}

.dial-core {
    opacity: 0.6;
}

.dial-index {
    stroke: var(--color-accent);
    stroke-width: 1.2;
}

/* ---------- Section heads ---------- */

.section-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: clamp(24px, 5vh, 48px);
}

.section-index {
    font-family: var(--font-family-mono);
    font-size: 13px;
    color: var(--color-accent);
}

.section-title {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 700;
    letter-spacing: -0.025em;
    white-space: nowrap;
}

.section-rule {
    flex: 1;
    max-width: 300px;
    height: 1px;
    background: linear-gradient(to right, var(--color-line-strong), transparent);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 1.2s var(--ease-out) 0.5s;
}

.section-head.in .section-rule {
    transform: scaleX(1);
}

/* ---------- About ---------- */

.about-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: clamp(32px, 6vw, 80px);
    align-items: start;
}

.about-text p {
    font-size: 17px;
    line-height: 1.8;
    color: var(--color-text-muted);
}

.about-text p + p {
    margin-top: 1.4em;
}

/* Redaction bars that lift when the panel is revealed */
.redact {
    position: relative;
    background: none;
    color: var(--color-text);
    white-space: nowrap;
}

.redact::after {
    content: "";
    position: absolute;
    inset: 0.1em -0.15em;
    background: var(--color-redact);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.7s var(--ease-in-out);
    transition-delay: var(--d, 0.4s);
}

.js .reveal:not(.in) .redact::after {
    transform: scaleX(1);
    transition: none;
}

.focus-list {
    list-style: none;
    border-top: 1px solid var(--color-line);
}

.focus-item {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 16px;
    align-items: baseline;
    padding: 18px 0;
    border-bottom: 1px solid var(--color-line);
    transition: padding-left 0.4s var(--ease-out);
}

.focus-item:hover {
    padding-left: 8px;
}

.focus-key {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-accent);
}

.focus-key::before {
    content: "> ";
    color: var(--color-text-faint);
}

.focus-value {
    font-size: 15px;
    color: var(--color-text);
}

/* ---------- Projects ---------- */

.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.project-card {
    --mx: 50%;
    --my: 50%;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 22px;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--border-radius);
    overflow: hidden;
    isolation: isolate;
}

/* Cursor-following light */
.project-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(420px circle at var(--mx) var(--my), var(--color-accent-soft), transparent 45%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Cursor-following border */
.project-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: radial-gradient(240px circle at var(--mx) var(--my), var(--color-accent), transparent 60%);
    -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.4s ease;
    pointer-events: none;
}

.project-card:hover::before,
.project-card:hover::after {
    opacity: 1;
}

.js .project-card.reveal.in:hover {
    transform: translateY(-4px);
    transition-delay: 0s;
    transition-duration: 0.5s;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-family-mono);
    font-size: 11px;
    margin-bottom: clamp(16px, 3vh, 32px);
}

.card-id {
    color: var(--color-accent);
}

.card-hash {
    color: var(--color-text-faint);
    letter-spacing: 0.05em;
}

.project-card h3 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}

.project-card p {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.55;
    margin-bottom: 18px;
}

.tags {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
}

.tags li {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 3px 8px;
    border: 1px solid var(--color-line);
    border-radius: 4px;
}

/* ---------- Contact ---------- */

.contact-body {
    max-width: 640px;
}

.contact-lead {
    font-size: clamp(20px, 2.4vw, 26px);
    line-height: 1.5;
    letter-spacing: -0.01em;
    margin-bottom: 32px;
}

.email-copy {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    padding: 14px 16px 14px 18px;
    margin-bottom: 28px;
    font-family: var(--font-family-mono);
    font-size: 13px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 8px;
    cursor: pointer;
}

.email-copy:hover {
    border-color: var(--color-line-strong);
}

.email-copy-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-copy-hint {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--color-text-faint);
    padding: 2px 8px;
    border: 1px solid var(--color-line);
    border-radius: 4px;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.email-copy.copied .email-copy-hint {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 40px;
}

.contact-meta {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
}

/* ---------- System (HD 110067) ---------- */

/* The vault dial would compete with the orbits: it steps out on this panel */
body[data-panel="lab"] .dial.ready {
    opacity: 0;
}

/* The orbits take the space the dial uses on the hero: right side, full height between the bars */
.system-grid {
    --orbit: min(calc(100svh - 80px - var(--bar-h) - 16px), calc(100vw - var(--content-x) - var(--frame) - 500px));
}

.orbit-view {
    position: absolute;
    right: var(--frame);
    top: calc(80px + (100svh - 80px - var(--bar-h) - var(--orbit)) / 2);
    width: var(--orbit);
    height: var(--orbit);
    touch-action: none;
}

.orbit-back {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s, color 0.2s ease;
}

.orbit-view.is-body .orbit-back {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease 0.3s, visibility 0s, color 0.2s ease;
}

.orbit-back:hover {
    color: var(--color-accent);
}

.has-cursor .orbit-back {
    cursor: none;
}

.orbit-view canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.orbit-view canvas.over-body {
    cursor: pointer;
}

.orbit-view canvas.is-dragging {
    cursor: grabbing;
}

.system-info {
    max-width: 440px;
}

/* List and detail card stacked in one cell, cross-fading */
.system-swap {
    display: grid;
    margin-bottom: 18px;
}

.system-overview,
.body-card {
    grid-area: 1 / 1;
    transition: opacity 0.4s ease, transform 0.5s var(--ease-out), visibility 0s linear 0.4s;
}

.body-card,
.system-swap.is-detail .system-overview {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
}

.system-swap.is-detail .body-card {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.4s ease 0.1s, transform 0.5s var(--ease-out) 0.1s, visibility 0s;
}

.body-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.body-card-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.body-card-step,
.body-card-close {
    font-family: var(--font-family-mono);
    font-size: 13px;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.body-card-close {
    margin-left: auto;
    font-size: 11px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.body-card-step:hover,
.body-card-close:hover {
    color: var(--color-accent);
}

.body-card-sub {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-accent);
    margin-bottom: 18px;
}

.body-card-stats {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 9px 14px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    padding: 14px 0;
    border-top: 1px solid var(--color-line);
    border-bottom: 1px solid var(--color-line);
    margin-bottom: 16px;
}

.body-card-stats dt {
    color: var(--color-text-faint);
}

.body-card-stats dd {
    color: var(--color-text);
}

.light-curve {
    margin-bottom: 16px;
}

.light-curve canvas {
    display: block;
    width: 100%;
    height: 64px;
}

.light-curve-meta {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
    margin-top: 6px;
}

.light-curve-meta .is-live {
    color: var(--color-accent);
}

.btn-small {
    padding: 8px 14px;
    font-size: 11px;
}

.system-lead {
    font-size: 14px;
    line-height: 1.65;
    color: var(--color-text-muted);
    margin-bottom: 18px;
}

.planet-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-family-mono);
    font-size: 11px;
    margin-bottom: 16px;
}

.planet-table th {
    font-weight: 400;
    text-align: left;
    color: var(--color-text-faint);
    padding: 0 8px 8px 0;
    border-bottom: 1px solid var(--color-line);
}

.planet-table td {
    padding: 6px 8px 6px 0;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-line);
    white-space: nowrap;
    transition: color 0.2s ease;
}

.planet-table tbody tr {
    cursor: pointer;
}

.planet-pick {
    font: inherit;
    font-size: 13px;
    color: var(--color-text);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.planet-next {
    font-variant-numeric: tabular-nums;
}

.planet-table tr:hover td,
.planet-table tr.hovered td,
.planet-table tr.selected td,
.planet-table tr.selected .planet-pick {
    color: var(--color-accent);
}

.planet-table tr.transiting .planet-next {
    color: var(--color-accent);
}

.system-chain {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
    margin-bottom: 16px;
}

.system-chain span {
    color: var(--color-text);
}

.system-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.speed {
    display: flex;
    border: 1px solid var(--color-line-strong);
    border-radius: 8px;
    overflow: hidden;
}

.speed button {
    font-family: var(--font-family-mono);
    font-size: 11px;
    padding: 7px 10px;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.speed button + button {
    border-left: 1px solid var(--color-line-strong);
}

.speed button:hover {
    color: var(--color-text);
}

.speed button[aria-pressed="true"] {
    color: var(--color-background);
    background: var(--color-accent);
}

.sim-clock {
    display: flex;
    flex-wrap: wrap;
    gap: 0 14px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

#sim-bjd {
    color: var(--color-text-faint);
}

#sim-offset {
    color: var(--color-accent);
}

.system-source {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
}

.has-cursor .planet-table tbody tr,
.has-cursor .planet-pick,
.has-cursor .orbit-view canvas.over-planet,
.has-cursor .speed button {
    cursor: none;
}

/* ---------- Section lead ---------- */

.section-lead {
    max-width: 560px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--color-text-muted);
    margin: calc(-1 * clamp(8px, 2vh, 20px)) 0 clamp(20px, 3.5vh, 32px);
}

/* ---------- List ⇄ detail swap (projects, writeups) ---------- */

.swap {
    display: grid;
}

.swap-list,
.swap-detail {
    grid-area: 1 / 1;
    min-width: 0;
    transition: opacity 0.4s ease, transform 0.5s var(--ease-out), visibility 0s linear 0.4s;
}

.swap-detail,
.swap.is-detail .swap-list {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    pointer-events: none;
}

/* Coming back, the list is visible at once (so focus can return to the card that opened the detail) */
.swap-list {
    transition: opacity 0.45s ease 0.1s, transform 0.55s var(--ease-out) 0.1s, visibility 0s;
}

.swap.is-detail .swap-list {
    transition: opacity 0.4s ease, transform 0.5s var(--ease-out), visibility 0s linear 0.4s;
}

.swap.is-detail .swap-detail {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: opacity 0.45s ease 0.1s, transform 0.55s var(--ease-out) 0.1s, visibility 0s;
}

/* ---------- Detail view ---------- */

.detail {
    max-width: 900px;
}

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

.detail-back,
.detail-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.detail-step {
    font-size: 15px;
    padding: 2px 8px;
}

.detail-back:hover,
.detail-step:hover {
    color: var(--color-accent);
}

.detail-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-count {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
}

.detail-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.detail-title .card-id {
    font-family: var(--font-family-mono);
    font-size: 13px;
}

.detail-title h3 {
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.detail .tags {
    margin: 0 0 24px;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: clamp(28px, 4vw, 56px);
    align-items: start;
}

.detail-summary {
    font-size: 17px;
    line-height: 1.65;
    color: var(--color-text);
    margin-bottom: 22px;
}

.detail-block {
    padding: 14px 0;
    border-top: 1px solid var(--color-line);
}

.detail-block h4,
.detail-side h4 {
    font-family: var(--font-family-mono);
    font-size: 11px;
    font-weight: 400;
    color: var(--color-accent);
    margin-bottom: 6px;
}

.detail-block p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--color-text-muted);
}

.detail-todo {
    font-style: italic;
    color: var(--color-text-faint) !important;
}

.detail-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 14px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    padding: 14px 0;
    border-top: 1px solid var(--color-line);
    border-bottom: 1px solid var(--color-line);
    margin-bottom: 18px;
}

.detail-meta dt {
    color: var(--color-text-faint);
}

.detail-meta dd {
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.detail-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-link,
.tl-link,
.contact-meta a {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: var(--color-line-strong);
    text-underline-offset: 3px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.detail-link:hover,
.tl-link:hover,
.contact-meta a:hover {
    color: var(--color-accent);
    text-decoration-color: var(--color-accent);
}

.steps {
    list-style: none;
    counter-reset: step;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.steps li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 28px 1fr;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text-muted);
}

.steps li::before {
    content: counter(step, decimal-leading-zero);
    font-family: var(--font-family-mono);
    font-size: 11px;
    line-height: 2.2;
    color: var(--color-accent);
}

.detail .btn-small {
    margin-top: 18px;
}

/* ---------- Badges & pills ---------- */

.badge,
.pill {
    display: inline-block;
    font-family: var(--font-family-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.4;
    padding: 1px 7px;
    border-radius: 4px;
    vertical-align: middle;
    white-space: nowrap;
}

.badge--example {
    margin-left: 8px;
    color: var(--color-text-faint);
    border: 1px dashed var(--color-line-strong);
}

.pill {
    color: var(--color-text-muted);
    border: 1px solid var(--color-line);
}

.pill--easy { color: var(--color-accent); border-color: var(--color-accent-soft); }
.pill--medium { color: #d9b26f; border-color: rgba(217, 178, 111, 0.25); }
.pill--hard,
.pill--insane { color: #e48f8f; border-color: rgba(228, 143, 143, 0.25); }

:root[data-theme="light"] .pill--medium { color: #8a6418; }
:root[data-theme="light"] .pill--hard,
:root[data-theme="light"] .pill--insane { color: #a83232; }

/* ---------- Project cards open their detail ---------- */

.card-open {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    background: none;
    border: none;
    border-radius: inherit;
    cursor: pointer;
}

.card-open:focus-visible {
    outline: 1px solid var(--color-accent);
    outline-offset: 2px;
}

.card-more {
    position: absolute;
    right: 22px;
    bottom: 20px;
    font-family: var(--font-family-mono);
    font-size: 13px;
    color: var(--color-text-faint);
    transition: color 0.3s ease, transform 0.4s var(--ease-out);
}

.project-card:hover .card-more {
    color: var(--color-accent);
    transform: translateX(4px);
}

/* ---------- Writeups ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.chip {
    font-family: var(--font-family-mono);
    font-size: 11px;
    padding: 5px 11px;
    color: var(--color-text-muted);
    background: none;
    border: 1px solid var(--color-line-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.chip:hover {
    color: var(--color-text);
}

.chip[aria-pressed="true"] {
    color: var(--color-background);
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.writeup-list {
    list-style: none;
    border-top: 1px solid var(--color-line);
}

.writeup-row {
    display: grid;
    grid-template-columns: 70px 110px minmax(0, 1fr) auto auto 20px;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 15px 4px;
    font: inherit;
    text-align: left;
    color: var(--color-text);
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-line);
    cursor: pointer;
    transition: padding-left 0.4s var(--ease-out), background-color 0.3s ease;
}

.writeup-row:hover {
    padding-left: 10px;
    background: var(--color-accent-soft);
}

.wr-date,
.wr-platform {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
}

.wr-platform {
    color: var(--color-text-muted);
}

.wr-title {
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wr-arrow {
    font-family: var(--font-family-mono);
    color: var(--color-text-faint);
    transition: color 0.2s ease, transform 0.4s var(--ease-out);
}

.writeup-row:hover .wr-arrow {
    color: var(--color-accent);
    transform: translateX(3px);
}

.writeup-empty {
    padding: 18px 0;
    font-size: 14px;
    color: var(--color-text-faint);
}

.writeup-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

/* ---------- Certifications (timeline) ---------- */

.certs-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: clamp(32px, 6vw, 80px);
    align-items: start;
}

.col-title {
    font-family: var(--font-family-mono);
    font-size: 11px;
    font-weight: 400;
    color: var(--color-accent);
    margin-bottom: 16px;
}

.timeline {
    list-style: none;
    position: relative;
}

/* The vertical line, drawn through the dots */
.timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: var(--color-line-strong);
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 11px 1fr;
    gap: 18px;
    padding-bottom: 22px;
}

.tl-dot {
    width: 11px;
    height: 11px;
    margin-top: 5px;
    border-radius: 50%;
    border: 1px solid var(--color-line-strong);
    background: var(--color-background);
    z-index: 1;
}

.is-obtained .tl-dot {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.is-in-progress .tl-dot {
    border-color: var(--color-accent);
    background: linear-gradient(to right, var(--color-accent) 50%, var(--color-background) 50%);
    box-shadow: 0 0 0 0 var(--color-accent-glow);
    animation: pulse 2.4s ease-out infinite;
}

.tl-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.is-planned .tl-name {
    color: var(--color-text-muted);
}

.tl-meta,
.tl-extra {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
}

.tl-status {
    padding: 1px 7px;
    border-radius: 4px;
    border: 1px solid var(--color-line);
}

.tl-status--obtained {
    color: var(--color-accent);
    border-color: var(--color-accent-soft);
}

.tl-status--in-progress {
    color: var(--color-text);
}

/* ---------- Lab ---------- */

.lab-eyebrow {
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-accent);
    margin-bottom: 8px;
}

/* ---------- Contact extras ---------- */

.contact-seeking {
    display: inline-block;
    font-family: var(--font-family-mono);
    font-size: 13px;
    color: var(--color-accent);
    padding: 6px 12px;
    border: 1px solid var(--color-accent-soft);
    border-radius: 8px;
    margin-bottom: 22px;
}

.fingerprint {
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.contact-meta p + p {
    margin-top: 6px;
}

.has-cursor .card-open,
.has-cursor .chip,
.has-cursor .writeup-row,
.has-cursor .detail-back,
.has-cursor .detail-step,
.has-cursor .lang-toggle {
    cursor: none;
}

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

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 13px 22px;
    font-family: var(--font-family-mono);
    font-size: 13px;
    text-decoration: none;
    border-radius: 8px;
    overflow: hidden;
    isolation: isolate;
    transition: color 0.3s ease, border-color 0.3s ease, transform 0.3s var(--ease-out);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    color: var(--color-background);
    background: var(--color-text);
    border: 1px solid var(--color-text);
}

.btn-primary::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--color-accent);
    transform: translateX(-101%);
    transition: transform 0.45s var(--ease-out);
}

.btn-primary:hover::before {
    transform: translateX(0);
}

.btn-primary:hover {
    border-color: var(--color-accent);
}

.btn-ghost {
    color: var(--color-text);
    background: none;
    border: 1px solid var(--color-line-strong);
}

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

/* ---------- Bottom bar ---------- */

.footbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: var(--bar-h);
    padding: 0 var(--frame);
    display: grid;
    grid-template-columns: var(--side) 1fr auto;
    align-items: center;
    font-family: var(--font-family-mono);
    font-size: 11px;
    color: var(--color-text-faint);
    opacity: 0;
    animation: fadeIn 1s ease 1.2s forwards;
}

.footbar-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    /* pull the icons' padding back so the glyphs sit on the frame line, under the logo */
    margin-left: -9px;
}

.footbar-tools a,
.term-open--bar {
    display: flex;
    padding: 9px;
    color: var(--color-text-muted);
    transition: color 0.2s ease, transform 0.3s var(--ease-out);
}

.footbar-tools a:hover,
.term-open--bar:hover {
    color: var(--color-accent);
    transform: translateY(-2px);
}

.footbar-tools svg {
    width: 18px;
    height: 18px;
}

/* Explicit columns: the tools column collapses to 0 on small screens */
.pager {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 18px;
}

.footbar-email {
    grid-column: 3;
    letter-spacing: 0.05em;
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footbar-email:hover {
    color: var(--color-accent);
}

.pager-count {
    letter-spacing: 0.1em;
}

#pager-current {
    color: var(--color-text);
}

.pager-ticks {
    display: flex;
    gap: 6px;
}

.pager-tick {
    display: block;
    padding: 10px 0;
}

.pager-tick::before {
    content: "";
    display: block;
    width: 18px;
    height: 1px;
    background: var(--color-line-strong);
    transition: width 0.6s var(--ease-out), background-color 0.3s ease;
}

.pager-tick:hover::before {
    background: var(--color-text-muted);
}

.pager-tick.active::before {
    width: 44px;
    background: var(--color-accent);
}

.pager-keys {
    display: flex;
    gap: 4px;
}

kbd {
    font-family: inherit;
    font-size: inherit;
    padding: 1px 5px;
    border: 1px solid var(--color-line);
    border-radius: 3px;
}

/* ---------- Session log ---------- */

/* The side column on wide screens; its title sits on the same line as the section titles */
.session-log {
    display: none;
}

@media (min-width: 1380px) and (min-height: 640px) {
    .session-log {
        position: fixed;
        z-index: 10;
        /* Mirrored box: logo → log = log → icons. The logo (28px) is centred 40px from the top,
           the icons (18px) are centred bar-h/2 from the bottom, hence the 45px correction. */
        --log-top: calc(var(--anchor) + 16px);
        left: var(--frame);
        top: var(--log-top);
        bottom: calc(var(--log-top) + var(--bar-h) / 2 - 45px);
        width: calc(var(--side) - 48px);
        padding-bottom: 12px;
        border-bottom: 1px solid var(--color-line);
        display: flex;
        flex-direction: column;
        gap: 14px;
        font-family: var(--font-family-mono);
        font-size: 11px;
        line-height: 1.5;
        color: var(--color-text-faint);
        pointer-events: none;
        opacity: 0;
        animation: fadeIn 1s ease 1.4s forwards;
        transition: opacity 0.5s ease, filter 0.5s ease;
    }
}

.session-log-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-line);
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.session-log-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 0 0 var(--color-accent-glow);
    animation: pulse 2.4s ease-out infinite;
}

/* Hugs its title; once full, the oldest lines overflow (and fade) out of the top */
.session-log-list {
    position: relative;
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    list-style: none;
    overflow: hidden;
}

.session-log-list.is-full {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40%);
    mask-image: linear-gradient(to bottom, transparent, #000 40%);
}

.log-entry {
    display: flex;
    flex-direction: column;
    animation: logIn 0.4s var(--ease-out) both;
}

.log-time {
    color: var(--color-text-faint);
    opacity: 0.7;
}

.log-msg {
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

.log-entry--nav .log-msg {
    color: var(--color-text);
}

.log-entry--dim .log-msg {
    color: var(--color-text-faint);
}

.log-entry:last-child .log-msg::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 1px;
    margin-left: 4px;
    vertical-align: middle;
    background: var(--color-accent);
    animation: blink 1.1s steps(1) infinite;
}

.term-active .session-log {
    opacity: 0 !important;
    filter: blur(8px);
    pointer-events: none;
}

@keyframes logIn {
    from { opacity: 0; transform: translateY(6px); }
}

@keyframes blink {
    50% { opacity: 0; }
}

/* ---------- Terminal mode ---------- */

.term-open {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    transition: color 0.2s ease;
}

.term-open svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.term-open:hover {
    color: var(--color-accent);
}

.term-open--bar {
    position: relative;
}

.term-open-label {
    position: absolute;
    left: 0;
    bottom: 100%;
    padding-left: 9px;
    font-family: var(--font-family-mono);
    font-size: 11px;
    white-space: nowrap;
    color: var(--color-text-muted);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.4s var(--ease-out);
    pointer-events: none;
}

.term-open--bar:hover .term-open-label,
.term-open--bar:focus-visible .term-open-label {
    opacity: 1;
    transform: none;
}

.term-open--header {
    display: none;
    width: 36px;
    height: 36px;
    justify-content: center;
    color: var(--color-text);
}

/* The site recedes while the terminal takes over */
.term-active .stage,
.term-active .header,
.term-active .footbar {
    opacity: 0 !important;
    filter: blur(8px);
    transform: scale(0.98);
    pointer-events: none;
    transition: opacity 0.5s ease, filter 0.5s ease, transform 0.6s var(--ease-out);
}

.stage,
.header,
.footbar {
    transition: opacity 0.5s ease 0.15s, filter 0.5s ease 0.15s, transform 0.6s var(--ease-out) 0.15s;
}

.terminal {
    --ox: 50%;
    --oy: 50%;
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--color-background) 92%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-family: var(--font-family-mono);
    font-size: 14px;
    line-height: 1.65;
    color: var(--color-text);
    clip-path: circle(0 at var(--ox) var(--oy));
    visibility: hidden;
    transition: clip-path 0.6s var(--ease-in-out), visibility 0s linear 0.6s;
}

.terminal.open {
    clip-path: circle(150vmax at var(--ox) var(--oy));
    visibility: visible;
    transition: clip-path 0.75s var(--ease-in-out), visibility 0s;
}

.term-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px var(--gutter);
    border-bottom: 1px solid var(--color-line);
    font-size: 12px;
}

.term-title {
    color: var(--color-text-muted);
}

.term-close {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 12px;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.term-close:hover {
    color: var(--color-accent);
}

.term-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px var(--gutter) 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-line-strong) transparent;
}

.term-output,
.term-line {
    max-width: 900px;
    margin: 0 auto;
}

.term-row {
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 1.65em;
    animation: termIn 0.25s ease both;
}

.term-pre {
    white-space: pre;
}

.term-file {
    color: var(--color-text);
    padding: 4px 0 8px;
}

.term-list {
    display: flex;
    flex-wrap: wrap;
    column-gap: 22px;
}

.term-accent { color: var(--color-accent); }
.term-dim { color: var(--color-text-faint); }
.term-error { color: #e48f8f; }
.term-ok { color: var(--color-accent); }

:root[data-theme="light"] .term-error { color: #b23b3b; }

.term-link {
    font: inherit;
    color: var(--color-text);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--color-line-strong);
    text-underline-offset: 3px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
    white-space: pre;
}

.term-link:hover {
    color: var(--color-accent);
    text-decoration-color: var(--color-accent);
}

.term-link.term-dir {
    color: var(--color-accent);
}

.term-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.term-prompt {
    color: var(--color-accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.term-input {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: max(16px, 1em);
    color: var(--color-text);
    caret-color: var(--color-accent);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
}

/* zsh-style completion menu */
.term-menu {
    max-width: 900px;
    margin: 6px auto 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2px 12px;
}

.term-menu:empty {
    display: none;
}

.term-menu--described {
    grid-template-columns: 1fr;
}

.term-menu-item {
    display: flex;
    gap: 16px;
    padding: 1px 8px;
    margin-left: -8px;
    font: inherit;
    text-align: left;
    color: var(--color-text);
    background: none;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    animation: termIn 0.2s ease both;
}

.term-menu-item.term-dir {
    color: var(--color-accent);
}

.term-menu-name {
    min-width: 8ch;
}

.term-menu-desc {
    color: var(--color-text-faint);
}

.term-menu-item:hover {
    background: var(--color-accent-soft);
}

/* Selected entry: inverse video, like zsh's menu-select */
.term-menu-item[aria-selected="true"] {
    color: var(--color-background);
    background: var(--color-accent);
}

.term-menu-item[aria-selected="true"] .term-menu-desc {
    color: var(--color-background);
    opacity: 0.75;
}

.has-cursor .terminal,
.has-cursor .terminal .term-body {
    cursor: none;
}

@keyframes termIn {
    from { opacity: 0; transform: translateY(3px); }
}

/* ---------- Custom cursor (fine pointers only) ---------- */

.cursor {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .has-cursor,
    .has-cursor a,
    .has-cursor button {
        cursor: none;
    }

    .cursor {
        display: block;
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 9999;
    }

    .cursor-dot,
    .cursor-ring {
        position: fixed;
        top: 0;
        left: 0;
        border-radius: 50%;
        will-change: transform;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .has-cursor.cursor-active .cursor-dot,
    .has-cursor.cursor-active .cursor-ring {
        opacity: 1;
    }

    .cursor-dot {
        width: 4px;
        height: 4px;
        margin: -2px 0 0 -2px;
        background: var(--color-text);
    }

    .cursor-ring {
        width: 32px;
        height: 32px;
        margin: -16px 0 0 -16px;
        border: 1px solid var(--color-line-strong);
    }

    .cursor-ring::before {
        content: "";
        position: absolute;
        inset: -1px;
        border-radius: 50%;
        border: 1px solid var(--color-accent);
        border-left-color: transparent;
        border-bottom-color: transparent;
        transform: scale(0.6) rotate(0deg);
        opacity: 0;
        transition: transform 0.45s var(--ease-out), opacity 0.3s ease;
    }

    .hovering .cursor-ring::before {
        opacity: 1;
        transform: scale(1.5) rotate(180deg);
    }

    .hovering .cursor-dot {
        background: var(--color-accent);
    }
}

/* ---------- Staggered reveal inside a panel ---------- */

.js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
    transition-delay: var(--delay, 0s);
}

.js .reveal.in {
    opacity: 1;
    transform: none;
}

/* First load of the hero: a pure-CSS entrance that starts with the first paint, instead of waiting
   for every script to run (that wait was most of the mobile First Contentful Paint). Once main.js
   marks the blocks .in, the usual transitions take over. */
.js .panel--hero.active .reveal:not(.in) {
    animation: heroIn 0.9s var(--ease-out) both;
}

.js .panel--hero .reveal:nth-child(1) { animation-delay: 0.05s; }
.js .panel--hero .reveal:nth-child(2) { animation-delay: 0.12s; }
.js .panel--hero .reveal:nth-child(3) { animation-delay: 0.19s; }
.js .panel--hero .reveal:nth-child(4) { animation-delay: 0.26s; }

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

/* ---------- Keyframes ---------- */

@keyframes fadeIn {
    to { opacity: 1; }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 var(--color-accent-glow); }
    70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

@keyframes grain {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-5%, 3%); }
    40% { transform: translate(3%, -6%); }
    60% { transform: translate(-7%, -2%); }
    80% { transform: translate(6%, 5%); }
    100% { transform: translate(0, 0); }
}

/* ---------- Responsive ---------- */

/* Short screens (laptops): tighten vertical rhythm so everything fits */
@media (min-width: 1380px) and (min-height: 640px) {
    :root {
        --side: 240px;
    }
}

@media (max-height: 780px) {
    :root {
        --anchor: clamp(96px, 16vh, 124px);
        --bar-h: 64px;
    }

    .hero-name {
        font-size: clamp(40px, 6vw, 68px);
        margin-bottom: 20px;
    }

    .hero-desc {
        margin-bottom: 28px;
    }

    .about-text p {
        font-size: 16px;
        line-height: 1.7;
    }

    .focus-item {
        padding: 13px 0;
    }

    .project-card {
        padding: 18px;
    }

    .project-card p {
        margin-bottom: 12px;
    }
}

@media (max-width: 1024px) {
    :root {
        --frame: var(--gutter);
        --side: 0px;
    }

    .footbar-tools {
        display: none;
    }

    .term-open--header {
        display: flex;
    }

    .project-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-top {
        margin-bottom: 14px;
    }

}

@media (max-width: 960px) {
    .menu-toggle {
        display: block;
    }

    .nav {
        gap: 4px;
    }

    .nav-list {
        position: fixed;
        inset: 0;
        z-index: -1;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        gap: 28px;
        padding: 0 var(--gutter);
        background: var(--color-background);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.35s ease, visibility 0.35s;
    }

    .menu-open .nav-list {
        opacity: 1;
        visibility: visible;
    }

    .nav-link {
        font-size: 28px;
        font-weight: 600;
        color: var(--color-text);
        gap: 14px;
    }

    .nav-index {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    :root {
        --anchor: 88px;
        --bar-h: 60px;
    }

    .dial {
        width: 120vw;
        right: -60vw;
    }

    .dial.ready {
        opacity: 0.35;
    }

    body:not([data-panel="top"]) .dial.ready {
        opacity: 0.15;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .about-text p {
        font-size: 15px;
        line-height: 1.7;
    }

    .about-text p + p {
        margin-top: 1em;
    }

    .focus-item {
        grid-template-columns: 76px 1fr;
        padding: 11px 0;
    }

    .focus-value {
        font-size: 14px;
    }

    .section-rule {
        display: none;
    }

    .redact {
        white-space: normal;
    }

    /* Projects become a horizontal swipeable strip */
    .project-grid {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 78%;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        margin: 0 calc(-1 * var(--gutter));
        padding: 4px var(--gutter) 8px;
        scroll-padding: 0 var(--gutter);
    }

    .project-grid::-webkit-scrollbar {
        display: none;
    }

    .project-card {
        scroll-snap-align: start;
        min-height: 230px;
    }

    .card-top {
        margin-bottom: 32px;
    }

    .contact-actions {
        margin-bottom: 28px;
    }

    .contact-lead {
        font-size: 18px;
        margin-bottom: 24px;
    }

    .contact-seeking {
        font-size: 12px;
        margin-bottom: 18px;
    }

    .orbit-view {
        position: static;
        width: min(100%, 380px);
        height: auto;
        aspect-ratio: 1;
        margin-bottom: 20px;
    }

    .system-info {
        max-width: none;
    }

    .detail-grid,
    .certs-grid {
        grid-template-columns: 1fr;
    }

    .writeup-row {
        grid-template-columns: minmax(0, 1fr) auto 16px;
        grid-template-areas: "title diff arrow" "meta meta meta";
        row-gap: 4px;
    }

    .wr-title { grid-area: title; }
    .writeup-row .pill--easy,
    .writeup-row .pill--medium,
    .writeup-row .pill--hard,
    .writeup-row .pill--insane { grid-area: diff; }
    .wr-arrow { grid-area: arrow; }
    .wr-date,
    .wr-platform,
    .writeup-row > .pill:not([class*="pill--"]) { display: none; }

    .col-teq {
        display: none;
    }

    .pager-keys,
    .footbar-email {
        display: none;
    }

    /* Panels can scroll on phones: keep their content from running under the pager */
    .footbar {
        background: linear-gradient(to bottom, transparent, var(--color-background) 45%);
    }

    .terminal {
        font-size: 13px;
    }

    .term-pre {
        white-space: pre-wrap;
    }

    .term-prompt {
        max-width: 55%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
}
