/* =============================================================================
   CSS Custom Properties (Theme Variables)
   These can be customized via JavaScript when loading app config
   ============================================================================= */
:root {
    /* Primary accent color - customizable via config */
    --primary-color: #ffc813;
    --primary-color-rgb: 255, 200, 19;

    /* Background colors */
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-overlay: rgba(0, 0, 0, 0.95);

    /* Text colors */
    --text-primary: rgba(255, 255, 255, 0.9);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Fonts - can be overridden by config */
    --font-primary: 'Playfair Display', Georgia, serif;
    --font-heading: 'Playfair Display', Georgia, serif;

    /* Spacing */
    --border-radius: 8px;
    --border-radius-lg: 20px;
}

/* Default Google Font - can be overridden by custom font in config */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    height: 100%;
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.main-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.title {
    font-family: var(--font-heading);
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-weight: normal;
}

.subtitle {
    font-family: var(--font-primary);
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-weight: 300;
}

/* Media Stats */
.media-stats {
    font-family: var(--font-primary);
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: -1rem; /* pull closer to subtitle */
    margin-bottom: 1rem;
}

/* Sorting Controls */
.sort-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 1rem;
    margin-bottom: 0rem;
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-group label {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sort-controls select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(var(--primary-color-rgb), 0.3);
    border-radius: 6px;
    color: white;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.sort-controls select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.sort-controls select:hover {
    border-color: rgba(var(--primary-color-rgb), 0.5);
    background: rgba(255, 255, 255, 0.15);
}

.sort-controls select option {
    background: var(--bg-secondary);
    color: white;
}

@media (max-width: 480px) {
    .sort-controls {
        justify-content: center;
    }
    .sort-controls select {
        min-width: 140px;
        font-size: 0.85rem;
    }
}

.upload-section {
    max-width: 600px;
    margin: 0 auto 4rem;
}

.upload-area {
    border: 1px solid rgba(var(--primary-color-rgb), 0.3);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.05);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.1);
}

.upload-text {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 300;
}

.upload-subtext {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 300;
}

#fileInput {
    display: none;
}

.progress-container {
    margin-top: 1rem;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.gallery-section {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    position: relative;
}

/* Fallback for older browsers */
@supports not (aspect-ratio: 1) {
    .photo-item {
        height: 0;
        padding-bottom: 100%;
    }
    
    .photo-item img, .photo-item video {
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* Fixed column counts by width */
@media (min-width: 480px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

.photo-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    /* Reduce offscreen work and reserve space to cut CLS */
    content-visibility: auto;
    contain: content;
    contain-intrinsic-size: 180px 180px; /* matches min column size */
}

.photo-item.loading {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(var(--primary-color-rgb), 0.1) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.photo-item.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(var(--primary-color-rgb), 0.1);
}

.photo-item .loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 2px solid rgba(var(--primary-color-rgb), 0.3);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

.photo-item .play-button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 3;
    backdrop-filter: blur(5px);
}

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

/* Global spin animation for loading indicators */
@keyframes spinGlobal {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.photo-item:hover {
    opacity: 0.8;
}

.photo-item img, .photo-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-item img.loaded, .photo-item video.loaded {
    opacity: 1;
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    overflow: hidden;
    cursor: default;
}

.lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    transform-origin: center center;
}

.lightbox img, .lightbox video {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    transition: opacity 0.2s ease;
}

.lightbox-content.loading {
    position: relative;
}

.lightbox-content.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid rgba(var(--primary-color-rgb), 0.3);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spinGlobal 1s linear infinite;
    z-index: 1;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    z-index: 1005; /* ensure it's always above info */
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close svg {
    width: 24px;
    height: 24px;
}

.lightbox-close:hover {
    color: var(--primary-color);
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 1002;
    user-select: none;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav svg {
    width: 32px;
    height: 32px;
}

.lightbox-nav:hover {
    color: var(--primary-color);
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-info {
    position: fixed;
    top: 20px;
    left: 20px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.75rem;
    text-align: left;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 10px;
    border-radius: var(--border-radius);
    backdrop-filter: blur(8px);
    z-index: 1001; /* below close button */
    max-width: 180px;
    opacity: 0.9;
    transition: opacity 0.3s ease, transform 0.3s ease;
    line-height: 1.2;
    overflow: hidden;
}

.lightbox-info.fade-out {
    opacity: 0;
    transform: translateY(-5px);
}

.lightbox-counter {
    margin-bottom: 2px;
    font-weight: 500;
    font-size: 0.8rem;
}

.lightbox-date {
    opacity: 0.8;
    font-size: 0.7rem;
    margin-bottom: 1px;
    white-space: nowrap;
}

.lightbox-uploader {
    opacity: 0.7;
    font-size: 0.65rem;
    margin-top: 1px;
    font-style: italic;
}

.upload-status {
    margin-top: 1rem;
    padding: 1rem;
    text-align: center;
    display: none;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.download-section {
    max-width: 600px;
    margin: 0 auto 2rem;
    text-align: center;
}

.download-all-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(var(--primary-color-rgb), 0.8) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
    min-width: 200px;
    justify-content: center;
}

.download-all-btn:hover {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.9) 0%, rgba(var(--primary-color-rgb), 0.7) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb), 0.3);
}

.download-all-btn:disabled {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.download-all-btn svg {
    transition: transform 0.3s ease;
}

/* Stacked text (label + subtitle) inside button */
.download-all-btn .btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.download-all-btn .btn-label {
    font-size: 1rem;
    font-weight: 600;
}

.download-all-btn .btn-subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
}

.download-all-btn:hover:not(:disabled) svg {
    transform: translateY(2px);
}

.download-status {
    margin-top: 1rem;
    padding: 0.5rem;
    text-align: center;
    display: none;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.download-status.success {
    color: #4CAF50;
}

.download-status.error {
    color: #f44336;
}

.no-photos {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 300;
}

/* Entrance animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }

    .title {
        font-size: 2.5rem;
        margin-bottom: 1rem;
        margin-top: 1rem;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .upload-section {
        margin-bottom: 2rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    /* Double Column Layout for Mobile */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .photo-item {
        aspect-ratio: 1;
    }

    /* Mobile Lightbox Adjustments */
    .lightbox-nav {
        background: rgba(0, 0, 0, 0.7);
        width: 60px;
        height: 60px;
    }

    .lightbox-nav svg {
        width: 32px;
        height: 32px;
    }

    .lightbox-prev {
        left: 5px;
    }

    .lightbox-next {
        right: 5px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.7);
        width: 50px;
        height: 50px;
    }

    .lightbox-close svg {
        width: 24px;
        height: 24px;
    }

    .lightbox-info {
        top: 20px;
        left: 15px;
        padding: 6px 10px;
        font-size: 0.7rem;
        max-width: 160px;
    }

    .lightbox-counter {
        font-size: 0.75rem;
    }

    .lightbox-date {
        font-size: 0.65rem;
    }

    .lightbox-content {
        max-width: 100vw;
        max-height: 100vh;
        padding: 0;
        width: auto;
        height: auto;
    }

    .lightbox img, .lightbox video {
        max-width: 100vw;
        max-height: 100vh;
        width: auto;
        height: auto;
        object-fit: contain;
    }
}

@media (max-width: 380px) {
    .main-container {
        padding: 0.5rem;
    }

    .title {
        font-size: 2rem;
    }

    .upload-area {
        padding: 1.5rem 1rem;
    }

    /* Single column for very small screens */
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .photo-item {
        aspect-ratio: 1;
    }

    .lightbox-nav {
        background: rgba(0, 0, 0, 0.8);
        width: 60px;
        height: 60px;
    }

    .lightbox-nav svg {
        width: 32px;
        height: 32px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-info {
        font-size: 0.68rem;
        padding: 5px 8px;
        max-width: 140px;
        left: 15px;
    }
}

@media (max-width: 430px) {
    .lightbox-info {
        font-size: 0.65rem;
        padding: 5px 8px;
        max-width: 130px;
        left: 10px;
    }
}

@media (max-width: 360px) {
    .lightbox-info {
        font-size: 0.62rem;
        padding: 4px 7px;
        max-width: 120px;
        left: 10px;
    }
}

@media (max-width: 320px) {
    .lightbox-info {
        font-size: 0.6rem;
        padding: 4px 6px;
        max-width: 110px;
        left: 8px;
    }
}

/* Landscape orientation - move info higher to avoid video controls */
@media (orientation: landscape) and (max-height: 500px) {
    .lightbox-info {
        top: 15px;
        left: 15px;
    }
}

/* Portrait with very small height - position carefully */
@media (orientation: portrait) and (max-height: 600px) {
    .lightbox-info {
        top: 10px;
    }
}

/* Authentication Modal */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100svh; /* better mobile viewport handling */
    background: var(--bg-overlay);
    z-index: 2000;
    display: grid; /* robust centering */
    place-items: center;
    backdrop-filter: blur(10px);
}

.auth-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(var(--primary-color-rgb), 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.auth-header h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: normal;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    text-align: left;
    position: relative;
}

.input-group label {
    display: block;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(var(--primary-color-rgb), 0.3);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    font-family: var(--font-primary);
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(var(--primary-color-rgb), 0.3);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.password-toggle-btn:hover {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.password-toggle-btn:focus {
    outline: none;
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.password-input-container {
    position: relative;
}

.password-input-container input {
    padding-right: 45px;
}

.auth-submit {
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(var(--primary-color-rgb), 0.8) 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 25px;
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.auth-submit:hover {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.9) 0%, rgba(var(--primary-color-rgb), 0.7) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-color-rgb), 0.4);
}

.auth-submit:active {
    transform: translateY(0);
}

.auth-error {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 1rem;
    display: none;
    padding: 0.5rem;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 8px;
}

/* Hide main content when not authenticated */
body.not-authenticated .main-container {
    display: none;
}

body.authenticated .auth-modal {
    display: none;
}

@media (max-width: 480px) {
    .auth-content {
        padding: 2rem 1.5rem;
        max-width: 95%;
    }
    
    .auth-header h2 {
        font-size: 1.5rem;
    }
    
    .auth-header p {
        font-size: 0.9rem;
    }
}

/* No additional spacing needed at top for video controls */

/* ---- Angleichung an die Einladung (ednaweiss.de/100) ---- */
@font-face {
  font-family: 'Montserrat';
  src: url('/fonts/Montserrat-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
}
@font-face {
  font-family: 'Montserrat';
  src: url('/fonts/Montserrat-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
}
:root {
  --primary-color: #0891B2;            /* Cyan wie die Einladung */
  --primary-color-rgb: 8, 145, 178;    /* muss das Komma-Triple bleiben! */
  --font-primary: 'Montserrat', system-ui, sans-serif;
  --font-heading: 'Montserrat', system-ui, sans-serif;
  --bg-primary: #0f172a;               /* Slate statt reinem Schwarz */
  --bg-secondary: #1e293b;
}
body.booting .main-container,
body.booting .auth-modal {
  display: none;
}
/* ---- Mobil: Inhalt nach oben, weniger Leerraum ---- */
@media (max-width: 600px) {
  .main-container { justify-content: flex-start; padding-top: 1.25rem; }
  .subtitle      { margin-bottom: 1.5rem; }
  .upload-section{ margin-bottom: 1.5rem; }
  .title         { font-size: 2.1rem; line-height: 1.1; margin: 0.25rem 0 0.5rem; }
}
