/* theme.css
   ============================================================================
   THEME COLORS — edit these variables to restyle the whole site.
   ============================================================================ */
:root {
    --brand:        #2563eb;   /* primary accent */
    --brand-dark:   #1d4ed8;   /* accent hover */
    --bg:           #f2f4f7;   /* page background */
    --surface:      #ffffff;   /* cards / bars */
    --text:         #1f2937;   /* main text */
    --text-muted:   #6b7280;   /* secondary text */
    --border:       #e5e7eb;
    --error-bg:     #fee2e2;   --error-fg:   #b91c1c;
    --success-bg:   #dcfce7;   --success-fg: #166534;
    --radius:       12px;
    --shadow:       0 6px 24px rgba(0,0,0,.08);
    --maxw:         1000px;
}

/* Optional dark mode — auto-applies if the visitor's device prefers dark. */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:         #0f172a;
        --surface:    #1e293b;
        --text:       #e2e8f0;
        --text-muted: #94a3b8;
        --border:     #334155;
    }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top navigation bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    padding: .75rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--brand); }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; align-items: center; gap: 1.25rem; margin-left: auto; flex-wrap: wrap; }
.mainnav a { color: var(--text); font-weight: 500; }
.nav-user { color: var(--text-muted); font-weight: 400; }
.btn-logout { background: var(--brand); color: #fff !important; padding: .4rem .8rem; border-radius: 8px; }
.btn-logout:hover { background: var(--brand-dark); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--text); margin-left: auto; }

/* ---------- Layout ---------- */
.content { width: 100%; max-width: var(--maxw); margin: 2rem auto; padding: 0 1rem; flex: 1; }
.content h1 { margin-top: 0; }
.site-footer { text-align: center; padding: 1.25rem; color: var(--text-muted); font-size: .85rem; }

/* ---------- Cards / auth pages ---------- */
.auth-page { justify-content: center; align-items: center; }
/* Auth pages: center the card, let it ignore the content max-width */
.auth-page .content {
    max-width: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
}
.card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 380px;
    margin: auto;
}
label { display: block; margin-bottom: .85rem; font-size: .9rem; }
input {
    width: 100%; padding: .6rem; margin-top: .25rem;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 1rem; background: var(--surface); color: var(--text);
}
button {
    width: 100%; padding: .7rem; border: 0; border-radius: 8px;
    background: var(--brand); color: #fff; font-size: 1rem; cursor: pointer;
}
button:hover { background: var(--brand-dark); }

.error   { background: var(--error-bg);   color: var(--error-fg);   padding: .6rem .8rem; border-radius: 8px; }
.success { background: var(--success-bg); color: var(--success-fg); padding: .6rem .8rem; border-radius: 8px; }
.muted   { color: var(--text-muted); font-size: .85rem; margin-top: 1rem; }
.notice  { color: var(--text-muted); background: var(--surface); padding: 1rem; border-radius: var(--radius); }

/* ---------- Category chips ---------- */
.category-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.5rem; }
.chip {
    padding: .45rem .9rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); font-weight: 500;
}
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip-active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Slideshow ---------- */
.slideshow {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.slide-stage {
    display: flex; align-items: center; justify-content: center;
    background: #000; aspect-ratio: 16 / 10; width: 100%;
}
.slide-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.slide-controls {
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    padding: .75rem;
}
.slide-btn {
    width: auto; min-width: 48px; padding: .4rem .8rem;
    font-size: 1.4rem; line-height: 1; border-radius: 8px;
}
.slide-btn.is-playing { background: var(--brand-dark); }
.slide-counter { color: var(--text-muted); font-size: .9rem; min-width: 60px; text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .nav-toggle { display: block; }
    .mainnav { display: none; flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: .75rem; }
    body.nav-open .mainnav { display: flex; }
    .mainnav { margin-left: 0; }
    .slide-stage { aspect-ratio: 4 / 3; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}

/* ---------- Grid view ---------- */
.grid-view { display: flex; flex-wrap: wrap; gap: 1rem; }
.grid-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .5rem;
    flex: 1 1 auto;
}
.grid-thumb {
    padding: 0;
    border: 0;
    background: none;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 1 / 1;
    cursor: pointer;
}
.grid-thumb img,
.grid-thumb video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.vid-indicator {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.6);
    color: #fff;
    padding: .3rem .5rem;
    border-radius: 50%;
    font-size: 1.2rem;
    pointer-events: none;
}
.grid-viewer {
    flex: 2 1 60%;
    min-width: 280px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    align-self: start;
}
.grid-stage {
    display: flex; align-items: center; justify-content: center;
    background: #000;
    aspect-ratio: 16 / 9;
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
}
.grid-stage img,
.grid-stage video {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
}
.grid-controls {
    display: flex; align-items: center; justify-content: center; gap: .6rem;
    margin-top: .75rem;
}
.grid-controls .slide-btn { width: auto; min-width: 44px; }
.grid-auto {
    text-align: center;
    margin-top: .5rem;
    font-size: .85rem;
    color: var(--text-muted);
}
.grid-auto input { width: auto; margin-right: .4rem; }

/* ---------- Thumbnail grid ---------- */
.grid-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .5rem;
    margin: 1rem 0;
}
.grid-thumb {
    position: relative; padding: 0; border: 0; background: #0002;
    border-radius: 8px; overflow: hidden; aspect-ratio: 1/1; cursor: pointer;
}
.grid-thumb img { width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .2s ease; }
.grid-thumb:hover img { transform: scale(1.05); }
.vid-indicator {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: rgba(0,0,0,.6); color: #fff; width: 40px; height: 40px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; pointer-events: none;
}

/* ---------- Pager ---------- */
.pager { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin: 1.5rem 0; }

/* ---------- Lightbox overlay ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.92);
    display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }
.lb-stage { max-width: 90vw; max-height: 82vh; display: flex; align-items: center; justify-content: center; }
.lb-stage img, .lb-stage video { max-width: 90vw; max-height: 82vh; object-fit: contain; border-radius: 6px; }
.lb-nav, .lb-close {
    position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0;
    cursor: pointer; width: 52px; height: 52px; border-radius: 50%; font-size: 2rem; line-height: 1;
}
.lb-nav:hover, .lb-close:hover { background: rgba(255,255,255,.28); }
.lb-prev { left: 2%; } .lb-next { right: 2%; }
.lb-close { top: 3%; right: 3%; width: 44px; height: 44px; font-size: 1.3rem; }
.lb-bar {
    position: absolute; bottom: 3%; left: 50%; transform: translateX(-50%);
    display: flex; gap: 1.25rem; align-items: center; color: #fff; font-size: .9rem;
}
.lb-auto input { width: auto; margin-right: .35rem; }
@media (max-width: 640px) {
    .lb-nav { width: 42px; height: 42px; font-size: 1.5rem; }
    .lb-stage img, .lb-stage video { max-height: 74vh; }
}

/* ---------- Upload form ---------- */
.upload-form { background: var(--surface); padding: 1.5rem; border-radius: var(--radius);
    box-shadow: var(--shadow); max-width: 560px; }
.upload-form select, .upload-form input[type="file"] {
    width: 100%; padding: .55rem; margin-top: .25rem; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); color: var(--text); }
