/* =====================================================================
   Huseyn Babayev — Swiss / International Typographic Style
   Modular layout inspired by swissgrid.posterhouse.org (palette + type unchanged)
   ===================================================================== */

/* --- Design tokens --------------------------------------------------- */
:root {
    --bg:            #ffffff;
    --bg-subtle:     #f4f4f2;
    --fg:            #0a0a0a;
    --fg-secondary:  #6b6b6b;
    --fg-muted:      #9a9a9a;
    --line:          #1a1a1a;          /* strong hairlines (Swiss rules) */
    --line-soft:     #e4e4e1;          /* soft separators */
    --accent:        #0aa3a3;          /* turquoise */
    --accent-fg:     #ffffff;

    --font-sans: 'Inter', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;

    --maxw: 1180px;
    --gutter: clamp(20px, 5vw, 64px);
    --nav-height: 64px;
    --section-min-h: calc(100dvh - var(--nav-height));
    --speed: 0.18s;
}

[data-theme="dark"] {
    --bg:            #0a0a0a;
    --bg-subtle:     #161616;
    --fg:            #f5f5f3;
    --fg-secondary:  #a0a0a0;
    --fg-muted:      #6a6a6a;
    --line:          #f0f0ee;
    --line-soft:     #2a2a2a;
    --accent:        #2dd4cf;
    --accent-fg:     #0a0a0a;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #0a0a0a;
        --bg-subtle:     #161616;
        --fg:            #f5f5f3;
        --fg-secondary:  #a0a0a0;
        --fg-muted:      #6a6a6a;
        --line:          #f0f0ee;
        --line-soft:     #2a2a2a;
        --accent:        #2dd4cf;
        --accent-fg:     #0a0a0a;
    }
}

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

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

html, body { margin: 0; padding: 0; height: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    font-size: 16px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    padding-top: var(--nav-height);
    transition: background-color var(--speed) ease, color var(--speed) ease;
}


img { max-width: 100%; display: block; }

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

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

em { font-style: italic; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Re-usable mono label (the Swiss "caption" voice) */
.meta-label,
.block-index,
.entry-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-muted);
    font-weight: 500;
}

/* =====================================================================
   Navigation
   ===================================================================== */
#main-header nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    z-index: 1000;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.nav-container {
    max-width: var(--maxw);
    height: 100%;
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.nav-brand {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}
.brand-mark {
    flex: none;
    display: block;
    height: 30px;
    width: auto;
    color: var(--fg);
    transition: transform var(--speed) ease;
}
/* Theme-aware two-tone mark: solid shape follows text color, knockout
   follows the page background so it works in light and dark. */
.brand-mark .cls-1 { fill: currentColor; }
.brand-mark .cls-2 { fill: var(--bg); }
.nav-brand:hover .brand-mark { transform: translateY(-1px); }
.brand-name { display: inline-flex; align-items: baseline; gap: 8px; }
.nav-brand-sub {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-left: auto;
    margin-right: 8px;
}
.nav-links a {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-secondary);
    position: relative;
    padding: 2px 0;
    transition: color var(--speed) ease;
}
.nav-links a:hover { color: var(--fg); }
.nav-links a::after {
    content: "";
    position: absolute;
    left: 0; bottom: -3px;
    width: 0; height: 1px;
    background: var(--accent);
    transition: width var(--speed) ease;
}
.nav-links a:hover::after { width: 100%; }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--line);
    border-radius: 0;
    width: 34px; height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--fg);
    transition: border-color var(--speed) ease, background var(--speed) ease, color var(--speed) ease;
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.theme-toggle .icon { width: 16px; height: 16px; }
.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: inline-block; }

/* Language switcher */
.lang-switcher-wrapper { position: relative; }
.lang-switcher { position: relative; }
.lang-switcher-button {
    background: none;
    border: 1px solid var(--line);
    border-radius: 0;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    transition: border-color var(--speed) ease, color var(--speed) ease;
}
.lang-switcher-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.lang-switcher-button .icon { width: 14px; height: 14px; }
.lang-switcher-button .chevron { transition: transform var(--speed) ease; }
.lang-switcher.open .chevron { transform: rotate(180deg); }

.lang-switcher-dropdown {
    position: absolute;
    top: calc(100% + 0px);
    right: 0;
    min-width: 190px;
    background: var(--bg);
    border: 1px solid var(--line);
    display: none;
    flex-direction: column;
    z-index: 1100;
}
.lang-switcher.open .lang-switcher-dropdown { display: flex; }
.lang-option {
    padding: 10px 14px;
    font-size: 0.82rem;
    color: var(--fg-secondary);
    border-bottom: 1px solid var(--line);
    transition: background var(--speed) ease, color var(--speed) ease;
}
.lang-option:last-child { border-bottom: 0; }
.lang-option:hover { background: var(--bg-subtle); color: var(--fg); }

/* Mobile menu toggle */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: 0;
    width: 34px; height: 34px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--fg);
}
.nav-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.nav-toggle .icon { width: 18px; height: 18px; }

/* =====================================================================
   Layout container
   ===================================================================== */
.scroll-container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--gutter);
    position: relative;
}

/* Brief modular column cue on first paint (portfolio only) */
.scroll-container::before {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: repeating-linear-gradient(
        to right,
        color-mix(in srgb, var(--accent) 28%, transparent) 0,
        color-mix(in srgb, var(--accent) 28%, transparent) 1px,
        transparent 1px,
        transparent calc(100% / 12)
    );
    opacity: 0;
    animation: grid-flash 1.8s ease 0.35s 1 forwards;
}
.scroll-container > * {
    position: relative;
    z-index: 1;
}

@keyframes grid-flash {
    0%   { opacity: 0; }
    18%  { opacity: 1; }
    55%  { opacity: 1; }
    100% { opacity: 0; }
}

/* =====================================================================
   Full-viewport scroll snap (index)
   ===================================================================== */
html {
    scroll-snap-type: y mandatory;
    scroll-padding-top: var(--nav-height);
}

.scroll-container > section {
    scroll-snap-align: start;
    scroll-snap-stop: normal;
    min-height: var(--section-min-h);
    min-height: calc(100vh - var(--nav-height)); /* fallback when dvh unsupported */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.scroll-container > section.hero {
    justify-content: center;
    padding-top: clamp(16px, 2.5vh, 32px);
    padding-bottom: clamp(16px, 2.5vh, 32px);
}

.scroll-container > section.block {
    justify-content: flex-start;
    padding-top: clamp(16px, 2.5vh, 32px);
    padding-bottom: clamp(16px, 2.5vh, 32px);
}

.scroll-container > section#publications {
    justify-content: flex-start;
    padding-top: clamp(16px, 2.5vh, 32px);
    padding-bottom: clamp(12px, 2vh, 24px);
    overflow: hidden;
}

#publications .publications-carousel-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#publications .publications-outer-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#publications .publications-horizontal-scroll {
    flex: 1 1 auto;
    min-height: 0;
}

#publications .note {
    flex: none;
}

#main-footer {
    scroll-snap-align: none;
    scroll-snap-stop: normal;
}

/* =====================================================================
   Hero
   ===================================================================== */
.hero {
    padding: clamp(48px, 10vh, 120px) 0 clamp(40px, 8vh, 96px);
    border-bottom: 1px solid var(--line);
}
.hero-top {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(180px, 5fr);
    gap: clamp(28px, 5vw, 64px);
    align-items: end;
    column-gap: clamp(28px, 5vw, 64px);
}
.hero-text { min-width: 0; }

.hero-portrait {
    margin: 0;
    align-self: end;
    padding: 0;
    max-width: 320px;
    justify-self: end;
    width: 100%;
}
.hero-portrait img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center top;
    display: block;
}
.hero-portrait-cap {
    margin: 10px 0 0;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}
.hero-portrait-cap::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 0;
    flex: none;
}

.hero-title {
    font-size: clamp(2.8rem, 8.5vw, 5.8rem);
    line-height: 0.94;
    font-weight: 600;
    letter-spacing: -0.045em;
    margin: 0 0 28px;
    max-width: 14ch;
}
.hero-title span { display: inline; }
.hero-lead {
    font-size: clamp(1rem, 2vw, 1.28rem);
    line-height: 1.28;
    color: var(--fg-secondary);
    max-width: 48ch;
    margin: 0 0 40px;
    font-weight: 400;
}
.hero-lead em {
    color: var(--fg);
    font-style: normal;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 1px;
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    border-top: 1px solid var(--line);
    padding-top: 20px;
}
.hero-links a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fg-secondary);
    transition: color var(--speed) ease;
}
.hero-links a .icon {
    width: 14px;
    height: 14px;
    flex: none;
    color: var(--fg-muted);
    transition: color var(--speed) ease;
}
.hero-links a:hover,
.hero-links a:hover .icon {
    color: var(--accent);
}

/* Hero entrance */
@keyframes hero-rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}
.hero-title,
.hero-lead,
.hero-portrait,
.hero-links {
    animation: hero-rise 0.7s cubic-bezier(0.22, 0.61, 0.21, 1) both;
}
.hero-title { animation-delay: 0.05s; }
.hero-lead { animation-delay: 0.14s; }
.hero-portrait { animation-delay: 0.18s; }
.hero-links { animation-delay: 0.28s; }

/* legacy scroll hint — neutralised */
.about-scroll-hint { display: none; }

/* =====================================================================
   Generic content block (catalog section)
   ===================================================================== */
.block { padding: clamp(36px, 6vh, 72px) 0; border-bottom: 1px solid var(--line); }
.block:last-of-type { border-bottom: 0; }

.block-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 16px 24px;
    padding-bottom: 14px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--line);
}
.block-title {
    font-size: clamp(1.35rem, 2.8vw, 1.85rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.block-title .icon { display: none; }
.block-head .block-index {
    white-space: nowrap;
    min-width: 11ch;
    text-align: right;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

/* Entry rows -------------------------------------------------------- */
.block-body { display: flex; flex-direction: column; }

.entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 200px);
    gap: 24px;
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
    align-items: start;
    transition: color var(--speed) ease;
}
.entry:last-child { border-bottom: 0; }
.entry:hover { background: transparent; }

.entry-main { min-width: 0; }
.entry-title {
    font-size: 1.12rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.28;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.entry-title .icon { display: none; }
.entry-desc {
    margin: 10px 0 0;
    color: var(--fg-secondary);
    font-size: 0.95rem;
    line-height: 1.4;
}
.entry-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.entry-list li {
    position: relative;
    padding-left: 18px;
    color: var(--fg-secondary);
    font-size: 0.92rem;
    line-height: 1.4;
}
.entry-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-family: var(--font-mono);
}

.entry-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding-top: 2px;
}
.entry-date { white-space: nowrap; }

/* Awards as enumerated rows ----------------------------------------- */
.award-list {
    list-style: none;
    margin: 0; padding: 0;
    counter-reset: award;
    display: flex;
    flex-direction: column;
}
.award-list li {
    counter-increment: award;
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
    font-size: 1rem;
    line-height: 1.4;
    transition: color var(--speed) ease;
}
.award-list li:last-child { border-bottom: 0; }
.award-list li:hover { background: transparent; }
.award-list li::before {
    content: counter(award, decimal-leading-zero);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent);
    letter-spacing: 0.05em;
    padding-top: 4px;
}

/* =====================================================================
   Skills
   ===================================================================== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin-top: 0;
    border-top: 1px solid var(--line);
}
.skills-category {
    padding: 24px 24px 24px 0;
    border-top: 0;
    border-right: 1px solid var(--line);
}
.skills-category:last-child {
    border-right: 0;
    padding-right: 0;
}
.skills-category:not(:first-child) {
    padding-left: 24px;
}
.skills-category h4 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg);
    margin: 0 0 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.skills-category h4 .icon { width: 14px; height: 14px; color: var(--accent); }
.skills-latin-italic { font-style: italic; }
.skills-category ul {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.skills-category li {
    font-size: 0.95rem;
    color: var(--fg-secondary);
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.skills-category li:last-child { border-bottom: 0; }

/* =====================================================================
   Publications
   ===================================================================== */
#publications { padding: clamp(36px, 6vh, 72px) 0; border-bottom: 1px solid var(--line); }
#publications > h2 {
    font-size: clamp(1.35rem, 2.8vw, 1.85rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0 0 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: baseline;
    gap: 10px;
}
#publications > h2 .icon { display: none; }

/* Scholar mini stats */
.scholar-mini-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}
.mini-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 22px 24px 22px 0;
    border-right: 1px solid var(--line);
}
.mini-card:last-child {
    border-right: 0;
    padding-right: 0;
}
.mini-card:not(:first-child) {
    padding-left: 24px;
}
.mini-card .icon { display: none; }
.mini-card .label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    order: 1;
}
.mini-card .value {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1;
    order: 2;
    margin: 6px 0;
}
.mini-card .subtitle {
    font-size: 0.8rem;
    color: var(--fg-secondary);
    order: 3;
}

/* Year filter toolbar */
.pub-year-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}
.pub-year-btn {
    background: none;
    border: 1px solid var(--line);
    color: var(--fg-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 0;
    transition: all var(--speed) ease;
}
.pub-year-btn:hover { border-color: var(--accent); color: var(--accent); }
.pub-year-btn.is-active {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
}

/* Horizontal scroll carousel */
.publications-carousel-wrap { position: relative; }
.publications-horizontal-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    padding-bottom: 14px;
}
.publications-container {
    display: flex;
    gap: 0;
    width: max-content;
    border-left: 1px solid var(--line);
}
.publication-card-link {
    display: block;
    width: 300px;
    flex: none;
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    transition: background var(--speed) ease;
}
.publication-card-link:hover { background: var(--bg-subtle); }
.publication-card-link.is-year-hidden { display: none; }
.publication-card {
    padding: 22px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.publication-card h4 {
    font-size: 0.98rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.32;
    margin: 0;
}
.publication-card .authors {
    font-size: 0.82rem;
    color: var(--fg-secondary);
    margin: 0;
    line-height: 1.4;
}
.publication-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
}
.publication-meta p {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
    margin: 0;
}
.publication-meta .icon { width: 14px; height: 14px; color: var(--accent); }

.note {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
    margin: 16px 0 0;
}

/* =====================================================================
   Contact
   ===================================================================== */
.contact-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(140px, 240px);
    gap: clamp(24px, 4vw, 48px);
    align-items: start;
    margin-top: 16px;
}
.contact-info-full {
    display: flex;
    flex-direction: column;
    margin-top: 0;
    min-width: 0;
}
.contact-info-full a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    transition: padding-left var(--speed) ease, color var(--speed) ease;
}
.contact-info-full a .icon { width: 16px; height: 16px; color: var(--accent); }
.contact-info-full a::after {
    content: "↗";
    margin-left: auto;
    font-family: var(--font-mono);
    color: var(--fg-muted);
    transition: color var(--speed) ease;
}
.contact-info-full a:hover { padding-left: 8px; color: var(--accent); }
.contact-info-full a:hover::after { color: var(--accent); }

.location-info {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
    margin: 0;
    color: var(--fg-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.location-info .icon { width: 16px; height: 16px; color: var(--accent); }

.map-container-full {
    width: 100%;
    margin: 0;
    border: 1px solid var(--line);
    overflow: hidden;
    filter: grayscale(1) contrast(1.05);
    transition: filter var(--speed) ease;
}
.map-container-full:hover { filter: grayscale(0); }
.map-container-full img { width: 100%; height: auto; display: block; }

/* =====================================================================
   Footer
   ===================================================================== */
footer {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 28px var(--gutter);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
footer p {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
}

/* =====================================================================
   Motion — scroll reveal, progress, nav state
   ===================================================================== */
.scroll-progress {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: 0 50%;
    z-index: 1200;
    will-change: transform;
}

#main-header nav { transition: background-color var(--speed) ease, border-color var(--speed) ease; }
#main-header nav.scrolled { box-shadow: none; }
[data-theme="dark"] #main-header nav.scrolled { box-shadow: none; }

html.reveal-ready .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.55s cubic-bezier(0.22, 0.61, 0.21, 1),
                transform 0.55s cubic-bezier(0.22, 0.61, 0.21, 1);
    will-change: opacity, transform;
}
html.reveal-ready .reveal.is-visible {
    opacity: 1;
    transform: none;
}

/* restrained catalog hover — color only, no float */
.entry { transition: color var(--speed) ease; }
.entry:hover { transform: none; }
.award-list li { transition: color var(--speed) ease; }
.award-list li:hover { transform: none; }
.publication-card-link { transition: background var(--speed) ease; }
.publication-card-link:hover { transform: none; }
.mini-card .value { transition: color var(--speed) ease; }
.mini-card:hover .value { color: var(--accent); }
.entry-title { transition: color var(--speed) ease; }
.entry:hover .entry-title { color: var(--accent); }
.skills-category li { transition: color var(--speed) ease; }
.skills-category li:hover { color: var(--fg); padding-left: 0; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 860px) {
    .hero-top { grid-template-columns: 1fr; gap: 28px; }
    .hero-portrait {
        max-width: 240px;
        order: -1;
        justify-self: start;
    }
    .skills-grid { grid-template-columns: 1fr; }
    .skills-category {
        padding: 20px 0;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .skills-category:last-child { border-bottom: 0; }
    .skills-category:not(:first-child) { padding-left: 0; }
    .hero-links { gap: 14px 16px; padding-top: 18px; }
    .hero-links a { font-size: 0.68rem; }
    .mini-card {
        padding: 18px 12px 18px 0;
    }
    .mini-card:not(:first-child) { padding-left: 12px; }
    .mini-card:last-child { padding-right: 0; }
    .contact-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .map-container-full { max-width: 240px; }
}

@media (max-width: 1024px) {
    .nav-links {
        position: fixed;
        top: var(--nav-height);
        left: 0; right: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        padding: 0 var(--gutter);
        margin: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--speed) ease;
    }
    #main-header nav.menu-open .nav-links { max-height: 70vh; }
    .nav-links a {
        width: 100%;
        padding: 16px 0;
        border-bottom: 1px solid var(--line);
        font-size: 0.8rem;
    }
    .nav-toggle { display: inline-flex; }
    .nav-brand-sub { display: none; }
}

@media (max-width: 768px) {
    .entry {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .entry-meta { order: -1; }
}

@media (max-width: 480px) {
    .award-list li { grid-template-columns: 36px 1fr; gap: 10px; }
    .publication-card-link { width: 82vw; }
    .nav-actions { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; animation: none !important; }
    html { scroll-snap-type: none; }
    html.reveal-ready .reveal { opacity: 1 !important; transform: none !important; }
    .scroll-progress { display: none; }
    .entry:hover, .award-list li:hover, .publication-card-link:hover { transform: none !important; }
    .scroll-container::before { display: none; }
    .hero-title, .hero-lead, .hero-portrait, .hero-links {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }
}

/* =====================================================================
   Command palette (Cmd/Ctrl-K)
   ===================================================================== */
.cmdk-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(56px, 12vh, 140px) 16px 16px;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
    backdrop-filter: blur(6px) saturate(120%);
    opacity: 0;
    transition: opacity 0.16s ease;
}
.cmdk-backdrop[hidden] { display: none; }
.cmdk-backdrop.is-open { opacity: 1; }

.cmdk {
    width: min(560px, 92vw);
    max-height: 74vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.14);
    overflow: hidden;
    transform: translateY(-10px) scale(0.985);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cmdk-backdrop.is-open .cmdk { transform: none; }

.cmdk-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.cmdk-search-icon { display: inline-flex; color: var(--fg-muted); }
.cmdk-search-icon svg { width: 18px; height: 18px; }
.cmdk-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    outline: none;
}
.cmdk-input::placeholder { color: var(--fg-muted); }

.cmdk kbd {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    line-height: 1;
    padding: 3px 6px;
    color: var(--fg-secondary);
    background: var(--bg-subtle);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.cmdk-esc { align-self: center; }

.cmdk-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    flex: 1;
}
.cmdk-group-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--fg-muted);
    padding: 12px 12px 6px;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    cursor: pointer;
    color: var(--fg);
}
.cmdk-item.is-active { background: var(--bg-subtle); }
.cmdk-item-icon { display: inline-flex; color: var(--fg-secondary); flex: none; }
.cmdk-item-icon svg { width: 17px; height: 17px; }
.cmdk-item.is-active .cmdk-item-icon { color: var(--accent); }
.cmdk-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cmdk-item-title {
    font-size: 0.93rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmdk-item-sub {
    font-size: 0.76rem;
    color: var(--fg-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmdk-item-hint { display: inline-flex; color: var(--fg-muted); opacity: 0; flex: none; }
.cmdk-item.is-active .cmdk-item-hint { opacity: 1; }
.cmdk-empty { padding: 26px 12px; text-align: center; color: var(--fg-muted); font-size: 0.9rem; }

.cmdk-footer {
    display: flex;
    gap: 16px;
    padding: 10px 14px;
    border-top: 1px solid var(--line-soft);
    font-size: 0.72rem;
    color: var(--fg-muted);
}
.cmdk-footer span { display: inline-flex; align-items: center; gap: 6px; }

/* Metrics panel */
.cmdk-metrics { list-style: none; padding: 16px; }
.cmdk-metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cmdk-metric { border: 1px solid var(--line-soft); border-radius: 10px; padding: 16px 10px; text-align: center; }
.cmdk-metric-value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 600; color: var(--accent); }
.cmdk-metric-label {
    font-size: 0.68rem;
    color: var(--fg-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cmdk-metrics-links { display: flex; gap: 10px; margin-top: 14px; }
.cmdk-metrics-link {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line-soft);
    border-radius: 9px;
    background: transparent;
    color: var(--fg);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.85rem;
}
.cmdk-metrics-link:hover { border-color: var(--accent); color: var(--accent); }
.cmdk-metrics-link svg { width: 15px; height: 15px; }
.cmdk-metrics-back { margin-top: 12px; text-align: center; font-size: 0.72rem; color: var(--fg-muted); }

/* Toast */
.cmdk-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    z-index: 3001;
    background: var(--fg);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.cmdk-toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

body.cmdk-open { overflow: hidden; }

/* Header trigger button */
.cmdk-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--fg-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.cmdk-trigger:hover { border-color: var(--accent); color: var(--fg); }
.cmdk-trigger:focus,
.cmdk-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 0;
}
.cmdk-trigger kbd {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: inherit;
    background: var(--bg-subtle);
    border: 1px solid var(--line-soft);
    border-radius: 0;
    padding: 1px 4px;
}
@media (max-width: 720px) { .cmdk-trigger { display: none; } }

@media (prefers-reduced-motion: reduce) {
    .cmdk-backdrop, .cmdk, .cmdk-toast { transition: none; }
    .cmdk { transform: none; }
}
