/* Minimal Coder Style - Japanese-inspired minimal aesthetic */

/* Fragment Mono font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fragment+Mono:ital@0;1&display=swap');

/* Default dark mode (Blue-tinted) */
:root {
    --bg: #1a1f2e;
    --text: #e8f0ff;
    --accent: #6aa7ff;
    --accent-light: #8ac7ff;
    --accent-medium: #5a92e8;
    --accent-dark: #4a7bc8;
    --yellow: #ffd866;
    --gray: #8090a8;
    --light-gray: #2a3548;
    --border: #3a4558;
    --code-bg: #161b28;
    --text-secondary: #a8b8d0;

    /* Glass surfaces (used for "boxes"/cards) */
    --card-blur: 10px;
    --card-bg: rgba(42, 53, 72, 0.62);
    --card-bg-hover: rgba(42, 53, 72, 0.72);
    --card-border: rgba(58, 69, 88, 0.9);
    --card-border-hover: rgba(106, 167, 255, 0.35);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);

    /* Section separation */
    --section-divider: rgba(58, 69, 88, 0.55);
}

/* Light mode colors - Blue-tinted */
body.light-mode {
    --bg: #ffffff !important;
    --text: #1a1f2e !important;
    --accent: #6aa7ff !important;
    --accent-light: #8ac7ff !important;
    --accent-medium: #5a92e8 !important;
    --accent-dark: #4a7bc8 !important;
    --yellow: #ffcc00 !important;   /* Bright golden yellow - only for NEW badges */
    --gray: #5a6a7e !important;
    --light-gray: #f4f6f9 !important;
    --border: #d0d8e0 !important;
    --code-bg: #e8ecf2 !important;
    --text-secondary: #6a7a90 !important;

    /* Glass surfaces (used for "boxes"/cards) */
    --card-blur: 10px;
    --card-bg: rgba(255, 255, 255, 0.78);
    --card-bg-hover: rgba(255, 255, 255, 0.86);
    --card-border: rgba(208, 216, 224, 0.95);
    --card-border-hover: rgba(106, 167, 255, 0.45);
    --card-shadow: 0 10px 28px rgba(0, 0, 0, 0.10);

    /* Section separation */
    --section-divider: rgba(208, 216, 224, 0.85);
}

/* Night red mode colors (low-glare, red-tinted) */
body.red-mode {
    --bg: #2a0a10 !important;
    /* Avoid pure-white glare in night mode */
    --text: #f3cfd3 !important;
    --accent: #ff5a6b !important;
    --accent-light: #ff8b96 !important;
    --accent-medium: #ff6e7d !important;
    --accent-dark: #d94555 !important;
    --yellow: #ff9a3c !important; /* use orange (not yellow) in red mode */
    --gray: #d2a3a9 !important;
    --light-gray: #3b0f18 !important;
    --border: #6a1d2c !important;
    --code-bg: #1f070c !important;
    --text-secondary: #d9aab0 !important;

    /* Glass surfaces (used for "boxes"/cards) */
    --card-blur: 10px;
    --card-bg: rgba(59, 15, 24, 0.62);
    --card-bg-hover: rgba(59, 15, 24, 0.72);
    --card-border: rgba(106, 29, 44, 0.9);
    --card-border-hover: rgba(255, 90, 107, 0.35);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);

    /* Section separation */
    --section-divider: rgba(106, 29, 44, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--accent);
    z-index: 9999;
    transition: width 0.1s linear;
    pointer-events: none;
}

html {
    height: 100%;
    background: radial-gradient(ellipse 140% 80% at 50% -5%, #1e3d72 0%, #1a1f2e 58%) fixed;
}

*, *::before, *::after {
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

body {
    min-height: 100%;
    font-family: 'Fragment Mono', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.8;
    background: transparent;
    color: var(--text);
    transition: background 0.5s ease, color 0.5s ease;
    font-weight: 400;
    letter-spacing: -0.2px;
    font-feature-settings: "liga" 1, "calt" 1; /* Enable ligatures */
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Ensure light mode applies properly */
html.light-mode {
    background: radial-gradient(ellipse 130% 70% at 50% -5%, #ddeafe 0%, #ffffff 55%) fixed !important;
}

/* Ensure red mode applies properly */
html.red-mode {
    background: radial-gradient(ellipse 130% 70% at 50% -5%, #3d1020 0%, #2a0a10 55%) fixed !important;
}

body.light-mode {
    background: transparent !important;
    color: #1a1a1a !important;
}

body.red-mode {
    background: transparent !important;
    color: var(--text) !important;
}

/* Terminal cursor effect */
@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Terminal typing animation */
.terminal-line {
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    display: inline-block;
    position: relative;
    max-width: 100%;
    min-height: 1.2em;
    vertical-align: top;
}

.terminal-line.typing {
    animation: typewriter var(--typing-duration, 2s) steps(var(--typing-steps, 30), end) forwards;
    overflow: hidden;
}

.terminal-line.typed {
    width: 100%;
    overflow: visible;
}

/* Cursor that rides the animation edge - stays within text bounds */
.terminal-line.typing::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 0;
    width: 2px;
    height: 1.2em;
    background: var(--accent);
    animation: blink 0.8s infinite;
    pointer-events: none;
}

body.light-mode .terminal-line.typing::after {
    background: var(--accent);
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}


/* Hide nav and social initially */
.terminal-nav,
.terminal-social {
    opacity: 0;
}

.terminal-nav {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    grid-column: 2;
}

.terminal-nav ul {
    display: flex;
    gap: 28px;
    margin: 0;
    padding: 0;
    list-style: none;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.terminal-nav li {
    list-style: none;
}

.terminal-social {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    gap: 18px;
    grid-column: 2;
}

.terminal-nav ul {
    row-gap: 8px; /* allow gentle vertical spacing when wrapping */
}

.terminal-social {
    flex-wrap: wrap;
    row-gap: 6px;
}

.terminal-social a {
    min-width: 20px;
    text-align: center;
}

/* Remove this media query - centering will only happen on mobile (<480px) */

.terminal-nav.show,
.terminal-social.show {
    opacity: 1;
    animation: fadeIn 0.1s ease-out;
}

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

.terminal-link,
.terminal-icon {
    opacity: 0;
    animation: none;
}

.terminal-line.fade-pop {
    width: 100%;
    overflow: visible;
    animation: fadeIn 0.1s ease-out forwards;
}

.terminal-link.show,
.terminal-icon.show {
    opacity: 1;
    animation: fadeIn 0.1s ease-out;
}

/* Header with terminal aesthetic */
.full-header,
section.full-header,
#top.full-header {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 60px;
    position: relative;
    background: linear-gradient(to bottom,
        rgba(10, 14, 24, 0.28) 0%,
        rgba(10, 14, 24, 0.28) 50%,
        rgba(10, 14, 24, 0.10) 80%,
        rgba(10, 14, 24, 0.00) 100%
    ) !important;
    background-color: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Subtle dot grid overlay on hero */
.full-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(106, 167, 255, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 1;
}

body.light-mode .full-header::after {
    background-image: radial-gradient(circle, rgba(26, 31, 46, 0.04) 1px, transparent 1px);
}

body.light-mode .full-header,
body.light-mode section.full-header,
body.light-mode #top.full-header {
    background: linear-gradient(to bottom,
        rgba(248, 249, 251, 0.74) 0%,
        rgba(248, 249, 251, 0.74) 50%,
        rgba(248, 249, 251, 0.30) 80%,
        rgba(248, 249, 251, 0.00) 100%
    ) !important;
    background-color: transparent !important;
}

body.red-mode .full-header,
body.red-mode section.full-header,
body.red-mode #top.full-header {
    background: linear-gradient(to bottom,
        rgba(31, 7, 13, 0.74) 0%,
        rgba(31, 7, 13, 0.74) 50%,
        rgba(31, 7, 13, 0.30) 80%,
        rgba(31, 7, 13, 0.00) 100%
    ) !important;
    background-color: transparent !important;
}

/* Gradient transition between header and main content */
.gradient-transition {
    width: 100%;
    height: 200px;
    background: transparent;
    position: relative;
    z-index: 2;
}

body.light-mode .gradient-transition {
    background: transparent;
}

body.red-mode .gradient-transition {
    background: transparent;
}

.terminal-prompt {
    position: absolute;
    left: 15px;
    color: var(--accent);
    font-size: 20px;
    opacity: 0;
    transition: none;
    z-index: 1;
    top: 50%;
    transform: translateY(-50%);
}

.terminal-prompt.active {
    opacity: 1;
    animation: blink 1s infinite;
}

body.light-mode .terminal-prompt {
    color: var(--accent);
}

.header-content {
    max-width: 900px;
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 80px;
    row-gap: 0;
    align-items: start;
    z-index: 2;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    grid-column: 2;
}

.header-portrait {
    opacity: 0;
    animation: fadeInPortrait 0.15s ease-out forwards;
    animation-delay: 0.05s;
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: start;
    padding-top: 5px;
    margin-left: -40px;
}

.header-portrait img {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 30%;
    border: 3px solid var(--accent);
    box-shadow: 0 4px 20px rgba(106, 167, 255, 0.35);
}

@keyframes fadeInPortrait {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.full-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 25px;
    letter-spacing: -0.5px;
    line-height: 1.5;
}

.full-header h1::before {
    content: '';
}

/* Job market line styling */
.job-market-line {
    color: var(--accent) !important; /* Same as terminal prompt */
    font-weight: 500;
}

.full-header h2 {
    font-size: 14px;
    font-weight: 400;
    color: var(--gray);
    margin-bottom: 12px;
    line-height: 1.5;
}

.full-header h2 .terminal-line::before {
    content: '//  ';
    color: var(--gray);
    opacity: 0.7;
    display: inline-block;
    position: relative;
}

.full-header p {
    font-size: 13px;
    color: var(--gray);
    opacity: 0.9;
    margin-bottom: 15px;
    margin-top: 0px;
    line-height: 1.5;
}

.full-header p.header-incoming {
    color: #e6c84a;
    opacity: 1;
    font-size: 12px;
    margin-top: 4px;
    margin-bottom: 0;
}

/* Navigation with bracket hover effect */
.full-header nav {
    margin-top: 0;
    width: 100%;
}

.full-header nav ul {
    list-style: none;
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
}

.full-header nav ul li {
    position: relative;
    flex-shrink: 0;
}

.full-header nav ul li::before {
    content: '/ ';
    color: var(--gray);
    opacity: 0.3;
    margin-right: 8px;
}

.full-header nav ul li:first-child::before {
    content: '';
    margin: 0;
}

.full-header nav ul li a {
    text-decoration: none;
    color: var(--text);
    font-size: 12px;
    position: relative;
    transition: color 0.2s;
    display: inline-block;
    line-height: 1;
    border-bottom: 1px dotted var(--gray);
    padding-bottom: 0;
    margin-bottom: 1px;
}

.full-header nav ul li a::before {
    content: '[';
    opacity: 0;
    color: var(--yellow);
    transition: opacity 0.2s;
}

.full-header nav ul li a::after {
    content: ']';
    opacity: 0;
    color: var(--yellow);
    transition: opacity 0.2s;
}

.full-header nav ul li a:hover::before,
.full-header nav ul li a:hover::after {
    opacity: 1;
}

.full-header nav ul li a:hover {
    color: var(--accent);
}

/* Social media icons */
.social-media {
    margin-top: 0;
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: flex-start;
}

.social-media a {
    color: var(--gray);
    font-size: 16px;
    transition: color 0.2s;
    text-decoration: none;
}

.social-media a:hover {
    color: var(--accent);
}

/* Main content */
main {
    padding: 100px 60px;
    max-width: clamp(600px, 50vw, 950px);
    margin: 0 auto;
    background: transparent;
    position: relative;
}

body.light-mode main {
    background: transparent;
}

main section {
    margin-bottom: 100px;
    position: relative;
    padding-left: 20px;
    scroll-margin-top: 80px; /* Offset for smooth scroll anchor links */
    padding-bottom: 70px; /* stronger section separation */
    border-bottom: 1px solid var(--section-divider);
}

main section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

/* Section markers */
main section::before {
    content: attr(id);
    position: absolute;
    left: -40px;
    top: 0;
    font-size: 10px;
    color: var(--accent-light);
    opacity: 0.4;
    text-transform: uppercase;
    letter-spacing: 2px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    background: transparent !important;
    z-index: -1;
}

/* Typography */
main h2 {
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

main h2::before {
    content: '## ';
    color: var(--accent-light);
    font-weight: 300;
}

h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: var(--text);
    background: var(--light-gray);
    padding: 8px 15px;
    border: 1px solid var(--border);
    position: relative;
}

h3::before {
    content: '### ';
    color: var(--accent-medium);
    opacity: 0.9;
    font-weight: 400;
}

/* Light mode h3 styling */
body.light-mode h3 {
    background: linear-gradient(135deg, rgba(106, 167, 255, 0.05) 0%, rgba(138, 199, 255, 0.05) 100%);
    border: 1px solid var(--border);
}

/* Subsection boxes - containers for h3 + content */
.subsection-box {
    margin-top: 30px;
    margin-bottom: 40px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.subsection-box:first-of-type {
    margin-top: 0;
}

body.light-mode .subsection-box {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--border);
}

.subsection-box h3 {
    margin-top: 0;
    margin-bottom: 20px;
}

/* Subsection accordion functionality */
.subsection-accordion-header {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.subsection-accordion-header::before {
    content: '>';
    position: absolute;
    left: -30px;
    top: 50%;
    color: var(--accent);
    background: var(--bg);
    padding: 0 5px;
    transition: transform 0.2s ease;
    transform-origin: center;
    transform: translateY(-50%) translateX(0) rotate(0deg);
}

.subsection-accordion.is-open .subsection-accordion-header::before {
    transform: translateY(-50%) translateX(0) rotate(90deg);
}

.subsection-accordion-header:hover::before,
.subsection-accordion-header:focus-visible::before {
    transform: translateY(-50%) translateX(2px) rotate(0deg);
}

.subsection-accordion.is-open .subsection-accordion-header:hover::before,
.subsection-accordion.is-open .subsection-accordion-header:focus-visible::before {
    transform: translateY(-50%) translateX(2px) rotate(90deg);
}

.subsection-accordion-content {
    display: none;
}

.subsection-accordion.is-open .subsection-accordion-content {
    display: block;
}

.subsection-accordion-header:focus-visible {
    outline: 2px solid rgba(106, 167, 255, 0.6);
    outline-offset: 3px;
    border-radius: 2px;
}

p {
    margin-bottom: 20px;
    color: var(--text);
    opacity: 0.9;
}

/* Links */
a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dotted var(--gray);
    transition: all 0.2s;
}

a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Papers list */
.papers-list {
    list-style: none;
    padding: 0;
}

/* News (scrollable timeline) */
.news-panel {
    margin-top: 10px;
    position: relative;
}

.news-panel::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(180deg, transparent 0%, var(--bg) 90%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.news-panel.expanded::after {
    opacity: 0;
}

.news-item:nth-child(n+6) {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
    transform: translateY(-8px);
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                margin-bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s ease;
}

.news-panel.expanded .news-item:nth-child(n+6) {
    max-height: 200px;
    opacity: 1;
    padding-top: 12px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-color: var(--border);
    transform: translateY(0);
}

/* Staggered reveal — each item cascades in */
.news-panel.expanded .news-item:nth-child(6)  { transition-delay: 0ms; }
.news-panel.expanded .news-item:nth-child(7)  { transition-delay: 50ms; }
.news-panel.expanded .news-item:nth-child(8)  { transition-delay: 100ms; }
.news-panel.expanded .news-item:nth-child(9)  { transition-delay: 150ms; }
.news-panel.expanded .news-item:nth-child(10) { transition-delay: 200ms; }
.news-panel.expanded .news-item:nth-child(11) { transition-delay: 250ms; }
.news-panel.expanded .news-item:nth-child(12) { transition-delay: 300ms; }
.news-panel.expanded .news-item:nth-child(13) { transition-delay: 350ms; }
.news-panel.expanded .news-item:nth-child(14) { transition-delay: 400ms; }

/* Collapse: reverse stagger (last disappears first) */
.news-item:nth-child(14) { transition-delay: 0ms; }
.news-item:nth-child(13) { transition-delay: 30ms; }
.news-item:nth-child(12) { transition-delay: 60ms; }
.news-item:nth-child(11) { transition-delay: 90ms; }
.news-item:nth-child(10) { transition-delay: 120ms; }
.news-item:nth-child(9)  { transition-delay: 150ms; }
.news-item:nth-child(8)  { transition-delay: 180ms; }
.news-item:nth-child(7)  { transition-delay: 210ms; }
.news-item:nth-child(6)  { transition-delay: 240ms; }

.news-toggle {
    display: inline-block;
    margin-top: 14px;
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
    letter-spacing: 0.5px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.news-toggle:hover {
    opacity: 1;
}

.news-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.news-item {
    display: grid;
    grid-template-columns: 86px 1fr;
    gap: 14px;
    align-items: start;
    padding: 12px 14px 12px 20px;
    margin-bottom: 12px;
    position: relative;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.news-item:last-child {
    margin-bottom: 0;
}

body.light-mode .news-item {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border);
}

.news-item::before {
    content: '>';
    position: absolute;
    left: -10px;
    top: 12px;
    color: var(--accent);
    background: var(--bg);
    padding: 0 5px;
}

.news-date {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding-top: 2px;
}

.news-title {
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

.news-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray);
    line-height: 1.6;
}

.news-link {
    color: var(--accent);
    border-bottom: 1px dotted var(--accent);
}

.news-footnote {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 12px;
}

@media (max-width: 480px) {
    .news-item {
        grid-template-columns: 72px 1fr;
        gap: 10px;
    }
    .news-panel {
        margin-top: 8px;
    }
}

.paper-item {
    margin-bottom: 40px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

body.light-mode .paper-item {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--border);
}

/* Reserve room for the hover hint so it never overlaps the title/coauthors (desktop/tablet)
   BUT don't waste space for the abstract when expanded. */
@media (min-width: 700px) {
    /* Collapsed: reserve space so the hint never overlaps (no layout shift on hover) */
    .paper-item {
        padding-right: 20px;
    }

    .paper-item:not(.is-abstract-open) {
        padding-right: 150px;
    }

    /* Expanded: keep full width (no reserved space) and hide hint (redundant) */
    .paper-item.is-abstract-open {
        padding-right: 20px;
    }

    .paper-item.is-abstract-open::after {
        display: none;
    }
}

/* On small screens, hide the hint text (space is tight and wrapping feels worse than the hint helps) */
@media (max-width: 699px) {
    .paper-item::after {
        display: none;
    }
}

.paper-item:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--accent);
    transform: translateX(2px);
    box-shadow: 0 0 15px rgba(106, 167, 255, 0.12);
}

.paper-item:focus-visible {
    outline: 2px solid rgba(106, 167, 255, 0.6);
    outline-offset: 3px;
}

body.light-mode .paper-item:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(106, 167, 255, 0.1);
}

.paper-item::before {
    content: '>';
    position: absolute;
    left: -10px;
    top: 20px;
    color: var(--accent);
    background: var(--bg);
    padding: 0 5px;
    transition: transform 0.2s ease;
    transform-origin: center;
    transform: translateX(0) rotate(0deg);
}

.paper-item:hover::before,
.paper-item:focus-visible::before {
    transform: translateX(2px) rotate(0deg);
}

.paper-item.is-abstract-open::before {
    transform: translateX(0) rotate(90deg); /* > becomes v-ish */
}

.paper-item.is-abstract-open:hover::before,
.paper-item.is-abstract-open:focus-visible::before {
    transform: translateX(2px) rotate(90deg);
}

/* Hover/focus affordance text (top-right) */
.paper-item::after {
    content: 'Show abstract';
    position: absolute;
    right: 14px;
    top: 14px;
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--accent-medium);
    background: rgba(0, 0, 0, 0); /* transparent by default */
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    pointer-events: none; /* don't block clicks */
    z-index: 2;
}

.paper-item.is-abstract-open::after {
    content: 'Hide abstract';
}

.paper-item:hover::after,
.paper-item:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
    background: rgba(106, 167, 255, 0.08);
    border-color: rgba(106, 167, 255, 0.25);
}

.paper-link,
.paper-title-no-link {
    font-weight: 500;
    color: var(--text) !important;
    border-bottom: none !important;
    display: inline-block; /* enable transform */
    position: relative; /* contain ::after (if present) */
    transition: color 0.2s ease, transform 0.15s ease;
    transform-origin: left center;
}

.paper-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none; /* don't hijack clicks on the whole paper card */
}

.paper-link:hover {
    color: var(--accent) !important;
    transform: rotate(1deg);
}

.paper-links {
    position: relative;
    z-index: 2;
}


.paper-subtitle {
    font-weight: 400;
    color: var(--text);
    font-size: 13px;
    display: block;
    margin-top: 5px;
}

.paper-tagline {
    font-weight: 400;
    color: var(--gray);
    font-size: 11px;
    display: block;
    margin-top: 4px;
    font-style: italic;
}

.paper-status {
    margin-top: 10px;
    font-size: 12px;
    color: var(--yellow);
}

.job-market-statement {
    color: var(--accent) !important;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
    position: relative;
    display: block;
    text-align: left;
}

.job-market-statement.magnified {
    transform: scale(1.3);
    text-shadow: 0 0 20px rgba(106, 167, 255, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
}

.publication-status {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--yellow);
    margin-top: 8px;
    margin-bottom: 0;
    padding: 2px 8px;
    background: var(--code-bg);
    border: 1px solid var(--border);
}

.co-authors {
    font-weight: 300;
    color: var(--gray);
    font-size: 12px;
}

.paper-abstract {
    margin-top: 15px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--gray);
    display: none; /* collapsed by default; JS will add .is-abstract-open */
}

.paper-item.is-abstract-open .paper-abstract {
    display: block;
}

.paper-links {
    margin-top: 15px;
}

.link-wrapper {
    display: inline-block;
    margin-right: 15px;
    font-size: 11px;
    color: var(--accent-medium);
}

/* Resources */
.github-graph {
    margin: 30px 0 40px;
    overflow-x: auto;
}

.github-graph-link {
    display: grid;
    grid-template-columns: repeat(53, 1fr);
    gap: 2px;
    text-decoration: none;
}

.github-graph-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    background: rgba(106, 167, 255, 0.07);
    transition: background 0.15s ease;
}

.github-graph-cell[data-level="1"] { background: rgba(106, 167, 255, 0.25); }
.github-graph-cell[data-level="2"] { background: rgba(106, 167, 255, 0.45); }
.github-graph-cell[data-level="3"] { background: rgba(106, 167, 255, 0.7); }
.github-graph-cell[data-level="4"] { background: var(--accent); }

body.light-mode .github-graph-cell { background: #e8ecf2; }
body.light-mode .github-graph-cell[data-level="1"] { background: rgba(106, 167, 255, 0.25); }
body.light-mode .github-graph-cell[data-level="2"] { background: rgba(106, 167, 255, 0.45); }
body.light-mode .github-graph-cell[data-level="3"] { background: rgba(106, 167, 255, 0.7); }
body.light-mode .github-graph-cell[data-level="4"] { background: var(--accent); }

.github-graph-months {
    display: grid;
    grid-template-columns: repeat(53, 1fr);
    gap: 2px;
    margin-bottom: 4px;
    font-size: 9px;
    color: var(--gray);
}

.github-graph-link:hover .github-graph-cell {
    opacity: 0.85;
}

.github-graph-link:hover .github-graph-cell:hover {
    opacity: 1;
    outline: 1px solid var(--accent);
}

.resources-list {
    list-style: none;
}

/* Resource cards grid layout */
.resources-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.resource-card {
    padding: 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 3px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.resource-card:hover {
    border-color: var(--card-border-hover);
    box-shadow: 0 0 12px rgba(106, 167, 255, 0.1);
}

.resource-card .resource-link {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.resource-desc {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 8px;
}

.resource-card-wide {
    grid-column: 1 / -1;
}

.resource-engines {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.resource-engines a {
    font-size: 10px;
    color: var(--accent);
    text-decoration: none;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 2px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.resource-engines a:hover {
    border-color: var(--accent);
    background: rgba(106, 167, 255, 0.08);
}

@media (max-width: 768px) {
    .resources-grid {
        grid-template-columns: 1fr;
    }
}

#resources h3 {
    margin-top: 60px;
    margin-bottom: 35px;
}

#resources h3:first-of-type {
    margin-top: 40px;
}

.resource-item {
    margin-bottom: 50px;
    padding: 24px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 2px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}

body.light-mode .resource-item {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--border);
}

.resource-item::before {
    content: '>';
    position: absolute;
    left: -10px;
    top: 24px;
    color: var(--accent);
    background: var(--bg);
    padding: 0 5px;
    transition: transform 0.2s ease;
    transform-origin: center;
    transform: translateX(0) rotate(0deg);
}

.resource-item:hover::before,
.resource-item:focus-visible::before {
    transform: translateX(2px) rotate(0deg);
}

.resource-item.is-resource-open::before {
    transform: translateX(0) rotate(90deg);
}

.resource-item.is-resource-open:hover::before,
.resource-item.is-resource-open:focus-visible::before {
    transform: translateX(2px) rotate(90deg);
}

.resource-item:focus-visible {
    outline: 2px solid rgba(106, 167, 255, 0.6);
    outline-offset: 3px;
}

.resource-item:hover {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

body.light-mode .resource-item:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Teaching evaluation highlight cards */
.teaching-evals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.eval-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 3px;
    transition: border-color 0.2s ease;
}

.eval-card:hover {
    border-color: var(--card-border-hover);
}

.eval-score {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    line-height: 1;
}

.eval-score .eval-max {
    font-size: 14px;
    font-weight: 400;
    color: var(--gray);
}

.eval-details h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.eval-details .course-level {
    font-size: 10px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.eval-details p {
    font-size: 10.5px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}

/* Course cards grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.course-card {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 15px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 3px;
    font-size: 12px;
    transition: border-color 0.2s ease;
}

.course-card:hover {
    border-color: var(--card-border-hover);
}

.course-role {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 2px;
    white-space: nowrap;
}

.course-lecturer .course-role {
    color: var(--accent);
    background: rgba(106, 167, 255, 0.1);
    border: 1px solid rgba(106, 167, 255, 0.25);
}

.course-ta .course-role {
    color: var(--gray);
    background: rgba(128, 144, 168, 0.1);
    border: 1px solid rgba(128, 144, 168, 0.2);
}

.course-card .course-name {
    flex: 1;
    color: var(--text);
    text-decoration: none;
}

a.course-name:hover {
    color: var(--accent);
}

.course-card .course-level {
    font-size: 9px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .teaching-evals-grid,
    .courses-grid {
        grid-template-columns: 1fr;
    }
}

/* Fallback: if blur isn't supported, revert to solid surfaces */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .paper-item {
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--border);
        box-shadow: none;
    }

    body.light-mode .paper-item {
        background: rgba(0, 0, 0, 0.05);
    }

    .resource-item {
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--border);
        box-shadow: none;
    }

    body.light-mode .resource-item {
        background: rgba(0, 0, 0, 0.05);
        border-color: var(--border);
    }
}

.resource-link {
    font-weight: 500;
    color: var(--text) !important;
    border: none !important;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
}

.resource-link:hover {
    color: var(--accent) !important;
    text-decoration: underline;
}

.resource-description {
    margin-top: 18px;
    font-size: 12px;
    color: var(--gray);
    line-height: 1.7;
    display: none; /* collapsed by default; JS toggles .is-resource-open */
}

.resource-item.is-resource-open .resource-description {
    display: block;
}

.resource-description ul {
    margin-top: 12px;
    margin-left: 20px;
    margin-bottom: 8px;
}

.resource-description li {
    margin-bottom: 8px;
}

/* Course links */
.course-link {
    font-family: monospace;
    font-size: 12px;
}

/* Teaching section course codes */
#teaching ul li strong {
    font-weight: 400; /* Remove bold */
    color: var(--accent-light); /* Use blue color for course codes */
    font-family: 'Fragment Mono', monospace;
    font-size: 13px;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 2px;
    margin-right: 8px;
    display: inline-block;
}

/* Teaching accordions (h3 blocks) */
#teaching .teaching-accordion-header {
    position: relative;
    cursor: pointer;
    user-select: none;
}

#teaching .teaching-accordion-header::before {
    content: '>';
    position: absolute;
    left: -30px; /* account for subsection-box padding (20px) + offset */
    top: 50%;
    color: var(--accent);
    background: var(--bg); /* match .paper-item chip */
    padding: 0 5px;
    transition: transform 0.2s ease;
    transform-origin: center;
    transform: translateY(-50%) translateX(0) rotate(0deg);
}

#teaching .teaching-accordion.is-open .teaching-accordion-header::before {
    transform: translateY(-50%) translateX(0) rotate(90deg);
}

#teaching .teaching-accordion-header:hover::before,
#teaching .teaching-accordion-header:focus-visible::before {
    transform: translateY(-50%) translateX(2px) rotate(0deg);
}

#teaching .teaching-accordion.is-open .teaching-accordion-header:hover::before,
#teaching .teaching-accordion.is-open .teaching-accordion-header:focus-visible::before {
    transform: translateY(-50%) translateX(2px) rotate(90deg);
}

#teaching .teaching-accordion-content {
    display: none;
    margin-top: 10px;
}

#teaching .teaching-accordion.is-open .teaching-accordion-content {
    display: block;
}

#teaching .teaching-accordion-header:focus-visible {
    outline: 2px solid rgba(106, 167, 255, 0.6);
    outline-offset: 3px;
    border-radius: 6px;
}

body.light-mode #teaching ul li strong {
    background: var(--code-bg);
    color: var(--accent-light);
}

/* Footer */
footer {
    background: rgba(10, 14, 24, 0.8); /* Semi-transparent dark blue */
    color: #fcfcfa !important; /* Light text for contrast */
    text-align: center;
    padding: 40px 30px;
    font-size: 11px;
    margin-top: 100px;
    border-top: 1px solid var(--border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

footer p {
    color: #fcfcfa !important; /* Ensure paragraph text is white */
    opacity: 1 !important;
    margin: 0;
}

body.light-mode footer {
    background: rgba(248, 249, 251, 0.8); /* Semi-transparent light */
    color: #1a1a1a !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.red-mode footer {
    background: rgba(31, 7, 13, 0.88);
    color: var(--text) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.red-mode footer p {
    color: var(--text) !important;
    opacity: 1 !important;
}

body.light-mode footer p {
    color: #1a1a1a !important;
    opacity: 1 !important;
}

.last-updated {
    margin-top: 6px !important;
    font-size: 11px;
    opacity: 0.5 !important;
    letter-spacing: 0.5px;
}

/* Glass-like button styling - True transparency */
.glass-button.floaty {
    /* Gentle idle motion for floating controls (theme / red / hamburger) */
    will-change: transform;
    animation: ui-float 8s ease-in-out infinite;
}

/* When interacting, let the normal hover/focus styles fully take over */
.glass-button.floaty:hover,
.glass-button.floaty:focus-visible,
.glass-button.floaty:active {
    animation: none;
}

@keyframes ui-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* Back to top button (inline in download bar) */
.back-to-top-inline {
    font-family: 'Fragment Mono', monospace;
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: color 0.2s ease;
}

.back-to-top-inline:hover {
    color: var(--accent-light);
}

.glass-button {
    position: relative;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 4px 24px 0 rgba(0, 0, 0, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Shimmer effect overlay - subtle */
.glass-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.05) 0%, transparent 40%);
    mix-blend-mode: overlay;
    pointer-events: none;
    opacity: 0.4;
}

body.light-mode .glass-button {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.01);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 
        0 4px 24px 0 rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.glass-button:hover {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 
        0 6px 30px 0 rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* Press feedback */
.glass-button:active {
    transform: translateY(-1px);
}

body.light-mode .glass-button:hover {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 
        0 6px 30px 0 rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* Subtle animation */
@keyframes glass-shimmer {
    0% { opacity: 0.6; }
    50% { opacity: 0.8; }
    100% { opacity: 0.6; }
}

.glass-button::before {
    animation: glass-shimmer 3s ease-in-out infinite;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #download-cta.download-cta {
        transition: none;
        transform: none;
    }
    .glass-button::before {
        animation: none;
    }
    .glass-button.floaty {
        animation: none;
    }
    .glass-button {
        transition: all 0.2s ease;
    }
}

/* Theme toggle button */
#theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    color: var(--text);
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    z-index: 1000;
    border-radius: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Red filter toggle button */
#red-toggle {
    position: fixed;
    bottom: 86px; /* stack above theme toggle */
    right: 30px;
    color: var(--text);
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    z-index: 1000;
    border-radius: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#red-toggle .red-icon {
    margin: 0;
    width: 20px;
    height: 20px;
    fill: currentColor;
}

#red-toggle .red-on-icon {
    display: none;
    color: var(--accent);
}

#red-toggle .red-off-icon {
    display: block;
    color: var(--text);
    opacity: 0.9;
}

body.red-mode #red-toggle .red-on-icon {
    display: block;
}

body.red-mode #red-toggle .red-off-icon {
    display: none;
}

#download-cta.download-cta {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 2px;
    color: var(--text);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#download-cta.download-cta.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.download-cta-label {
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    user-select: none;
}

.download-cta-link {
    font-size: 12px;
    border-bottom: 1px dotted var(--gray);
}

.download-cta-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.download-cta-sep {
    color: var(--gray);
    opacity: 0.6;
    user-select: none;
}

#theme-toggle .theme-icon {
    margin: 0;
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

#theme-toggle .moon-icon {
    display: block;
}

#theme-toggle .sun-icon {
    display: none;
}

body.light-mode #theme-toggle .moon-icon {
    display: none;
}

body.light-mode #theme-toggle .sun-icon {
    display: block;
}

#theme-toggle .sun-icon {
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Navigation button (mobile) */
.nav-button {
    display: none;
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 1001;
    cursor: pointer;
    padding: 0;
    border-radius: 0;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.nav-button .bar {
    width: 18px;
    height: 2px;
    background: var(--text);
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 1px;
}

/* Fixed navigation */
.fixed-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 15px 60px;
    z-index: 999;
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fixed-nav.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.fixed-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0;
    padding: 20px 0;
}

.fixed-nav a {
    color: var(--text);
    font-size: 14px;
    border: none;
    padding: 8px 0;
    display: block;
}

.fixed-nav a:hover {
    color: var(--accent);
}

/* ASCII decorations */
.ascii-divider {
    text-align: center;
    margin: 60px 0;
    color: var(--gray);
    opacity: 0.3;
    font-size: 10px;
    letter-spacing: 10px;
}

/* Code-like styling for certain elements */
code {
    font-family: inherit;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 0;
    font-size: 12px;
}

/* Sticky header that appears on scroll */
.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 998;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(10, 14, 24, 0.55);
    border-bottom: 1px solid var(--border);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

body.light-mode .sticky-header {
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body.red-mode .sticky-header {
    background: rgba(31, 7, 13, 0.92);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.sticky-header.visible {
    transform: translateY(0);
    opacity: 1;
}

.sticky-header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 60px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
}

.sticky-portrait {
    grid-column: 1;
    justify-self: start;
    align-self: center;
    display: flex;
    align-items: center;
}

.sticky-nav {
    grid-column: 2;
    display: flex;
    justify-content: center;
    min-width: 0; /* Allow shrinking */
}

.sticky-social {
    grid-column: 3;
    justify-self: end;
}

/* Adjust layout for narrower screens */
@media (max-width: 1100px) {
    .sticky-header-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        justify-items: center;
        gap: 15px;
    }

    .sticky-portrait {
        grid-column: 1;
        grid-row: 1;
        justify-self: center;
    }

    .sticky-nav {
        grid-column: 1;
        grid-row: 2;
        justify-content: center;
    }

    .sticky-nav ul {
        gap: 8px 12px; /* Tighter spacing on smaller screens */
    }

    .sticky-nav a {
        font-size: 10px; /* Smaller font to fit better */
    }

    .sticky-social {
        grid-column: 1;
        grid-row: 3;
        justify-self: center;
    }
}

.sticky-portrait img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 8px rgba(106, 167, 255, 0.25);
}

.sticky-nav ul {
    list-style: none;
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap; /* Allow wrapping when needed */
    align-items: center;
    justify-content: center; /* Center when wrapping occurs */
    row-gap: 8px; /* Vertical spacing when wrapped */
}

.sticky-nav ul li {
    position: relative;
    white-space: nowrap; /* Prevent text breaking within items */
    flex-shrink: 0; /* Prevent items from shrinking */
    display: inline-block; /* Make sure item is treated as a block */
}

.sticky-nav ul li::before {
    content: '';  /* Remove separators since nav wraps */
    margin: 0;
}

.sticky-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 11px;
    border: none;
    transition: color 0.2s;
    position: relative;
    white-space: nowrap; /* Prevent link text from wrapping */
    display: inline-block; /* Ensure link stays as one unit */
}

.sticky-nav a::before {
    content: '[';
    opacity: 0;
    color: var(--yellow);
    transition: opacity 0.2s;
}

.sticky-nav a::after {
    content: ']';
    opacity: 0;
    color: var(--yellow);
    transition: opacity 0.2s;
}

.sticky-nav a:hover::before,
.sticky-nav a:hover::after {
    opacity: 1;
}

.sticky-nav a:hover {
    color: var(--accent);
}

.sticky-social {
    display: flex;
    gap: 15px;
}

.sticky-social a {
    color: var(--gray);
    font-size: 15px;
    transition: color 0.2s;
    text-decoration: none;
    border: none;
}

.sticky-social a:hover {
    color: var(--accent);
}

/* Responsive - Mobile Devices */

/* Large screens - everything fits, use left-aligned layout */
@media (min-width: 1600px) {
    .header-content {
        align-items: flex-start;
    }

    .header-text {
        align-self: flex-start;
        text-align: left;
        width: 100%;
    }

    .header-portrait {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
    }

    .header-portrait img {
        margin: 0;
    }

    .terminal-nav {
        justify-content: flex-start;
        width: 100%;
        align-self: flex-start;
    }

    .terminal-nav ul {
        justify-content: flex-start;
    }

    .terminal-social {
        justify-content: flex-start;
        width: 100%;
        text-align: left;
    }
}

/* Medium-large screens - keep left-aligned layout */
@media (max-width: 1599px) {
    .header-content {
        align-items: flex-start;
        text-align: left;
    }

    .header-portrait {
        margin-bottom: 20px;
    }

    .terminal-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .terminal-nav ul {
        justify-content: flex-start;
    }

    .terminal-social {
        justify-content: flex-start;
    }
}

/* Medium screens - adjust sticky header layout */
@media (max-width: 1200px) {
    .sticky-header-content {
        gap: 20px;
        padding: 12px 40px;
        justify-content: flex-start; /* Keep left-aligned on medium screens */
    }

    .sticky-nav ul {
        gap: 15px;
        justify-content: flex-start; /* Keep left-aligned on medium screens */
    }

    .sticky-nav a {
        font-size: 10px;
    }

    .sticky-social {
        gap: 12px;
    }

    /* Start wrapping navigation cleanly at this width */
    .full-header nav ul {
        flex-wrap: wrap;
        justify-content: flex-start; /* Keep left-aligned on medium screens */
        gap: 6px 18px;
    }

    .full-header nav ul li::before {
        content: ''; /* Remove separator content */
        margin: 0;
    }

    .full-header nav ul li {
        flex-shrink: 0;
    }

    .full-header nav ul li a {
        font-size: 12px;
        white-space: nowrap;
        width: fit-content;
    }
}

/* iPad Pro (12.9" and 11") - Portrait */
@media (max-width: 1024px) {
    .full-header {
        padding: 0 40px;
    }

    main {
        padding: 80px 40px;
    }

    /* Better navigation wrapping at medium widths */
    .full-header nav ul {
        flex-wrap: wrap;
        justify-content: flex-start; /* Keep left-aligned on tablets */
        gap: 6px 15px;
        max-width: 650px;
    }

    .full-header nav ul li {
        flex-shrink: 0;
    }

    .full-header nav ul li a {
        font-size: 11.5px;
        padding: 0;
        white-space: nowrap;
        width: fit-content;
    }

    /* Hide separators when wrapping to avoid awkward positioning */
    .full-header nav ul li::before {
        content: '';
        margin: 0;
    }
}

/* iPad (10.2", 10.5", 9.7") - Portrait & iPad Mini */
@media (max-width: 834px) {
    .full-header {
        padding: 0 35px;
    }

    .full-header::before {
        left: 25px;
    }

    main {
        padding: 70px 35px;
    }

    main section::before {
        left: -30px;
    }

    /* Tighter navigation for smaller tablets - still left-aligned */
    .full-header nav ul {
        gap: 6px 12px;
        max-width: 550px;
        justify-content: flex-start;
    }

    .full-header nav ul li {
        flex-shrink: 0;
    }

    .full-header nav ul li a {
        font-size: 10.5px;
        padding: 0;
        white-space: nowrap;
        width: fit-content;
    }

    .full-header nav ul li::before {
        content: '';
        margin: 0;
    }
}

/* Large phones (iPhone 15 Pro Max, 14 Plus, etc.) - Landscape */
@media (max-width: 768px) {
    .full-header {
        padding: 0 30px;
    }

    .full-header::before {
        left: 20px;
    }

    .header-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding-left: 0;
    }

    .header-portrait {
        order: -1;
        margin-top: 0;
        margin-bottom: 20px;
        margin-left: 0;
        align-self: flex-start;
    }

    .header-text {
        order: 0;
    }

    .full-header nav {
        width: 100%;
    }

    main {
        padding: 60px 30px;
    }

    main section::before {
        display: none;
    }

    /* Don't show nav-button at this breakpoint - only on mobile */

    /* Adjust navigation for tablets */
    .full-header nav ul {
        flex-wrap: wrap;
        gap: 6px;
    }

    .full-header nav ul li {
        margin-bottom: 0;
    }

    /* Adjust sticky header for tablets */
    .sticky-header-content {
        padding: 10px 30px;
        gap: 20px;
        justify-content: center; /* Center all content */
        text-align: center;
    }

    .sticky-nav ul {
        gap: 15px;
        justify-content: center; /* Center nav items */
    }

    .sticky-nav a {
        font-size: 10px;
    }

    .sticky-social {
        gap: 12px;
        justify-content: center; /* Center social icons */
    }

    .sticky-social a {
        font-size: 13px;
    }
}

/* Hide/show mobile vs desktop content */
.mobile-only {
    display: none;
}

/* Standard phones (iPhone 15, 14, 13, etc.) - Portrait */
@media (max-width: 480px) {
    #download-cta.download-cta {
        display: none;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-block !important;
    }

    .mobile-only.terminal-line {
        display: block !important;
        margin-bottom: 5px;
    }

    /* Hide sticky header on mobile, use hamburger menu instead */
    .sticky-header {
        display: none;
    }
    body, html {
        font-size: 12px;
    }

    /* Add indentation for course list items on mobile */
    #teaching ul li {
        padding-left: 70px;
        text-indent: -70px;
    }

    #teaching ul li strong {
        text-indent: 0;
        min-width: 60px;
        display: inline-block;
    }

    .full-header {
        padding: 40px 20px 60px 20px; /* Add bottom padding to prevent overlap */
        min-height: auto; /* Don't force full viewport height on mobile */
        height: auto; /* Allow content to determine height */
    }

    .terminal-prompt {
        display: none;  /* Hide terminal prompt on mobile */
    }

    .header-content {
        padding-left: 0 !important;
        text-align: center !important;
        margin: 0 auto;
        align-items: center !important;
        padding-bottom: 40px; /* Extra spacing at bottom */
    }

    .header-text {
        text-align: center !important;
        align-items: center !important;
        width: 100%;
    }

    .header-portrait {
        margin-top: 40px;
        margin-bottom: 30px;
        text-align: center !important;
        width: 100%;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .header-portrait img {
        width: 180px;
        height: 180px;
        margin: 0 auto;
        display: block;
    }

    .full-header h1 {
        font-size: 24px;
        text-align: center !important;
    }

    .full-header h2 {
        font-size: 13px;
        text-align: center !important;
    }

    .full-header p {
        text-align: center !important;
    }

    .full-header p.header-incoming .terminal-line {
        white-space: normal;
        word-break: break-word;
        width: auto;
        max-width: 100%;
    }

    .full-header h2 .terminal-line::before {
        display: none;  /* Remove // on mobile */
    }

    .full-header nav ul {
        flex-direction: column;
        gap: 8px;
        align-items: center !important;  /* Center navigation items */
        justify-content: center !important;  /* Center navigation on mobile */
    }

    .full-header nav ul li::before {
        display: none;  /* Hide navigation separators on mobile */
    }

    .terminal-nav {
        justify-content: center !important;  /* Center nav container on mobile */
        width: 100%;
    }

    .terminal-social {
        justify-content: center !important;  /* Center social icons on mobile */
        width: 100%;
    }
    
    main {
        padding: 50px 20px;
    }
    
    main section {
        padding-left: 10px;
        margin-bottom: 60px;
    }
    
    h2 {
        font-size: 14px;
    }
    
    .paper-item, .resource-item {
        padding: 15px;
    }
    
    .social-media {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;  /* Center social media icons */
    }
    
    #theme-toggle {
        bottom: 20px;
        right: 25px;
    }

    #red-toggle {
        bottom: 76px;
        right: 25px;
    }
    
    .nav-button {
        display: flex;
        top: 20px;
        right: 25px;
    }
}

/* Small phones (iPhone SE, older models) */
@media (max-width: 375px) {
    .full-header h1 {
        font-size: 22px;
    }
    
    .full-header nav ul li a {
        font-size: 11px;
    }
    
    .paper-abstract {
        font-size: 11px;
    }
    
    .resource-description {
        font-size: 11px;
    }
}

/* Scroll-triggered fade-in for main sections */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .fade-in {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ========================================================
   Portrait sidebar layout (scroll view)
   ======================================================== */
.main-layout {
    display: flex;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
}

.portrait-sidebar {
    width: 220px;
    flex-shrink: 0;
    align-self: flex-start;
    position: sticky;
    top: 100px;
    padding-top: 100px;
    display: flex;
    justify-content: flex-end;
    padding-right: 10px;
}

.portrait-sidebar-sticky {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.portrait-sidebar-sticky img {
    width: 145px;
    height: 145px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 30%;
    border: 2px solid var(--accent);
    box-shadow: 0 4px 20px rgba(106, 167, 255, 0.25);
    display: block;
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
    opacity: 0.92;
}

body.red-mode .portrait-sidebar-sticky img {
    box-shadow: 0 4px 20px rgba(255, 90, 107, 0.25);
}

/* Override main's auto-centering when inside layout */
.main-layout > main {
    flex: 1;
    min-width: 0;
    margin: 0;
    max-width: 920px;
}

/* Hide sidebar on tablets/phones */
@media (max-width: 960px) {
    .main-layout {
        display: block;
    }
    .portrait-sidebar {
        display: none;
    }
    .main-layout > main {
        max-width: clamp(600px, 50vw, 950px);
        margin: 0 auto;
    }
}

/* Print styles */
@media print {
    body {
        font-size: 11px;
    }
    
    .theme-toggle,
    .red-toggle,
    .nav-button,
    .fixed-nav {
        display: none !important;
    }
}

/* cd ~ transition overlay */
#page-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}
