@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif&display=swap');

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

:root {
    --bg: #121212;
    --text: #f5f0e8;
    --text-muted: #9a9590;
    --text-secondary: #c8c3bb;
    --line-color: #3d3d3d;
    --spacing: clamp(16px, 3vw, 40px);
}

::selection {
    background-color: var(--text);
    color: var(--bg);
}

html, body {
    height: 100%;
    overflow: hidden;
    scroll-behavior: smooth;
}

body {
    font-family: 'Geist Mono', 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background-color 0.6s ease, color 0.6s ease;
}

a {
    color: var(--text);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    padding: var(--spacing);
    padding-bottom: 0;
    gap: var(--spacing);
}

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

.sidebar {
    grid-column: 1 / 2;
    display: flex;
    flex-direction: column;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.nav-item {
    font-size: 12px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
    padding: 0;
    width: fit-content;
    white-space: nowrap;
    transition: color 0.2s ease;
}

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

.nav-item.active {
    color: var(--text);
}

/* ========== THEME TOGGLE ========== */

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    padding: 0;
    margin-top: 16px;
    width: fit-content;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

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

/* ========== CONTENT ========== */

.content {
    grid-column: 2 / 5;
    overflow: visible;
    position: relative;
}

section {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 52px;
}

section.active {
    opacity: 1;
    visibility: visible;
}

section {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

section:hover {
    scrollbar-color: var(--line-color) transparent;
}

section::-webkit-scrollbar { width: 6px; }
section::-webkit-scrollbar-track { background: transparent; }
section::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
section:hover::-webkit-scrollbar-thumb { background: var(--line-color); }

/* ========== SECTION HEADINGS ========== */

.section-description {
    font-family: 'Instrument Serif', serif;
    font-size: clamp(25px, 4vw, 36px);
    line-height: 1.3;
    color: var(--text);
    margin-bottom: clamp(20px, 3vw, 32px);
}

#about {
    justify-content: center;
    overflow: hidden;
}

.about-intro {
    font-size: clamp(28px, 4.5vw, 54px);
}

.typewriter-text {
    font-family: 'Instrument Serif', serif;
    font-size: inherit;
    color: var(--text);
}

.typewriter-cursor {
    font-family: 'Instrument Serif', serif;
    font-size: inherit;
    color: var(--text);
    animation: blink 0.7s infinite;
    margin-left: 2px;
}

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

/* ========== ITEMS LIST (projects, writing, experience, certs) ========== */

.items {
    display: flex;
    flex-direction: column;
}

.item {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: clamp(12px, 2vw, 24px);
    align-items: start;
    padding-top: 16px;
}

.item + .item {
    margin-top: 24px;
}

.item-meta {
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding-top: 4px;
    border-top: 1px solid var(--line-color);
}

.item-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--line-color);
}

.item-title {
    font-size: 15px;
    font-weight: 400;
}

.item-subtitle {
    font-size: 13px;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-style: italic;
}

.item-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.item-tools {
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 4px;
}

.item-links {
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 8px;
}

.item-links a {
    color: var(--text-secondary);
}

.item-links a:hover {
    color: var(--text);
}

.item.no-meta {
    grid-template-columns: 1fr 2fr;
}

.item.no-meta .item-content {
    grid-column: 2;
}

/* ========== CONTACT BAR (FOOTER) ========== */

.contact-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px var(--spacing);
    background-color: var(--bg);
    z-index: 100;
    transition: background-color 0.6s ease;
}

.profile-photo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
    margin-left: auto;
}

.contact-bar a {
    font-size: 12px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.contact-bar a:hover {
    color: var(--text);
    text-decoration: none;
}

.contact-bar .dot {
    color: var(--text-muted);
    font-size: 12px;
}

/* ========== DARK MODE ========== */

body.light-mode {
    --bg: #f5f0e8;
    --text: #121212;
    --text-muted: #7a756e;
    --text-secondary: #4a4540;
    --line-color: #d4cfc7;
}

/* ========== MOBILE TOP BAR ========== */

.mobile-top-bar {
    display: none;
}

.hamburger {
    display: none;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.open .hamburger-line:first-child {
    transform: translateY(4px) rotate(45deg);
}

.hamburger.open .hamburger-line:last-child {
    transform: translateY(-4px) rotate(-45deg);
}

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

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr 2fr;
    }
    .sidebar { grid-column: 1 / 2; }
    .content { grid-column: 2 / 3; }
}

@media (max-width: 768px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    .mobile-top-bar {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 12px;
        padding: var(--spacing) var(--spacing) 0;
        position: fixed;
        top: 0;
        right: 0;
        z-index: 10020;
    }

    .hamburger {
        display: flex;
    }

    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: calc(100vh - 52px);
        height: calc(100dvh - 52px);
        padding-top: calc(var(--spacing) + 36px);
    }

    .nav-links .theme-toggle {
        display: none;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 10010;
        background-color: var(--bg);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 40px;
        padding: 60px var(--spacing);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .sidebar.menu-open {
        opacity: 1;
        visibility: visible;
    }

    .nav-links {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }

    .nav-item {
        font-size: 13px;
        letter-spacing: 0.2em;
    }

    .content {
        grid-column: 1;
        grid-row: 1;
    }

    .about-intro {
        font-size: 7vw !important;
    }

    .item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .item-content {
        grid-column: 1;
    }

    .contact-bar {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .about-intro {
        font-size: 6.5vw !important;
    }

    .profile-photo {
        display: none;
    }

    .contact-links {
        margin-left: 0;
    }
}
