/* =========================================================================
   Shared styles — loaded first on every page.
   Page-specific CSS (css/home.css, css/pages/*.css) loads AFTER this file
   so it can override rules defined here.
   ========================================================================= */

/* Design tokens — change a value here and every rule below follows. */
:root {
    --bg-page: rgb(222, 222, 222);
    --bg-window: rgb(41, 41, 41);
    --bg-titlebar: #333;
    --text-default: #000;
    --text-inverse: #fff;
    --link: #00bfff;
    --link-hover: #66d9ff;
    --focus-ring: #ffcc00;
    --radius-window: 20px;
    --radius-nav: 12px;
    --shadow-1: 0 3px 8px rgba(0, 0, 0, 0.1);
    --shadow-2: 0 6px 12px rgba(0, 0, 0, 0.25);
    --bottom-nav-h: 60px;
}

/* Reset: zero margins/padding and use a sane box model everywhere. */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Reserves the scrollbar's space so the layout doesn't shift
       when a short page grows tall enough to need one. */
    scrollbar-gutter: stable;
}

html,
body {
    overflow-x: hidden;
}

body {
    font-family: 'share tech mono', monospace;
    background-color: var(--bg-page);
    color: var(--text-default);
    min-height: 100vh;

    /* Column layout lets the footer sit at the bottom even on short pages. */
    display: flex;
    flex-direction: column;

    background-image: url("../assets/images/cube-grid-background.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* iOS Safari + mobile in general stutter with fixed backgrounds; scroll it instead. */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }
}

/* -------------------------------------------------------------------------
   Accessibility utilities
   ------------------------------------------------------------------------- */

/* Skip link: invisible until focused, then jumps to #main.
   Lets keyboard users bypass the nav on every page. */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    padding: 8px 12px;
    background: var(--bg-window);
    color: var(--text-inverse);
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* One consistent focus ring for all interactive elements. */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Site header + top navigation (injected by js/components.js)
   Constrained to the same 900px column the main content uses, so the
   nav doesn't stretch the full viewport width.
   ------------------------------------------------------------------------- */

header {
    max-width: 900px;
    margin: 0 auto 10px;
    padding: 20px 20px 0;
    text-align: center;
}

header h1 {
    font-size: 2.8rem;
    line-height: 1.1;
    margin-top: 20px;
}

header nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 0;
    margin-top: 20px;
}

/* Both the header nav and the footer nav render as dark pill buttons. */
header nav a,
footer nav a {
    display: block;
    padding: 12px 18px;
    background-color: var(--bg-window);
    color: var(--text-inverse);
    border-radius: var(--radius-nav);
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    word-break: break-word;
    box-shadow: var(--shadow-1);
    transition: 0.2s ease;
}

header nav a:hover,
footer nav a:hover {
    background-color: #e1e2e2;
    color: var(--text-default);
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

/* Marks the current page (components.js sets aria-current="page"). */
header nav a[aria-current="page"],
footer nav a[aria-current="page"] {
    background-color: #e1e2e2;
    color: var(--text-default);
}

.font-control {
    margin-top: 15px;
    text-align: center;
}

.font-control input {
    width: 70%;
    margin-top: 5px;
}

/* -------------------------------------------------------------------------
   Main content containers
   ------------------------------------------------------------------------- */

.page-wrapper {
    flex: 1;
    /* pushes footer to the bottom */
    padding: 20px;
    max-width: 900px;
    margin: 0 auto var(--bottom-nav-h);
}

/* "Retro window" frame — titlebar on top, content below. */
.retro-window {
    background: #ffffffcf;
    border: 3px solid #444;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 20px;
}

.window-titlebar {
    background: var(--bg-titlebar);
    color: var(--text-inverse);
    padding: 12px 15px;
    font-weight: bold;
    border-bottom: 2px solid #444;
    display: flex;
    align-items: center;
}

.content-window {
    background-color: var(--bg-window);
    color: var(--text-inverse);
    padding: 30px;
    margin: 20px 10px;
    border-radius: var(--radius-window);
    box-shadow: var(--shadow-1);
}

/* -------------------------------------------------------------------------
   Site footer + bottom nav (injected by js/components.js)
   ------------------------------------------------------------------------- */

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-h);

    background-color: rgba(74, 74, 74, 0.684);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* The <nav> inside <footer> is the flex row that holds the link buttons;
   the button styling itself lives in the combined header/footer rule above. */
footer nav {
    height: 100%;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 12px;
}

/* Footer is only 60px tall — nudge the buttons a hair smaller than the
   header pills, with extra horizontal breathing room around each label. */
footer nav a {
    padding: 10px 22px;
    font-size: 14px;
    white-space: nowrap;
}

@media (max-width: 520px) {
    :root {
        --bottom-nav-h: 96px;
    }

    footer nav {
        flex-wrap: wrap;
        align-content: center;
        justify-content: center;
        gap: 6px;
        padding: 8px;
    }

    body footer nav a {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* -------------------------------------------------------------------------
   Utilities
   ------------------------------------------------------------------------- */

.blue-link {
    color: var(--link);
    text-decoration: none;
}

.blue-link:visited {
    color: var(--link);
}

.blue-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* -------------------------------------------------------------------------
   Glitch animation (used on page titles)
   ------------------------------------------------------------------------- */

.glitch {
    display: inline-block;
    animation: glitch-1 2s infinite linear;
    transform-origin: center;
    will-change: transform;
}

@keyframes glitch-1 {

    0%,
    12%,
    15%,
    52%,
    55%,
    82%,
    85%,
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        color: var(--text-default);
    }

    13% {
        opacity: 0.85;
        transform: scaleY(1.15);
        color: #444;
    }

    53% {
        opacity: 0.85;
        transform: scaleX(0.92);
        color: #222;
    }

    83% {
        opacity: 1;
        transform: rotate(-2deg);
        color: #000;
    }
}

/* Respect the OS-level "reduce motion" setting. */
@media (prefers-reduced-motion: reduce) {
    .glitch {
        animation: none;
    }

    * {
        transition: none !important;
    }
}

/* -------------------------------------------------------------------------
   Lightbox (unified — all three image grids share this one element,
   handled by js/main.js)
   ------------------------------------------------------------------------- */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    padding: 20px;

    /* Hidden by default; main.js toggles .is-open. */
    display: none;
    align-items: center;
    justify-content: center;
}

.lightbox.is-open {
    display: flex;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    color: var(--text-inverse);
    font-size: 2.5rem;
    line-height: 1;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

/* Any image marked clickable gets the pointer cursor. */
.gallery-item img,
.project-card img,
.clickable-image {
    cursor: pointer;
}
