/*
====================================
     GLOBAL & ROOT STYLES
====================================
*/

:root {
    /* colors */
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #0f1720;
    --muted: #6b6b6b;
    --accent-pink: #E91E63;
    --primary: #3a5fa0;
    --text-light: whitesmoke;
    --bg-light: whitesmoke;

    /* fonts */
    --font-sans: "Helvetica Neue", Arial, sans-serif;
    --font-heading: "helvetica-lt-pro", "Helvetica Neue", Arial, sans-serif;
    --font-german-heading: "cofo-raffine", sans-serif;
    --font-mono: SFMono-Regular, Menlo, monospace;

    /* sizes */
    --fs-base: 16px;
    --fs-sm: 14px;
    --fs-lg: 20px;

    --h1-size: 3rem;
    --h2-size: 2rem;
    --max-width: 1200px;

    /* spacing & layout */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;

    /* border */
    --border-radius-sm: 4px;
    --border-radius-md: 12px;
    --border-radius-pill: 20px;
    /* For buttons */
    --nav-height: 80px;
}

/* Base Reset & Box Sizing */
html {
    font-size: var(--fs-base);
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

/* Body & Typography Defaults */
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: calc(var(--nav-height) + var(--spacing-sm));
    overflow-x: hidden;
    min-height: 100vh;

    /* Background gradient + vintage dotted texture */
    background:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.08) 1px, transparent 0),
        linear-gradient(to bottom, #ffffff, #f5f5f5, #e8e8e8);
    background-size: 3px 3px, 100% 100%;
    background-blend-mode: overlay;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 var(--spacing-xs) 0;
    font-weight: 700;
    color: var(--text);
    line-height: 1.05;
}

h1 {
    font-family: var(--font-heading);
    font-size: var(--h1-size);
    color: var(--surface);
}

h2 {
    font-family: var(--font-heading);
    font-size: var(--h2-size);
}

p {
    font-size: 1.05rem;
    line-height: 1.5;
    font-family: "helvetica-neue-lt-pro", sans-serif;
    font-weight: 300;
    font-style: italic;
    color: var(--text-light);
}

.title {
    font-size: 14rem;
}

/* Utility Classes */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
}

.title-german {
    font-family: var(--font-german-heading);
    font-weight: 900;
    font-size: 1.6rem;
    color: var(--accent-pink);
    margin: 0 0 0.25rem 0;
    line-height: 1;
    letter-spacing: .02em;
    text-align: center;
    text-transform: none;
}

.sub-title {
    font-size: 5rem;
    font-family: var(--font-german-heading);
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 0.25rem;
}

#white-text {
    color: var(--text-light);
}

.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.page {
    width: 100%;
    min-height: 100vh;
    display: block;
    padding: var(--spacing-lg) var(--spacing-sm);
    box-sizing: border-box;
}

/* CTA Button Styling */
.cta-button {
    display: inline-block;
    color: var(--text-light);
    text-decoration: none;
    padding: 8px 16px;
    border: 2px solid var(--accent-pink);
    border-radius: var(--border-radius-pill);
    transition: background-color 0.3s ease, transform 0.3s ease;
    font-family: var(--font-heading);
    font-size: var(--spacing-sm);
    cursor: pointer;
    background: var(--accent-pink);
}

.cta-button:hover {
    background-color: #c2185b;
    transform: translateY(-2px);
}

#white-outline {
    border-color: var(--text-light);
    color: var(--text-light);
    background: transparent;
}

#white-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/*
====================================
    1. PAGE INTRO (#page-intro)
====================================
*/
#page-intro .section1 {
    padding-top: 0;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: min(120vh, 1000px);
    grid-template-areas: "stack";
    place-items: end center;
    position: relative;
    overflow: visible;
    width: 100%;
    gap: 0;
    isolation: isolate;
}

/* All direct children are layered on top of each other */
.hero-grid>* {
    grid-area: stack;
    justify-self: center;
}


.moon,
.mountain_picture {
    position: relative;
    will-change: transform, opacity;
}

.title-german {
    font-size: 2.6rem;
    color: var(--accent-pink);
    position: relative;
    z-index: 60;
}

.introduction {
    position: relative;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    text-align: justify;
}

.text-wrapper {
    position: relative;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    max-width: 900px;
    padding: var(--spacing-sm);
    transform: translateY(-8vh);
}

/* Explicit Z-Index Stacking */
.moon {
    z-index: 15;
}

.mountain_picture {
    z-index: 30;
}

/* Main mountain on top of some layers */

.clouds-back,
.clouds-front {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(1200px, 95%);
    pointer-events: none;
    will-change: transform;
}

.clouds-back {
    top: 8vh;
    z-index: 12;
    opacity: 0.95;
}

.clouds-front {
    top: 16vh;
    z-index: 35;
    opacity: 0.92;
}


.compas {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 100px;
    max-width: 30%;
    pointer-events: auto;
    z-index: 80;
    /* UI element always on top */
    opacity: 0.9;
    transition: transform 360ms cubic-bezier(.2, .8, .2, 1), opacity 180ms ease;
    will-change: transform, opacity;
}

.compas:hover,
.compas:focus {
    transform: translate(-50%, -50%) translateX(8px) translateY(-6px) rotate(6deg) scale(1.06);
    opacity: 1;
}

/* Section 2 (Memories) */
.section2 {
    background-color: var(--accent-pink);
}

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
    max-width: 900px;
    margin: 0 auto;
}

.sub-title-black {
    font-size: 3rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-dark);

}

.polaroid-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    max-width: 1000px;
    margin: var(--spacing-lg) auto;
    padding: var(--spacing-lg);
}

.polaroid {
    background: var(--surface);
    padding: var(--spacing-sm);
    padding-bottom: 2.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    transform: rotate(0deg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.polaroid:nth-child(1) {
    transform: rotate(-2deg);
}

.polaroid:nth-child(2) {
    transform: rotate(1deg);
}

.polaroid:nth-child(3) {
    transform: rotate(-1deg);
}

.polaroid:nth-child(4) {
    transform: rotate(1deg);
}

.polaroid:nth-child(5) {
    transform: rotate(-2deg);
}

.polaroid:nth-child(6) {
    transform: rotate(1deg);
}

.polaroid:nth-child(9) {
    transform: rotate(-1deg);
}

.polaroid:nth-child(8) {
    transform: rotate(1deg);
}

.polaroid:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), 0 6px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.polaroid img {
    width: 100%;
    height: fit-content;
    object-fit: cover;
    display: block;
}

/*
====================================
    2. BACKPACK DRAGGING (#page-backpack)
====================================
*/

#page-backpack .container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: var(--spacing-lg);
    justify-items: center;
    min-height: 100vh;
    padding: 0;
}

#page-backpack .header {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    justify-items: center;
    padding: var(--spacing-lg);
    width: 100%;
    align-items: center;
}

/* main game area becomes a big grid that fills the remaining viewport */
.game-area {
    display: grid;
    grid-template-columns: 1fr 420px;
    grid-template-rows: 1fr;
    gap: var(--spacing-lg);
    align-items: start;
    justify-items: center;
    padding: 0 var(--spacing-lg) var(--spacing-lg) var(--spacing-lg);
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    position: relative;
}

/* items container (left side) */
.items-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6rem;
    align-items: center;
    justify-items: center;
    width: fit-content;
}

.box {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transform: scale(4);
}

.box img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Right Side Column */
.side-column {
    grid-column: 2 / 3;
    display: grid;
    grid-template-columns: 1fr;
    /* Stack elements vertically */
    grid-template-rows: auto auto 1fr;
    gap: var(--spacing-md);
    align-items: center;
    justify-items: center;
    padding-top: var(--spacing-sm);
    position: relative;
    height: 100%;
}

.backpack {
    grid-column: 1 / 2;
    grid-row: auto;
    /* Allow to flow */
    justify-self: center;
    align-self: end;
    /* Anchor to the bottom of the column */
}

.backpack-img {
    width: 220px;
    height: auto;
    pointer-events: none;
    transform: scale(2);
}

/* Feedback/Success Messages */
.feedback-container {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    align-items: center;
    justify-content: end;
    position: relative;
}

/* Feedback text - Positioned absolutely in the middle of the page */
.feedback-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-light);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    max-width: 400px;
    text-align: center;
    z-index: 9999;
    font-size: 1.05rem;
    color: #333;
    pointer-events: none;
}

.success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary);
    color: var(--text-light);
    padding: var(--spacing-lg) 3rem;
    border-radius: var(--border-radius-md);
    opacity: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: center;
    z-index: 10000;
    max-width: 500px;
}



.correct-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid var(--accent-pink);
    color: var(--accent-pink);
    padding: 6px 40px;
    border-radius: 18px;
    font-weight: 700;
    font-size: 5rem;
    font-family: inherit;
    pointer-events: none;
    min-width: 36px;
    text-align: center;
    margin: var(--spacing-xs) 0;
    z-index: 40;
}

/*
====================================
    3. CLIMBING WALK (#page-climb)
====================================
*/

#page-climb {
    margin: 0;

    background-size: cover;
    background-repeat: no-repeat;
    font-family: var(--font-mono);
    position: relative;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

.page-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

.climb-wrap {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-sm);
    display: grid;
    grid-template-columns: 300px 1fr;
    grid-template-rows: auto auto 1fr;
    /* Added 4th row for path area */
    gap: var(--spacing-md);
    height: calc(100vh - 4rem);
    max-height: calc(100vh - 4rem);
    z-index: 2;
}

/* Grid cell assignments */
.page-climb.header {
    grid-row: 1;
    grid-column: 1 / 3;
    text-align: center;
}

.start-webcam-btn {
    grid-row: 2;
    grid-column: 1 / 3;
    justify-self: center;
    width: fit-content;
}

.left-panel {
    grid-column: 1 / 2;
    grid-row: 1 / 4;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.instruction {
    background-color: rgba(58, 95, 160, 0.7);
    color: var(--text-light);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    text-align: center;
    font-size: 1.05rem;
    position: relative;
    z-index: 2;
}

/* place the instruction box in flow */
.action-description {
    position: relative;
    font-size: 1.05rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 5px;
    z-index: 2;
}

/* path-area is an overlay */
.path-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: visible;
    z-index: 1;
    pointer-events: none;
}

.path-area svg {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

.path-area svg path {
    fill: none;
    stroke: var(--text);
    stroke-width: 7;
    stroke-dasharray: 10, 10;
    stroke-linecap: round;
}

/* shoeprint: relative to #page-climb */
#shoeprint {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: block;
    width: 120px;
}

#shoeprint img {
    width: 100%;
    height: auto;
    display: block;
    transform: scale(1.5);
}


.debug-info {
    position: relative;
    background: rgba(0, 0, 0, 0.7);
    max-width: 300px;
    color: var(--text-light);
    padding: 12px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 3;
    font-family: var(--font-mono);
    margin-left: auto;
    margin-right: auto;
}

/* Webcam canvas (p5 canvas) */
#defaultCanvas0 {
    z-index: 10;
    position: relative;
}

/* Camera error overlay */
.camera-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.text-black {
    color: var(--text);
}

.camera-error-message {
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: 15px;
    max-width: 500px;
    text-align: center;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.camera-error-message h2 {
    font-size: 1.3rem;
    margin: 0;
    color: var(--accent-pink);
}

.cow-head {
    transform: scale(0.6);
}

/*
====================================
    4. STORM PROTECTION (#page-storm)
====================================
*/

#page-storm {
    position: relative;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    padding-top: var(--nav-height);
}

/* Start button styling */
#page-storm>.cta-button {
    position: relative;
    z-index: 10;
    margin: var(--spacing-lg) auto;
    display: block;
    width: fit-content;
}

/* Background videos */
.bgvideo,
.bgvideo2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transition: opacity 2s ease;
}

/* Storm hidden at start, sunny visible */
.bgvideo {
    opacity: 0;
}

.bgvideo2 {
    opacity: 1;
}

/* Header styling */
#page-storm .header {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: var(--spacing-lg);
    margin: var(--spacing-md) auto;
}

/* Title text */
#page-storm .header h1 {
    /* Targeted to avoid collision with .hero-title */
    font-size: 2.5rem;
    font-weight: 700;
    padding-bottom: var(--spacing-sm);
    color: var(--text-light);
}

#page-storm .header p {
    margin: var(--spacing-xs) 0;
    line-height: 1.6;
}

/* Webcam container positioned in top right */
#webcam-container {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    width: 300px;
    height: 300px;
    z-index: 10;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Webcam canvas styling */
#webcam-container canvas {
    border-radius: 15px;
    width: 100% !important;
    height: 100% !important;
}


#page-storm .instruction {
    position: relative;
    z-index: 10;
    color: var(--text-light);
    text-align: center;
    margin-top: 10vh;
}

/* Storm warning instruction */
.instruction-storm {
    position: relative;
    z-index: 10;
    text-align: center;
    display: none;
    background-color: rgba(255, 140, 0, 0.9);
    color: var(--text);
    font-weight: 600;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-md);
    max-width: 500px;
    line-height: 1.4;
    margin: var(--spacing-md) auto;
}

/* Storm countdown overlay */
.storm-countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    pointer-events: none;
}

.countdown-display {
    font-size: 6rem;
    font-weight: bold;
    color: var(--accent-pink);
    animation: pulse-countdown 1s infinite;
}

@keyframes pulse-countdown {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/*
====================================
    5. SUMMIT (#page-summit)
====================================
*/
#page-summit {
    background-color: var(--accent-pink);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) 0 0 0;
    gap: var(--spacing-md);
}

#page-summit .sub-title {
    color: var(--text-light);
    font-size: 4rem;
}


.sub-title-black {
    color: var(--text);
}

#page-summit p {
    font-size: 1.2rem;
}

.image-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    width: 100%;
}

.top-image {
    width: 100vw;
    height: auto;
    object-fit: cover;
    margin: 0;
    display: block;
}

.bells-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.center-block {
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.section img {
    width: 100%;
    margin: 0 auto;
    height: auto;
}

.sub-title_description {
    padding: 1.5rem;
}

/* ensure no accidental transforms create new stacking contexts */
.mountain_picture img,
.mountain-element2 img,
.cow img,
.clouds-back img,
.clouds-front img {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform, opacity;
}