/* =====================
   Theme variables
   ===================== */
:root {
    --nav-edge: 20px;
    --card-img-size: 85%;
    --card-img-dim:  0; /* 0 = fully visible, 1 = fully hidden */
    --bg:           #F4F0F4;
    --surface:      #ffffff;
    --text:         #333333;
    --text-muted:   #666666;
    --accent:       #8A7B9F;
    --accent-soft:  #b0a0c4;
    --header-bg:    #8A7B9F;
    --header-text:  #ffffff;
    --border:       rgba(0,0,0,0.1);
    --shadow:       rgba(0,0,0,0.12);
    --nav-text:     #555555;
    --nav-hover:    #8A7B9F;
}

body.dark {
    --bg:           #100f1a;
    --surface:      #1c1b2a;
    --text:         #e8e4f0;
    --text-muted:   #9b96ae;
    --accent:       #9b8bbb;
    --accent-soft:  #7b6e9a;
    --header-bg:    #1e1b2e;
    --header-text:  #e8e4f0;
    --border:       rgba(155,139,187,0.2);
    --shadow:       rgba(0,0,0,0.4);
    --nav-text:     #9b96ae;
    --nav-hover:    #c4b8d8;
}

/* =====================
   Global transitions
   ===================== */
body, header, nav, .section, footer {
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

/* =====================
   Base
   ===================== */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
}

h1, h2, h3 {
    color: var(--text);
}

/* =====================
   Header
   ===================== */

/* Sticky wrapper — header + nav scroll together */
.topbar-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow);
    transition: box-shadow 0.5s ease;
}

header {
    background-color: var(--header-bg);
    color: var(--header-text);
    text-align: center;
    display: flex;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    overflow: hidden;
    isolation: isolate;
    transition: background-color 0.5s ease;
}

/* Robots */
header .header-robot {
    width: 15%;
    height: auto;
    align-self: center;
    transition: opacity 0.4s ease, max-width 0.5s ease, margin 0.5s ease, width 0.5s ease;
    max-width: 15%;
}
header .main-robot { transform: scaleX(-1); margin: 10px auto 10px 30px; }
header .last-robot  { margin: 10px 30px 10px auto; }

body.scrolled header .header-robot,
body.projects-section header .header-robot {
    opacity: 0;
    max-width: 0;
    margin: 0;
    pointer-events: none;
}

/* Title block */
.header-title {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    flex: 1;
    overflow: visible;
}
.header-title h1 {
    margin: 10px 0 0;
    font-size: 1.75em;
    color: var(--header-text);
    transition: font-size 0.5s ease, color 0.5s ease;
}

/* Subtitle / adjectives — hide on scroll */
.header-subtitle {
    margin: 0;
    font-size: 1.25em;
    font-style: italic;
    color: var(--header-text);
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 60px;
    opacity: 1;
    letter-spacing: 0;
    transition: opacity 0.3s ease, max-height 0.4s ease, margin 0.4s ease, letter-spacing 2s ease-out;
}
body.scrolled .header-subtitle,
body.projects-section .header-subtitle {
    opacity: 0;
    max-height: 0;
    margin: 0;
    pointer-events: none;
}

/* Easter egg links — absolutely placed at header edges */
.header-title .subtle {
    position: absolute;
    right: 22px;
    color: var(--header-bg); /* same as background = invisible until hover */
    text-decoration: none;
    font-size: 14px;
    transition: opacity 0.3s ease, color 0.3s;
}
.header-title .subtle:hover { color: rgba(255,255,255,0.5); }
.header-title .showy {
    position: absolute;
    left: 22px;
    bottom: 60px;
    font-size: 22pt;
    color: rgba(255,255,255,0.35);
    text-decoration: none;
    transition: opacity 0.3s ease, color 0.2s;
}
.header-title .showy:hover { color: rgba(255,255,255,0.7); }
body.scrolled .header-title .subtle,
body.scrolled .header-title .showy,
body.projects-section .header-title .subtle,
body.projects-section .header-title .showy {
    opacity: 0;
    pointer-events: none;
}

/* Shared pill — nav-gear (left) and theme-toggle (right) */
.nav-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    color: var(--accent);
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 0.2s, color 0.2s;
}
.nav-pill:hover {
    border-color: var(--text);
    color: var(--text);
}
nav .nav-pill.left-side {
    position: absolute;
    left: var(--nav-edge);
    text-decoration: none;
}
nav .nav-pill.right-side {
    position: absolute;
    right: var(--nav-edge);
    justify-content: center;
    text-decoration: none;
}


.social-links {
    display: flex;
    align-items: center;
    gap: 10px;
}
.social-links a {
    text-decoration: none;
    display: flex;
    align-items: center;
}
.social-links svg {
    height: 30px;
    width: auto;
    transition: fill 0.3s;
}
.social-links svg:hover {
    fill: #333;
}
body.dark .social-links svg {
    fill: rgba(200, 185, 230, 0.8);
}
body.dark .social-links svg:hover {
    fill: #e8e4f0;
}


/* =====================
   Nav
   ===================== */
nav {
    background-color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.5s ease, padding 0.4s ease, font-size 0.4s ease;
}
.nav-links {
    display: flex;
    gap: 24px;
}
nav a {
    text-decoration: none;
    color: var(--nav-text);
    font-size: 0.95em;
    transition: color 0.3s;
}
nav a:hover {
    color: var(--nav-hover);
}
body.projects-section nav {
    padding: 5px 20px;
    font-size: 0.8em;
}

body.projects-section nav .nav-pill {
    display: none;
}

/* =====================
   Container & sections
   ===================== */
.container {
    width: 80%;
    margin: 20px auto;
}
body.projects-section .container {
    display: none;
}

.section {
    background: var(--surface);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 0 10px var(--shadow);
    transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

.interactive {
    width: 100%;
    min-height: 400px;
    background-color: #0d0c18;
    text-align: center;
    line-height: 400px;
    font-size: 20px;
    color: #666;
    margin-top: 20px;
}

/* =====================
   Footer
   ===================== */
footer {
    text-align: center;
    position: fixed;
    width: 100%;
    bottom: 0;
    pointer-events: none;
}
footer p {
    color: var(--text-muted);
    padding: 0;
    margin: 1px;
    text-align: right;
    opacity: 0.35;
}

/* =====================
   Animated subtitle (unused in compact header but kept for fallback)
   ===================== */
.descriptive-text-container {
    position: relative;
    display: inline-block;
    width: 105px;
    height: 1.3em;
    line-height: 1.25em;
    margin-right: 0.25em;
    vertical-align: middle;
    text-align: right;
    white-space: nowrap;
}
.descriptive-text {
    position: absolute;
    top: 0; right: 0;
    width: auto;
    white-space: nowrap;
    transition: opacity 2s ease-in-out;
    opacity: 0;
}
h2.spaced { letter-spacing: 0.05em; }
.adj1, .adj2, .adj3 { display: inline; }
.adj1.show, .adj2.show, .adj3.show { opacity: 1; }

/* =====================
   Projects — scroll-driven, alternating sides
   ===================== */
#projects {
    padding: 0;
    background: transparent;
    box-shadow: none;
    margin-bottom: 0;
}

.projects-scroll {
    position: relative;
    background: #0a0914;
}

/* Sticky image panel — overlaps entries via negative margin */
.projects-images {
    position: sticky;
    top: 0;
    height: 100vh;
    margin-bottom: -100vh;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.project-image {
    position: absolute;
    top: 0;
    height: 100%;
    width: 52%;
    will-change: opacity, transform;
    transform-origin: center center;
}
.project-image[data-side="left"]  { left: 0; }
.project-image[data-side="right"] { right: 0; }

.project-image::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.project-image[data-side="left"]::after {
    background: linear-gradient(to right, transparent 55%, #0a0914 95%);
}
.project-image[data-side="right"]::after {
    background: linear-gradient(to left, transparent 55%, #0a0914 95%);
}

/* Scrolling entries — overlay the sticky images */
.projects-entries {
    position: relative;
    z-index: 2;
    padding-bottom: 50vh; /* scroll room for last entry to reach center */
    pointer-events: none; /* pass clicks through transparent areas to image panel */
}

.project-entry {
    min-height: 100vh;
    display: flex;
    align-items: center;
}
.project-entry[data-side="left"] {
    justify-content: flex-end;
    background: linear-gradient(to right,
        transparent 0%, transparent 42%,
        rgba(10,9,20,0.8) 54%, #0a0914 65%);
}
.project-entry[data-side="right"] {
    justify-content: flex-start;
    background: linear-gradient(to left,
        transparent 0%, transparent 42%,
        rgba(10,9,20,0.8) 54%, #0a0914 65%);
}

.entry-content {
    pointer-events: auto;
    width: 44%;
    padding: 80px 48px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}
.project-entry.active .entry-content {
    opacity: 1;
    transform: translateY(0);
}

/* Per-card gradient art */
.project-image[data-card="escort"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/TalkingLights.png') center/var(--card-img-size) no-repeat,
        radial-gradient(ellipse at 30% 60%, rgba(0,120,110,0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(0,80,140,0.4) 0%, transparent 55%),
        linear-gradient(135deg, #030f18 0%, #061e1a 100%);
}
.project-image[data-card="bopen"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/annotated_bo.png') center/var(--card-img-size) no-repeat,
        radial-gradient(ellipse at 60% 40%, rgba(100,40,200,0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 70%, rgba(40,10,100,0.4) 0%, transparent 45%),
        linear-gradient(135deg, #060310 0%, #0d0520 100%);
}
.project-image[data-card="scantelope"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/ginkgo.jpg') center/var(--card-img-size) no-repeat,
        repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(0,180,160,0.06) 39px, rgba(0,180,160,0.06) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(0,180,160,0.06) 39px, rgba(0,180,160,0.06) 40px),
        radial-gradient(ellipse at 50% 50%, #072530 0%, #030f18 100%);
}
.project-image[data-card="saikoled"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/myki.png') center/var(--card-img-size) no-repeat,
        radial-gradient(ellipse at 50% 50%, rgba(200,80,0,0.5) 0%, transparent 40%),
        radial-gradient(ellipse at 20% 70%, rgba(120,0,180,0.3) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 30%, rgba(0,120,200,0.3) 0%, transparent 40%),
        linear-gradient(135deg, #0f0500 0%, #1a0800 100%);
}
.project-image[data-card="lightbridge"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/lighting.jpg') center/var(--card-img-size) no-repeat,
        repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(255,200,0,0.03) 3px, rgba(255,200,0,0.03) 4px),
        radial-gradient(ellipse at 50% 70%, rgba(180,120,0,0.5) 0%, transparent 50%),
        linear-gradient(180deg, #05050f 0%, #0f0a00 60%, #05050f 100%);
}
.project-image[data-card="esb"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/esb.jpg') center/var(--card-img-size) no-repeat,
        radial-gradient(ellipse at 50% 90%, rgba(220,160,0,0.4) 0%, transparent 40%),
        radial-gradient(ellipse at 30% 40%, rgba(60,40,0,0.2) 0%, transparent 50%),
        linear-gradient(180deg, #030308 0%, #100a00 70%, #030308 100%);
}
.project-image[data-card="fabrication"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/printer.jpg') center/var(--card-img-size) no-repeat,
        repeating-linear-gradient(45deg,  transparent, transparent 18px, rgba(120,120,150,0.04) 18px, rgba(120,120,150,0.04) 19px),
        repeating-linear-gradient(-45deg, transparent, transparent 18px, rgba(120,120,150,0.04) 18px, rgba(120,120,150,0.04) 19px),
        linear-gradient(135deg, #0d0d14 0%, #181820 50%, #0d0d14 100%);
}
.project-image[data-card="matterport"] {
    background:
        linear-gradient(rgb(0 0 0 / var(--card-img-dim)), rgb(0 0 0 / var(--card-img-dim))),
        url('files/plugin.jpg') center/var(--card-img-size) no-repeat,
        radial-gradient(ellipse at 40% 40%, rgba(60,80,220,0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(120,40,200,0.3) 0%, transparent 45%),
        linear-gradient(135deg, #020210 0%, #08081e 100%);
}

.project-card-category {
    font-size: 0.7em;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #9b8bbb;
}
.project-entry h3 {
    font-size: 1.7em;
    margin: 0;
    color: #e8e4f0;
    line-height: 1.2;
}
.project-card-year {
    font-size: 0.85em;
    color: #6b6480;
}
.project-entry p {
    font-size: 0.95em;
    line-height: 1.7;
    color: #9b96ae;
    margin: 0;
    max-width: 420px;
}
.project-entry ul {
    margin: 0;
    padding-left: 18px;
    font-size: 0.9em;
    line-height: 1.8;
    color: #9b96ae;
    max-width: 420px;
}
.project-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.project-card-tags span {
    font-size: 0.7em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 10px;
    border: 1px solid rgba(155,139,187,0.25);
    border-radius: 2px;
    color: #7b708e;
}
.project-card-link {
    font-size: 0.8em;
    color: #9b8bbb;
    text-decoration: none;
    letter-spacing: 0.05em;
    align-self: flex-start;
}
.project-card-link:hover { color: #e8e4f0; }

.project-image-caption {
    position: absolute;
    bottom: 38px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.65em;
    color: #9b8bbb;
    text-decoration: none;
    letter-spacing: 0.05em;
    pointer-events: auto;
    cursor: pointer;
    z-index: 2;
    padding: 0 24px;
}
.project-image-caption:hover { color: #e8e4f0; }
.thumb-lightbox .project-image-caption {
    position: static;
    margin-top: 14px;
    font-size: 0.75em;
    padding: 0;
}



/* =====================
   Popup
   ===================== */
.popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.65);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.popup-content {
    background-color: var(--surface);
    padding: 30px 30px 24px 24px;
    border-radius: 5px;
    width: 80%;
    height: 80%;
    overflow: auto;
    position: relative;
    border: 1px solid var(--border);
    transition: background-color 0.5s ease;
}
.popup-content iframe { border: 1px solid var(--border); }
.popup-close {
    position: absolute;
    top: 5px; right: 10px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    color: var(--text-muted);
}
.popup-close:hover { color: var(--text); }

/* =====================
   Responsive
   ===================== */
@media (max-width: 600px) {
    :root { --nav-edge: 10px; }
    header {
        flex-direction: column;
    }
    header .header-robot {
        width: 60%;
        margin: 10px 0 0;
    }
    header .last-robot {
        display: none;
    }
    .header-title {
        padding: 0 0 10px;
    }
    .header-title h1 { font-size: 1.3em; }
    .header-subtitle { font-size: 1em; }
    nav .nav-pill {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
    }
    .toggle-text, .nav-gear-text { display: none; }
}

/* Mobile thumbnails */
.mobile-thumb {
    display: none;
    position: absolute;
    bottom: 28px;
    right: 20px;
    width: 176px;
    height: 136px;
    border-radius: 10px;
    overflow: hidden;
    transform-origin: bottom right;
    will-change: transform, opacity;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    background-size: cover;
    background-position: center;
}
.mobile-thumb[data-card="escort"]      { background: url('files/TalkingLights.png') center/cover no-repeat; }
.mobile-thumb[data-card="bopen"]       { background: url('files/annotated_bo.png')  center/cover no-repeat; }
.mobile-thumb[data-card="scantelope"]  { background: url('files/ginkgo.jpg')        center/cover no-repeat; }
.mobile-thumb[data-card="saikoled"]    { background: url('files/myki.png')          center/cover no-repeat; }
.mobile-thumb[data-card="lightbridge"] { background: url('files/lighting.jpg')      center/cover no-repeat; }
.mobile-thumb[data-card="esb"]         { background: url('files/esb.jpg')           center/cover no-repeat; }
.mobile-thumb[data-card="fabrication"] { background: url('files/printer.jpg')       center/cover no-repeat; }
.mobile-thumb[data-card="matterport"]  { background: url('files/plugin.jpg')        center/cover no-repeat; }

/* Thumb lightbox */
.thumb-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: lbFadeIn 0.2s ease;
}
@keyframes lbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.thumb-lightbox-img {
    width: 85vw;
    height: 66vw;
    max-height: 72vh;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}
.thumb-lightbox-img[data-card="escort"]      { background-image: url('files/TalkingLights.png'); }
.thumb-lightbox-img[data-card="bopen"]       { background-image: url('files/annotated_bo.png'); }
.thumb-lightbox-img[data-card="scantelope"]  { background-image: url('files/ginkgo.jpg'); }
.thumb-lightbox-img[data-card="saikoled"]    { background-image: url('files/myki.png'); }
.thumb-lightbox-img[data-card="lightbridge"] { background-image: url('files/lighting.jpg'); }
.thumb-lightbox-img[data-card="esb"]         { background-image: url('files/esb.jpg'); }
.thumb-lightbox-img[data-card="fabrication"] { background-image: url('files/printer.jpg'); }
.thumb-lightbox-img[data-card="matterport"]  { background-image: url('files/plugin.jpg'); }
.thumb-lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 1.4em;
    line-height: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 700px) {
    .projects-images { display: none; }
    .projects-entries { padding-bottom: 0; }
    .project-entry { background: #0a0914 !important; min-height: auto; position: relative; }
    .entry-content { width: 100%; padding: 60px 24px 180px; opacity: 1; transform: none; }
    .project-entry[data-card="fabrication"] .mobile-thumb { bottom: 8px; }
    .project-entry h3 { font-size: 1.2em; }
    .site-name { font-size: 0.95em; }
    .mobile-thumb { display: block; cursor: pointer; pointer-events: auto; }
}
