/* ═══════════════════════════════════════════════════════
   DCT Reconstruction & Quantization Sandbox – Styles
   ═══════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    --bg-primary: #0c0e14;
    --bg-secondary: #13161f;
    --bg-card: rgba(22, 27, 40, 0.75);
    --bg-glass: rgba(30, 36, 54, 0.55);
    --border-color: rgba(100, 120, 180, 0.15);
    --border-glow: rgba(100, 140, 255, 0.25);
    --text-primary: #e8ecf4;
    --text-secondary: #8b95b0;
    --text-muted: #5a6380;
    --accent-1: #6c8cff;
    --accent-2: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #6c8cff 0%, #a78bfa 100%);
    --danger: #ff6b8a;
    --success: #4ade80;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 20px rgba(108, 140, 255, 0.15);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    line-height: 1.55;
    overflow-x: hidden;
    padding-bottom: 100px;
    /* room for sticky slider */
}

/* ─── Top Navigation ─── */
#top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(12, 14, 20, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
}

#back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

#back-btn:hover {
    border-color: var(--accent-1);
    background: rgba(108, 140, 255, 0.1);
}

#back-btn:active {
    transform: scale(0.96);
}

#nav-title {
    font-size: 1rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

#nav-spacer {
    width: 80px;
}

/* ─── Pages ─── */
.page {
    display: none;
    padding: 20px 16px 30px;
    max-width: 860px;
    margin: 0 auto;
    animation: fadeIn 0.35s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

/* ─── Preset Grid (Page 1) ─── */
#preset-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.preset-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.preset-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.preset-card:active {
    transform: scale(0.98);
}

.preset-card canvas {
    width: 100%;
    aspect-ratio: 1;
    display: block;
    image-rendering: auto;
}

.card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.92rem;
    border-top: 1px solid var(--border-color);
    background: rgba(12, 14, 20, 0.5);
}

.card-icon {
    font-size: 1.15rem;
}

/* Upload card */
.upload-card {
    display: flex;
    flex-direction: column;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 50px 20px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    border: 2px dashed rgba(100, 120, 180, 0.25);
    border-radius: var(--radius-sm);
    margin: 16px;
    transition: var(--transition);
}

.upload-card:hover .upload-placeholder {
    border-color: var(--accent-1);
    color: var(--accent-1);
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ─── Block Selection (Page 2) ─── */
#block-select-container {
    display: flex;
    justify-content: center;
}

#image-canvas-wrap {
    position: relative;
    display: inline-block;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    cursor: crosshair;
    max-width: 100%;
}

#image-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
}

#grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ─── Analysis Panels (Page 3) ─── */
#analysis-panels {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.analysis-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.analysis-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.analysis-card h3 {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.analysis-card canvas {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1;
    image-rendering: pixelated;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* Stats Bar */
#stats-bar {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    min-width: 140px;
    backdrop-filter: blur(8px);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Sticky Slider Dock ─── */
#slider-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    padding: 12px 16px 20px;
    background: rgba(12, 14, 20, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#slider-dock.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

#slider-inner {
    max-width: 680px;
    margin: 0 auto;
}

#slider-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.slider-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-gradient);
    border-radius: 99px;
}

/* Range slider styling */
#threshold-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
    outline: none;
    cursor: pointer;
}

#threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-1);
    box-shadow: 0 2px 8px rgba(108, 140, 255, 0.35);
    cursor: grab;
    transition: transform 0.15s ease;
}

#threshold-slider::-webkit-slider-thumb:active {
    transform: scale(1.15);
    cursor: grabbing;
}

#threshold-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-1);
    box-shadow: 0 2px 8px rgba(108, 140, 255, 0.35);
    cursor: grab;
}

/* ─── Full Image Reconstruction ─── */
#full-recon-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

#full-recon-title {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

#full-recon-panels {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.full-recon-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.full-recon-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.full-recon-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.full-recon-card canvas {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    image-rendering: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: block;
    margin: 0 auto;
}

#full-recon-stats {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Tablet / Desktop (≥ 768px) ─── */
@media (min-width: 768px) {
    #top-nav {
        padding: 14px 28px;
    }

    #nav-title {
        font-size: 1.15rem;
    }

    .page {
        padding: 30px 28px 40px;
        max-width: 1100px;
    }

    .page-header h2 {
        font-size: 1.65rem;
    }

    #preset-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    #analysis-panels {
        grid-template-columns: 1fr 1fr 1fr;
    }

    #full-recon-panels {
        grid-template-columns: 1fr 1fr;
    }

    #slider-dock {
        padding: 16px 28px 24px;
    }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 120, 180, 0.25);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 120, 180, 0.4);
}

/* ─── Selection ─── */
::selection {
    background: rgba(108, 140, 255, 0.3);
}