:root {
    --void-bg: #070E15;      /* project pages' background: the colour the wipe covers the screen with */
    --desk-bg: #F4F0EB;      /* 3D scene background */
    --neon-green: #CCFF00;
    --pure-black: #000000;
    --pure-white: #FFFFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background-color: var(--desk-bg);
    user-select: none;
}

#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
}

#canvas-container canvas {
    display: block;
    touch-action: none;   /* drag-to-orbit works with touch too */
}

#canvas-container canvas.has-custom-cursor {
    cursor: none !important;
}

body.is-dragging #canvas-container canvas:not(.has-custom-cursor) {
    cursor: grabbing !important;
}

/* --- TOP RIGHT CONTROLS --- */
.toggle-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: stretch;
    gap: 10px;
    z-index: 1000;
}

.toggle-hint {
    background: var(--neon-green);
    color: var(--pure-black);
    border: 3px solid var(--pure-black);
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    box-shadow: 3px 3px 0px var(--pure-black);
    animation: flashHint 0.8s ease-in-out infinite alternate;
    white-space: nowrap;
}

@keyframes flashHint {
    0%   { opacity: 1;   transform: scale(1); }
    100% { opacity: 0.3; transform: scale(0.95); }
}

.mode-toggle-btn {
    display: inline-flex;
    align-items: center;
    background: var(--pure-white);
    color: var(--pure-black);
    border: 3px solid var(--pure-black);
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    text-decoration: none;
    box-shadow: 4px 4px 0px var(--pure-black);
    cursor: pointer;
    transition: all 0.1s ease;
}

.mode-toggle-btn:hover {
    background: var(--neon-green);
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px var(--pure-black);
}

.mode-toggle-btn:active {
    transform: translateY(2px);
    box-shadow: 2px 2px 0px var(--pure-black);
}

.switch-btn span {
    display: inline-block;
    min-width: 2.2em;
    margin-left: 4px;
    padding: 0 4px;
    background: var(--neon-green);
    border: 2px solid var(--pure-black);
    text-align: center;
}

.switch-btn[aria-pressed="false"] span {
    background: #DDD;
}

/* --- PROJECT PINS ---
   The <button> is positioned by app.js (transform); the .pin-face inside
   carries the look, so hover/pop-in/bob animations don't fight the positioning. */
.project-pin {
    position: absolute;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    z-index: 10;
    will-change: transform;
}

.project-pin[hidden] {
    display: none;
}

.pin-face {
    position: absolute;
    inset: 0;
    background: var(--pure-white);
    border: 2px solid var(--pure-black);
    color: var(--pure-black);
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    animation: pinBob 2.6s ease-in-out infinite;
}

/* `translate` is separate from `transform`, so bobbing stacks with the hover nudge */
@keyframes pinBob {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -5px; }
}

.pin-face::after {
    content: '➔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(calc(-50% - 1px), calc(-50% - 1px));
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
}

/* Hovering the pin OR its object lights both up */
.project-pin:hover .pin-face,
.project-pin:focus-visible .pin-face,
.project-pin.is-active .pin-face {
    background: var(--neon-green);
    box-shadow: 3px 3px 0px var(--pure-black);
    transform: translate(-2px, -2px);
    animation-play-state: paused;
}

.project-pin:active .pin-face {
    transform: translate(1px, 1px);
    box-shadow: 0 0 0 var(--pure-black);
}

.project-pin.is-soon .pin-face {
    border-style: dashed;
    background: #E6E6E6;
}

.project-pin.is-soon .pin-face::after {
    content: '…';
    transform: translate(-50%, -60%);
}

.project-pin:focus-visible,
.mode-toggle-btn:focus-visible {
    outline: 3px solid var(--pure-black);
    outline-offset: 3px;
}

/* --- HOVER LABEL --- */
.hover-label {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: var(--pure-white);
    border: 3px solid var(--pure-black);
    box-shadow: 5px 5px 0px var(--neon-green);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.hover-label.is-visible {
    opacity: 1;
}

.hover-label strong {
    font-size: 14px;
    font-weight: 900;
    line-height: 1.1;
    text-transform: uppercase;
}

.hover-label span {
    font-size: 12px;
    font-weight: 700;
    color: #444;
}

@media (hover: none) {
    .hover-label { display: none; }
}

/* --- CUSTOM CURSOR --- */
.cursor-dot,
.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.cursor-dot.is-visible,
.cursor-ring.is-visible {
    opacity: 1;
}

.cursor-dot {
    z-index: 42;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    background: var(--pure-white);
    box-shadow: 0 0 0 1.5px var(--pure-black);
    border-radius: 50%;
}

.cursor-ring {
    z-index: 41;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 2px solid var(--pure-white);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--pure-white);
    font-size: 16px;
    font-weight: 900;
    transition: opacity 0.15s ease, width 0.2s ease, height 0.2s ease, margin 0.2s ease,
                background-color 0.2s ease, border-radius 0.2s ease, border-width 0.2s ease;
}

/* the project/drag rings sit on bright fills (neon green, white), so keep their
   glyph dark for contrast regardless of the white default above */
.cursor-ring.is-project,
.cursor-ring.is-drag {
    border-color: var(--pure-black);
    color: var(--pure-black);
}

/* over a project: big neon ring with an arrow */
.cursor-ring.is-project {
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-width: 3px;
    background: rgba(204, 255, 0, 0.55);
}

.cursor-ring.is-project::after {
    content: '➔';
}

/* when the ring shows an icon, hide the dot so it doesn't cover it */
.cursor-ring.is-project ~ .cursor-dot,
.cursor-ring.is-drag ~ .cursor-dot {
    opacity: 0;
}

/* over something you can poke */
.cursor-ring.is-poke {
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-style: dashed;
}

/* dragging the camera */
.cursor-ring.is-drag {
    width: 58px;
    height: 34px;
    margin: -17px 0 0 -29px;
    border-radius: 17px;
    border-width: 3px;
    background: var(--pure-white);
}

.cursor-ring.is-drag::after {
    content: '↔';
    font-size: 18px;
}

/* --- FIRST-VISIT TITLE CARD --- */
.intro-card {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 6vw;
    pointer-events: none;
}

.intro-card[hidden] {
    display: none;
}

.intro-line {
    overflow: hidden;
    padding: 0 10px 10px 0;  /* room for the offset shadow */
    line-height: 0.86;
}

.intro-line span {
    display: inline-block;
    font-size: clamp(4rem, 14vw, 13rem);
    font-weight: 900;
    letter-spacing: -0.04em;
    text-transform: uppercase;
    color: var(--neon-green);
    text-shadow: 6px 6px 0px var(--pure-white);
}

.intro-sub {
    margin-top: 1.5rem;
}

.intro-sub span {
    display: inline-block;
    padding: 8px 14px;
    background: var(--pure-black);
    color: var(--neon-green);
    font-size: clamp(0.8rem, 1.4vw, 1.1rem);
    font-weight: 900;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px var(--pure-white);
}

/* --- CONTROLS GUIDE --- */
.desk-hud {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 25;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    max-width: calc(100vw - 200px);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--neon-green);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.desk-hud.is-visible {
    opacity: 0.85;
}

.desk-hud .key {
    display: inline-block;
    color: var(--pure-black);
    margin-right: 4px;
    padding: 3px 6px;
    background: var(--pure-white);
    border: 2px solid var(--pure-black);
    box-shadow: 2px 2px 0px var(--pure-black);
}

/* --- TOAST (first-visit hint, "coming soon") --- */
.desk-toast {
    position: fixed;
    left: 50%;
    bottom: 64px;
    z-index: 30;
    max-width: calc(100vw - 40px);
    padding: 10px 18px;
    background: var(--pure-black);
    color: var(--pure-white);
    border: 3px solid var(--pure-black);
    box-shadow: 4px 4px 0px var(--neon-green);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.desk-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* --- PAGE WIPE ---
   Six bars drop down with a neon leading edge, covering the screen in the
   same dark colour the project pages fade in from. app.js animates them. */
.wipe {
    position: fixed;
    inset: 0;
    z-index: 450;
    display: flex;
    overflow: hidden;
    pointer-events: none;
}

.wipe i {
    flex: 1;
    height: calc(100% + 18px);
    margin-right: -1px;   /* no hairline gaps between bars */
    background: linear-gradient(to bottom, var(--void-bg) calc(100% - 18px), var(--neon-green) calc(100% - 18px));
    transform: translateY(-101%);
}

.is-returning .wipe i {
    transform: translateY(0);
}

/* --- LOADING SCREEN --- */
.loader {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--desk-bg);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader.is-done {
    opacity: 0;
    visibility: hidden;
}

/* Returning from a project: stay dark, and only show the loading box if loading is slow */
.is-returning .loader {
    background: var(--void-bg);
}

.is-returning .loader-box {
    visibility: hidden;
    animation: showWhenSlow 0s 0.6s forwards;
}

@keyframes showWhenSlow {
    to { visibility: visible; }
}

.loader-box {
    width: min(320px, 80vw);
    background: var(--pure-white);
    border: 3px solid var(--pure-black);
    box-shadow: 6px 6px 0px var(--neon-green);
    padding: 1rem 1.25rem;
    font-weight: 900;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.loader-bar {
    margin-top: 0.75rem;
    height: 14px;
    border: 3px solid var(--pure-black);
    background: var(--pure-white);
    overflow: hidden;
}

#loader-fill {
    width: 0%;
    height: 100%;
    background: var(--neon-green);
    transition: width 0.2s ease;
}

/* When the server doesn't report the file size, show a sliding bar instead */
.loader-bar.is-indeterminate #loader-fill {
    width: 35%;
    animation: loaderSlide 0.9s ease-in-out infinite alternate;
}

@keyframes loaderSlide {
    from { transform: translateX(0); }
    to   { transform: translateX(186%); }
}

.loader.is-error .loader-bar {
    display: none;
}

.noscript-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 600;
    background: var(--pure-white);
    border: 3px solid var(--pure-black);
    padding: 1rem 1.25rem;
    font-weight: 700;
}

/* --- LIGHTS OUT --- */
.night-mask {
    --mx: 50%;
    --my: 60%;
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle at var(--mx) var(--my),
        transparent 0, transparent 140px,
        rgba(7, 14, 21, 0.55) 320px,
        rgba(7, 14, 21, 0.85) 100%);
}

/* pins become glowing beacons in the dark */
.is-night .pin-face {
    box-shadow: 0 0 0 2px var(--neon-green), 0 0 18px rgba(204, 255, 0, 0.75);
}

.is-night .cursor-ring { border-color: var(--pure-white); color: var(--pure-white); }
.is-night .cursor-ring.is-project,
.is-night .cursor-ring.is-drag { border-color: var(--pure-black); color: var(--pure-black); }
.is-night .cursor-dot { background: var(--pure-white); }
.is-night .desk-hud { color: var(--pure-white); }
.is-night .desk-toast { border-color: var(--pure-white); }

/* --- PARTY MODE --- */
.is-party .pin-face {
    animation: pinParty 0.47s ease-in-out infinite alternate;
}

@keyframes pinParty {
    from { translate: 0 0; rotate: -12deg; }
    to   { translate: 0 -10px; rotate: 12deg; }
}

.confetti {
    position: fixed;
    inset: 0;
    z-index: 36;
    overflow: hidden;
    pointer-events: none;
}

.confetti i {
    position: absolute;
    top: -24px;
    width: var(--w);
    height: var(--h);
    background: var(--c);
    border: 2px solid var(--pure-black);
    animation: confettiFall var(--d) cubic-bezier(0.3, 0.2, 0.6, 1) var(--delay) forwards;
}

@keyframes confettiFall {
    to { transform: translate(var(--dx), calc(100vh + 60px)) rotate(var(--rot)); }
}

/* --- POKE COMBOS --- */
.fx-layer {
    position: fixed;
    inset: 0;
    z-index: 35;
    pointer-events: none;
}

.combo-pop {
    position: fixed;
    font-size: calc(30px * var(--s, 1));
    font-weight: 900;
    font-style: italic;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--neon-green);
    -webkit-text-stroke: 5px var(--pure-black);
    paint-order: stroke fill;   /* outline sits behind the fill, so the neon stays bright */
    text-shadow: 4px 4px 0px var(--pure-black);
    transform: translate(-50%, -50%);
    animation: comboPop 0.9s cubic-bezier(0.2, 1.2, 0.4, 1) forwards;
}

.combo-pop.is-big {
    color: var(--pure-white);
    text-shadow: 4px 4px 0px var(--pure-black), 8px 8px 0px var(--neon-green);
}

@keyframes comboPop {
    0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.3) rotate(var(--r)); }
    15%  { opacity: 1; transform: translate(-50%, -100%) scale(1.25) rotate(var(--r)); }
    30%  { opacity: 1; transform: translate(-50%, -110%) scale(1) rotate(var(--r)); }
    70%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -230%) scale(0.95) rotate(var(--r)); }
}

/* --- SECRETS --- */
.achievement {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 40px);
    padding: 12px 18px 12px 12px;
    background: var(--pure-black);
    color: var(--pure-white);
    border: 3px solid var(--pure-white);
    box-shadow: 6px 6px 0px var(--neon-green);
    transform: translateX(calc(-100% - 40px));
    transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.2);
    pointer-events: none;
}

.achievement.is-visible {
    transform: none;
}

.achievement-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--neon-green);
    color: var(--pure-black);
    border: 3px solid var(--pure-white);
    font-size: 22px;
}

.achievement small {
    display: block;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--neon-green);
}

.achievement strong {
    display: block;
    font-size: 16px;
    font-weight: 900;
    text-transform: uppercase;
}

.achievement-desc {
    font-size: 12px;
    color: #CCC;
}

.trophy-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    padding: 8px 12px;
    background: var(--pure-white);
    color: var(--pure-black);
    border: 3px solid var(--pure-black);
    box-shadow: 4px 4px 0px var(--pure-black);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.trophy-btn span {
    margin-left: 4px;
    padding: 0 5px;
    background: var(--neon-green);
    border: 2px solid var(--pure-black);
}

.trophy-btn:hover {
    background: var(--neon-green);
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px var(--pure-black);
}

.trophy-btn:focus-visible {
    outline: 3px solid var(--pure-black);
    outline-offset: 3px;
}

.trophy-btn.is-bump {
    animation: trophyBump 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes trophyBump {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.25) rotate(-4deg); }
    100% { transform: scale(1); }
}
#sound-toggle, #lights-toggle { display: none; }

.trophy-dialog {
    margin: auto;
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    padding: 1.5rem;
    background: var(--pure-white);
    color: var(--pure-black);
    border: 4px solid var(--pure-black);
    box-shadow: 12px 12px 0px var(--neon-green);
    font-family: 'Inter', sans-serif;
    user-select: text;
}

.trophy-dialog::backdrop {
    background: rgba(7, 14, 21, 0.7);
}

.trophy-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 4px solid var(--pure-black);
}

.trophy-head h2 {
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1;
}

.trophy-head p {
    margin-top: 0.3rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: #555;
}

.trophy-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trophy-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 3px dashed #BBB;
    color: #666;
}

.trophy-list li.is-done {
    border: 3px solid var(--pure-black);
    box-shadow: 4px 4px 0px var(--neon-green);
    color: var(--pure-black);
}

.trophy-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: #E6E6E6;
    border: 2px solid var(--pure-black);
    font-weight: 900;
}

.is-done .trophy-icon {
    background: var(--neon-green);
}

.trophy-list strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 900;
    text-transform: uppercase;
}

.trophy-list span {
    font-size: 0.8rem;
    font-weight: 500;
}

/* --- SECRETS UI: hidden for now (tracking in app.js is untouched) --- */
.achievement,
.trophy-btn {
    display: none !important;
}

/* --- SMALL SCREENS --- */
@media (max-width: 700px) {
    .toggle-hint { display: none; }
    .toggle-container { top: 12px; right: 12px; gap: 8px; }
    .mode-toggle-btn { padding: 7px 10px; font-size: 11px; }
    .desk-hud { left: 12px; bottom: 12px; font-size: 10px; max-width: calc(100vw - 150px); }
    .trophy-btn { right: 12px; bottom: 12px; }
    .achievement { top: 64px; left: 12px; }
    .desk-toast { bottom: 96px; }
}

/* --- REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
    .toggle-hint,
    .pin-face,
    .is-party .pin-face,
    .trophy-btn.is-bump,
    .loader-bar.is-indeterminate #loader-fill {
        animation: none;
    }
    .pin-face,
    .mode-toggle-btn,
    .loader,
    .desk-toast,
    .cursor-ring,
    #loader-fill {
        transition: none;
    }
}
