/* ----------------------------
   Global styles
---------------------------- */
:root {
    --vh: 100vh; /* fallback for older browsers */
}

html, body {
    height: 100%;
}

body {
    font-family: sans-serif;
    margin: 0;
    padding: 5px; /* header/footer grid inset */
    box-sizing: border-box;
    min-height: calc(var(--vh, 1vh) * 100);
    background-color: black;
    font-size: 13px;
    color: white;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 5px); /* iPhone home indicator */
}

::selection {
    background-color: #fff;
    color: black;
}

/* ----------------------------
   Desktop Header and Footer
---------------------------- */
header {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    padding: 5px;
    z-index: 2;
    align-items: start;
}
footer {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    padding: 5px;
    z-index: 2;
    align-items: end;
}

main {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    padding: 50px 5px 0 5px;
    z-index: 2;
}

/* Basic text */
header p,
footer p,
main p,
header a,
footer a,
main a {
    margin: 0;
    color: white;
    user-select: text;
    text-decoration: none;
    white-space: normal;
}

header a:hover,
footer a:hover,
main a:hover {
    color: #39FF14;
}

/* ----------------------------
   Footer project title
---------------------------- */
#project-title {
    grid-column: 1 / 3; /* spans first two columns on desktop */
    font-size: 13px;
    line-height: 1;
    white-space: pre-line;
}

/* ----------------------------
   Header overflow behavior
---------------------------- */
header p, footer p {
    display: inline-block;      /* keeps each p independent */
    white-space: normal;        /* allows wrapping downward */
    overflow-wrap: break-word;  /* wrap long words */
}

/* Desktop: keep toggle in header grid right-aligned */
header p:last-child {
    justify-self: end;
}

/* Desktop: right-align CV by default */
footer p:last-child,
footer a.cv-link {
    justify-self: end;
    position: static;
}

/* ----------------------------
   Media placed by JS
---------------------------- */
.fixed-media {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    object-fit: contain;
    z-index: 0;
    max-width: 40vw;
    max-height: 50vh;
}

@media (max-width: 800px) {
    .fixed-media {
        max-width: 80vw;
        max-height: 40vh;
    }
}

/* Prevent media selection */
img, video {
    user-select: none;
}

/* ----------------------------
   Theme toggle
---------------------------- */
#theme-toggle {
    width: 18px;
    height: 18px;
    cursor: pointer;
    user-select: none;
    display: block;
    transition: opacity 0.3s ease;
}

#theme-toggle:hover {
    opacity: 0.5;
}

/* ----------------------------
   Mobile adjustments - HEADER
---------------------------- */
@media (max-width: 800px) {
    header {
        display: flex;
        flex-direction: column; /* stacked list */
        align-items: flex-start;
        gap: 4px;
        padding: 5px;
    }

    #theme-toggle {
        position: absolute;
        top: 5px;
        right: 5px;
        z-index: 10;
    }
}

/* ----------------------------
   Mobile adjustments - FOOTER
---------------------------- */
@media (max-width: 800px) {
    footer {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* last four columns become two columns */
        gap: 4px 10px;
        align-items: start;
        padding: 5px;
    }

    /* Project title spans both columns */
    #project-title {
        grid-column: 1 / -1;
        margin-bottom: 20px; /* spacing before other items */
    }

    /* Mobile: CV should NOT align right */
    footer p:last-child,
    footer a.cv-link {
        justify-self: start;
    }

    /* Other footer items flow naturally into two columns */
    footer p:not(#project-title),
    footer a:not(#project-title) {
        margin: 0;
    }
}

/* ----------------------------
   Light mode overrides
---------------------------- */
.light-mode {
    background-color: white;
    color: black;
}

.light-mode header a,
.light-mode footer a,
.light-mode main a {
    color: black;
}

.light-mode header a:hover,
.light-mode footer a:hover,
.light-mode main a:hover {
    color: #39FF14;
}

.light-mode header p,
.light-mode footer p,
.light-mode main p {
    color: black;
}

