/*
Theme Name: Marcher
Theme URI: https://example.com
Author: Krea & Antigravity
Description: A custom theme for the "Marcher: A Philosophy" audiobook and gallery.
Version: 1.0
Requires at least: 5.0
Tested up to: 6.4
Requires PHP: 7.2
Text Domain: marcher
*/

@import url('https://fonts.googleapis.com/css2?family=Reem+Kufi+Ink&display=swap');

:root {
    --bg-dark: #050505;
    --text-light: #f6f3ed;
    --accent-crimson: #ff0000;
    --accent-dark: #4a1518;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: 'Times New Roman', Times, serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Reem Kufi Ink', sans-serif;
    color: var(--accent-crimson);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 60px 0;
    border-bottom: 1px solid var(--accent-dark);
}

.hero h1 {
    font-size: 4rem;
    margin-bottom: 20px;
}

.hero img {
    max-width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    border: 2px solid var(--accent-dark);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Audio Player */
.audio-section {
    padding: 60px 0;
    text-align: center;
    border-bottom: 1px solid var(--accent-dark);
}

.audio-player-container {
    background: #111;
    padding: 30px;
    border-radius: 10px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 1px solid var(--accent-dark);
}

audio {
    width: 100%;
    margin-bottom: 20px;
    outline: none;
}

.track-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
    max-height: 300px;
    overflow-y: auto;
}

.track-list li {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #222;
    transition: background 0.3s ease, color 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.track-list li:hover {
    background: var(--accent-dark);
    color: #fff;
}

.track-list li.active {
    background: var(--accent-crimson);
    color: #fff;
    font-weight: bold;
}

.badge {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: #333;
    color: #ccc;
    font-family: sans-serif;
}

.badge.revised {
    background: var(--accent-crimson);
    color: #fff;
}

/* Gallery Section */
.gallery-section {
    padding: 60px 0;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 1px solid #222;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(196, 35, 53, 0.2);
    border-color: var(--accent-crimson);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Download Section */
.download-section {
    padding: 60px 0;
    text-align: center;
    border-bottom: 1px solid var(--accent-dark);
}

.download-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.email-input {
    width: 100%;
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid var(--accent-dark);
    background: #111;
    color: var(--text-light);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.email-input:focus {
    border-color: var(--accent-crimson);
    box-shadow: 0 0 10px rgba(196, 35, 53, 0.3);
}

.download-btn {
    width: 100%;
    padding: 15px 20px;
    border-radius: 8px;
    border: none;
    background: var(--accent-crimson);
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(196, 35, 53, 0.4);
}

.download-btn:hover {
    background: #e6293e;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(196, 35, 53, 0.6);
}

.download-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(196, 35, 53, 0.4);
}

/* Custom Scrollbar for track list */
.track-list::-webkit-scrollbar {
    width: 8px;
}

.track-list::-webkit-scrollbar-track {
    background: #111;
}

.track-list::-webkit-scrollbar-thumb {
    background: var(--accent-dark);
    border-radius: 4px;
}

.track-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-crimson);
}

/* Reader Mode / Text Sync */
.text-sync-section {
    padding: 40px 0;
    max-width: 800px;
    margin: 0 auto;
}

.reader-mode-box {
    background: #0a0a0a;
    border: 1px solid var(--accent-dark);
    padding: 30px;
    border-radius: 10px;
    font-size: 1.25rem;
    line-height: 2;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    position: relative;
}

.reader-mode-box p {
    margin: 0;
    transition: color 0.3s ease;
}

/* Modal styles for gallery */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    padding-top: 50px; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.9); 
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    animation-name: zoom;
    animation-duration: 0.3s;
}

@keyframes zoom {
    from {transform:scale(0)} 
    to {transform:scale(1)}
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: var(--accent-crimson);
    text-decoration: none;
    cursor: pointer;
}

/* Slideshow */
.slideshow-container {
    max-width: 800px;
    position: relative;
    margin: auto;
    border: 2px solid var(--accent-dark);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    background: #000;
}

.slide {
    display: none;
    cursor: pointer;
}

.slide img {
    width: 100%;
    height: 600px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.slide:hover img {
    transform: scale(1.02);
}

.prev, .next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -22px;
    color: white;
    font-weight: bold;
    font-size: 24px;
    transition: 0.4s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0,0,0,0.3);
    text-decoration: none;
}

/* Because RTL flows right-to-left, left arrow (prev) is actually logically 'next' visually. We adjust the arrows. */
.next { right: 0; border-radius: 3px 0 0 3px; }
.prev { left: 0; border-radius: 0 3px 3px 0; }

.prev:hover, .next:hover {
    background-color: var(--accent-crimson);
}

.dot-container {
    padding: 20px 0;
}

.dot {
    cursor: pointer;
    height: 12px;
    width: 12px;
    margin: 0 5px;
    background-color: #333;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.active-dot, .dot:hover {
    background-color: var(--accent-crimson);
}

.fade {
    animation-name: fade;
    animation-duration: 1.5s;
}

@keyframes fade {
    from {opacity: .4} 
    to {opacity: 1}
}

/* Screensaver Mode */
#screensaver-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000;
    z-index: 9999;
    overflow: hidden;
}

#screensaver-images {
    position: relative;
    width: 100%; height: 100%;
}

.ss-img {
    position: absolute;
    top: -10%; left: -10%;
    width: 120%; height: 120%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 2s ease-in-out, transform 12s linear;
    mix-blend-mode: screen;
}

.screensaver-hint {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
    font-family: sans-serif;
    pointer-events: none;
    z-index: 10000;
}

/* Infinite Mondrian Gallery CSS */
#ambient-gallery-container {
    width: 100%;
    height: 800px;
    overflow-y: auto;
    position: relative;
    background: #000; /* Mondrian black borders */
    border: 15px solid #000;
}

/* Hide scrollbar for cleaner look */
#ambient-gallery-container::-webkit-scrollbar {
    display: none;
}
#ambient-gallery-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#ambient-gallery-track {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-flow: dense; /* The secret to the Mondrian packing */
    gap: 10px; /* The black lines */
    background: #000;
    padding-bottom: 20px;
}

.ambient-tile {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: brightness(0.85);
    cursor: pointer;
    background: #fff; /* In case image doesn't load immediately */
}

.ambient-tile:hover {
    transform: scale(0.98); /* Slight inset effect */
    filter: brightness(1.1);
    z-index: 20;
    position: relative;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* Mondrian Sizing Classes */
.span-1x1 {
    grid-column: span 1;
    grid-row: span 1;
    aspect-ratio: 1 / 1;
}

.span-1x2 {
    grid-column: span 1;
    grid-row: span 2;
    aspect-ratio: 1 / 2;
}

.span-2x1 {
    grid-column: span 2;
    grid-row: span 1;
    aspect-ratio: 2 / 1;
}

.span-2x2 {
    grid-column: span 2;
    grid-row: span 2;
    aspect-ratio: 1 / 1;
}

.span-3x2 {
    grid-column: span 3;
    grid-row: span 2;
    aspect-ratio: 3 / 2;
}

@media (max-width: 900px) {
    #ambient-gallery-track { grid-template-columns: repeat(4, 1fr); gap: 8px;}
    .span-3x2 { grid-column: span 2; aspect-ratio: 1 / 1;}
}
@media (max-width: 600px) {
    #ambient-gallery-track { grid-template-columns: repeat(2, 1fr); gap: 5px; }
    #ambient-gallery-container { border-width: 5px; }
    .span-2x2 { grid-column: span 2; grid-row: span 2; }
    .span-2x1 { grid-column: span 2; grid-row: span 1; }
    .span-3x2 { grid-column: span 2; grid-row: span 2; aspect-ratio: 1 / 1;}
}
