/**
 * Tydrys Panorama Viewer Styles
 * Cross-device compatible (iOS Safari + Android Chrome + tablets)
 */

/* ===== Base reset for touch devices ===== */
*,
*::before,
*::after {
    -webkit-tap-highlight-color: transparent;
}

/* ===== Marker content panel (hotspot info popup) ===== */
.psv-marker-content {
    max-width: 400px;
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overscroll-behavior: contain;
}

.psv-marker-content img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 4px;
    margin: 8px 0;
}

.psv-marker-content .clip_frame {
    max-width: 100%;
    overflow: hidden;
}

/* Hide broken images (relative paths from old Muse export) */
.psv-marker-content img[src^="images/"] {
    display: none;
}

.psv-marker-content h1 {
    font-size: 1.2em;
    margin: 0 0 10px 0;
    color: #468c94;
}

.psv-marker-content p {
    font-size: 14px;
    line-height: 1.5;
    margin: 5px 0;
}

/* ===== Map custom button ===== */
.psv-map .map-custom-btn {
    display: none;
}

.psv-map.psv-map--maximized .map-custom-btn {
    display: block;
}

.map-custom-btn {
    position: absolute;
    cursor: pointer;
    width: 150px !important;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    min-height: 44px; /* touch target */
}

/* ===== Time period transitions ===== */
.time-period-1,
.time-period-2 {
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.time-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.opacity-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Timeline container ===== */
.timeline-container.active {
    opacity: 1;
    pointer-events: auto;
}

.timeline-container.inactive {
    opacity: 0;
    pointer-events: none;
}

.psv-custom-button custom-slider {
    display: block !important;
}

.psv-custom-button {
    width: 75%;
    display: block !important;
}

.psv--has-navbar .psv-map--bottom-left {
    top: 25px !important;
}

/* Timeline labels */
.timeline-container {
    position: relative;
    width: 100%;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    position: absolute;
    top: -50px;
    width: 100%;
}

.timeline-label {
    width: fit-content;
    font-size: 12px;
    font-weight: bold;
    background: #468c94;
    padding: 10px;
    border-radius: 3px;
}

/* ===== Fullscreen overlay (mobile only) ===== */
@media screen and (min-width: 765px) {
    #fullscreen-overlay {
        display: none !important;
    }
}

#fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.4) !important;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#fullscreen-overlay p {
    font-size: 18px;
    margin-bottom: 20px;
    text-align: center;
}

#fullscreen-overlay .psv-fullscreen-prompt,
.psv-fullscreen-prompt-single {
    font-size: 16px;
    color: #00bcd4;
    text-decoration: underline;
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* ===== Opacity slider (cross-browser) ===== */
.opacity-slider {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    background: #fff;
    border-radius: 5px;
    outline: none;
    border: none;
    touch-action: manipulation;
}

.opacity-slider::-webkit-slider-runnable-track {
    background: #468C94;
    height: 10px;
    border-radius: 5px;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 24px;
    width: 24px;
    margin-top: -7px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

.opacity-slider::-moz-range-track {
    background: #468C94;
    height: 10px;
    border-radius: 5px;
}

.opacity-slider::-moz-range-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

.opacity-slider::-ms-track {
    background: #468C94;
    height: 10px;
    border-radius: 5px;
    border-color: transparent;
    color: transparent;
}

.opacity-slider::-ms-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

/* ===== Start overlay ===== */
#start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    z-index: 9999;
    background-size: cover !important;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.overlay-text {
    z-index: 100;
    padding: 2rem;
    background: hsl(186.15deg 35.78% 42.75% / 75%);
    border-radius: 10px;
    max-width: calc(100% - 2rem);
}

.overlay-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
}

/* ===== iOS Fullscreen Fix ===== */
.ios-fullscreen body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body.ios-fullscreen-active {
    overflow: hidden;
    height: 100%;
    height: 100dvh;
    position: fixed;
    width: 100%;
}

.ios-exit-btn {
    position: fixed;
    top: 15px;
    top: calc(15px + env(safe-area-inset-top));
    right: 15px;
    right: calc(15px + env(safe-area-inset-right));
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 10001;
    transition: background 0.2s ease;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
}

.ios-exit-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

body.ios-fullscreen-active .ios-exit-btn {
    display: flex !important;
}

body.ios-fullscreen-active #viewer-reizen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 9999 !important;
    background: #000 !important;
}

.psv-fullscreen-emulation {
    z-index: 100;
}

/* iOS: hide native fullscreen button (not supported) */
@supports (-webkit-touch-callout: none) {
    .psv-button[data-id="fullscreen"] {
        display: none !important;
    }
}

.ios-fullscreen #viewer-reizen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 9999;
    background: black;
}

/* ===== Responsive: small phones ===== */
@media screen and (max-width: 480px) {
    .psv-marker-content {
        max-width: calc(100vw - 30px);
        max-height: 70vh;
        max-height: 70dvh;
        padding: 12px;
    }

    .timeline-label {
        font-size: 10px;
        padding: 6px;
    }

    .timeline-labels {
        top: -40px;
    }

    .overlay-text {
        padding: 1rem;
        font-size: 14px;
    }
}

/* ===== Responsive: landscape phones ===== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .psv-marker-content {
        max-height: 85vh;
        max-height: 85dvh;
        max-width: 50vw;
    }

    .timeline-labels {
        top: -35px;
    }

    .timeline-label {
        font-size: 10px;
        padding: 5px;
    }

    #fullscreen-overlay p {
        font-size: 14px;
    }
}

/* ===== Responsive: tablets ===== */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .psv-marker-content {
        max-width: 450px;
    }
}

/* ===== Disable hover on touch devices ===== */
@media (hover: none) and (pointer: coarse) {
    .ios-exit-btn:hover {
        background: rgba(0, 0, 0, 0.6);
    }

    .opacity-slider::-webkit-slider-thumb {
        height: 28px;
        width: 28px;
        margin-top: -9px;
    }
}
