:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --text-color: #1f2937;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --accent-color: #3b82f6;
    --heading-color: #111827;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #e5e7eb;
        --bg-color: #111827;
        --card-bg: #1f2937;
        --border-color: #374151;
        --heading-color: #f9fafb;
        --accent-color: #60a5fa;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

header {
    background-color: var(--card-bg);
    padding: 4rem 0 3rem;
    border-bottom: 1px solid var(--border-color);
}

.header-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.header-flex {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
}

.profile-img {
    width: 160px;
    height: 160px;
    border-radius: 24px;
    object-fit: cover;
    object-position: center top;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.header-content h1 {
    font-size: 2.5rem;
    color: var(--heading-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.header-location {
    font-size: 1.1rem;
    color: var(--text-color);
    font-weight: 400;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.location-sep {
    color: var(--border-color);
    margin: 0 0.75rem;
}

.contact-links {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .header-flex {
        flex-direction: column;
        text-align: center;
        gap: 2rem;
    }
    .subtitle {
        justify-content: center;
    }
    .contact-links {
        justify-content: center;
    }
}

.contact-links a, .contact-links span {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.contact-links a:hover {
    color: var(--primary-color);
}

/* Sidebar Styling */
.sidebar-nav {
    width: 150px;
    position: fixed; /* Using fixed but with a top margin to keep it below header */
    left: 4rem;
    top: 25rem; 
    z-index: 50;
    transition: top 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
}

.sidebar-nav.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 2px solid var(--border-color);
}

.toc li {
    margin-bottom: 0.5rem;
}

.toc-link {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    margin-left: -2px; /* Overlap the ul border */
    opacity: 0.6;
}

.toc-link:hover, .toc-link.active {
    opacity: 1;
    color: var(--primary-color);
}

.toc-link.active {
    border-left: 2px solid var(--primary-color);
    font-weight: 600;
}

/* Ensure sidebar stays below header and moves up as user scrolls */
@media (min-width: 1301px) {
    /* JS will handle dynamic positioning to "stick" it after header is passed */
}

/* Menu Toggle Button (Mobile Only) */
.menu-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    cursor: pointer;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(20px);
}

.menu-toggle.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

@media (max-width: 1300px) {
    .sidebar-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        background-color: var(--card-bg);
        z-index: 999;
        padding: 6rem 2rem 2rem;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
    }

    .sidebar-nav.active {
        left: 0;
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    .toc {
        position: static;
    }

    .toc-link {
        font-size: 1.1rem;
        padding: 0.75rem 0;
        opacity: 1;
    }

    .toc-link.active::before {
        display: none;
    }
}

main {
    padding: 3rem 0;
}

section {
    margin-bottom: 4rem;
}

section h2 {
    font-size: 1.75rem;
    color: var(--heading-color);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.section-header:hover {
    opacity: 0.8;
}

.section-header h2 {
    margin-bottom: 0;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin-top 0.3s ease;
}

.collapsible-content.expanded {
    max-height: 2000px;
    opacity: 1;
    margin-top: 1.5rem;
    padding-top: 0.5rem; /* Space for hover expansion */
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

#about p {
    font-size: 1.1rem;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-top: 0.5rem;
}

.timeline-item {
    padding-left: 1.5rem;
    border-left: 2px solid var(--border-color);
    position: relative;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

.timeline-item h3 {
    font-size: 1.25rem;
    color: var(--heading-color);
}

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

.date {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 1rem;
}

.description {
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.5;
}

.timeline-item ul {
    list-style: disc;
    margin-left: 1.25rem;
}
.timeline-item li {
    margin-bottom: 0.5rem;
}

.project-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
}

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.pub-meta {
    font-size: 0.9rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

.pub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding-top: 0.5rem;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    padding-top: 0.5rem;
}

.project-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card h3 {
    margin-bottom: 0.75rem;
    color: var(--heading-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.card-header h3 {
    margin-bottom: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.github-link {
    color: var(--text-color);
    font-size: 1.25rem;
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.github-link:hover {
    color: var(--primary-color);
    opacity: 1;
    transform: scale(1.1);
}

.system-design-btn, .screenshot-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.system-design-btn:hover, .screenshot-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.wip {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

@media (prefers-color-scheme: dark) {
    .badge.wip {
        background-color: #78350f;
        color: #fef3c7;
        border: 1px solid #92400e;
    }
}

.project-card p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    flex-grow: 1;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.tags span {
    background-color: var(--border-color);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.project-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.project-link:hover {
    text-decoration: underline;
}

.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
}

.skill-category.wide {
    grid-column: 1 / -1;
}

.skills-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.skill-category h4 {
    color: var(--heading-color);
    margin-bottom: 1.25rem;
    font-size: 1.2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.skill-item {
    margin-bottom: 1.25rem;
}

.skill-group {
    margin-bottom: 2rem;
}

.skill-sub-item {
    margin-left: 1.5rem;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.skill-sub-item .skill-bar-bg {
    height: 4px;
}

.skill-sub-item .skill-info {
    font-size: 0.85rem;
    opacity: 0.8;
}

.skill-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.skill-bar-bg {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.skill-bar-fill {
    height: 100%;
    width: 0; /* Initial state for animation */
    background: linear-gradient(90deg, var(--accent-color), var(--primary-color));
    border-radius: 4px;
    transition: width 1.5s cubic-bezier(0.1, 0, 0.2, 1);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    overflow: auto;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 1000px;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.close-modal {
    color: var(--text-color);
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
}

.close-modal:hover {
    opacity: 1;
}

#modal-title {
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 1.5rem;
}

#mermaid-container {
    background: white; /* Mermaid diagrams often look better on white or specifically themed backgrounds */
    padding: 2rem;
    border-radius: 8px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

@media (prefers-color-scheme: dark) {
    #mermaid-container {
        background: #1e293b;
    }
}

/* AI Chat Styling */
.ai-chat-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ai-chat-toggle {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
}

.ai-chat-window {
    display: none;
    width: 350px;
    height: 450px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 1rem;
}

.ai-chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: block; /* Shown by default */
}

.ai-status-dot.offline {
    background-color: #ef4444; /* red */
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.ai-status-dot.initializing {
    background-color: #f97316; /* orange */
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.ai-status-dot.online {
    background-color: #4ade80; /* green */
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

.close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    margin-left: auto;
    cursor: pointer;
    opacity: 0.8;
}

.ai-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.ai-message.bot {
    align-self: flex-start;
    background-color: var(--border-color);
    color: var(--text-color);
    border-bottom-left-radius: 2px;
}

.ai-message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
}

.ai-chat-input {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.ai-chat-input input {
    flex-grow: 1;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    outline: none;
}

.ai-chat-input button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 8px;
    cursor: pointer;
}

@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 2rem);
        height: 400px;
    }
}

footer {
    padding: 3rem 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.7;
}

.weather-modal-content {
    max-width: 1100px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow: hidden;
}

.weather-container {
    flex-grow: 1;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.loader-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background-color: var(--border-color);
    overflow: hidden;
    z-index: 10;
    display: none;
}

.loader-bar::after {
    content: '';
    position: absolute;
    left: -50%;
    height: 100%;
    width: 50%;
    background-color: var(--accent-color);
    animation: loading 1.5s infinite linear;
}

@keyframes loading {
    from { left: -50%; }
    to { left: 100%; }
}

.weather-container iframe {
    display: block;
    width: 100%;
    height: 100%;
}

.close-weather-modal {
    color: var(--text-color);
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
    z-index: 10;
}

.close-weather-modal:hover {
    opacity: 1;
}

@media (max-width: 768px) {
    .weather-modal-content {
        width: 95%;
        padding: 1rem;
        height: 90vh;
    }
}

/* Setlist Bot Modal Styling */
.setlist-modal-content {
    max-width: 600px;
}

.api-form {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

.form-group input {
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
}

.submit-api-btn {
    padding: 1rem;
    border-radius: 8px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.submit-api-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.api-result {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.result-placeholder {
    color: var(--text-color);
    opacity: 0.5;
    text-align: center;
    margin-top: 1rem;
}

.close-setlist-modal {
    color: var(--text-color);
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
}

.close-setlist-modal:hover {
    opacity: 1;
}

.setlist-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setlist-item:last-child {
    border-bottom: none;
}
