/*
 * Web Comic Reader — styles.css  v2.2.3
 *
 * CHANGELOG
 * ─────────────────────────────────────────────────────────────────────────
 * [FIX v2.2.3] Dock redesigned to match DHLKeyuser live site:
 *   • #webtoonDock is always a fixed bottom bar, never auto-hidden.
 *   • .webtoon-dock-handle shows only page counter + chevron toggle.
 *   • .webtoon-dock-content holds the full #readerToolbar, expanded by
 *     default. Chevron rotates to indicate state.
 *   • No .auto-hidden class or scroll-direction hide logic.
 *   • Paged mode: dock still shows, zoom/gap controls visually disabled.
 *   • --dock-height CSS var used to add bottom padding to both
 *     #scrollContainer and #pagedContainer so content is never obscured.
 * [FIX v2.2.2] float:none guard retained.
 * [FIX v2.2.1] Dropzone vendor-prefix warnings removed.
 * ─────────────────────────────────────────────────────────────────────────
 */

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
    --bg:          #f7f8fb;
    --card:        #ffffff;
    --border:      #e5e7eb;
    --text:        #111111;
    --muted:       #6b7280;
    --brand:       #2563eb;
    --dock-height: 0px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg:     #0b0c0e;
        --card:   #121418;
        --border: #1e232a;
        --text:   #e5e7eb;
        --muted:  #9ca3af;
    }
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Page ───────────────────────────────────────────────────────────────── */
body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0 calc(var(--dock-height) + 40px);
}

/* ── Upload card ────────────────────────────────────────────────────────── */
.wrap {
    width: min(560px, 90%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.05);
    padding: 30px 26px;
    text-align: center;
    position: relative;
    margin-bottom: 20px;
    transition: padding .2s;
}
h1 { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
p  { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

/* ── Collapse button ────────────────────────────────────────────────────── */
.collapse-btn {
    position: absolute; top: 10px; right: 10px;
    width: 28px; height: 28px; padding: 0;
    background: var(--bg); color: var(--text);
    border: none; border-radius: 6px;
    cursor: pointer; opacity: .6; transition: opacity .2s;
    display: none; align-items: center; justify-content: center;
}
.collapse-btn:hover { opacity: 1; background: var(--border); }
.collapse-btn.show  { display: flex; }

/* ── Collapsed upload card ──────────────────────────────────────────────── */
.wrap.collapsed            { padding: 12px 20px; }
.wrap.collapsed #uploadView,
.wrap.collapsed .footer-default { display: none !important; }
.wrap.collapsed .footer-collapsed { display: block; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer-default {
    margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center;
}
.footer-default a { color: var(--muted); text-decoration: none; transition: color .2s; }
.footer-default a:hover { color: var(--text); }

.footer-collapsed {
    display: none; font-size: 14px; color: var(--muted);
    cursor: pointer; padding: 4px 0; text-align: center; transition: color .2s;
}
.footer-collapsed:hover { color: var(--text); }
.footer-collapsed::before { content: '▼ '; font-size: 10px; margin-right: 4px; }

/* ── Dropzone ───────────────────────────────────────────────────────────── */
#dropzone {
    border: 2px dashed var(--border) !important;
    border-radius: 14px; background: transparent !important;
    padding: 36px 20px; min-height: 200px;
    display: flex !important; align-items: center; justify-content: center;
    cursor: pointer; transition: border-color .2s, background .2s;
}
#dropzone.dz-drag-hover {
    border-color: var(--brand) !important;
    background: rgba(37,99,235,.06) !important;
}
.dz-message {
    display: flex !important; flex-direction: column;
    align-items: center; gap: 6px; margin: 0 !important; pointer-events: none;
}
.dz-upload-icon { color: var(--muted); margin-bottom: 6px; transition: color .2s; }
#dropzone.dz-drag-hover .dz-upload-icon { color: var(--brand); }
.dz-main-text { font-size: 16px; font-weight: 600; color: var(--text); }
.dz-sub-text  { font-size: 14px; color: var(--muted); }
.hint         { font-size: 13px; color: var(--muted); }
.dropzone .dz-preview { display: none !important; }
.dz-progress { display: none; }

/* ── Large-file warning ─────────────────────────────────────────────────── */
.file-size-warning {
    margin-top: 8px; padding: 8px 14px; border-radius: 8px;
    background: #fef9c3; color: #854d0e; font-size: 13px; border: 1px solid #fde68a;
}
@media (prefers-color-scheme: dark) {
    .file-size-warning { background: #422006; color: #fcd34d; border-color: #78350f; }
}

/* ── Loading overlay ────────────────────────────────────────────────────── */
.se-pre-con {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.75); backdrop-filter: blur(8px);
    display: none !important;
}
.se-pre-con[style*="display: block"] {
    display: flex !important; flex-direction: column;
    align-items: center; justify-content: center;
}
.spinner {
    width: 60px; height: 60px;
    border: 5px solid rgba(255,255,255,.2);
    border-top-color: #fff; border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-text {
    font-size: 20px; font-weight: 600; color: #fff;
    margin-top: 24px; text-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.chunk-progress { margin-top: 24px; width: 260px; text-align: center; }
.chunk-bar-wrap {
    width: 100%; height: 6px; background: rgba(255,255,255,.2);
    border-radius: 3px; overflow: hidden;
}
.chunk-bar {
    height: 100%; width: 0; background: #4ade80;
    border-radius: 3px; transition: width .15s ease;
}
.chunk-label { margin-top: 8px; font-size: 13px; color: rgba(255,255,255,.7); }

/* ═══════════════════════════════════════════════════════════════════════════
   READER OUTPUT AREA
   [FIX v2.2.3] No float:center — output uses block layout.
   In scroll-mode, output spans full width with no card styling.
═══════════════════════════════════════════════════════════════════════════ */
#output {
    width: 90%; max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px calc(var(--dock-height) + 24px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.05);
    display: none;
}
#output.scroll-mode {
    width: 100%; max-width: none;
    padding: 0 0 calc(var(--dock-height) + 24px);
    background: none; border: none;
    box-shadow: none; border-radius: 0;
}

/* ── Archive title / hint ───────────────────────────────────────────────── */
.reader-meta {
    font-size: 13px; color: var(--muted);
    margin-bottom: 12px; text-align: center;
}
#output.scroll-mode .reader-meta {
    max-width: 1200px; margin: 12px auto; padding: 0 20px; text-align: left;
}

/* ── Paged mode ─────────────────────────────────────────────────────────── */
.paged-container  { text-align: center; }
.paged-image-link { display: block; text-decoration: none; cursor: zoom-in; }
.paged-image {
    width: 100%; max-width: 100%; height: auto;
    border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.08);
    display: block; margin: 0 auto;
}
/* (lightbox-links div removed — PhotoSwipe 5 uses a JS data array, not DOM anchors) */

/* ── Scroll / Webtoon mode ──────────────────────────────────────────────── */
.scroll-container {
    display: flex; flex-direction: column; align-items: center;
    width: 100%;
}
.scroll-page {
    display: block; width: 100%;
    line-height: 0; margin-bottom: 16px;
    text-align: center;
}
.scroll-page--tight { margin-bottom: 0; }
.scroll-page img {
    width: var(--scroll-image-width, 90vw);
    max-width: 100%; height: auto; display: inline-block;
}

/* Full-bleed in scroll mode — no gaps between pages */
#output.scroll-mode .scroll-page {
    margin-bottom: 0; padding: 0; line-height: 0;
}
#output.scroll-mode .scroll-page img {
    display: block; margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WEBTOON DOCK — fixed bottom bar
   [FIX v2.2.3] Matches DHLKeyuser live site:
     • Always visible when a comic is open (display: flex)
     • Handle row: page indicator left, chevron right
     • Content row: full toolbar, shown by default (expanded)
     • No auto-hide. Only collapses on explicit chevron click.
     • Chevron points UP = expanded (toolbar visible)
     • Chevron points DOWN = collapsed (toolbar hidden)
═══════════════════════════════════════════════════════════════════════════ */
.webtoon-dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    flex-direction: column;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,.10);
}
@media (prefers-color-scheme: dark) {
    .webtoon-dock { background: rgba(18,20,24,.96); }
}

/* Handle strip — always visible */
.webtoon-dock-handle {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 6px 16px; min-height: 38px;
}

.dock-page-indicator {
    font-size: 13px; font-weight: 600; color: var(--muted);
    min-width: 60px;
}

.dock-toggle-btn {
    width: 32px; height: 32px; padding: 0;
    background: transparent; border: none;
    color: var(--muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px; transition: background .15s, color .15s;
}
.dock-toggle-btn:hover { background: var(--border); color: var(--text); }

.dock-toggle-icon {
    display: block;
    transition: transform .2s ease;
}
/* Collapsed: chevron points DOWN (rotate 180°) */
.webtoon-dock.collapsed .dock-toggle-icon { transform: rotate(180deg); }

/* Toolbar content area */
.webtoon-dock-content {
    padding: 8px 16px 12px;
    border-top: 1px solid var(--border);
}
.webtoon-dock.collapsed .webtoon-dock-content { display: none; }

/* ── Reader toolbar (lives inside .webtoon-dock-content) ────────────────── */
.reader-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    justify-content: center;
}
.reader-toolbar-group {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.toolbar-label {
    font-size: 11px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .6px; white-space: nowrap;
}

/* Mode toggle pills */
.mode-toggle {
    display: inline-flex;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.mode-btn {
    background: var(--bg); border: none; color: var(--text);
    padding: 5px 14px; font-size: 13px; cursor: pointer;
    font-family: inherit; transition: background .15s, color .15s;
    white-space: nowrap;
}
.mode-btn.active { background: var(--brand); color: #fff; }
.mode-btn:not(.active):hover { background: var(--border); }

/* Nav / action buttons */
.reader-btn {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 5px 12px; font-size: 13px; border-radius: 6px;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: background .15s, transform .1s;
}
.reader-btn:hover:not(:disabled) { background: var(--border); transform: translateY(-1px); }
.reader-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.page-indicator {
    font-size: 13px; font-weight: 600; color: var(--text);
    min-width: 56px; text-align: center;
}
.zoom-level {
    font-size: 13px; color: var(--muted);
    min-width: 44px; text-align: center;
}
.smart-gap-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--muted); cursor: pointer; user-select: none;
}
.smart-gap-toggle input { accent-color: var(--brand); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media only screen and (max-width: 768px) {
    body { padding: 16px 0 calc(var(--dock-height) + 16px); }
    #output { width: 100%; padding: 12px 12px calc(var(--dock-height) + 16px); border-radius: 0; border-left: none; border-right: none; }
    #output.scroll-mode { padding-bottom: calc(var(--dock-height) + 16px); }

    .reader-toolbar { gap: 8px 12px; }
    .mode-toggle    { width: 100%; }
    .mode-btn       { flex: 1; text-align: center; }
    .reader-toolbar-group { flex-wrap: nowrap; }

    .webtoon-dock-handle { padding: 4px 12px; }
    .webtoon-dock-content { padding: 6px 12px 10px; }
}

/* ── Full-page drop overlay ──────────────────────────────────────────── */
#page-drop-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(37, 99, 235, 0.18);
    backdrop-filter: blur(2px);
    pointer-events: none;
    border: 3px dashed rgba(99, 155, 255, 0.7);
    border-radius: 12px;
    margin: 8px;
    transition: opacity 0.15s;
}
#page-drop-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-drop-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 2rem;
    background: rgba(15, 23, 42, 0.55);
    border-radius: 16px;
    backdrop-filter: blur(4px);
}
.page-drop-message svg {
    opacity: 0.9;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

/* ── Credits footer ───────────────────────────────────────────────────── */
.credits {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    line-height: 1.5;
    padding: 4px 0;
}
.credits a {
    color: var(--accent, #3b82f6);
    text-decoration: none;
    font-weight: 500;
}
.credits a:hover { text-decoration: underline; }
.credits-sep {
    color: var(--border, #334155);
    user-select: none;
}
