/* ── UCM Colors: Gold #dbaa00, Blue #0f2d52, Dark #071828 ── */

@font-face {
    font-family: 'PixelPurl';
    src: url('../assets/PixelPurl.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

html {
    margin: 0;
    padding: 0;
    background-color: #071828;
    overflow-x: hidden;
}

body {
    font-family: 'PixelPurl', 'Segoe UI', system-ui, -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100vh;
    margin: 0;
    box-sizing: border-box;
    background-color: #071828;
    color: #ffffff;
    transition: background-color 0.4s ease;
}

.top-bar, #main-nav {
    transition: opacity 0.3s ease;
}

h1 { margin-bottom: 32px; color: #dbaa00; }

.top-bar {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    box-sizing: border-box;
    flex-shrink: 0;
}

#logo {
    margin: 0;
    font-size: 3.2rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#logo span { font-size: 2.4rem; color: #dbaa00; transition: transform 0.3s ease; }
#logo:hover { opacity: 0.85; }
#logo:hover span { transform: translateY(2px); }

.search-bar {
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 1rem;
    outline: none;
    width: 250px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}
.search-bar::placeholder { color: rgba(255, 255, 255, 0.5); }
.search-bar:focus {
    border-color: #dbaa00;
    box-shadow: 0 0 0 2px rgba(219, 170, 0, 0.3);
    width: 260px;
}

nav { display: flex; flex-direction: column; gap: 6px; }

#main-nav {
    flex: 1;
    align-self: stretch;
    width: 100%;
    padding: 6px 0 20px 0;
    overflow: hidden;
    box-sizing: border-box;
}

nav a {
    flex: 1;
    max-height: 90px;
    display: flex;
    align-items: center;
    font-size: 2.6rem;
    font-weight: bold;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, #071828, #0f2d52);
    padding: 0 45px;
    border-radius: 0;
    text-align: left;
    letter-spacing: 2px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(219, 170, 0, 0.15);
    transition: all 0.3s ease;
}
nav a:hover {
    background: linear-gradient(135deg, #0f2d52, #1a4a7a);
    box-shadow: 0 10px 20px rgba(219, 170, 0, 0.15);
    border-color: rgba(219, 170, 0, 0.5);
    transform: translateY(-3px);
}

.sidebar {
    height: 100%;
    width: 250px;
    position: fixed;
    z-index: 1000;
    top: 0; left: -250px;
    background-color: #071828;
    overflow-x: hidden;
    transition: left 0.3s ease;
    padding-top: 60px;
    box-shadow: 4px 0 15px rgba(0,0,0,0.4);
}
.sidebar a {
    padding: 15px 25px;
    text-decoration: none;
    font-size: 1.5rem;
    color: #e6f1ff;
    display: block;
    transition: 0.2s;
}
.sidebar a:hover {
    background-color: #0f2d52;
    color: #dbaa00;
    padding-left: 30px;
}
.sidebar .closebtn {
    position: absolute;
    top: 10px; right: 15px;
    font-size: 28px;
    line-height: 1;
    padding: 6px 10px;
    margin: 0;
    display: inline-block;
    border-radius: 6px;
}
.sidebar .closebtn:hover {
    background: #0f2d52;
    color: #dbaa00;
    padding: 6px 10px;    /* keep padding fixed — cancel the sidebar a:hover shift */
}

@keyframes floatUp {
    from { transform: translateY(100px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* strip height + bottom gap = 220 + 16 = 236px — used in calc() below */
.hero-section, .stem-strip, .games-section { display: none; }

@media (min-width: 769px) {
    html {
        height: 100%;
        overflow-y: scroll;
        overflow-x: hidden;
        scroll-behavior: smooth;
        background-color: #071828;
        margin: 0;
        padding: 0;
    }

    body {
        height: auto;
        overflow: visible;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        min-height: 100vh;
    }

    .top-bar, #main-nav, .sidebar { display: none !important; }

    /* ── Hero: fills viewport minus the strip height so strip sits at the bottom ── */
    .hero-section {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: calc(100vh - 236px);
        position: relative;
        box-sizing: border-box;
    }

    .hero-title {
        font-size: clamp(5rem, 10vw, 12rem);
        color: #dbaa00;
        margin: 0 0 clamp(12px, 2vh, 24px) 0;
        text-align: center;
        line-height: 1.05;
        display: inline-block;
        white-space: nowrap;
    }
    .hero-title::after {
        content: '|';
        display: inline-block;
        margin-left: 0.05em;
        color: #dbaa00;
        font-weight: 300;
        animation: blinkCaret 2s step-end infinite;
    }
    @keyframes blinkCaret {
        50% { opacity: 0; }
    }

    .hero-subtitle {
        font-size: clamp(2rem, 4vw, 3.4rem);
        color: rgba(255, 255, 255, 0.72);
        margin: 0 0 clamp(28px, 4.5vh, 60px) 0;
        text-align: center;
        font-family: 'PixelPurl', 'Segoe UI', system-ui, sans-serif;
    }

    .about-btn {
        display: inline-block;
        padding: clamp(18px, 2.4vh, 28px) clamp(48px, 6.5vw, 96px);
        font-size: clamp(1.6rem, 2.6vw, 2.2rem);
        font-family: 'PixelPurl', 'Segoe UI', system-ui, sans-serif;
        color: #dbaa00;
        background: transparent;
        border: 2px solid #dbaa00;
        border-radius: 8px;
        text-decoration: none;
        transition: background 0.2s ease, color 0.2s ease;
    }
    .about-btn:hover {
        background: #dbaa00;
        color: #071828;
    }

    /* Bouncing scroll hint at bottom of hero */
    .scroll-hint {
        position: absolute;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        color: rgba(255, 255, 255, 0.3);
        font-size: 1.6rem;
        animation: bounceDown 1.6s ease-in-out infinite;
        line-height: 1;
        pointer-events: none;
    }
    @keyframes bounceDown {
        0%, 100% { transform: translateX(-50%) translateY(0);   opacity: 0.3; }
        50%       { transform: translateX(-50%) translateY(8px); opacity: 0.7; }
    }

    /* STEM strip: in normal flow after hero, sticky so it locks to the top on scroll */
    .stem-strip {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 100;
        height: 236px;
        gap: 14px;
        padding: 16px 32px 16px;
        background: #071828;
        box-sizing: border-box;
    }

    .stem-strip-letter {
        flex: 1;
        position: relative;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(219, 170, 0, 0.35);
        border-radius: 10px;
        background: linear-gradient(135deg, #071828, #0f2d52);
        transition: background 0.2s ease;
    }
    .stem-strip-letter:hover { background: linear-gradient(135deg, #0f2d52, #1a4a7a); }

    .stem-strip-bg {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 0.55;
        filter: grayscale(1) brightness(2.5);
        pointer-events: none;
    }

    .stem-strip-char {
        position: relative;
        z-index: 2;
        font-size: clamp(4.5rem, 8vw, 7.5rem);
        font-weight: bold;
        color: #dbaa00;
        font-family: 'PixelPurl', 'Segoe UI', system-ui, sans-serif;
        white-space: nowrap;
    }

    /*  Typing hover: remaining words types out beside the letter */
    .stem-strip-char::after {
        content: '';
        display: inline-block;
        overflow: hidden;
        white-space: nowrap;
        vertical-align: baseline;
        width: 0;
        font-size: 0.4em;
        color: inherit;
        letter-spacing: 1px;
    }
    .stem-strip-letter[data-cat="s"] .stem-strip-char::after {
        content: 'cience';
        transition: width 0.42s steps(6, end);
    }
    .stem-strip-letter[data-cat="t"] .stem-strip-char::after {
        content: 'echnology';
        transition: width 0.55s steps(9, end);
    }
    .stem-strip-letter[data-cat="e"] .stem-strip-char::after {
        content: 'ngineering';
        transition: width 0.6s steps(10, end);
    }
    .stem-strip-letter[data-cat="m"] .stem-strip-char::after {
        content: 'ath';
        transition: width 0.28s steps(3, end);
    }

    .stem-strip-letter[data-cat="s"]:hover .stem-strip-char::after { width: 6.2ch; }
    .stem-strip-letter[data-cat="t"]:hover .stem-strip-char::after { width: 9.4ch; }
    .stem-strip-letter[data-cat="e"]:hover .stem-strip-char::after { width: 10.4ch; }
    .stem-strip-letter[data-cat="m"]:hover .stem-strip-char::after { width: 3.2ch; }

    /* to make sure doesn't run when dim tiles after a category is picked */
    .stem-strip-letter.stem-dimmed:hover .stem-strip-char::after { width: 0; }

    /* ── Games section ── */
    .games-section {
        display: flex;
        flex-direction: column;
        min-height: calc(100vh - 236px);
        height: auto;
        overflow: visible;
        padding-bottom: 32px;
        box-sizing: border-box;
    }

    .games-grid {
        flex: 1;
        display: flex;
        gap: 14px;
        padding: 16px 32px;
        box-sizing: border-box;
        overflow: visible;
        align-items: flex-start;
        flex-wrap: nowrap;
    }

    .games-col {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* ── Game cards ── */
    .desktop-card {
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        height: auto;
        background: transparent;
        padding: 10px;
        border-radius: 10px;
        border: none;
        text-align: center;
        text-decoration: none;
        color: #ffffff;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        transition: transform 0.18s ease;
        cursor: pointer;
        box-sizing: border-box;
        position: relative;
        z-index: 1;
    }
    .desktop-card:hover {
        transform: scale(1.02);
        z-index: 10;
    }
    .desktop-card:hover .dc-img-wrapper {
        border-color: rgba(219, 170, 0, 0.7);
    }

    .dc-img-wrapper {
        flex: none;
        width: 100%;
        aspect-ratio: 16 / 9;
        border-radius: 5px;
        margin-bottom: 0;
        overflow: hidden;
        position: relative;
        border: 1px solid rgba(219, 170, 0, 0.3);
        background: rgba(219, 170, 0, 0.08);
        transition: border-color 0.18s ease;
    }

    .dc-img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
        border: none;
        border-radius: 5px;
    }

    .dc-placeholder {
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.25);
        border: 1px dashed rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        color: rgba(255, 255, 255, 0.3);
        font-size: 0.6rem;
        font-style: italic;
        box-sizing: border-box;
    }

    .dc-title-row {
        margin-bottom: 3px;
        flex-shrink: 0;
        min-height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 10px;
    }

    .dc-title {
        font-size: 2.5rem;
        font-weight: bold;
        line-height: 1.2;
        text-align: center;
        flex: 0 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
    }

    .dc-author {
        font-size: 0.95rem;
        color: #dbaa00;
        flex-shrink: 0;
    }

    /* info icon — positioned at bottom-right of the image wrapper */
    .dc-info {
        position: absolute;
        bottom: 8px;
        right: 8px;
        z-index: 10;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: rgba(7, 24, 40, 0.72);
        border: 1px solid rgba(219, 170, 0, 0.55);
        color: #fbefc6;
        font-family: 'Georgia', 'Times New Roman', serif;
        font-style: italic;
        font-weight: 700;
        font-size: 1.1rem;
        line-height: 1;
        cursor: help;
        transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
    }
    .dc-info::before {
        content: 'i';
    }
    .dc-info:hover {
        background: rgba(219, 170, 0, 0.38);
        border-color: rgba(219, 170, 0, 0.95);
        transform: scale(1.12);
    }
    /* Tooltip appears above the info button */
    .dc-info::after {
        content: attr(data-desc);
        position: absolute;
        bottom: calc(100% + 8px);
        right: 0;
        top: auto;
        left: auto;
        width: max-content;
        max-width: 220px;
        padding: 12px 14px;
        background: #071828;
        color: #ffffff;
        border: 1px solid rgba(219, 170, 0, 0.5);
        border-radius: 8px;
        font-family: 'PixelPurl', 'Segoe UI', system-ui, sans-serif;
        font-style: normal;
        font-weight: normal;
        font-size: 0.78rem;
        line-height: 1.45;
        text-align: left;
        white-space: normal;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
        opacity: 0;
        visibility: hidden;
        transform: translateY(4px);
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
        pointer-events: none;
        z-index: 100;
    }
    .dc-info:hover::after {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .light-mode .dc-info {
        background: rgba(255, 255, 255, 0.82);
        border-color: rgba(15, 45, 82, 0.55);
        color: #0f2d52;
    }
    .light-mode .dc-info:hover {
        background: rgba(15, 45, 82, 0.28);
        border-color: rgba(15, 45, 82, 0.85);
        color: #ffffff;
    }
    .light-mode .dc-info::after {
        background: #ffffff;
        color: #071828;
        border-color: rgba(15, 45, 82, 0.45);
        box-shadow: 0 6px 20px rgba(15, 45, 82, 0.22);
    }
}

/* ── Tablets / small desktops (769–1199px wide) ── */
@media (min-width: 769px) and (max-width: 1199px) {
    .stem-strip {
        height: 210px;
        padding: 14px 4vw 14px;
    }
    .hero-section  { height: calc(100vh - 210px); }
    .games-section { min-height: calc(100vh - 210px); }
    .games-grid    { padding: 14px 4vw; }

    .hero-title    { font-size: clamp(6rem, 11vw, 10rem); }
    .hero-subtitle { font-size: clamp(2.4rem, 4.2vw, 3.2rem); }
    .about-btn     { font-size: clamp(1.7rem, 2.8vw, 2.1rem); padding: clamp(18px, 2.6vh, 26px) clamp(48px, 7vw, 90px); }
    .stem-strip-char { font-size: clamp(4.5rem, 8vw, 7rem); }
    .dc-title      { font-size: clamp(1rem, 1.4vw, 1.15rem); }
    .dc-author     { font-size: clamp(0.85rem, 1.2vw, 0.95rem); }

    .desktop-card   { height: auto; }
}

/* ── Landscape phones: wide but very short (e.g. iPhone in landscape) ── */
@media (min-width: 769px) and (max-height: 500px) {
    .stem-strip {
        height: 110px;
        padding: 8px 4vw 8px;
    }
    .hero-section  { height: calc(100vh - 110px); }
    .games-section { height: calc(100vh - 110px); }
    .hero-subtitle { margin-bottom: 16px; }
    .scroll-hint   { display: none; }
    .games-grid    { padding: 8px 4vw; gap: 8px; }
    .games-col     { gap: 8px; }
    .dc-title      { font-size: 0.85rem; }
    .dc-author     { font-size: 0.75rem; }
    .desktop-card  { height: auto; }
}

@media (max-width: 768px) {
    .hero-section, .stem-strip, .games-section { display: none; }

    .top-bar {
        flex-direction: row;
        align-items: center;
        padding: 14px 76px 14px 20px; 
    }
    #logo { font-size: 2rem; }
    .search-bar { display: none; }


    .theme-toggle {
        width: 34px;
        height: 34px;
        top: 14px;
        right: 14px;
    }

    #main-nav {
        padding-top: 75px;
    }
    .theme-toggle svg {
        width: 17px;
        height: 17px;
    }

    /* Light mode for mobile */
    .light-mode body { background-color: #e8eef5; color: #071828; }
    .light-mode .top-bar { background-color: #e8eef5; }
    .light-mode #logo { color: #071828; }
    .light-mode #logo span { color: #b08800; }
    .light-mode nav a {
        color: #071828;
        background: linear-gradient(135deg, #d0dce8, #baced8);
        border-color: rgba(15, 45, 82, 0.25);
    }
    .light-mode nav a:hover {
        background: linear-gradient(135deg, #baced8, #a8c0d0);
        border-color: rgba(15, 45, 82, 0.55);
        box-shadow: 0 10px 20px rgba(15, 45, 82, 0.15);
    }
    .light-mode .sidebar { background-color: #e8eef5; }
    .light-mode .sidebar a { color: #0f2d52; }
    .light-mode .sidebar a:hover { background-color: #d0dce8; color: #b08800; }
}

/* Theme toggle button on all screens */
.theme-toggle {
    display: flex;
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    width: 69px;
    height: 69px;
    border-radius: 50%;
    border: 1px solid rgba(219, 170, 0, 0.45);
    background: rgba(255, 255, 255, 0.06);
    color: #dbaa00;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.theme-toggle:hover {
    background: rgba(219, 170, 0, 0.14);
    border-color: rgba(219, 170, 0, 0.75);
    transform: scale(1.08);
}
.theme-toggle svg {
    width: 33px;
    height: 33px;
    pointer-events: none;
}

.icon-sun  { display: block; }
.icon-moon { display: none;  }

.light-mode .icon-sun  { display: none;  }
.light-mode .icon-moon { display: block; }

@media (min-width: 769px) {

    .stem-strip-letter {
        cursor: pointer;
        transition: background 0.35s ease, border-color 0.35s ease,
                    box-shadow 0.35s ease, filter 0.35s ease;
    }

    .stem-strip-letter.stem-active {
        background: linear-gradient(135deg, #0f2d52, #1a4a7a) !important;
        border-color: rgba(219, 170, 0, 0.85) !important;
        box-shadow: 0 0 28px rgba(219, 170, 0, 0.28), inset 0 0 14px rgba(219, 170, 0, 0.07);
    }
    .stem-strip-letter.stem-active .stem-strip-bg {
        opacity: 0.8;
        filter: grayscale(0.2) brightness(2.2);
    }
    .stem-strip-letter.stem-active .stem-strip-char {
        text-shadow: 0 0 18px rgba(219, 170, 0, 0.6);
    }

    /* Dimmed tiles: blur + darken in place, no layout change */
    .stem-strip-letter.stem-dimmed {
        filter: blur(2px) brightness(0.35) saturate(0.3);
        pointer-events: none;
    }

    /* Keep full text visible when a letter is active */
    .stem-strip-letter[data-cat="s"].stem-active .stem-strip-char::after { width: 6.2ch; }
    .stem-strip-letter[data-cat="t"].stem-active .stem-strip-char::after { width: 9.4ch; }
    .stem-strip-letter[data-cat="e"].stem-active .stem-strip-char::after { width: 10.4ch; }
    .stem-strip-letter[data-cat="m"].stem-active .stem-strip-char::after { width: 3.2ch; }

    /* Games columns: blur + darken dimmed, no layout change */
    .games-col {
        transition: filter 0.4s ease;
    }
    .games-col.stem-active {
        filter: none;
    }
    .games-col.stem-dimmed {
        filter: blur(3px) brightness(0.28) saturate(0.25);
        pointer-events: none;
    }
}

.light-mode,
.light-mode html {
    background-color: #e8eef5;
}
.light-mode body {
    background-color: #e8eef5;
    color: #071828;
}

@media (min-width: 769px) {
    .light-mode html {
        background-color: #e8eef5;
    }

    .light-mode .hero-title  { color: #0f2d52; }
    .light-mode .hero-subtitle { color: rgba(7, 24, 40, 0.65); }
    .light-mode .about-btn {
        color: #0f2d52;
        border-color: #0f2d52;
    }
    .light-mode .about-btn:hover {
        background: #0f2d52;
        color: #e8eef5;
    }
    .light-mode .scroll-hint { color: rgba(7, 24, 40, 0.3); }

    .light-mode .stem-strip {
        background: #e8eef5;
    }
    .light-mode .stem-strip-letter {
        background: linear-gradient(135deg, #d0dce8, #baced8);
        border-color: rgba(15, 45, 82, 0.25);
    }
    .light-mode .stem-strip-letter:hover {
        background: linear-gradient(135deg, #baced8, #a8c0d0);
    }
    .light-mode .stem-strip-letter.stem-active {
        background: linear-gradient(135deg, #a8c0d0, #8fb4c8) !important;
        border-color: rgba(15, 45, 82, 0.65) !important;
        box-shadow: 0 0 28px rgba(15, 45, 82, 0.2), inset 0 0 14px rgba(15, 45, 82, 0.05);
    }
    .light-mode .stem-strip-letter.stem-active .stem-strip-char {
        text-shadow: 0 0 18px rgba(15, 45, 82, 0.4);
    }
    .light-mode .stem-strip-char { color: #0f2d52; }
    .light-mode .stem-strip-bg {
        filter: grayscale(0.5) brightness(0.8);
        opacity: 0.4;
    }

    /* Games section */
    .light-mode .games-section { background: #e8eef5; }
    .light-mode .desktop-card {
        background: transparent;
        border: none;
        color: #071828;
    }
    .light-mode .desktop-card:hover .dc-img-wrapper {
        border-color: rgba(15, 45, 82, 0.65);
    }
    .light-mode .dc-img-wrapper {
        border-color: rgba(15, 45, 82, 0.25);
        background: rgba(15, 45, 82, 0.06);
    }
    .light-mode .dc-author { color: #0f2d52; }
    .light-mode .dc-placeholder {
        background-color: rgba(15, 45, 82, 0.08);
        border-color: rgba(15, 45, 82, 0.2);
        color: rgba(7, 24, 40, 0.35);
    }

}

.light-mode .theme-toggle {
    border-color: rgba(15, 45, 82, 0.45);
    background: rgba(15, 45, 82, 0.06);
    color: #0f2d52;
}
.light-mode .theme-toggle:hover {
    background: rgba(15, 45, 82, 0.14);
    border-color: rgba(15, 45, 82, 0.75);
}

/* Mobile info popup */
.mobile-info-popup {
    position: absolute;
    z-index: 9999;
    width: 220px;
    padding: 12px 14px;
    background: #071828;
    color: #ffffff;
    border: 1px solid rgba(219, 170, 0, 0.55);
    border-radius: 8px;
    font-family: 'PixelPurl', 'Segoe UI', system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}
.light-mode .mobile-info-popup {
    background: #ffffff;
    color: #071828;
    border-color: rgba(15, 45, 82, 0.45);
}
