@import url('colors.css');

html {
    overflow-y: scroll;
    /* Ensures scrollbar is always visible */
}

body {
    margin: 0;
    font-family: "Ubuntu", sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color-primary);
    text-align: justify;
    background: var(--page-gradient);
    background-attachment: fixed;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Faint plotting grid behind the content: a data cue, not a texture. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 22px 22px;
}

h1 {
    color: var(--text-color-primary);
}

.content-wrapper {
    display: grid;
    grid-template-columns: 20% 80%;
    /* Adjust column widths */
    column-gap: 15px;
    padding: 2% 4% 3% 3%;
}


/* Logo left, nav centered, theme toggle right.
   The 1fr side columns keep the nav centred on the page, not between its neighbours. */
.site-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 15px;
    padding: 20px 4% 10px;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s ease, backdrop-filter 0.3s ease, box-shadow 0.3s ease;
}

/* Shrunk state while scrolling down. Children scale individually (rather
   than the header as a whole), and the header's own box-model (padding,
   height) never changes - only transforms and paint properties do. Changing
   padding here would change document height, which on pages barely taller
   than the viewport flips scrollY's clamped max and re-triggers the
   opposite state on the next scroll event, bouncing forever. */
.site-header.is-compact {
    background: var(--glass-panel);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-soft);
}

.site-header .site-logo,
.site-header .main-nav,
.site-header .theme-toggle {
    transition: transform 0.3s ease;
}

.site-header.is-compact .site-logo {
    transform: scale(0.88);
    transform-origin: left center;
}

.site-header.is-compact .main-nav {
    transform: scale(0.88);
    transform-origin: center;
}

.site-header.is-compact .theme-toggle {
    transform: scale(0.88);
    transform-origin: right center;
}

/* Hovering the shrunk header brings it back to full size, per spec. */
.site-header.is-compact:hover .site-logo,
.site-header.is-compact:hover .main-nav,
.site-header.is-compact:hover .theme-toggle {
    transform: scale(1);
}

.site-header .site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
    white-space: nowrap;
}

/* Accent marker: reads as a cursor / active indicator. */
.site-header .site-logo::before {
    content: "";
    width: 4px;
    height: 20px;
    border-radius: 2px;
    background: var(--gradient-brand);
}

.site-header .site-logo:hover {
    opacity: 0.85;
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    background: var(--glass-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 6px;
}

.main-nav .nav-link {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--text-color-secondary);
    text-transform: uppercase;
    padding: 8px 16px;
    margin: 0 2px;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.main-nav .nav-link.active {
    color: #FFFFFF;
    background: var(--gradient-brand);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.main-nav .nav-link:not(.active):hover {
    background: var(--accent-tint);
    color: var(--accent-primary);
}

.site-header .theme-toggle {
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 16px;
    color: var(--text-color-secondary);
    background: var(--glass-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.site-header .theme-toggle:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-soft);
}


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

/* Tablet and below: the sidebar stops being a column and becomes a card
   above the content, keeping the same reading order. */
@media (max-width: 900px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        row-gap: 18px;
        padding: 0 5% 8%;
    }

    /* Once stacked, the contact card would push the actual content of every
       page below the fold, so it is kept only on About. */
    #sidebar-container {
        display: none;
    }

    body.page-about #sidebar-container {
        display: block;
    }
}

@media (max-width: 600px) {

    /* Logo and toggle share the first row, the nav gets a full-width row
       underneath so it stays centred instead of being squeezed. */
    .site-header {
        grid-template-columns: 1fr auto;
        row-gap: 12px;
        padding: 16px 5% 8px;
    }

    .site-header .site-logo {
        grid-row: 1;
        grid-column: 1;
        font-size: 21px;
    }

    .site-header .theme-toggle {
        grid-row: 1;
        grid-column: 2;
    }

    .main-nav {
        grid-row: 2;
        grid-column: 1 / -1;
    }

    .main-nav .nav-link {
        font-size: 11px;
        padding: 7px 10px;
        margin: 0;
    }

    /* Justified text on a narrow column opens up word gaps. */
    body {
        text-align: left;
    }
}