/* ── DWS Storytelling – Frontend Styles ─────────────────────────────────────── */
:root{
    --var-orange: #FF5D00;
}

/* ── Scene container ────────────────────────────────────────────────────────── */
.dws-storytelling {
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

.dws-scene {
    position: relative;
    width: 100%;
    overflow: hidden; /* JS keeps labels/popups within scene bounds */
}

/* ── Background ─────────────────────────────────────────────────────────────── */
.dws-bg {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

/* ── Route SVG overlay ──────────────────────────────────────────────────────── */
/* preserveAspectRatio="none" is set in PHP so it fills exactly */
.dws-route-svg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none;
    overflow: visible;
}

/* ── Hiker ──────────────────────────────────────────────────────────────────── */
#dws-hiker {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
    will-change: transform;
}

.dws-hiker-inner {
    width: 50px;
    height: 70px;
    display: block;
    transform-origin: 50% 100%;
}

.dws-hiker-inner .dws-hiker-svg,
.dws-hiker-inner .dws-hiker-default {
    width: 100%;
    height: 100%;
}

.dws-hiker-inner .dws-hiker-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Walking bob animation — on inner element, doesn't conflict with GSAP on outer */
@keyframes dws-walk-bob {
    0%, 100% { margin-top: 0; }
    50%       { margin-top: -4px; }
}

#dws-hiker.dws-walking .dws-hiker-inner {
    animation: dws-walk-bob 0.35s ease-in-out infinite;
}

/* Mirror hiker when walking toward lower path progress (backward) */
#dws-hiker.dws-hiker--backward .dws-hiker-inner {
    transform: scaleX(-1);
}

/* ── Station anchor (zero-size, positioned by JS) ───────────────────────────── */
.dws-station {
    position: absolute;
    width: 0;
    height: 0;
    z-index: auto; /* no stacking context – children compete on scene level */
    /* left/top are set by JS */
}

/* ── Station marker (numbered circle) ──────────────────────────────────────── */
.dws-station-marker {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Offset so the marker is centered on the anchor point */
    width: 2em;
    height: 2em;
    top: -1em;
    left: -1em;

    border-radius: 50%;
    background-color: white;
    color: var(--var-orange);
    border: 3px solid var(--var-orange);
    box-shadow: 0 2px 10px rgba(2, 30, 80, 0.35);

    font-family: 'Fira Sans Condensed', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 2em;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;

    z-index: 30; /* above hiker (10) on scene level */
}

.dws-station-marker:hover {
    background-color: var(--var-orange, #bab94D);
    transform: scale(1.2);
    box-shadow: 0 4px 16px rgba(2, 30, 80, 0.4);
}

.dws-station-marker[aria-expanded="true"] {
    background-color: var(--var-orange, #bab94D);
    transform: scale(1.1);
    color: white;
}

.dws-station-marker:active, .dws-station-marker:focus{
    background-color: white !important;    
    color: var(--var-orange) !important;
    border: 3px solid var(--var-orange) !important;
    outline: none;
    position: inherit !important;
}

/* ── Station label (always visible title badge) ───────────────────────────── */
.dws-station-label {
    position: absolute;
    /* Position set dynamically by JS – stays within scene bounds */
    left: 0;
    top: 0;
    transform: none;

    /*white-space: nowrap;*/
    background-color:var(--var-orange);
    
    border-radius: 0;
    padding: 5px 40px;
    width: max-content;
    max-width: 300px;

    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    color: white;
    font-weight: 700;

    pointer-events: none;
    z-index: 25; /* above hiker (10), below marker (30) on scene level */
    /*box-shadow: 0 1px 5px rgba(2, 30, 80, 0.12);*/
}

/* Hide label when popup is open (popup title takes over) */
.dws-station-marker[aria-expanded="true"] ~ .dws-station-label {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    .dws-station-label {
        font-size: 1.0rem;
        padding: 2px 7px;
        left: 20px;
    }
}

/* ── Popup ──────────────────────────────────────────────────────────────────── */

/* Default: hidden. Never use the HTML `hidden` attribute for popups —
   some themes override [hidden] to display:block. */
.dws-station-popup {
    display: none;

    position: absolute;
    /* Position set dynamically by JS – stays within scene bounds */
    top: 0;
    left: 0;
    bottom: auto;

    /* Reliable width: auto sizes to content, floors at min-width */
    width: auto;
    min-width: 240px;
    max-width: 520px;

    /*background: #ffffff;*/
    border-radius: 0px; 
    
    /*box-shadow: 0 8px 36px rgba(2, 30, 80, 0.18), 0 2px 8px rgba(2, 30, 80, 0.1);*/
    padding: 10px 10px 10px;

    z-index: 100;
    pointer-events: all;
    box-sizing: border-box;
}

/* Visible state — JS adds this class */
.dws-station-popup.is-open {
    display: block;
    animation: dws-popup-in 0.22s ease forwards;
    z-index: 200;
}

@keyframes dws-popup-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Popup: close button */
.dws-popup-close {
    /*position: absolute;*/
    margin-left: 10px;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--var-blau, #021E50);
    opacity: 0.4;
    padding: 4px;
    line-height: 1;
    border-radius: 3px;
    transition: opacity 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dws-popup-close:hover {
    opacity: 1;
    background: rgba(2, 30, 80, 0.06);
}

.dws-popup-close:focus {
    position: inherit !important;
    background-color: transparent !important;
}

/* Popup: station number badge */
.dws-popup-number {
    
    display: inline-flex;
    display:none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--var-blau, #021E50);
    color: var(--var-creme, #f3f0e3);
    font-family: 'Fira Sans Condensed', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}

/* Popup: title */
.dws-popup-title {
    display:flex;
    font-family: 'Outfit';
    width: max-content;
    max-width: 500px;
    padding: 5px 10px;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    background-color: var(--var-orange);
    color:white;
    letter-spacing: 0.02em;
    margin: 0 24px 10px 0; /* right margin leaves space for close button */
    margin-bottom:0;
}

/* Popup: body text */
.dws-popup-content {
    font-family: 'Outfit', sans-serif;
    font-size: var(--var-copytext, 1.4rem);
    font-size: clamp(1.2rem, 1.5vw, 1.6rem);
    line-height: 1.55;
    color: var(--var-orange);
    border:3px solid var(--var-orange);
    background-color:white;
    padding:10px;
}

.dws-popup-content > *:last-child {
    margin-bottom: 0;
}

.dws-popup-content a {
    color: var(--var-blau, #021E50);
    text-underline-offset: 2px;
}

.dws-popup-content a:hover {
    color: var(--var-laub, #bab94D);
}

/* ── Responsive tweaks ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dws-hiker-inner {
        width: 36px;
        height: 50px;
    }

    .dws-station-marker {
        width: 30px;
        height: 30px;
        top: -15px;
        left: -15px;
        font-size: 1.2rem;
    }

    .dws-station-popup {
        min-width: 180px;
        max-width: 260px;
        padding: 14px 14px 12px;
    }
}

@media (max-width: 480px) {
    .dws-station-popup {
        max-width: 220px;
    }
}



/* ── Mobile story list [dws_storytelling_mobile] ─────────────────────────── */
/* Hidden on desktop, shown only on mobile. No JS or SVG required.            */

.dws-mobile-story {
    display: none; /* hidden until the mobile breakpoint */
}


/* Hide the animated mountain version on mobile */
@media (max-width: 767px) {
    .dws-storytelling {
        display: none;
    }
}

@media (max-width: 767px) {
    .dws-mobile-story {
        display: block;
        padding: 0;
        margin: 0;
    }

    .dws-mobile-station {
        display: flex;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.2rem 0;
        border-bottom: 1px solid rgba(2, 30, 80, 0.12);
    }

    .dws-mobile-station:last-child {
        border-bottom: none;
    }

    .dws-mobile-num {
        line-height: 1em;
        font-family: 'Fira Sans Condensed', sans-serif;
        font-weight: 700;
        font-size: 3.4rem;
        color: white;
        background-color: #EE5203;
        border-radius: 50%;
        aspect-ratio: 1 / 1;
        width: 1em;
        flex-shrink: 0;
        height: 1em;
        display: flex;
        flex-direction: row;
        align-content: center;
        justify-content: center;
        align-items: center;
        top: 10px;
        transform: translateY(5px);
    }

    .dws-mobile-info {
        flex: 1 1 auto;
        padding-top: 0.15em; /* align text baseline with the number */
    }

    .dws-mobile-title {
        font-family: 'Fira Sans Condensed', sans-serif;
        font-size: 3rem;
        font-weight: 700;
        color: var(--var-blau, #021E50);
        margin: 0 0 0.35rem 0;
    }

    .dws-mobile-text {
        font-size: 2rem;
        line-height: 1.55;
    }

    .dws-mobile-text p:first-child { margin-top: 0; }
    .dws-mobile-text p:last-child  { margin-bottom: 0; }
}
