/* CSS VARIABLES & THEMES */
:root {
    --bg: #f8f9fa;
    --fg: #24292e;
    --accent: #009380;
    --radius: 8px;
    --max-width: 700px;
    --border: #e5e7eb;
    --sidebar-width: 300px;
    --sidebar-bg: #f0f0f0;
    --tab-bar-bg: #f0f0f0;
}

body[data-theme="dark"] {
    --bg: #202124;
    --fg: #e8eaed;
    --border: #2a2a2a;
    --sidebar-bg: #2a2a2a;
    --tab-bar-bg: #2a2a2a;
}

body[data-theme="light"] {
    --bg: #f8f9fa;
    --fg: #24292e;
    --border: #f0f0f0;
    --sidebar-bg: #f0f0f0;
    --tab-bar-bg: #f0f0f0;
}

/* DARK THEME OVERRIDES */
body[data-theme="dark"] .social-links img {
    filter: brightness(0) invert(1);
    opacity: 0.9;
}
body[data-theme="dark"] .nav-link {
    background: #3a3a3a;
    border-color: #555;
}
body[data-theme="dark"] .nav-links::after {
    background: #555;
}
body[data-theme="dark"] .header-bottom::after {
    background: #555;
}
body[data-theme="dark"] .nav-link.active {
    background: #202124;
    border-bottom-color: #202124;
}
body[data-theme="dark"] .nav-link:hover:not(.active) {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
}
body[data-theme="dark"] #theme-toggle:hover {
    background: var(--accent);
    color: #fff;
}
body[data-theme="dark"] .hamburger-line {
    background: var(--fg);
}

/* CSS RESET */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* TYPOGRAPHY */
body {
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

p {
    margin-bottom: 1rem;
}

code {
    font-family: 'JetBrains Mono', monospace;
    background-color: rgba(128, 128, 128, 0.1);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

/* LINKS */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover,
a:focus {
    color: color-mix(in srgb, var(--accent) 80%, white);
}

/* ==================== */
/* SIDEBAR STYLES */
/* ==================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 3rem 1.25rem 1.5rem 1.25rem;
}

.sidebar-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.sidebar-avatar {
    width: 160px;
    height: auto;
    margin-bottom: 1rem;
}

/* Mac tooltip Easter egg */
.mac-tooltip-wrapper {
    position: relative;
    display: inline-block;
    cursor: help;
}

.mac-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: calc(100%);
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--fg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 300;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    text-align: left;
}

.mac-tooltip::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-bottom-color: var(--border);
}

.mac-tooltip::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-bottom-color: var(--bg);
    z-index: 1;
}

.mac-tooltip-wrapper:hover .mac-tooltip,
.mac-tooltip-wrapper:focus .mac-tooltip,
.mac-tooltip-wrapper.tooltip-active .mac-tooltip {
    visibility: visible;
    opacity: 1;
}

.mac-tooltip .tooltip-title {
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

body[data-theme="dark"] .mac-tooltip {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.site-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 0.25rem 0;
    color: var(--fg);
    line-height: 1.3;
}

.site-name a {
    text-decoration: none;
    color: var(--fg);
    transition: color 0.2s ease;
}

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

.wiki-suffix {
    color: #999;
}

.tagline {
    font-size: 1.05rem;
    color: var(--fg);
    opacity: 0.7;
    margin: 0.25rem 0 0 0;
    font-family: 'JetBrains Mono', monospace;
}

.social-links {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: center;
}

.social-links a {
    display: inline-block;
    transition: opacity 0.2s ease;
}

.social-links img {
    width: 28px;
    height: 28px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.social-links img:hover {
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
}

.sidebar-credit {
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.6;
    margin: 1.5rem 0;
    font-family: 'JetBrains Mono', monospace;
}

.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle-text {
    font-size: 0.75rem;
    margin: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
    white-space: nowrap;
}

#theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--fg);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s ease;
}

#theme-toggle:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
}

.theme-toggle-container:hover .theme-toggle-text {
    opacity: 1;
}

/* ==================== */
/* HAMBURGER MENU (Mobile) */
/* ==================== */

.hamburger {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 1rem;
    z-index: 250;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
}

.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--fg);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    opacity: 1;
}

/* ==================== */
/* MAIN WRAPPER */
/* ==================== */

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== */
/* HEADER / TABS */
/* ==================== */

header.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--tab-bar-bg);
    width: 100%;
    padding: 1rem 1.5rem 0 0;
}

.header-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    position: relative;
    max-width: none;
    margin: 0;
}

.header-bottom::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: -1.5rem;
    height: 1px;
    background: #ccc;
    z-index: 0;
}

.nav-links {
    display: flex;
    gap: 0;
    background: transparent;
    border-radius: 8px 8px 0 0;
    padding: 0;
    position: relative;
    flex: 1;
}

.nav-link {
    position: relative;
    color: var(--fg);
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    padding: 0.65rem 0.8rem;
    background: #e8e8e8;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-right: 1px solid #ccc;
    flex: 0.2;
    min-width: 0;
    margin-right: -1px;
}

.nav-link:first-child {
    border-left: 1px solid #ccc;
    border-radius: 8px 8px 0 0;
}

body[data-theme="dark"] .nav-link {
    background: #3a3a3a;
    border-color: #555;
}

body[data-theme="dark"] .nav-link:first-child {
    border-left-color: #555;
}

.nav-link:last-child {
    border-right: 1px solid #ccc;
    margin-right: -1px;
}

.nav-link:hover:not(.active) {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
}

.nav-link.active {
    background: var(--bg);
    color: var(--fg);
    border-bottom: 1px solid var(--bg);
    margin-bottom: -1px;
    z-index: 2;
    position: relative;
}

.nav-link.active::before {
    content: "";
    position: absolute;
    bottom: -1px;
    left: -1px;
    width: 1px;
    height: 1px;
    background: var(--bg);
    z-index: 3;
}

/* Hide the white pixel for first tab since it overlaps sidebar edge */
.nav-link:first-child.active::before {
    display: none;
}


.nav-link.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 1px;
    height: 1px;
    background: var(--bg);
    z-index: 3;
}

.tab-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-title::after {
    content: ".html";
    opacity: 0.5;
    font-weight: 300;
}

.tab-close {
    margin-left: 0.1rem;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.nav-link:hover:not(.active) .tab-close {
    opacity: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

/* ==================== */
/* LAYOUT / MAIN */
/* ==================== */

/* Content area with left border starting from tab corner */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ccc;
    margin-top: -1px; /* Connect to tab border */
}

body[data-theme="dark"] .content-area {
    border-left-color: #555;
}

/* Extend border from bottom of first tab */
.nav-links::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    bottom: 0;
    width: 1px;
    background: #ccc;
    z-index: 1;
}

body[data-theme="dark"] .nav-links::before {
    background: #555;
}

main {
    max-width: var(--max-width);
    margin: 3rem 1.5rem 1rem 8rem;
    padding: 0;
    flex: 1 0 auto;
    text-align: left;
}

main h1,
main h2,
main h3 {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
}

main h1 { margin-bottom: 1rem; }
main h2 { margin: 2rem 0 1rem; }

/* ==================== */
/* FOOTER */
/* ==================== */

.site-footer {
    text-align: left;
    font-size: 0.875rem;
    color: var(--fg);
    opacity: 0.6;
    margin: 4rem 1.5rem 2rem 3.5rem;
    flex-shrink: 0;
    max-width: var(--max-width);
}

.site-footer p {
    margin: 0;
}

/* ==================== */
/* ACCENT COLOR PICKER - SET CARD STYLE */
/* ==================== */

.color-picker-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--fg);
    opacity: 0.7;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    text-align: center;
}

.set-card-choices {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.set-card-choice {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 2px;
}

.set-card-choice:hover {
    transform: translateY(-2px);
}

.set-card-choice.active {
    transform: translateY(-4px);
}

.set-card {
    width: 60px;
    height: 40px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.set-card-choice:hover .set-card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.set-card-choice.active .set-card {
    border-color: var(--accent);
    box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1);
}

.set-symbol {
    transition: all 0.2s ease;
}

.set-card-choice:hover .set-symbol {
    transform: scale(1.1);
}

/* Dark theme adjustments for Set cards */
body[data-theme="dark"] .set-card {
    background: #3a3a3a;
    border-color: #555;
}

body[data-theme="dark"] .set-card-choice:hover .set-card {
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .set-card-choice.active .set-card {
    box-shadow: 0 0 5px 2px rgba(255, 255, 255, 0.1);
}

/* ==================== */
/* OBSIDIAN-STYLE INFO BOX */
/* ==================== */

.info-box {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg));
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    position: relative;
}

.info-box::before {
    position: absolute;
    top: 1rem;
    left: 1.25rem;
    font-size: 1.1rem;
    line-height: 1;
}

.info-box p {
    margin: 0;
    padding-left: 0.8rem;
    color: var(--fg);
    opacity: 0.9;
}

.info-box code {
    background: none;
    padding: 0;
}

.info-box code .info-label {
    background: none;
    padding: 0;
    font-weight: bold;
    color: var(--accent);
}

/* Dark theme adjustments for info box */
body[data-theme="dark"] .info-box {
    background: color-mix(in srgb, var(--accent) 15%, var(--bg));
    box-shadow: 0 1px 3px rgba(255, 255, 255, 0.1);
}

/* ==================== */
/* DESIGN (PORTFOLIO GALLERY) */
/* ==================== */

.portfolio-gallery {
    column-count: 2;
    column-gap: 1rem;
    padding-bottom: 1rem;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    text-align: center;
}

.gallery-item img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.caption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 125%;
    color: #666;
}

.carousel-images img {
    display: none;
    width: 100%;
    height: auto;
}

.carousel-images img.active {
    display: block;
}

.carousel-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.carousel-index {
    color: #666;
    font-size: 0.9rem;
    user-select: none;
}

.arrow {
    font-family: 'Jetbrains Mono', monospace;
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    width: 2rem;
    height: 2rem;
    line-height: 1;
}

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

/* ==================== */
/* PORTFOLIO PAGE - PROJECT CARDS */
/* ==================== */

.portfolio-main {
    max-width: 1000px;
    margin: 3rem 5rem 1rem 8rem;
}

.project-card {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 3rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid var(--border);
}

.project-card:last-child {
    border-bottom: none;
    margin-bottom: 1rem;
}

.project-info {
    flex: 1;
    min-width: 0;
}

.project-info h2 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.project-info p {
    margin-bottom: 0;
}

.project-image {
    flex: 1.2;
    min-width: 0;
}

.project-image > img {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.project-image.carousel {
    text-align: center;
}

.project-image.carousel .carousel-images img {
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.project-image .caption {
    text-align: center;
}

body[data-theme="dark"] .project-image > img,
body[data-theme="dark"] .project-image.carousel .carousel-images img {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==================== */
/* RESPONSIVE DESIGN */
/* ==================== */

@media (max-width: 900px) {
    :root {
        --sidebar-width: 200px;
    }
    
    .site-name {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    /* Hide theme toggle text on mobile */
    .theme-toggle-text {
        display: none;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Show hamburger on mobile */
    .hamburger {
        display: flex;
    }
    
    /* Show overlay when sidebar is open */
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }
    
    .sidebar-overlay.open {
        pointer-events: auto;
    }
    
    /* Reset main wrapper margin on mobile */
    .main-wrapper {
        margin-left: 0;
    }
    
    /* Adjust topbar for mobile */
    header.topbar {
        padding: 0.75rem 0.75rem 0 0.75rem;
        padding-left: 3.5rem; /* Make room for hamburger */
    }
    
    .nav-links {
        gap: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
        flex: 1;
    }
    
    .nav-link {
        padding: 0.5rem 0.4rem;
        font-size: 0.8rem;
    }
    
    .content-area {
        border-left: none;
    }
    
    .tab-close {
        margin-left: 0.1rem;
        font-size: 0.9rem;
    }
    
    main { 
        margin: 1rem; 
        padding: 0;
    }
    
    main ul, main ol { 
        padding-left: 1.25rem; 
        margin-left: 0; 
    }

    .portfolio-gallery {
        column-count: 1;
        overflow-x: visible;
    }
    
    /* Portfolio cards stack on mobile */
    .portfolio-main {
        margin: 1rem;
    }
    
    .project-card {
        flex-direction: column;
        gap: 1rem;
    }
    
    .project-image {
        order: -1; /* Image first on mobile */
    }
    
    /* Fix Set cards overflow on mobile */
    .sidebar-footer {
        padding: 0 0.5rem;
        overflow: hidden;
    }
    
    .set-card-choices {
        justify-content: center;
    }
    
    .color-picker-label {
        font-size: 0.7rem;
        text-align: center;
    }
    
    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    .nav-link {
        padding: 0.35rem 0.25rem;
        font-size: 0.7rem;
    }
    
    .tab-title::after {
        content: "";
    }
    
    .tab-close {
        display: none;
    }
}
