/* ============================================================
   PORTFOLIO — MAIN CSS
   Architecture: CSS Grid, Custom Properties, Mobile-First
   ============================================================ */

/* --- Custom Properties --- */
:root {
    /* Colors */
    --color-bg:            #0e0e12;
    --color-bg-card:       rgba(255, 255, 255, 0.055);
    --color-bg-card-hover: rgba(255, 255, 255, 0.09);
    --color-border:        rgba(255, 255, 255, 0.08);
    --color-border-hover:  rgba(255, 255, 255, 0.18);
    --color-accent:        #c8a96e;
    --color-accent-light:  #e8c98e;
    --color-accent-dim:    rgba(200, 169, 110, 0.15);
    --color-text:          #9a9590;
    --color-text-muted:    #8a8278;
    --color-text-dim:      #5a5248;

    /* Typography */
    --font-main:     'Inter', system-ui, sans-serif;
    --font-size-xs:  0.72rem;
    --font-size-sm:  0.85rem;
    --font-size-md:  1rem;
    --font-size-lg:  1.2rem;
    --font-size-xl:  1.6rem;
    --font-size-2xl: 2.4rem;

    /* Spacing */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    /* Layout */
    --container-max:     1280px;
    --container-padding: var(--space-lg);
    --card-radius:       8px;
    --card-radius-lg:    12px;

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-normal: 280ms ease;
    --transition-slow:   500ms ease;
}

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

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

body {
    font-family: var(--font-main);
    font-size: var(--font-size-md);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Background Canvas --- */
.background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.6;
}

/* --- Portfolio Container --- */
.portfolio-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--container-padding);
    position: relative;
    z-index: 1;
}

/* --- Identity Header --- */
.identity-header {
    padding: var(--space-2xl) 0 var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-lg);
}

.identity-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-lg);
}

.identity-avatar {
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(200, 169, 110, 0.45);
    box-shadow: 0 0 0 3px rgba(200, 169, 110, 0.08);
    max-height: 130px;
}

.identity-avatar-img {
    display: block;
    height: 130px;
    width: auto;
    object-fit: cover;
    filter: saturate(0.85);
}

.identity-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.identity-name {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.identity-name span {
    color: var(--color-accent);
}

.identity-tagline {
    font-size: var(--font-size-lg);
    font-weight: 300;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.identity-location {
    font-size: var(--font-size-sm);
    color: var(--color-text-dim);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.identity-contact {
    display: flex;
    gap: 0.55rem;
    margin-top: var(--space-sm);
    flex-wrap: wrap;
}

.identity-contact a {
    color: var(--color-accent);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color var(--transition-fast);
}

.identity-contact a + a {
    position: relative;
    padding-left: 0.7rem;
}

.identity-contact a + a::before {
    content: '|';
    position: absolute;
    left: 0;
    color: var(--color-text-dim);
    pointer-events: none;
}

.identity-contact a:hover {
    color: var(--color-accent-light);
}

/* Defensive fallback: hide any stale print button from old cached scripts */
.print-resume-btn,
#print-resume-btn {
    display: none !important;
}

/* --- Main Navigation --- */
.main-navigation {
    margin-bottom: var(--space-xl);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(14, 14, 18, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    margin-left: calc(-1 * var(--container-padding));
    margin-right: calc(-1 * var(--container-padding));
    padding: var(--space-sm) var(--container-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.nav-link {
    color: #c9bfb0;
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color var(--transition-fast);
    padding: var(--space-xs) 0;
    position: relative;
}

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

.nav-link:hover {
    color: #e8e0d0;
}

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

.nav-dropdown-wrapper {
    position: relative;
    outline: none;
}

.nav-dropdown-btn,
.nav-link-print {
    color: #c8a96e;
    font-size: var(--font-size-sm);
    font-weight: 700;
    font-family: inherit;
    border: 1.5px solid #c8a96e;
    border-radius: 4px;
    padding: 5px 14px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: none;
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Give the print link a small gap from the Contact button */
.nav-link-print {
    margin-left: 0.65rem;
}
.nav-dropdown-wrapper:hover .nav-dropdown-btn,
.nav-dropdown-wrapper:focus-within .nav-dropdown-btn {
    color: #e8e0d0;
    background-color: #c8a96e;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    padding-top: 8px;
    background: transparent;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 200;
}

.nav-dropdown-wrapper:hover .nav-dropdown-menu,
.nav-dropdown-wrapper:focus-within .nav-dropdown-menu {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.nav-dropdown-item {
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 10px 16px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: #141412;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-dropdown-item:first-child {
    border-top: 1px solid var(--color-border);
    border-radius: 6px 6px 0 0;
}

.nav-dropdown-item:last-child {
    border-bottom: 1px solid var(--color-border);
    border-radius: 0 0 6px 6px;
}

.nav-dropdown-item:hover {
    color: #c8a96e;
    background: #181810;
}

@media print {
    .main-navigation,
    .theme-toggle,
    .nav-link-print,
    .nav-dropdown-wrapper,
    #featured,
    .portfolio-column,
    #portfolio {
        display: none !important;
    }

    /* Force a clean white background for printable output */
    body {
        background: #fff;
        color: #111;
    }
}

/* Compact print-preview class to try to fit content on a single page */
.print-single-page .portfolio-container {
    max-width: 190mm;
    margin: 8mm auto;
    font-size: 12px;
}

.print-single-page .two-column-layout {
    grid-template-columns: 1fr !important;
    gap: 0.4rem !important;
}

.print-single-page #background-canvas {
    display: none !important;
}

.print-single-page .identity-avatar-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
}

/* Hide avatar, contact links, and tagline when using compact print */
.print-single-page .identity-avatar,
.print-single-page .identity-contact,
.print-single-page .identity-tagline {
    display: none !important;
}

/* Also hide the rendered name in compact/print mode */
.print-single-page .identity-name { display: none !important; }

/* Hide the whole header block so it doesn't reserve vertical space */
.print-single-page .identity-header { display: none !important; }

.print-single-page .section-header h2 {
    font-size: 10px;
    padding-left: 0.4rem;
}

.print-single-page .section-content,
.print-single-page .entry-desc {
    font-size: 12px;
    line-height: 1.2;
}

.print-single-page .bookshelf,
.print-single-page .portfolio-gallery,
.print-single-page .right-column {
    display: none !important;
}

/* Additional tight print rules */
@media print {
    html, body { width: 210mm; height: 297mm; margin: 0; -webkit-print-color-adjust: exact; color-adjust: exact; }
    .portfolio-container { max-width: 190mm; margin: 6mm auto; padding: 6mm !important; font-size: 11px; }
    .two-column-layout { grid-template-columns: 1fr !important; }
    img { max-width: 100% !important; height: auto !important; }
    #background-canvas { display: none !important; }
    .bookshelf, .portfolio-gallery, .right-column { display: none !important; }
    .identity-avatar,
    .identity-contact,
    .identity-tagline,
    .identity-name,
    .identity-header { display: none !important; }
    .section-header { margin-bottom: 0.4rem; }
    .section-header h2 { font-size: 9px; padding-left: 0.4rem; }
    .section-content, .entry-desc { font-size: 11px; line-height: 1.15; }
    a { color: #111 !important; text-decoration: none !important; }
    * { page-break-inside: avoid; }
}

/* Fixes for unexpected blank final page when printing */
@media print {
    /* Ensure page height is automatic and no element forces full viewport spacing */
    html, body { height: auto !important; min-height: auto !important; overflow: visible !important; }

    /* Allow normal breaking for most elements so content fills pages naturally */
    * { page-break-inside: auto !important; }

    /* Avoid sticky positioning in print which can consume viewport space */
    .objective-section,
    .identity-header,
    .main-navigation { position: static !important; top: auto !important; }

    /* Prevent the container from forcing an extra blank page */
    .portfolio-container { page-break-after: auto !important; }

    /* Restrict strict no-break rules to entries only */
    .experience-entry, .education-entry { page-break-inside: avoid !important; }
}

/* --- Two Column Layout --- */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-lg);
    align-items: start;
    margin-bottom: var(--space-lg);
}

/* --- Shared Section Styles --- */
.section-header {
    margin-bottom: var(--space-md);
}

.section-header h2 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-accent);
    border-left: 3px solid var(--color-accent);
    padding-left: var(--space-sm);
}

/* --- Objective Section --- */
.objective-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius-lg);
    padding: var(--space-lg);
    position: sticky;
    top: 60px;
}

.objective-section .section-content {
    font-size: var(--font-size-sm);
    line-height: 1.8;
    color: #9a9590;
}

.objective-section .section-content p + p {
    margin-top: var(--space-md);
}

/* "ABOUT" label gets a distinct grey — different from accent gold and book colors */
.objective-section .section-header h2 {
    color: #7aaa8a;        /* About — bright sage, draws eye */
    border-left-color: #7aaa8a;
}

/* --- Right Column --- */
.right-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* --- Featured Bookshelf --- */
.bookshelf {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    padding-bottom: var(--space-lg);
    position: relative;
}

/* The shelf board line underneath the books */
.bookshelf::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-accent), transparent 80%);
    border-radius: 2px;
    opacity: 0.5;
}

.book-card {
    flex: 1 1 180px;
    min-width: 160px;
    max-width: 240px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    display: flex;
    flex-direction: row;
    overflow: hidden;
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
    cursor: pointer;
}

.book-card:hover {
    transform: translateY(-8px);
    border-color: var(--color-border-hover);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* Colored spine on the left — color comes from --book-color set inline */
.book-spine {
    width: 5px;
    flex-shrink: 0;
    background: var(--book-color, var(--color-accent));
    opacity: 0.9;
    transition: opacity var(--transition-normal);
}

.book-card:hover .book-spine {
    opacity: 1;
}

.book-content {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
}

.book-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--book-color, var(--color-accent));
    opacity: 0.5;
}

.book-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.book-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.65;
    flex: 1;
}

.book-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: var(--space-xs);
}

.book-link {
    display: inline-block;
    margin-top: var(--space-xs);
    color: var(--book-color, var(--color-accent));
    text-decoration: none;
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    transition: opacity var(--transition-fast);
}

.book-link:hover {
    opacity: 0.75;
}

/* --- Shared Tag Pill (used by bookshelf, skills, etc.) --- */
.tag {
    font-size: var(--font-size-xs);
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--color-accent-dim);
    color: var(--color-accent-light);
    letter-spacing: 0.04em;
}

/* --- Skills Section --- */
.skills-section {
    --section-color: #4e9e7a;  /* Skills — deep teal-green */
    margin-bottom: var(--space-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius-lg);
    padding: var(--space-lg);
}

.skills-section .section-header h2 {
    color: var(--section-color);
    border-left-color: var(--section-color);
}

.skills-grid {
    columns: 4;
    column-gap: var(--space-md);
}

.skill-card {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    transition: border-color var(--transition-normal), background var(--transition-normal);
}

.skill-card:hover {
    border-color: var(--color-border-hover);
    background: var(--color-bg-card-hover);
}

.skill-card-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--section-color);
}

.skill-card-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.skill-card-items span {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 3px 8px;
}

/* --- Bottom Three Columns --- */
.bottom-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.bottom-column {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius-lg);
    padding: var(--space-lg);
}

/* Per-section accent — change once here to sync heading, org labels, and clickables */
.experience-column { --section-color: #4a7a58; }  /* mature forest green */
.education-column  { --section-color: #5a6880; }  /* desaturated slate */
.portfolio-column  { --section-color: #4a7ab8; }  /* muted blue */

.experience-column .section-header h2,
.education-column .section-header h2,
.portfolio-column .section-header h2 {
    color: var(--section-color);
    border-left-color: var(--section-color);
}

/* --- Experience Entries --- */
.experience-entry,
.education-entry {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.experience-entry:last-child,
.education-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.entry-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.entry-org {
    font-size: var(--font-size-xs);
    color: var(--color-accent);
    margin-bottom: 2px;
}

.experience-column .entry-org,
.education-column  .entry-org,
.portfolio-column  .entry-org { color: var(--section-color); }

.entry-date {
    font-size: var(--font-size-xs);
    color: var(--color-text-dim);
    margin-bottom: var(--space-sm);
}

.entry-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.7;
}

/* --- Portfolio Gallery --- */
.portfolio-categories {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.portfolio-category-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 3px 12px;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-main);
}

.portfolio-category-btn:hover,
.portfolio-category-btn.active {
    border-color: var(--section-color);
    color: var(--section-color);
}

.portfolio-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.gallery-item {
    aspect-ratio: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    color: var(--color-text-dim);
    overflow: hidden;
    transition: border-color var(--transition-normal);
}

.gallery-item:hover {
    border-color: var(--color-border-hover);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fullscreen button overlay */
.gallery-fullscreen-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #e8e0d0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    padding: 5px;
    backdrop-filter: blur(4px);
}

.gallery-fullscreen-btn svg {
    width: 100%;
    height: 100%;
}

.gallery-item:hover .gallery-fullscreen-btn,
.gallery-item:focus-within .gallery-fullscreen-btn {
    opacity: 1;
}

.gallery-fullscreen-btn:hover {
    background: rgba(200, 169, 110, 0.8);
}

/* Lightbox */
#gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#gallery-lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
    transform: scale(0.96);
    transition: transform 0.25s ease;
}

#gallery-lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-title {
    color: rgba(232,220,200,0.8);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.lightbox-close {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 36px;
    height: 36px;
    background: rgba(30,30,40,0.9);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    color: #e8e0d0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: background 0.15s ease;
}

.lightbox-close:hover {
    background: rgba(200, 169, 110, 0.8);
}

.lightbox-close svg {
    width: 100%;
    height: 100%;
}

/* --- Footer Spacer --- */
.main-content::after {
    content: '';
    display: block;
    height: var(--space-2xl);
}

/* --- Responsive: Tablet (≤ 1024px) --- */
@media (max-width: 1024px) {
    .bottom-columns {
        grid-template-columns: 1fr 1fr;
    }

    .bottom-column:last-child {
        grid-column: 1 / -1;
    }
}

/* --- Responsive: Mobile (≤ 768px) --- */
@media (max-width: 768px) {
    :root {
        --container-padding: var(--space-sm);
        --font-size-2xl: 1.4rem;
        --font-size-xl:  1.1rem;
        --font-size-lg:  0.95rem;
        --font-size-md:  0.88rem;
        --font-size-sm:  0.78rem;
        --font-size-xs:  0.68rem;
        --space-2xl: 1.5rem;
        --space-xl:  1rem;
        --space-lg:  0.75rem;
        --space-md:  0.5rem;
        --space-sm:  0.35rem;
    }

    .identity-wrapper {
        gap: 0.6rem;
    }

    .identity-avatar {
        max-height: 64px;
    }

    .identity-avatar-img {
        height: 64px;
    }

    .portfolio-container {
        padding: 0 var(--space-sm);
    }

    .two-column-layout {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .objective-section {
        position: static;
        padding: var(--space-md);
    }

    .section-header {
        margin-bottom: 0.4rem;
    }

    .section-header h2 {
        font-size: 0.65rem;
    }

    .section-content {
        font-size: 0.78rem;
        line-height: 1.6;
    }

    /* Books wrap to 2 per row on narrow screens */
    .book-card {
        flex: 1 1 calc(50% - var(--space-md));
        max-width: none;
        padding: var(--space-sm);
    }

    .book-title {
        font-size: 0.78rem;
    }

    .book-desc {
        font-size: 0.68rem;
    }

    .book-spine {
        width: 6px;
    }

    .skills-grid {
        columns: 2;
        gap: var(--space-sm);
    }

    .skill-card {
        padding: var(--space-sm);
        break-inside: avoid;
    }

    .skill-card-title {
        font-size: 0.7rem;
    }

    .skill-card-items span {
        font-size: 0.65rem;
        padding: 2px 5px;
    }

    .bottom-columns {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .bottom-column {
        padding: var(--space-md);
    }

    .bottom-column:last-child {
        grid-column: unset;
    }

    .entry-title {
        font-size: 0.78rem;
    }

    .entry-org,
    .entry-date,
    .entry-desc {
        font-size: 0.72rem;
    }

    .portfolio-categories {
        gap: var(--space-xs);
    }

    .portfolio-category-btn {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .identity-name {
        font-size: 1.3rem;
    }

    .identity-tagline {
        font-size: 0.85rem;
    }

    .main-navigation {
        padding: 0.3rem var(--space-sm);
        align-items: flex-start;
        gap: 0.35rem;
    }

    .nav-content {
        flex: 1;
        min-width: 0;
        gap: 0.35rem 0.45rem;
    }

    .theme-toggle {
        margin-left: 0;
        flex-shrink: 0;
    }

    .nav-link,
    .nav-dropdown-btn {
        font-size: 0.65rem;
    }

    .nav-dropdown-wrapper {
        position: static;
    }

    .nav-dropdown-menu {
        position: fixed;
        top: 3.15rem;
        right: 0.5rem;
        left: auto;
        min-width: min(240px, calc(100vw - 1rem));
        max-width: calc(100vw - 1rem);
        background: #141412;
        border: 1px solid var(--color-border);
        border-radius: 8px;
        padding-top: 0;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    }

    .nav-dropdown-item {
        border-left: 0;
        border-right: 0;
    }
}

/* --- Responsive: Small Mobile (≤ 480px) --- */
@media (max-width: 480px) {
    /* Books go full-width on tiny screens */
    .book-card {
        flex: 1 1 100%;
        max-width: none;
    }

    .skills-grid {
        columns: 1;
    }

    .skill-card {
        height: auto;
        min-height: 80px;
    }

    .portfolio-gallery {
        grid-template-columns: 1fr;
    }
}

/* --- Light Mode --- */
[data-theme="light"] body {
    filter: invert(1) saturate(1.35) contrast(1.08);
    background-color: #080a0d;
}

[data-theme="light"] .main-navigation {
    background: rgba(8, 10, 13, 0.92);
}

[data-theme="light"] .book-desc,
[data-theme="light"] .entry-desc,
[data-theme="light"] .skill-card-items,
[data-theme="light"] .text-dim,
[data-theme="light"] .text-muted,
[data-theme="light"] .objective-section .section-content,
[data-theme="light"] .objective-section .section-content p {
    color: #ffffff !important;
}

[data-theme="light"] .section-header h2,
[data-theme="light"] .skill-card-title,
[data-theme="light"] .entry-org,
[data-theme="light"] .portfolio-category-btn.active,
[data-theme="light"] .portfolio-category-btn:hover {
    filter: invert(1) saturate(1.2) brightness(1.16);
    -webkit-text-stroke: 0;
    text-shadow: none;
}

[data-theme="light"] .section-header h2,
[data-theme="light"] .skill-card-title {
    font-weight: 700;
}

[data-theme="light"] .book-label,
[data-theme="light"] .book-link {
    color: var(--book-color, var(--color-accent)) !important;
    opacity: 1;
    filter: none;
}

[data-theme="light"] .book-spine {
    background: var(--book-color, var(--color-accent)) !important;
    filter: none;
}

/* Re-invert photos so they look normal */
[data-theme="light"] .identity-avatar-img,
[data-theme="light"] .gallery-item img {
    filter: invert(1);
}

/* --- Theme Toggle Button --- */
.theme-toggle {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
}

/* Show sun in dark mode, moon in light mode */
.icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun  { display: none; }

/* Utility Classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.text-accent { color: var(--color-accent); }
.text-muted  { color: var(--color-text-muted); }
.text-dim    { color: var(--color-text-dim); }
