/* ============================================================
   Portfolio – Monochrome Design System
   One file for all pages. No Tailwind CDN needed.
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&family=Special+Elite&family=IM+Fell+English:ital@0;1&display=swap');

/* ---------- CSS Custom Properties (Design Tokens) ---------- */
:root {
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Space Grotesk', 'Inter', system-ui, sans-serif;

    /* Light Mode Colors */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-tertiary: #E5E5E5;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FAFAFA;
    --bg-input: #F5F5F5;

    --text-primary: #0A0A0A;
    --text-secondary: #525252;
    --text-muted: #737373;
    --text-inverse: #FAFAFA;

    --accent: #0A0A0A;
    --accent-hover: #262626;
    --accent-subtle: #F5F5F5;

    --border: #E5E5E5;
    --border-hover: #D4D4D4;

    --tag-bg: #F5F5F5;
    --tag-text: #404040;

    --status-active-bg: #ECFDF5;
    --status-active-text: #065F46;
    --status-research-bg: #F3E8FF;
    --status-research-text: #6B21A8;
    --status-planning-bg: #EFF6FF;
    --status-planning-text: #1E40AF;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.07), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Spacing */
    --section-padding: 6rem;
    --container-max: 1200px;
    --container-narrow: 768px;

    /* Borders */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Paper & Typewriter */
    --paper-bg: #f5f0e1;
    --paper-bg-card: #faf6ec;
    --paper-bg-dark: #f0e8d5;
    --paper-border: #d4c5a0;
    --paper-border-light: #e5d8bc;
    --paper-ink: #2c1810;
    --paper-ink-heading: #1a0d07;
    --paper-ink-muted: #6b5a3d;
    --paper-ink-faded: #9b8a70;
    --paper-accent: #8b2500;
    --paper-accent-blue: #2e5a88;
    --paper-shadow: rgba(44, 24, 16, 0.12);
    --paper-shadow-lg: rgba(44, 24, 16, 0.18);
    --font-typewriter: 'Special Elite', 'Courier New', Courier, monospace;
    --font-medieval: 'IM Fell English', 'Georgia', 'Times New Roman', serif;
}

/* ---------- Dark Mode Overrides ---------- */
.dark {
    --bg-primary: #0A0A0A;
    --bg-secondary: #141414;
    --bg-tertiary: #1F1F1F;
    --bg-card: #141414;
    --bg-card-hover: #1A1A1A;
    --bg-input: #1F1F1F;

    --text-primary: #FAFAFA;
    --text-secondary: #A3A3A3;
    --text-muted: #8C8C8C;
    --text-inverse: #0A0A0A;

    --accent: #FAFAFA;
    --accent-hover: #D4D4D4;
    --accent-subtle: #1F1F1F;

    --border: #262626;
    --border-hover: #404040;

    --tag-bg: #1F1F1F;
    --tag-text: #A3A3A3;

    --status-active-bg: #064E3B;
    --status-active-text: #A7F3D0;
    --status-research-bg: #4C1D95;
    --status-research-text: #DDD6FE;
    --status-planning-bg: #1E3A5F;
    --status-planning-text: #BFDBFE;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);

    /* Paper & Typewriter (dark) */
    --paper-bg: #2c2416;
    --paper-bg-card: #332a1a;
    --paper-bg-dark: #251e12;
    --paper-border: #4a3f2e;
    --paper-border-light: #3d3425;
    --paper-ink: #d4c5b2;
    --paper-ink-heading: #e8dcc8;
    --paper-ink-muted: #b5a58a;
    --paper-ink-faded: #6b5e4e;
    --paper-accent: #c7512e;
    --paper-accent-blue: #6b9ec2;
    --paper-shadow: rgba(0, 0, 0, 0.35);
    --paper-shadow-lg: rgba(0, 0, 0, 0.5);

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    line-height: 1.6;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    line-height: 1.2;
}

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

/* ---------- Container ---------- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* ---------- Premium Design Tokens ---------- */

/* Glassmorphism Panel */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass-panel {
    background: rgba(20, 20, 20, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Animated Gradient Hero Text */
.gradient-text {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    animation: gradientShift 4s linear infinite;
    /* Light mode gradient (dark tones for readability on light bg) */
    background-image: linear-gradient(to right, #0A0A0A, #525252, #A3A3A3, #0A0A0A);
}

/* Light gradient in dark mode or dark sections */
.dark .gradient-text, .force-dark .gradient-text {
    background-image: linear-gradient(to right, #FAFAFA, #A3A3A3, #525252, #FAFAFA);
}

@keyframes gradientShift {
    to { background-position: 200% center; }
}

/* ---------- Hero (theme-aware) ---------- */
.hero-section {
    background-color: var(--bg-primary);
    transition: background-color var(--transition-base);
}

.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-subtle);
    border: 1px solid var(--border);
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    width: fit-content;
}

.hero-pill-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1.05;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    font-weight: 500;
    color: var(--text-secondary);
}

.hero-subtitle #typewriter-text {
    color: var(--text-primary);
}

.hero-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 32rem;
    line-height: 1.8;
}

.hero-motto {
    font-size: 0.9375rem;
    font-style: italic;
    color: var(--text-secondary);
    max-width: 32rem;
    letter-spacing: 0.02em;
    border-left: 3px solid var(--border-hover);
    padding-left: 1rem;
}

.hero-social {
    /* Icon is 24px; the box is padded out to the 44px touch-target minimum.
       Negative margin keeps the row optically aligned with the text above it. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-left: -0.625rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.hero-social:hover {
    color: var(--text-primary);
}

.hero-glow {
    position: absolute;
    inset: -2rem;
    background: radial-gradient(circle, rgba(10, 10, 10, 0.07) 0%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}

.dark .hero-glow {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
}

.hero-profile-img {
    width: 16rem;
    height: 16rem;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--bg-primary);
    display: block;
}

.hero-scroll {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    color: var(--text-muted);
    animation: bounce 2s infinite;
}

/* ---------- Animations ---------- */

/* Typewriter Effect Cursor */
.typewriter-cursor {
    display: inline-block;
    width: 3px;
    height: 1.1em;
    background-color: var(--accent);
    vertical-align: middle;
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Staggered Fade Up / Reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Profile Image Ring Animation */
.profile-ring {
    position: relative;
    display: inline-block;
    border-radius: 50%;
    padding: 4px;
    background: linear-gradient(45deg, var(--border), var(--text-muted), var(--border));
    background-size: 200% 200%;
    animation: gradientRing 4s ease infinite;
}

@keyframes gradientRing {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ---------- Preloader (Branded) ---------- */
.preloader {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.brand-loader {
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-heading);
    letter-spacing: -0.05em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.brand-loader span {
    opacity: 0;
    transform: translateY(10px);
    animation: letterReveal 0.5s forwards;
    display: inline-block;
}

.brand-loader .dot {
    color: var(--text-muted);
    animation: dotPulse 1.5s infinite;
}

@keyframes letterReveal {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- Navigation ---------- */
.nav-header {
    position: sticky;
    top: 0;
    z-index: 40;
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

.dark .nav-header {
    background: rgba(10, 10, 10, 0.85);
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    max-width: var(--container-max);
    margin: 0 auto;
}

.nav-logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.nav-logo-dot {
    color: var(--text-muted);
}

.nav-links {
    display: none;
    gap: 2rem;
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    transition: color var(--transition-fast);
    position: relative;
}

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

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: var(--text-primary);
    transition: width var(--transition-base);
}

.nav-link:hover::after {
    width: 100%;
}

.nav-link.active::after {
    width: 100%;
}

/* Mobile Menu */
.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.mobile-menu-btn:hover {
    background-color: var(--bg-secondary);
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.mobile-menu.open {
    display: block;
}

.mobile-menu a {
    display: block;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.mobile-menu a:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    /* 44px floor so buttons clear the touch-target minimum on mobile */
    min-height: 2.75rem;
    padding: 0.75rem 1.75rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-clickable {
    cursor: pointer;
}

/* ---------- Section Headers ---------- */
.section-label {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.section-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.75rem;
    letter-spacing: -0.02em;
}

.section-desc {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    max-width: var(--container-narrow);
}

/* Every section used to open with the same centred label/title/description
   stack, so the page had one pace from top to bottom and "centred" carried no
   meaning. Supporting sections (skills, research, blog) now use this quieter
   left-aligned header, leaving the full centred treatment to the two moments
   that earn it: the work showcase and the closing call to action. */
/* No bottom margin: each section's grid already carries its own top margin,
   tuned for the previous centred header. Adding one here would double it. */
.section-head-inline {
    text-align: left;
    max-width: 46rem;
    margin: 0;
}

.section-head-inline .section-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

/* Short rule leading into the label — anchors the left edge so the quieter
   header still reads as deliberate rather than merely unstyled. */
.section-head-inline .section-label::before {
    content: "";
    width: 1.75rem;
    height: 1px;
    background: var(--border-hover);
    flex-shrink: 0;
}

.section-head-inline .section-title {
    margin-top: 0.625rem;
}

.section-head-inline .section-desc {
    margin-top: 0.75rem;
    margin-left: 0;
    max-width: 42rem;
}

/* ---------- Tags / Badges ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--tag-bg);
    color: var(--tag-text);
}

.status-active {
    background: var(--status-active-bg);
    color: var(--status-active-text);
}

.status-research {
    background: var(--status-research-bg);
    color: var(--status-research-text);
}

.status-planning {
    background: var(--status-planning-bg);
    color: var(--status-planning-text);
}

/* ---------- Icon Circles ---------- */
.icon-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-primary);
    flex-shrink: 0;
}

.icon-circle svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ---------- Check List Style ---------- */
.check-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.check-list li {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem 0.5rem;
    color: var(--text-secondary);
}

.skill-name {
    flex: 1 1 auto;
    min-width: 0;
}

/* A checklist of tools is an unverifiable claim — every candidate has one.
   Where a project demonstrates the skill, this opens that project's case
   study, turning the claim into something the reader can check. */
.skill-proof {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 1.75rem;
    padding: 0.15rem 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--accent);
    background: var(--tag-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.skill-proof::after {
    content: "\2192";
}

.skill-proof:hover,
.skill-proof:focus-visible {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.check-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
    color: var(--text-muted);
}

/* ---------- Forms ---------- */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-input,
.form-textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.08);
}

.dark .form-input:focus,
.dark .form-textarea:focus {
    box-shadow: 0 0 0 3px rgba(250, 250, 250, 0.08);
}

/* ---------- Social Links ---------- */
.social-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.social-link:hover {
    background: var(--bg-secondary);
    border-color: var(--border-hover);
}

.social-link svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.social-link span {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.social-link:hover span {
    color: var(--text-primary);
}

/* ---------- Footer ---------- */
.footer {
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer a {
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

/* Footer link columns are stacked text links. A full 44px box would double the
   footer's height, so these get a 36px hit area — comfortably past the 24px
   WCAG AA floor — while the column keeps its compact proportions. */
.footer-grid a:not(.nav-logo) {
    display: flex;
    align-items: center;
    min-height: 2.25rem;
}

.footer a:hover {
    color: var(--text-primary);
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 1.125rem;
    height: 1.125rem;
}

/* ---------- Preloader Spinner ---------- */
.preloader-spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---------- Profile Image ---------- */
.profile-img {
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    transition: border-color var(--transition-base);
}

.profile-img:hover {
    border-color: var(--text-muted);
}

/* ---------- Project Filter Buttons ---------- */
.filter-btn {
    /* min-height keeps the control at the 44px touch-target minimum */
    min-height: 2.75rem;
    padding: 0.5rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

/* ---------- Project Card Image ---------- */
.project-img {
    width: 100%;
    height: 14rem;
    object-fit: cover;
}

.project-card-tag {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: var(--text-inverse);
}

/* Responsive project / research grids (ID rules so they don't depend on
   escaped utility class tokens, and override the base .grid-1 single column) */
#projectGrid,
#research-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
    gap: 2rem;
}

/* ---------- Project Card — gradient thumbnail placeholder ---------- */
.project-thumb {
    width: 100%;
    height: 11rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}

.project-thumb-icon {
    width: 3.25rem;
    height: 3.25rem;
    opacity: 0.85;
}

/* Live demo badge (top-right of card) */
.project-live-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.dark .project-live-badge { color: #34D399; }

/* Demos hosted on a free tier that sleeps when idle: honest amber badge, no "live" claim */
.project-live-badge.is-cold {
    background: rgba(245, 158, 11, 0.15);
    color: #B45309;
    border-color: rgba(245, 158, 11, 0.35);
}

.dark .project-live-badge.is-cold { color: #FBBF24; }

.project-live-badge.is-cold .project-live-dot {
    background-color: #F59E0B;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.9);
    animation: none;
}

/* Cold-start hint under the demo button in the project modal */
.demo-cold-note {
    width: 100%;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.project-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #10B981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* Small tech tags on project cards */
.project-mini-tag {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    background: var(--tag-bg);
    color: var(--tag-text);
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    width: 100%;
    max-width: 48rem;
    max-height: 90vh;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-body > * + * {
    margin-top: 1.5rem;
}

.modal-img {
    width: 100%;
    max-height: 20rem;
    object-fit: cover;
    border-radius: var(--radius-md);
}

/* ---------- Counter Animation ---------- */
.counter-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ---------- Fade-in Animation ---------- */
.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);
}

/* ---------- 3D Canvas ---------- */
.canvas-3d {
    width: 100%;
    height: 500px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}

.canvas-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(245, 245, 245, 0.5);
    border-radius: var(--radius-xl);
    color: var(--text-secondary);
}

.dark .canvas-loader {
    background: rgba(20, 20, 20, 0.5);
}

/* ---------- Prose (Blog / Notebook) ---------- */
.prose {
    color: var(--text-secondary);
    line-height: 1.8;
    max-width: none;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.prose h1 { font-size: 2rem; font-weight: 800; }
.prose h2 {
    font-size: 1.5rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}
.prose h3 { font-size: 1.25rem; font-weight: 600; }

.prose p {
    margin-bottom: 1rem;
}

.prose a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.prose a:hover {
    opacity: 0.7;
}

.prose ul, .prose ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.prose li {
    margin-bottom: 0.25rem;
}

.prose code {
    font-size: 0.875em;
    background: var(--bg-secondary);
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-weight: 500;
}

.prose pre {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1.5rem 0;
}

.prose pre code {
    background: none;
    padding: 0;
    font-weight: 400;
}

.prose img {
    border-radius: var(--radius-md);
    max-width: 100%;
}

.prose blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 1.5rem 0;
}

.prose input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: var(--text-primary);
}

/* ---------- Grid Utilities ---------- */
.grid { display: grid; }
.grid-1 { grid-template-columns: 1fr; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* ---------- Flex Utilities ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* ---------- Spacing Utilities ---------- */
.mx-auto { margin-left: auto; margin-right: auto; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.relative { position: relative; }
.hidden { display: none !important; }

.section {
    padding: var(--section-padding) 0;
}

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
    .sm\:grid-2 { grid-template-columns: repeat(2, 1fr); }
    .sm\:text-5xl { font-size: 3rem; }
    .sm\:flex-row { flex-direction: row; }
}

@media (min-width: 768px) {
    .nav-links { display: flex; }
    .mobile-menu-btn { display: none; }

    .md\:grid-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:grid-3 { grid-template-columns: repeat(3, 1fr); }
    .md\:grid-4 { grid-template-columns: repeat(4, 1fr); }
    .md\:grid-5-col { grid-template-columns: repeat(5, 1fr); }
    .md\:col-span-3 { grid-column: span 3; }
    .md\:col-span-2 { grid-column: span 2; }
    .md\:text-left { text-align: left; }
    .md\:mx-0 { margin-left: 0; margin-right: 0; }

    .section-title {
        font-size: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .lg\:grid-2 { grid-template-columns: repeat(2, 1fr); }
    .lg\:grid-3 { grid-template-columns: repeat(3, 1fr); }
    .lg\:grid-5-col { grid-template-columns: 3fr 2fr; }
    .lg\:pt-0 { padding-top: 0; }
    .lg\:text-left { text-align: left; }
    .lg\:mx-0 { margin-left: 0; margin-right: 0; }

    .section-title {
        font-size: 2.75rem;
    }
}

/* ============================================================
   Gallery – Enhanced Layout
   ============================================================ */

/* --- Gallery Grid Cards (with thumbnail) --- */
.gallery-card {
    display: block;
    text-decoration: none;
    overflow: hidden;
    transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
}

.gallery-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.gallery-card-thumb {
    width: 100%;
    height: 13rem;
    object-fit: cover;
    background: var(--bg-secondary);
    display: block;
}

.gallery-card-placeholder {
    width: 100%;
    height: 13rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.gallery-card-placeholder svg {
    width: 2.5rem;
    height: 2.5rem;
    opacity: 0.4;
}

.gallery-card-body {
    padding: 1.25rem;
}

.gallery-card-body h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
}

.gallery-card-body p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.gallery-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.gallery-card-cta {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* --- Detail Page: 3D Viewer --- */
.viewer-wrapper {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
}

.viewer-wrapper .canvas-3d {
    border-radius: 0;
}

.viewer-controls-hint {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    opacity: 0.8;
}

/* --- Detail Page: Info Card --- */
.detail-info {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

@media (min-width: 768px) {
    .detail-info {
        grid-template-columns: 1fr 18rem;
    }
}

.detail-description h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.detail-description p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* --- Spec Table --- */
.spec-card {
    padding: 1.5rem;
    height: fit-content;
}

.spec-card h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
}

.spec-table tr {
    border-bottom: 1px solid var(--border);
}

.spec-table tr:last-child {
    border-bottom: none;
}

.spec-table td {
    padding: 0.625rem 0;
    font-size: 0.8125rem;
    vertical-align: top;
}

.spec-table td:first-child {
    color: var(--text-muted);
    font-weight: 500;
    width: 40%;
    padding-right: 0.75rem;
}

.spec-table td:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* --- Media Section Headers --- */
.media-section {
    margin-top: 2.5rem;
}

.media-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.media-section-header svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.media-section-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.media-section-header .media-count {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: auto;
}

/* --- Media Image Grid --- */
.media-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .media-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .media-grid { grid-template-columns: repeat(3, 1fr); }
}

.media-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.media-item:hover {
    border-color: var(--border-hover);
    transform: scale(1.02);
}

.media-item img {
    width: 100%;
    height: 12rem;
    object-fit: cover;
    display: block;
}

.media-item-caption {
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.media-item-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: var(--text-inverse);
}

.media-item-zoom {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border-radius: var(--radius-full);
    color: white;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.media-item:hover .media-item-zoom {
    opacity: 1;
}

/* --- Lightbox --- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    cursor: zoom-out;
    padding: 2rem;
}

.lightbox.open {
    display: flex;
}

.lightbox img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-caption {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
    background: rgba(0,0,0,0.6);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    font-size: 1.25rem;
    transition: background var(--transition-fast);
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.2);
}

/* --- Empty State --- */
.empty-media {
    padding: 2rem 1.5rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ---------- Nav CV Download Button ---------- */
.btn-nav-cv {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--accent);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.btn-nav-cv:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ---------- CV Dropdown ---------- */
.cv-dropdown {
    display: none;
    position: relative;
}

.cv-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 16rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
    z-index: 1000;
}

.cv-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cv-dropdown-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem 0.375rem;
    margin: 0;
}

.cv-dropdown-menu a {
    display: block;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.cv-dropdown-menu a:hover {
    background: var(--bg-secondary);
}

.cv-dropdown-menu a strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cv-dropdown-menu a span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

@media (min-width: 768px) {
    .cv-dropdown { display: block; margin-left: 1rem; }
}

/* ---------- Scroll to Top ---------- */
.scroll-top-btn {
    position: fixed;
    bottom: 5rem;
    right: 1.25rem;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* ---------- PWA Install Banner ---------- */
.pwa-banner,
.notif-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 55;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.dark .pwa-banner,
.dark .notif-banner {
    box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
}

.pwa-banner-inner,
.notif-banner-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------- Premium Footer ---------- */
.footer-premium {
    border-top: 1px solid var(--border);
    padding: 3rem 0 1.5rem;
    background: var(--bg-secondary);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr;
    }
}

.footer-grid a:hover {
    color: var(--text-primary) !important;
}

.footer-bottom {
    padding-top: 1.5rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ============================================================
   Paper & Typewriter Blog Theme
   =
/* Blog Card (stacked paper sheets) */
.blog-card {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.75rem 2rem !important;
    border: 1px solid var(--paper-border) !important;
    border-radius: 2px !important;
    background-color: var(--paper-bg-card) !important;
    color: var(--paper-ink) !important;
    font-family: var(--font-typewriter) !important;
    box-shadow: 0 1px 3px var(--paper-shadow), 0 6px 16px rgba(44, 24, 16, 0.08), inset 0 0 60px rgba(139, 119, 90, 0.03) !important;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: paperSlideIn 0.5s ease both;
}

@keyframes paperSlideIn {
    from { opacity: 0; transform: translateY(16px) rotate(0.5deg); }
    to { opacity: 1; transform: translateY(0) rotate(0deg); }
}

.blog-card:hover {
    transform: translateY(-3px) rotate(-0.3deg);
    box-shadow: 0 3px 8px var(--paper-shadow), 0 10px 28px rgba(44, 24, 16, 0.13), inset 0 0 60px rgba(139, 119, 90, 0.04) !important;
}

.blog-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: repeating-linear-gradient(1deg, transparent, transparent 2px, rgba(139, 119, 90, 0.5) 2px, rgba(139, 119, 90, 0.5) 3px);
}

.blog-card-body {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.blog-card-meta {
    font-size: 0.75rem;
    color: var(--paper-ink-muted);
    margin-bottom: 0.5rem;
    font-family: var(--font-typewriter);
    letter-spacing: 0.02em;
}

.blog-card-title {
    font-size: 1.3rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    font-family: var(--font-medieval) !important;
    letter-spacing: 0.01em;
}

.blog-card-title a {
    color: var(--paper-ink-heading) !important;
    text-decoration: none;
    transition: color 0.2s;
}

.blog-card-title a:hover {
    color: var(--paper-accent) !important;
    opacity: 1;
}

.blog-card-desc {
    font-size: 0.8125rem;
    color: var(--paper-ink);
    margin-bottom: 0.75rem;
    line-height: 1.7;
    font-family: var(--font-typewriter);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.blog-card-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-family: var(--font-typewriter);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: transparent;
    color: var(--paper-ink-muted);
    border: 1px solid var(--paper-border-light);
    border-radius: 1px;
}

.blog-card-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--paper-border);
    color: var(--paper-ink-muted);
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

.blog-card-arrow:hover {
    border-color: var(--paper-ink);
    color: var(--paper-ink-heading);
    background: rgba(139, 119, 90, 0.08);
}

/* Blog Controls */
.blog-search-wrap {
    position: relative;
}

.blog-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--paper-ink-muted);
    pointer-events: none;
}

.blog-search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--paper-border);
    border-radius: 2px;
    background: var(--paper-bg-card);
    color: var(--paper-ink);
    font-size: 0.875rem;
    font-family: var(--font-typewriter);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.blog-search-input:focus {
    border-color: var(--paper-ink-muted);
    box-shadow: 0 0 0 3px rgba(139, 119, 90, 0.1);
}

.blog-search-input::placeholder {
    color: var(--paper-ink-faded);
    font-family: var(--font-typewriter);
}

/* Tag Filter Buttons */
.blog-tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.blog-tag-btn {
    padding: 0.3rem 0.8rem;
    font-size: 0.6875rem;
    font-family: var(--font-typewriter);
    letter-spacing: 0.04em;
    border: 1px solid var(--paper-border-light);
    border-radius: 1px;
    background: transparent;
    color: var(--paper-ink-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: lowercase;
}

.blog-tag-btn:hover {
    border-color: var(--paper-ink-muted);
    color: var(--paper-ink);
    background: rgba(139, 119, 90, 0.06);
}

.blog-tag-btn.active {
    background: var(--paper-ink);
    color: var(--paper-bg-card);
    border-color: var(--paper-ink);
}

/* ===== Blog Post View (Full Paper Sheet) ===== */
.blog-post-sheet {
    background-color: var(--paper-bg-card);
    color: var(--paper-ink);
    font-family: var(--font-typewriter);
    border: 1px solid var(--paper-border);
    border-radius: 2px;
    box-shadow: 0 2px 6px var(--paper-shadow), 0 8px 24px rgba(44, 24, 16, 0.13), inset 0 0 80px rgba(139, 119, 90, 0.03);
    position: relative;
    overflow: hidden;
    padding: 2.5rem 3rem;
}

.blog-post-sheet::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.04;
    background-image:
        repeating-linear-gradient(2deg, transparent, transparent 3px, rgba(139, 119, 90, 0.5) 3px, rgba(139, 119, 90, 0.5) 4px),
        repeating-linear-gradient(87deg, transparent, transparent 5px, rgba(139, 119, 90, 0.3) 5px, rgba(139, 119, 90, 0.3) 6px);
}

.blog-post-sheet::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.05;
    background:
        radial-gradient(ellipse at 10% 90%, rgba(139, 119, 90, 0.7) 0%, transparent 45%),
        radial-gradient(ellipse at 90% 10%, rgba(160, 120, 60, 0.4) 0%, transparent 40%);
}

.blog-post-header {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.blog-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.blog-post-tags .tag {
    font-family: var(--font-typewriter);
    font-size: 0.625rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: transparent;
    color: var(--paper-ink-muted);
    border: 1px solid var(--paper-border-light);
    border-radius: 1px;
    padding: 0.1rem 0.5rem;
}

.blog-post-title {
    font-size: 2.2rem !important;
    font-weight: 400 !important;
    font-family: var(--font-medieval) !important;
    letter-spacing: 0.02em !important;
    margin-bottom: 0.75rem !important;
    line-height: 1.25;
    color: var(--paper-ink-heading) !important;
}

.blog-post-meta {
    font-size: 0.8125rem;
    color: var(--paper-ink-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-typewriter);
    letter-spacing: 0.03em;
}

.blog-meta-sep {
    color: var(--paper-border);
}

/* Ornamental divider */
.ornament-divider {
    text-align: center;
    margin: 1.5rem 0;
    color: var(--paper-ink-muted);
    font-family: var(--font-typewriter);
    font-size: 0.75rem;
    letter-spacing: 0.5em;
    user-select: none;
    position: relative;
    z-index: 1;
}

/* Back link */
.blog-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-family: var(--font-typewriter);
    color: var(--paper-ink-muted);
    margin-bottom: 2rem;
    text-decoration: none;
    transition: color 0.2s;
}

.blog-back-link:hover {
    color: var(--paper-accent);
}

/* Table of Contents (aged library card) */
.blog-toc {
    background: var(--paper-bg-dark);
    border: 1px solid var(--paper-border);
    border-radius: 2px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.blog-toc-title {
    font-size: 0.6875rem;
    font-family: var(--font-typewriter);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--paper-ink-muted);
    margin-bottom: 0.75rem;
    border-bottom: 1px dashed var(--paper-border-light);
    padding-bottom: 0.5rem;
}

.blog-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.blog-toc-item {
    margin-bottom: 0.3rem;
}

.blog-toc-item a {
    font-size: 0.8125rem;
    font-family: var(--font-typewriter);
    color: var(--paper-ink-muted);
    text-decoration: none;
    transition: color 0.2s;
    line-height: 1.6;
}

.blog-toc-item a:hover {
    color: var(--paper-accent);
}

.blog-toc-h1 { padding-left: 0; }
.blog-toc-h2 { padding-left: 1.2rem; }
.blog-toc-h3 { padding-left: 2.4rem; }
.blog-toc-h1 a { color: var(--paper-ink); }

/* Share Buttons */
.blog-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--paper-border-light);
    color: var(--paper-ink-muted);
    text-decoration: none;
    transition: all 0.2s;
}

.blog-share-btn:hover {
    border-color: var(--paper-ink);
    color: var(--paper-ink);
    background: rgba(139, 119, 90, 0.08);
}

/* ===== Prose Overrides for Typewriter Look ===== */
.blog-post-sheet .prose {
    font-family: var(--font-typewriter);
    color: var(--paper-ink);
    line-height: 1.85;
    font-size: 0.9375rem;
    position: relative;
    z-index: 1;
}

.blog-post-sheet .prose h1,
.blog-post-sheet .prose h2,
.blog-post-sheet .prose h3,
.blog-post-sheet .prose h4 {
    font-family: var(--font-medieval);
    font-weight: 400;
    color: var(--paper-ink-heading);
    letter-spacing: 0.02em;
}

.blog-post-sheet .prose h1 {
    font-size: 1.75rem;
    border-bottom: 2px double var(--paper-border-light);
    padding-bottom: 0.5rem;
    margin-top: 2.5rem;
}

.blog-post-sheet .prose h2 {
    font-size: 1.4rem;
    margin-top: 2rem;
    border-bottom: 1px solid var(--paper-border-light);
    padding-bottom: 0.35rem;
}

.blog-post-sheet .prose h3 {
    font-size: 1.15rem;
    margin-top: 1.75rem;
}

.blog-post-sheet .prose p {
    margin-bottom: 1.2rem;
    text-align: justify;
    hyphens: auto;
}

/* Drop cap (first letter of first paragraph) */
.blog-post-sheet .prose > p:first-of-type::first-letter,
.blog-post-sheet .prose h1 + p::first-letter,
.blog-post-sheet .prose h2 + p::first-letter,
.blog-post-sheet .prose .ornament-divider + p::first-letter {
    font-family: var(--font-medieval);
    font-size: 3.5em;
    float: left;
    line-height: 0.75;
    padding-right: 0.15em;
    padding-top: 0.05em;
    color: var(--paper-accent);
    font-weight: 400;
}

.blog-post-sheet .prose a {
    color: var(--paper-accent-blue);
    text-decoration: none;
    border-bottom: 1px dotted var(--paper-accent-blue);
    transition: color 0.2s, border-color 0.2s;
}

.blog-post-sheet .prose a:hover {
    color: var(--paper-accent);
    border-bottom-color: var(--paper-accent);
}

.blog-post-sheet .prose blockquote {
    border-left: 3px solid var(--paper-border);
    margin: 1.5rem 0;
    padding: 0.75rem 1.5rem;
    background: rgba(139, 119, 90, 0.04);
    font-style: italic;
    color: var(--paper-ink-muted);
    font-family: var(--font-typewriter);
}

.blog-post-sheet .prose blockquote p {
    margin-bottom: 0.5rem;
}

.blog-post-sheet .prose ul,
.blog-post-sheet .prose ol {
    padding-left: 1.75rem;
    margin-bottom: 1.2rem;
}

.blog-post-sheet .prose li {
    margin-bottom: 0.4rem;
}

.blog-post-sheet .prose li::marker {
    color: var(--paper-ink-muted);
}

.blog-post-sheet .prose code {
    font-family: var(--font-typewriter);
    font-size: 0.85em;
    background: rgba(139, 119, 90, 0.1);
    color: var(--paper-accent);
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    border: 1px solid var(--paper-border-light);
}

.blog-post-sheet .prose pre {
    background: var(--paper-bg-dark);
    border: 1px solid var(--paper-border);
    border-radius: 2px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: var(--font-typewriter);
    font-size: 0.8125rem;
    line-height: 1.7;
    color: var(--paper-ink);
}

.blog-post-sheet .prose pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.blog-post-sheet .prose img {
    max-width: 100%;
    border: 3px solid var(--paper-bg);
    box-shadow: 0 2px 8px var(--paper-shadow);
    border-radius: 2px;
    margin: 1.5rem 0;
}

.blog-post-sheet .prose hr {
    border: none;
    border-top: 1px dashed var(--paper-border);
    margin: 2rem 0;
}

.blog-post-sheet .prose table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5rem 0;
    font-size: 0.875rem;
}

.blog-post-sheet .prose th,
.blog-post-sheet .prose td {
    border: 1px solid var(--paper-border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.blog-post-sheet .prose th {
    background: var(--paper-bg-dark);
    font-family: var(--font-typewriter);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--paper-ink-muted);
}

.blog-post-sheet .prose strong {
    color: var(--paper-ink-heading);
}

.dark .blog-post-sheet .prose strong {
    color: #e8dcc8;
}

/* ===== Latest Blog Posts on Homepage (paper style) ===== */
/* Homepage blog cards use the site's own card language (Inter, neutral surface,
   16px radius) rather than the --paper-* typewriter system. That aesthetic is a
   deliberate full-page choice on blog.html and notebook.html, but three sepia
   cards dropped between Work and Contact read as a broken component, not a
   change of voice. Inheriting .card also drops the !important arms race. */
.home-blog-card {
    padding: 1.5rem;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    color: var(--text-secondary);
}

.home-blog-card:hover h3 {
    color: var(--accent);
}

/* Title leads in the DOM, so no CSS reordering is needed here. */
.home-blog-card h3 {
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    transition: color var(--transition-fast);
}

.home-blog-card .card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    letter-spacing: 0.02em;
}

/* The paper system colours this separator --paper-border, which lands at
   1.37:1 against the card and reads as an unexplained gap. */
.home-blog-card .blog-meta-sep {
    color: var(--text-muted);
}

.home-blog-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--font-sans);
    flex: 1;
}

/* Tags on the homepage cards follow the project-card tag styling, not the
   paper system's typewriter tags. */
.home-blog-card .blog-card-tag {
    font-family: var(--font-sans);
    background: var(--tag-bg);
    color: var(--tag-text);
    border: none;
    border-radius: var(--radius-sm);
    letter-spacing: 0.01em;
    text-transform: none;
}

/* ===== Blog Page Background ===== */
.blog-page-bg {
    background-color: var(--paper-bg);
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(139, 119, 90, 0.02) 4px, rgba(139, 119, 90, 0.02) 8px),
        radial-gradient(ellipse at 20% 30%, rgba(200, 170, 120, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(180, 150, 110, 0.04) 0%, transparent 40%);
}

.blog-page-content {
    max-width: 820px;
    margin: 0 auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .blog-post-sheet {
        padding: 2rem !important;
    }
}

@media (max-width: 640px) {
    /* Layout */
    .section {
        padding: 3rem 0;
    }
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Typography */
    .section-title {
        font-size: 1.625rem;
    }
    .section-desc {
        font-size: 1rem;
    }

    /* Blog cards */
    .blog-card {
        flex-direction: column;
        padding: 1.25rem !important;
    }
    .blog-card-arrow {
        align-self: flex-end;
    }
    .blog-post-title {
        font-size: 1.5rem !important;
    }
    .blog-post-sheet {
        padding: 1.5rem !important;
    }
    .blog-page-content {
        padding: 0 1rem;
    }

    /* Profile image */
    .profile-ring img {
        width: clamp(10rem, 45vw, 16rem) !important;
        height: clamp(10rem, 45vw, 16rem) !important;
    }

    /* Counters grid */
    #counters .counter-value {
        font-size: 1.75rem !important;
    }
    #counters .card {
        padding: 1rem !important;
    }

    /* Project grid cards */
    #projectGrid .card {
        padding: 1rem !important;
    }
    .project-card-tag {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }

    /* Research cards */
    #research-grid .card {
        padding: 1.25rem !important;
    }

    /* Contact form */
    .social-link span {
        font-size: 0.8125rem;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .footer-premium {
        padding: 2rem 0 1rem;
    }

    /* Blog controls */
    .blog-tag-filters {
        gap: 0.35rem;
    }
    .blog-tag-btn {
        padding: 0.25rem 0.6rem;
        font-size: 0.625rem;
    }

    /* 3D Canvas */
    .canvas-3d {
        height: 300px !important;
    }

    /* Latest posts on homepage */
    .home-blog-card h3 {
        font-size: 0.9375rem;
    }
}

@media (max-width: 480px) {
    .blog-post-title {
        font-size: 1.3rem !important;
    }
    .blog-post-sheet {
        padding: 1.25rem !important;
    }
    .blog-card {
        padding: 1rem !important;
    }
}

/* Keep the expanded home navigation readable on tablets and small laptops. */
@media (max-width: 1279px) {
  .portfolio-home .nav-links { display: none; }
  .portfolio-home .mobile-menu-btn { display: flex; }
}

.portfolio-home .nav-links { gap: 1rem; }
