/**
 * Dynamic Pages CSS
 * Styles for API-driven pages with gallery backgrounds
 * 
 * @version 2.1.0
 */

/* ============================================
   PAGE MODE - Content Overlay
   When viewing a page with gallery background
   ============================================ */

/* Hide info panel in page mode - it's not needed */
.gallery-app.page-mode #info-panel,
.gallery-app.page-mode .info-panel {
    display: none !important;
}

/* Hide the info button in page mode */
.gallery-app.page-mode #overlay-info-btn,
.gallery-app.page-mode #stock-info-btn {
    display: none !important;
}

/* Hide the bottom image info overlay in page mode */
/* This includes title, Order Prints, Download buttons */
.gallery-app.page-mode #image-info-overlay,
.gallery-app.page-mode .image-info-overlay {
    display: none !important;
}

/* ============================================
   Page Mode - Filter Button Disabled State
   ============================================ */

/* Disabled filter toggle button in page mode */
#filter-toggle.page-mode-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto; /* Keep pointer events for tooltip */
    position: relative;
}

#filter-toggle.page-mode-disabled:hover {
    background: transparent;
    transform: none;
}

#filter-toggle.page-mode-disabled::after {
    content: '';
    position: absolute;
    inset: 0;
    cursor: not-allowed;
}

/* Add a subtle indicator icon */
#filter-toggle.page-mode-disabled .icon {
    opacity: 0.5;
}

/* Hide keywords bar in page mode */
.gallery-app.page-mode #keywords-bar,
.gallery-app.page-mode .keywords-bar {
    display: none !important;
}

/* Page Content Overlay */
.page-content-overlay {
    position: fixed;
    top: var(--header-height, 60px); /* Below header */
    left: 0;
    right: 0;
    bottom: calc(var(--controls-height, 40px) + var(--thumbnail-height, 100px)); /* Above thumbnail strip + controls */
    z-index: 40;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 30px 40px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
    /* Lighter overlay - image visible behind */
    background: linear-gradient(
        to bottom,
        rgba(10, 10, 10, 0.75) 0%,
        rgba(10, 10, 10, 0.6) 50%,
        rgba(10, 10, 10, 0.4) 100%
    );
    /* No blur - keep image sharp */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-content-overlay::-webkit-scrollbar {
    width: 6px;
}

.page-content-overlay::-webkit-scrollbar-track {
    background: transparent;
}

.page-content-overlay::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.page-content-overlay::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* Idle mode - thumbnails hidden, extend to just above controls */
body.idle .page-content-overlay {
    bottom: calc(var(--controls-height, 40px) + 10px);
}

/* Hidden state */
.page-content-overlay.collapsed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-30px);
}

/* Content wrapper - 90% width */
.page-content-wrapper {
    position: relative;
    max-width: 90%;
    width: 100%;
}

/* Article container - matches page dark theme */
.page-content-article {
    background: rgba(10, 10, 10, 0.85);
    border-radius: 0;
    padding: 0 50px 40px 50px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    height: 100%;
    box-sizing: border-box;
}

/* Page header */
.page-content-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-content-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: white;
    margin: 0;
    line-height: 1.3;
}

/* Page body - supports rich HTML content */
.page-content-body {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    line-height: 1.85;
}

.page-content-body h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: white;
    margin: 1.5em 0 0.6em;
    font-weight: 600;
}

.page-content-body h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: white;
    margin: 1.5em 0 0.5em;
    font-weight: 600;
}

.page-content-body h3 {
    font-size: 1.4rem;
    color: white;
    margin: 1.3em 0 0.5em;
    font-weight: 600;
}

.page-content-body h4 {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.95);
    margin: 1.2em 0 0.4em;
    font-weight: 600;
}

.page-content-body h5,
.page-content-body h6 {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 1em 0 0.4em;
    font-weight: 600;
}

.page-content-body p {
    margin: 0 0 1.2em;
}

.page-content-body a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.page-content-body a:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

.page-content-body strong,
.page-content-body b {
    color: white;
    font-weight: 600;
}

.page-content-body em,
.page-content-body i {
    font-style: italic;
}

.page-content-body ul,
.page-content-body ol {
    margin: 0 0 1.2em 1.8em;
    padding: 0;
}

.page-content-body li {
    margin-bottom: 0.6em;
}

.page-content-body ul li {
    list-style-type: disc;
}

.page-content-body ol li {
    list-style-type: decimal;
}

.page-content-body blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid #60a5fa;
    background: rgba(96, 165, 250, 0.1);
    border-radius: 0 8px 8px 0;
    color: rgba(255, 255, 255, 0.85);
    font-style: italic;
}

.page-content-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5em 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.page-content-body video,
.page-content-body iframe {
    max-width: 100%;
    border-radius: 12px;
    margin: 1.5em 0;
}

.page-content-body pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1em 1.2em;
    overflow-x: auto;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.page-content-body code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Consolas', monospace;
}

.page-content-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.page-content-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.page-content-body th,
.page-content-body td {
    padding: 0.8em 1em;
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-align: left;
}

.page-content-body th {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
}

.page-content-body tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
}

.page-content-body hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin: 2em 0;
}

/* Toggle button */
.page-content-toggle {
    position: fixed;
    bottom: 140px;
    right: 30px;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.page-content-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.02);
}

.page-content-toggle .icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

/* When collapsed, rotate icon */
.page-content-toggle.show-content .icon {
    transform: rotate(180deg);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .page-content-overlay {
        padding: 20px 30px;
        bottom: calc(var(--controls-height, 40px) + var(--thumbnail-height, 80px));
    }
    
    .page-content-article {
        padding: 30px 35px;
    }
    
    .page-content-title {
        font-size: 2rem;
    }
    
    .page-content-toggle {
        bottom: 120px;
        right: 20px;
    }
}

@media (max-width: 768px) {
    .page-content-overlay {
        top: var(--header-height, 55px);
        padding: 16px 20px;
        bottom: calc(var(--controls-height, 40px) + var(--thumbnail-height, 70px));
    }
    
    .page-content-article {
        padding: 24px 28px;
        border-radius: 0;
    }
    
    .page-content-title {
        font-size: 1.7rem;
    }
    
    .page-content-body {
        font-size: 1rem;
    }
    
    .page-content-toggle {
        bottom: 105px;
        right: 15px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .page-content-toggle .toggle-text {
        display: none;
    }
}

@media (max-width: 480px) {
    .page-content-overlay {
        padding: 12px 16px;
    }
    
    .page-content-article {
        padding: 20px;
    }
    
    .page-content-title {
        font-size: 1.5rem;
    }
    
    .page-content-toggle {
        bottom: 100px;
        right: 10px;
    }
}

/* ============================================
   Base Dynamic Page Layout
   ============================================ */

.dynamic-page {
    position: relative;
    min-height: 100vh;
    background: #0a0a0a;
}

.dynamic-page-container {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: hidden;
}

.dynamic-page-container.hidden {
    display: none;
}

/* ============================================
   Gallery Background Layer
   ============================================ */

.page-gallery-background {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.page-gallery-background.interactive {
    pointer-events: auto;
}

/* ============================================
   Filmstrip Mode
   ============================================ */

.filmstrip-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    height: 120px;
    overflow: hidden;
    pointer-events: auto;
}

.filmstrip-track {
    display: flex;
    gap: 8px;
    padding: 0 20px;
    animation: filmstrip-scroll 60s linear infinite;
    will-change: transform;
}

.filmstrip-track:hover {
    animation-play-state: paused;
}

.filmstrip-item {
    flex-shrink: 0;
    width: 180px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
    cursor: pointer;
}

.filmstrip-item:hover {
    opacity: 1;
    transform: scale(1.05);
}

.filmstrip-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.filmstrip-item:hover img {
    transform: scale(1.1);
}

@keyframes filmstrip-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============================================
   Background Image Mode
   ============================================ */

.background-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.4;
    transition: opacity 0.5s;
}

.page-content-overlay:hover ~ .page-gallery-background .background-image,
.dynamic-page:hover .background-image {
    opacity: 0.2;
}

/* ============================================
   Grid Mode
   ============================================ */

.page-grid-gallery {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4px;
    padding: 60px 20px 20px;
    opacity: 0.3;
    overflow-y: auto;
    pointer-events: auto;
}

.page-grid-gallery:hover {
    opacity: 0.5;
}

.grid-item {
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.3s;
}

.grid-item:hover {
    opacity: 1;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.grid-item:hover img {
    transform: scale(1.1);
}

/* ============================================
   Carousel Mode
   ============================================ */

.page-carousel {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-track {
    width: 100%;
    height: 100%;
    position: relative;
}

.carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-slide.active {
    opacity: 0.4;
}

.carousel-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2rem;
    padding: 20px 15px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.3s;
    pointer-events: auto;
    opacity: 0;
}

.page-carousel:hover .carousel-prev,
.page-carousel:hover .carousel-next {
    opacity: 1;
}

.carousel-prev:hover,
.carousel-next:hover {
    background: rgba(255, 255, 255, 0.2);
}

.carousel-prev { left: 20px; }
.carousel-next { right: 20px; }

/* ============================================
   Standalone Page Content Overlay (NOT for page mode)
   Used by page-dynamic.php template
   ============================================ */

.standalone-page-content-overlay {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 100px 20px;
    background: rgba(10, 10, 10, calc(1 - var(--content-opacity, 0.3)));
    transition: background 0.3s;
}

.standalone-page-content-overlay:hover {
    background: rgba(10, 10, 10, 0.85);
}

.page-content-container {
    max-width: none;
    width: 100%;
}

/* ============================================
   Page Article
   ============================================ */

.page-article {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0;
    padding: 40px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.3s, border-color 0.3s;
}

.standalone-page-content-overlay:hover .page-article {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.page-header {
    margin-bottom: 30px;
    text-align: center;
}

.page-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
}

.page-body {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.1rem;
    line-height: 1.8;
}

.page-body h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: white;
    margin-top: 2em;
    margin-bottom: 0.5em;
}

.page-body h3 {
    font-size: 1.4rem;
    color: white;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.page-body h4 {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.page-body p {
    margin-bottom: 1em;
}

.page-body a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s;
}

.page-body a:hover {
    border-color: #60a5fa;
}

.page-body ul,
.page-body ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.page-body li {
    margin-bottom: 0.5em;
}

.page-body blockquote {
    border-left: 3px solid #60a5fa;
    padding-left: 1.5em;
    margin: 1.5em 0;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.page-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5em 0;
}

.page-body code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.page-body pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

.page-body pre code {
    background: none;
    padding: 0;
}

/* ============================================
   Navigation Menu (API-driven)
   ============================================ */

.api-nav-menu {
    display: flex;
    align-items: center;
}

.api-nav-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 8px;
}

.api-nav-menu .menu-item {
    position: relative;
}

.api-nav-menu .menu-item > a {
    display: block;
    padding: 8px 16px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.3s, background 0.3s;
}

.api-nav-menu .menu-item > a:hover,
.api-nav-menu .menu-item.current > a {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.api-nav-menu .menu-item.current > a {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* Submenu */
.api-nav-menu .has-children > ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 8px 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-direction: column;
    z-index: 100;
}

.api-nav-menu .has-children:hover > ul {
    display: flex;
}

.api-nav-menu .has-children > ul .menu-item > a {
    padding: 10px 20px;
    border-radius: 0;
}

.api-nav-menu .has-children > ul .menu-item > a:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Menu type indicators */
.api-nav-menu .menu-type-external > a::after {
    content: '↗';
    margin-left: 4px;
    font-size: 0.75em;
    opacity: 0.5;
}

.api-nav-menu .menu-type-gallery > a::before {
    content: '▣';
    margin-right: 6px;
    font-size: 0.75em;
    opacity: 0.5;
}

/* ============================================
   Page Transitions
   ============================================ */

.page-transition-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-transition-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-transition-exit {
    opacity: 1;
}

.page-transition-exit-active {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ============================================
   Back to Gallery Button
   ============================================ */

.back-to-gallery {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: white;
    font-size: 0.9rem;
    text-decoration: none;
    backdrop-filter: blur(10px);
    transition: background 0.3s, transform 0.3s;
}

.back-to-gallery:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-4px);
}

.back-to-gallery svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   Responsive Styles (for standalone pages only)
   ============================================ */

@media (max-width: 1024px) {
    .standalone-page-content-overlay {
        padding: 80px 20px;
    }
    
    .page-article {
        padding: 30px;
    }
    
    .page-title {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .page-title {
        font-size: 1.8rem;
    }
    
    .page-article {
        padding: 24px;
        border-radius: 0;
    }
    
    .standalone-page-content-overlay {
        padding: 80px 16px;
    }
    
    .page-body {
        font-size: 1rem;
    }
    
    .filmstrip-container {
        height: 80px;
        bottom: 60px;
    }
    
    .filmstrip-item {
        width: 120px;
        height: 80px;
    }
    
    .carousel-prev,
    .carousel-next {
        padding: 15px 10px;
        font-size: 1.5rem;
    }
    
    .carousel-prev { left: 10px; }
    .carousel-next { right: 10px; }
    
    .page-grid-gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 2px;
        padding: 60px 10px 10px;
    }
    
    .back-to-gallery {
        top: 70px;
        left: 10px;
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Mobile menu */
    .api-nav-menu ul {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .api-nav-menu .menu-item > a {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1.5rem;
    }
    
    .page-article {
        padding: 20px;
    }
    
    .filmstrip-container {
        height: 60px;
        bottom: 50px;
    }
    
    .filmstrip-item {
        width: 90px;
        height: 60px;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .page-gallery-background,
    .filmstrip-container,
    .back-to-gallery,
    .api-nav-menu {
        display: none !important;
    }
    
    .page-content-overlay {
        background: white !important;
        padding: 20px;
    }
    
    .page-article {
        background: none !important;
        border: none !important;
        backdrop-filter: none !important;
    }
    
    .page-title,
    .page-body,
    .page-body h2,
    .page-body h3,
    .page-body h4 {
        color: black !important;
    }
    
    .page-body a {
        color: blue !important;
    }
}
