/* Gallery styles, shared by ?view=slideshow (default) and ?view=cards. */
/* Theme: ?theme=light|dark (js/boot.js sets <html data-theme>). With no
   parameter the :root values below apply, which are the original colours: the
   page does NOT follow prefers-color-scheme. The background always stays
   transparent so the host page shows through the iframe. */
:root {
    --text: currentColor;
    --text-muted: #666;
    --bg: transparent;
    --accent: currentColor;
    --track: rgba(255, 255, 255, 0.2);
    --placeholder-bg: rgba(0, 0, 0, 0.1);
    --badge-bg: rgba(255, 255, 255, 0.7);
    --badge-fg: inherit;
    --badge-hover: #ffffb3ba;
    --glow: #ffffb369;
    --glow-strong: #ffd700;
    --shadow-color: hsla(0, 0%, var(--l, 0%), 0.2);
    --hover-glow: hsla(60, 100%, var(--l, 70%), 0.4);
}

:root[data-theme="light"] {
    color-scheme: light;
    --text: #222;
    --text-muted: #666;
    --track: rgba(0, 0, 0, 0.1);
    --placeholder-bg: rgba(0, 0, 0, 0.1);
    --badge-bg: rgba(255, 255, 255, 0.7);
    --badge-fg: #222;
    --badge-hover: rgba(224, 180, 0, 0.6);
    --glow: rgba(224, 180, 0, 0.6);
    --glow-strong: #e0b400;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --hover-glow: rgba(224, 180, 0, 0.6);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --text: #ddd;
    --text-muted: #999;
    --track: rgba(255, 255, 255, 0.2);
    --placeholder-bg: rgba(255, 255, 255, 0.2);
    --badge-bg: rgba(0, 0, 0, 0.5);
    --badge-fg: #eee;
    --badge-hover: #ffffb3ba;
    --glow: #ffffb369;
    --glow-strong: #ffd700;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --hover-glow: hsla(60, 100%, 70%, 0.4);
}

/* Base styles */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: monospace;
    background: var(--bg);
    color: var(--text);
}

body.embedded {
    overflow: hidden;
    width: 100%;
    height: 100vh;
}

.container {
    max-width: 100%;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Swiper modifications */
.swiper {
    width: 100%;
    height: 100vh; /* Set explicit height */
    display: flex;
    align-items: center;
}

.swiper-slide {
    height: 100%; 
    transition: transform 0.1s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.slide-content {
    max-height: 100%; /* Ensure content doesn't overflow */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px; /* Add some padding */
}

/* Media elements */
.swiper-slide img,
.swiper-slide video {
    max-height: 75vh; /* Account for caption + pagination space */
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Pagination styles */
.swiper-pagination {
    position: fixed !important;
    bottom: 10px !important;
    z-index: 10;
}

.swiper-pagination-bullet {
    background: var(--text-muted);
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    margin: 0 5px;
    display: inline-block;
}

.swiper-pagination-bullet-active {
    opacity: 1;
    background: var(--glow);
}

.swiper-pagination-bullet:hover {
    opacity: 0.8;
}

.swiper-pagination-bullet-active:hover {
    opacity: 1;
}

/* Thumbnail preview tooltip on bullet hover */
.bullet-thumbnail {
    position: fixed;
    transform: translate(-50%, -100%) translateY(-8px);
    width: 160px;
    height: 100px;
    border-radius: 4px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    background: #111;
}

.bullet-thumbnail.visible {
    opacity: 1;
}

.bullet-thumbnail img,
.bullet-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Add styles for the active/center slide */
.swiper-slide-active {
    transform: scale(1.2);
    z-index: 2;
}

/* Adjust adjacent slides */
.swiper-slide-prev,
.swiper-slide-next {
    transform: scale(0.7);
    opacity: 0.2;
}



/* Update caption styles */
.slide-caption {
    position: relative;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-family: monospace;
    padding: 5px;
    padding-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    max-width: 100%;
    word-break: break-word;
}

.caption-text {
    font-weight: bold;
}

.caption-tags {
    font-weight: normal;
    opacity: 0.7;
}

.caption-year {
    opacity: 0.5;
}

.tag-link {
    display: inline-block;
}

.tag-link a {
    color: inherit;
    text-decoration: none;
    border-bottom: none;
    transition: all 0.2s ease;
}

.tag-link a:hover {
    opacity: 0.6;
    text-decoration: none;
    border-bottom: none;
}

/* Update link styles */
.swiper-slide a {
    position: relative;
    display: inline-block;
    width: fit-content;
}

.swiper-slide a:hover {
    cursor: pointer;
}

/* Add styles for clickable captions */
.slide-caption a {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    max-width: 100%;
}

.slide-caption a:hover {
    border-bottom-color: inherit;
    text-decoration: underline;
    border-bottom: none;
}



/* Loading styles */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--text-muted);
    border-radius: 50%;
    border-top-color: var(--text-muted);
    animation: spin 1s linear infinite;
}

.loader-text {
    color: var(--text-muted);
    margin-top: 10px;
    font-family: monospace;
}

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

/* Hide loader when content is loaded */
.loader.hidden {
    display: none;
}

/* Loading progress bar */
.loading-progress-container {
    width: 200px;
    margin-top: 20px;
}

.loading-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--track);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--glow), var(--glow-strong));
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Video fallback styles */
.video-fallback {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    background: var(--placeholder-bg);
    border-radius: 8px;
    border: 2px dashed var(--text-muted);
}

.video-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.video-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.video-download {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: var(--glow);
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.video-download:hover {
    background: var(--glow-strong);
}

/* Improved slide placeholder */
.slide-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-muted);
    font-family: monospace;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    border-top-color: var(--glow);
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

/* Add hover effect for clickable images */
.swiper-slide a img,
.swiper-slide a video {
    transition: all 0.3s ease;
}

.swiper-slide a:hover img,
.swiper-slide a:hover video {
    transform: scale(1.02); /* Subtle zoom on hover */
    /* Combine both shadows */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), 0 0 20px var(--glow); /* Base shadow + glow effect */
}


/* Add a small icon to indicate clickable images */
.swiper-slide a {
    position: relative;
}

.swiper-slide a::after {
    content: '↗';
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--badge-bg);
    color: var(--badge-fg);
    padding: 5px 8px;
    border-radius: 0 8px 0 8px;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.swiper-slide a:hover::after {
    opacity: 1;
    background: var(--badge-hover);
}

/* Add this new rule to hide the arrow on caption links */
.slide-caption a::after {
    display: none;  /* This will hide the arrow on caption links */
}

.error-message {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}


@media (hover: none) {
    .swiper-pagination {
        bottom: 20px !important;
    }
    
    .swiper-pagination-bullet {
        width: 12px;
        height: 12px;
        margin: 0 6px;
    }

    .slide-caption {
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    .swiper-pagination {
        bottom: 25px !important;
        padding: 0 20px;
    }
    
    .swiper-pagination-bullet {
        width: 14px;
        height: 14px;
        margin: 0 4px;
    }
    
    .slide-caption {
        font-size: 11px;
        padding: 3px;
    }
    
    .loading-progress-container {
        width: 150px;
    }
}


/* ==========================================================================
   ?view=cards — three.js card ring. Everything above is shared; captions,
   tags, loader and theming are the same classes in both views.
   ========================================================================== */

body.view-cards .container {
    position: relative;
    width: 100%;
    display: block;
}

body.view-cards .slide-caption {
    padding-bottom: 5px;
}

body.view-cards .loader {
    transition: opacity 0.4s ease;
}

#cards-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;       /* we handle drag ourselves */
    cursor: grab;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#cards-canvas.ready {
    opacity: 1;
}

#cards-canvas.dragging {
    cursor: grabbing;
}

#cards-canvas.pointing {
    cursor: pointer;
}

/* Arc labels — the no-troika stand-in for the demo's billboarded Text.
   Positioned every frame from the projected arc midpoint. */
#arc-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.arc-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-family: monospace;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

/* Centre preview */
#preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 5;
}

#preview.visible {
    opacity: 1;
}

/* Media sits in the middle of the ring. */
#preview .slide-content {
    position: absolute;
    top: 50%;
    left: 50%;
    /* The ring's centre projects slightly above the viewport centre. */
    transform: translate(-50%, -54%);
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 90%;
}

/* Sized to sit inside the ring rather than cover it — the upstream preview
   card is about a third of the ring's diameter. */
#preview img,
#preview video {
    max-height: 40vh;
    max-width: 44vw;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Caption sits below the ring, in the empty band above the hint. Tags stay
   clickable even though the rest of the preview is inert. */
#preview .slide-caption {
    position: absolute;
    bottom: 38px;
    left: 0;
    width: 100%;
    pointer-events: auto;
}

/* Clickable indicator, mirroring the slideshow's ↗ badge */
#preview .slide-content.has-link img,
#preview .slide-content.has-link video {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px var(--glow);
}

.hint {
    position: absolute;
    bottom: 14px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
    z-index: 3;
    transition: opacity 0.5s ease;
}

.hint.hidden {
    opacity: 0;
}

@media (max-width: 768px) {
    #preview img,
    #preview video {
        max-height: 32vh;
        max-width: 72vw;
    }

    .arc-label {
        font-size: 11px;
    }
}
