/* Theme variables - space (default) */
:root,
[data-theme="space"] {
    --bg-primary: #03060c;
    --text-primary: #f5f5f5;
    --nav-bg: rgba(44, 44, 44, 0.9);
    --nav-inner-bg: #1a1a1a1a;
    --footer-bg: #1a1a1a;
    --link-color: #9d9dbe;
    --link-visited: rgb(147 157 227);
    --link-hover: #6a0dad;
    --navbar-bg: #3333332e;
    --navbar-link: #fff;
    --navbar-link-hover-bg: #ddd;
    --navbar-link-hover-color: #333;
    --overlay-gradient: radial-gradient(rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0));
    --heading-shadow: 2px 1px 2px #000;
}

[data-theme="garden"] {
    --bg-primary: linear-gradient(180deg, #87ceeb 0%, #b8e0b8 50%, #6b8e6b 100%);
    --text-primary: #0b1a0b;
    --nav-bg: rgba(60, 90, 60, 0.92);
    --nav-inner-bg: rgba(45, 75, 45, 0.95);
    --footer-bg: rgba(45, 70, 45, 0.95);
    --link-color: #274d27;
    --link-visited: #386538;
    --link-hover: #1e4d1e;
    /* Footer has dark green bg; use lighter link color so links are visible */
    --footer-link-color: #b8e0b8;
    --footer-link-visited: #9bc99b;
    --footer-link-hover: #d4f0d4;
    --navbar-bg: rgba(55, 85, 55, 0.85);
    --navbar-link: #e8f0e8;
    --navbar-link-hover-bg: rgba(200, 220, 200, 0.9);
    --navbar-link-hover-color: #1a2f1a;
    --overlay-gradient: radial-gradient(rgba(255, 248, 220, 0.35), rgba(255, 255, 255, 0) 60%);
    --heading-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Garden scene: trees (only visible in garden theme) */
.garden-scene {
    opacity: 0;
    visibility: hidden;
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    /* Promote to compositor layer to reduce scroll jank on mobile */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

[data-theme="garden"] .garden-scene {
    opacity: 1;
    visibility: visible;
}

/* Ocean on the horizon */
.garden-ocean {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18vh;
    height: 4vh;
    background: linear-gradient(180deg, #4a9bd9 0%, #2e75a8 40%, #1e547a 100%);
    z-index: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

/* Garden ground band */
.garden-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 18vh;
    min-height: 100px;
    background: linear-gradient(180deg, #5a8f5a 0%, #3d6b3d 40%, #2d5a2d 100%);
    z-index: 1;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

/* Trees: trunk + foliage (column-reverse so trunk is at bottom, foliage on top) */
.garden-scene .tree {
    position: absolute;
    bottom: 0;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    z-index: 2;
}

.garden-scene .tree-trunk {
    width: 24px;
    height: 22vh;
    min-height: 55px;
    max-height: 90px;
    background: linear-gradient(90deg, #5d4037 0%, #6d4c41 50%, #4e342e 100%);
    border-radius: 2px 2px 0 0;
    box-shadow: inset 2px 0 4px rgba(0, 0, 0, 0.3), 2px 0 4px rgba(0, 0, 0, 0.2);
}

.garden-scene .tree-foliage {
    width: 0;
    height: 0;
    border-style: solid;
    margin-top: -2px;
}

.garden-scene .tree-left {
    left: -2%;
}

.garden-scene .tree-left .tree-trunk {
    width: 26px;
    height: 24vh;
    background: linear-gradient(90deg, #4e342e 0%, #5d4037 50%, #3e2723 100%);
}

.garden-scene .tree-left .tree-foliage {
    border-width: 0 min(12vw, 90px) min(38vh, 260px) min(12vw, 90px);
    border-color: transparent transparent #1e4d1e transparent;
    filter: drop-shadow(4px 2px 6px rgba(0, 0, 0, 0.2));
}

.garden-scene .tree-right {
    right: -2%;
}

.garden-scene .tree-right .tree-trunk {
    width: 22px;
    height: 20vh;
    background: linear-gradient(90deg, #3e2723 0%, #6d4c41 50%, #5d4037 100%);
}

.garden-scene .tree-right .tree-foliage {
    border-width: 0 min(11vw, 85px) min(34vh, 230px) min(11vw, 85px);
    border-color: transparent transparent #2d5a2d transparent;
    filter: drop-shadow(-4px 2px 6px rgba(0, 0, 0, 0.2));
}

.garden-scene .tree-center {
    left: 50%;
    transform: translateX(-50%);
}

.garden-scene .tree-center .tree-trunk {
    width: 20px;
    height: 18vh;
    background: linear-gradient(90deg, #5d4037 0%, #4e342e 100%);
}

.garden-scene .tree-center .tree-foliage {
    border-width: 0 min(10vw, 70px) min(30vh, 200px) min(10vw, 70px);
    border-color: transparent transparent #256b25 transparent;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

body {
    background-color: var(--bg-primary);
    font-family: "Roboto", sans-serif;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    transition: color 0.4s ease, background-color 0.4s ease;
}

[data-theme="garden"] body {
    background: var(--bg-primary);
    background-color: transparent;
    background-attachment: fixed;
}

#light {
    background-image: var(--overlay-gradient);
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 0;
    pointer-events: none;
}

/* Scene transition overlay */
#sceneTransitionOverlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

#sceneTransitionOverlay.transitioning {
    pointer-events: auto;
}

header {
    background-color: var(--nav-bg);
    position: fixed;
    width: 100%;
    z-index: 100;
    transition: background-color 0.4s ease;
}

nav {
    width: 100%;
    z-index: 1000;
    position: fixed;
}

nav ul {
    display: flex;
    justify-content: space-around;
    list-style-type: none;
    padding: 15px;
    background-color: var(--nav-inner-bg);
    transition: background-color 0.4s ease;
}

nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: bold;
}

nav a:hover {
    color: var(--link-hover);
}

section {
    padding: 100px 50px;
    text-align: center;
    min-height: 100vh;
    overflow-y: auto;
    transition: transform 1s ease;
}

h1,
h2,
h3 {
    margin-bottom: 30px;
    text-shadow: var(--heading-shadow);
    line-height: 34px;
    margin: 0 auto;
    white-space: nowrap;
}

.project {
    margin: 20px 0;
    background-color: #e95ea371;
    padding: 15px;
    border-radius: 20px;
    box-shadow: -8px 8px 8px rgba(0, 0, 0, 0.5), 8px 8px 5px rgba(0, 0, 0, 0.4);
    max-width: 323px;
    position: relative;
    z-index: 101;
}

.project:hover {
    box-shadow: -8px 8px 8px rgba(0, 0, 0, 0.5), 8px 8px 5px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

#portfolioContent .project {
    background-color: #0973e971;
}

footer {
    background-color: var(--footer-bg);
    color: var(--navbar-link);
    padding-bottom: 7px;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 999;
    transition: background-color 0.4s ease, color 0.4s ease;
}

footer p {
    margin: 0;
}

/* Garden theme: footer has dark green bg; override link color for visibility */
[data-theme="garden"] footer a {
    color: var(--footer-link-color);
}
[data-theme="garden"] footer a:visited {
    color: var(--footer-link-visited);
}
[data-theme="garden"] footer a:hover {
    color: var(--footer-link-hover);
}

.canvas-container {
    top: 0;
    left: 0;
    min-height: 700px;
    min-width: 500px;
    overflow: auto;
}

#home {
    position: absolute;
    top: 0;
}

a:visited {
    color: var(--link-visited);
}

a {
    color: var(--link-color);
}

img {
    width: 299px;
}

#load {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
}

canvas {
    position: fixed;
    z-index: -1;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#portfolioContent.visible+#load,
#playgroundContent.visible+#load {
    padding-top: 70px;
    margin-top: 0;
    transition: margin-top 0.5s;
}

.hidden {
    opacity: 0;
    visibility: hidden;
    height: 0;
    transition: opacity 0.5s, visibility 0.5s, height 0.5s;
}

.visible {
    opacity: 1;
    visibility: visible;
    height: auto;
}

#contentWrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    transition: all 1s ease;
    transform: translateY(20vh);
}

/* Hero area: no tap highlight or focus rectangle on mobile touch */
#spacemanContainer,
#spacemanContainer * {
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}
#spacemanContainer:focus:not(:focus-visible),
#spacemanContainer *:focus:not(:focus-visible) {
    outline: none;
}

#portfolioContent.visible+#load,
#playgroundContent.visible+#load {
    margin-top: 0;
    transition: margin-top 1s ease;
}

#portfolioContent,
#playgroundContent {
    z-index: 100;
}

.hidden {
    opacity: 0;
    display: none;
    transition: opacity 0.2s ease-in-out;
}

.visible {
    opacity: 1;
    visibility: visible;
    height: auto;
}

section#projects,
section#portfolioProjects {
    margin-top: 269px;
    position: relative;
    z-index: 100;
}

.section-invisible {
    display: none;
}


/* Media queries for responsive design */
@media (max-width: 767px) {
    nav ul {
        flex-direction: column;
    }

    section {
        padding: 80px 25px;
    }

    h1,
    h2,
    h3 {
        font-size: 24px;
    }

    .project {

        max-width: 231px;
    }

    img {
        width: 199px;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 1.5s ease-out forwards;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--navbar-bg);
    padding: 5px 0;
    position: relative;
}

.navbar-left,
.navbar-right {
    display: flex;
    align-items: center;
    margin: 0 10px;
}

.navbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

.navbar a {
    color: var(--navbar-link);
    text-decoration: none;
    padding: 8px 16px;
}

.navbar a:hover {
    background-color: var(--navbar-link-hover-bg);
    color: var(--navbar-link-hover-color);
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--navbar-link);
    color: var(--navbar-link);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
}

.theme-toggle-icon {
    margin-right: 4px;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    background-color: var(--navbar-link-hover-bg);
    color: var(--navbar-link-hover-color);
    outline: none;
}

body {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Open Sans', sans-serif;
}

h1 {
    font-size: 2em;
}

h2 {
    font-size: 1.75em;
}

h3 {
    font-size: 1.5em;
}

h4 {
    font-size: 1.25em;
}

h5 {
    font-size: 1.1em;
}

h6 {
    font-size: 0.9em;
}

.navbar a {
    font-size: 0.9em;
}

.read-more {
    font-size: 0.9em;
}

@media screen and (max-width: 767px) {
    /* Stabilize garden scene height so it doesn't resize when mobile URL bar hides/shows */
    .garden-scene {
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        height: 100vh;
        height: 100svh;
        min-height: 100vh;
        min-height: 100svh;
    }

    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.6em;
    }

    h3 {
        font-size: 1.4em;
    }

    h4 {
        font-size: 1.2em;
    }

    h5 {
        font-size: 1em;
    }

    h6 {
        font-size: 0.8em;
    }

    .navbar a {
        font-size: 0.8em;
        padding: 6px 8px;
    }

    /* Option 2 + 3: split 3 links across bar, float button to empty space (right) */
    .navbar-left,
    .navbar-right {
        display: contents;
    }

    .navbar-center {
        position: static;
        left: auto;
        transform: none;
        order: 4;
    }

    .navbar-right a:first-child {
        order: 1;
    }

    .navbar-left a {
        order: 2;
    }

    .navbar-right a:last-child {
        order: 3;
    }

    .read-more {
        font-size: 0.8em;
    }
}
