/* ═══════════════════════════════════════════
   Theme Variables
═══════════════════════════════════════════ */
:root {
    --bg:           #f5f4f0;
    --bg-card:      #ffffff;
    --text:         #1a1a1a;
    --text-muted:   #6b6b6b;
    --link:         #1a1a1a;
    --border:       #d0cfc9;
    --img-border:   #1a1a1a;
    --accent:       #2255e0;
    --accent-light: #dde6ff;
    --shadow:       0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 32px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.07);
    --radius:       14px;
    --mono:         'JetBrains Mono', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #0f1115;
        --bg-card:      #181c22;
        --text:         #e6e6e6;
        --text-muted:   #888;
        --link:         #e6e6e6;
        --border:       #2e3340;
        --img-border:   #ffffff;
        --accent:       #7eaaff;
        --accent-light: #1a2340;
        --shadow:       0 2px 12px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
        --shadow-hover: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.25);
    }
}

html.dark-theme, body.dark-theme {
    --bg:           #0f1115;
    --bg-card:      #181c22;
    --text:         #e6e6e6;
    --text-muted:   #888;
    --link:         #e6e6e6;
    --border:       #2e3340;
    --img-border:   #ffffff;
    --accent:       #7eaaff;
    --accent-light: #1a2340;
    --shadow:       0 2px 12px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
    --shadow-hover: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.25);
}

html.light-theme, body.light-theme {
    --bg:           #f5f4f0;
    --bg-card:      #ffffff;
    --text:         #1a1a1a;
    --text-muted:   #6b6b6b;
    --link:         #1a1a1a;
    --border:       #d0cfc9;
    --img-border:   #1a1a1a;
    --accent:       #2255e0;
    --accent-light: #dde6ff;
    --shadow:       0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 32px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.07);
}

/* ═══════════════════════════════════════════
   Global Reset & Base
═══════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease,
                border-color 0.3s ease, box-shadow 0.3s ease;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    /* Subtle dot-grid texture */
    background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
    background-size: 28px 28px;
    color: var(--text);
    font-family: 'Overlock', Georgia, serif;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ═══════════════════════════════════════════
   Accent colour
═══════════════════════════════════════════ */
.accent { color: var(--accent); }

/* ═══════════════════════════════════════════
   Header / Navbar
═══════════════════════════════════════════ */
.navbar {
    width: 100%;
    height: 9vh;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-top: 1vh;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 200;
    backdrop-filter: blur(8px);
}

.name {
    display: flex;
    align-items: center;
    gap: 1vw;
}

.name h1 {
    font-size: clamp(20px, 1.5vw, 30px);
    margin: 0;
    line-height: 1.1;
}

.name h1 a {
    color: var(--text);
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s ease, color 0.2s ease;
}
.name h1 a:visited { color: var(--text); }
.name h1 a:hover   { transform: scale(1.05); }

.menu { display: flex; gap: 2vw; }
.menu a {
    font-size: clamp(13px, 1vw, 20px);
    text-decoration: none;
    color: var(--link);
}
.menu a:hover { text-decoration: underline; }

.activeHome { text-decoration: underline; }
.activeSub  { text-decoration: underline; }
.activeMore { text-decoration: underline; }

/* Dropdowns */
.dropdownPerson, .dropdownInterest {
    position: relative;
    display: inline-block;
}
.activePerson:hover  { text-decoration: underline; }
.activeInterest:hover { text-decoration: underline; }

.dropdownPerson:hover .dropdownPersonContent,
.dropdownInterest:hover .dropdownInterestContent {
    display: flex;
    gap: 2vw;
    padding-top: 2vh;
}

.dropdownPersonContent {
    display: none;
    position: absolute;
    transform: translateX(-15%);
    z-index: 1;
}
.dropdownInterestContent {
    display: none;
    position: absolute;
    transform: translateX(-35%);
    z-index: 1;
}
.dropdownPersonContent a,
.dropdownInterestContent a {
    padding: 5px 10px;
    border: 2px solid var(--border);
    border-radius: 30px;
    text-decoration: none;
    color: var(--text);
    font-size: clamp(13px, 1vw, 20px);
    background: var(--bg-card);
}

.location h1 {
    font-size: clamp(20px, 1.5vw, 30px);
    margin: 0;
    line-height: 1.1;
}

.headerRight { display: flex; align-items: center; gap: 1vw; }

.hub-button,
.theme-toggle {
    padding: 8px 14px;
    font-size: clamp(11px, 0.8vw, 16px);
    border-radius: 20px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    border: 1px solid var(--border);
    outline: none;
    box-shadow: none;
    font-family: 'Overlock', serif;
}
.hub-button { text-decoration: none; display: inline-block; }
.hub-button:hover, .theme-toggle:hover { transform: scale(1.07); background: var(--accent-light); }
.theme-toggle:focus, .theme-toggle:active { outline: none; box-shadow: none; }

.theme-toggle img.iconTheme {
    width: clamp(15px, 1.1vw, 22px);
    height: clamp(15px, 1.1vw, 22px);
    display: block;
}

/* ═══════════════════════════════════════════
   Main content area
═══════════════════════════════════════════ */
.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 4vh 2vw 8vh;
    gap: 0;
}

/* ═══════════════════════════════════════════
   Competition Card
═══════════════════════════════════════════ */
.comp-card {
    width: min(1100px, 94vw);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 3vh 0;
    overflow: hidden;
    /* Scroll-reveal starting state */
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.55s ease, transform 0.55s ease,
                box-shadow 0.3s ease, border-color 0.3s ease;
}

.comp-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.comp-card:hover {
    box-shadow: var(--shadow-hover);
}

/* ── Card header bar ── */
.card-header {
    display: flex;
    align-items: center;
    gap: 1.2em;
    padding: 1.1em 2em 1em;
    border-bottom: 1px solid var(--border);
    background: var(--accent-light);
}

.card-num {
    font-family: var(--mono);
    font-size: clamp(11px, 0.85vw, 14px);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.08em;
    opacity: 0.8;
    flex-shrink: 0;
}

.card-title {
    font-size: clamp(17px, 1.5vw, 26px);
    font-weight: 900;
    margin: 0;
    line-height: 1.2;
    color: var(--text);
}

.card-title .accent { color: var(--accent); }

.card-date {
    margin-left: auto;
    font-family: var(--mono);
    font-size: clamp(10px, 0.8vw, 13px);
    color: var(--text-muted);
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 10px;
    background: var(--bg-card);
}

/* ── Card body: two-column layout ── */
.card-body {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
}

/* reverse: image on left */
.card-body.reverse {
    flex-direction: row-reverse;
}

.card-text {
    flex: 1;
    padding: 2em 2.2em;
    border-right: 1px solid var(--border);
    min-width: 0;
}

.card-body.reverse .card-text {
    border-right: none;
    border-left: 1px solid var(--border);
}

.card-text ul {
    font-size: clamp(13px, 1vw, 16px);
    line-height: 1.7;
    margin: 0.3em 0 0.9em 0;
    padding-left: 1.2em;
    color: var(--text);
}

.card-text ul strong {
    display: block;
    font-size: clamp(12px, 0.9vw, 15px);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 0.3em;
    list-style: none;
}

/* Override: strong sits outside li, treat it as a label */
.card-text ul > strong { margin-left: -1.2em; }

.card-text li { margin-bottom: 0.25em; }

.card-media {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1em;
    padding: 2em 1.8em;
    background: var(--bg);
}

/* ═══════════════════════════════════════════
   Shared icon (GitHub / PDF)
═══════════════════════════════════════════ */
.comp-icon {
    width: clamp(40px, 3.5vw, 56px);
    height: clamp(40px, 3.5vw, 56px);
    border-radius: 50%;
    transition: transform 0.25s ease, filter 0.25s ease;
    display: block;
}

.comp-icon:hover { transform: scale(1.15) rotate(-4deg); }

/* ═══════════════════════════════════════════
   Shared media (image / video)
═══════════════════════════════════════════ */
.comp-media {
    width: clamp(260px, 22vw, 420px);
    aspect-ratio: 5 / 3;
    height: auto;
    border-radius: 10px;
    object-fit: cover;
    cursor: zoom-in;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: block;
}

.comp-media:hover {
    transform: scale(1.025);
    box-shadow: var(--shadow-hover);
}

/* ═══════════════════════════════════════════
   Project-specific utilities
═══════════════════════════════════════════ */

/* Inline demo / YouTube links inside card-text */
.proj-link {
    display: inline-block;
    font-family: var(--mono);
    font-size: clamp(11px, 0.85vw, 13px);
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    border: 1.5px solid var(--accent);
    border-radius: 20px;
    padding: 3px 11px;
    margin: 2px 4px 2px 0;
    transition: background 0.2s ease, color 0.2s ease;
}
.proj-link:hover {
    background: var(--accent);
    color: #fff;
}
html.dark-theme .proj-link:hover,
body.dark-theme .proj-link:hover {
    color: #0f1115;
}

/* Red accent for one-off emphasis (e.g. "shut down") */
.tag-red { color: #d93025; }

/* Lightbox overlay (populated by JS) */
#media-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.75);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    cursor: zoom-out;
}

#media-lightbox.open {
    display: flex;
}

#media-lightbox img,
#media-lightbox video {
    max-width: 90vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    border: none !important;
    background-color: transparent !important;
    cursor: zoom-out;
    /* Reset any transition from the global rule */
    transition: none;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ═══════════════════════════════════════════
   Global image border rule
═══════════════════════════════════════════ */
img:not(.iconPhone):not(.iconEmail):not(.iconLinkedin):not(.iconGithub):not(.iconTheme):not(.comp-icon):not(.iconChessChess):not(.iconChess):not(.iconGoogleDrivePhotography):not(.magIcon):not(.iconResume):not(.iconGithubRepoDiscord):not(.iconGithubRepoApp):not(.iconYoutube) {
    border: 2px solid var(--border);
    background-color: var(--bg-card);
    background-clip: padding-box;
}

/* Dark theme icon invert */
html.dark-theme .iconTheme,
html.dark-theme .iconGithub,
html.dark-theme .comp-icon,
body.dark-theme .iconTheme,
body.dark-theme .iconGithub,
body.dark-theme .comp-icon {
    filter: invert(1) brightness(1.15);
}

/* ═══════════════════════════════════════════
   Sticky competition nav
═══════════════════════════════════════════ */
.project-nav {
    position: fixed;
    top: 50%;
    left: clamp(8px, 1.5vw, 20px);
    transform: translateY(-50%);
    z-index: 100;
}

.project-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pnav-link {
    display: block;
    padding: 6px 12px;
    font-size: clamp(10px, 0.8vw, 13px);
    font-family: var(--mono);
    font-weight: 700;
    text-decoration: none;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    background: var(--bg-card);
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease,
                background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    white-space: nowrap;
}

.pnav-link:hover {
    opacity: 1;
    transform: translateX(3px);
    color: var(--text);
}

.pnav-link.pnav-active {
    opacity: 1;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateX(4px);
}

html.dark-theme .pnav-link.pnav-active,
body.dark-theme .pnav-link.pnav-active {
    color: #0f1115;
}

@media (max-width: 700px) {
    .project-nav { display: none; }

    .card-body,
    .card-body.reverse {
        flex-direction: column;
    }

    .card-text {
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }

    .card-body.reverse .card-text {
        border-left: none;
        border-bottom: 1px solid var(--border);
    }
}