/* ═══════════════════════════════════════════════════════════════
   RustMaps — app.css
   Dark industrial theme inspired by Rust's post-apocalyptic aesthetic
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
    --bg-base:        #0d0f14;
    --bg-surface:     #141820;
    --bg-card:        #1a1f2e;
    --bg-elevated:    #1f2535;
    --bg-hover:       #252c3d;

    --rust:           #ce4a0e;
    --rust-hover:     #e05512;
    --rust-dim:       #7a2c08;
    --rust-glow:      rgba(206,74,14,.25);

    --accent:         #f0a030;
    --accent-dim:     #8a5c18;

    --text-primary:   #e8e4d8;
    --text-secondary: #9a9486;
    --text-muted:     #5a5650;

    --border:         #2a2f40;
    --border-hover:   #3a4055;

    --tier1:          #e85d4a;
    --tier2:          #e8a83a;
    --outpost:        #4ae87a;
    --small:          #4a9ae8;

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  20px;

    --shadow-sm:  0 2px 8px rgba(0,0,0,.4);
    --shadow-md:  0 4px 20px rgba(0,0,0,.6);
    --shadow-lg:  0 8px 40px rgba(0,0,0,.8);

    --font-display: 'Rajdhani', sans-serif;
    --font-body:    'Inter', sans-serif;

    --nav-h: 60px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--rust); }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; }

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
    position: sticky; top: 0; z-index: 100;
    height: var(--nav-h);
    background: rgba(13,15,20,.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}
.nav-inner {
    max-width: 1400px; margin: 0 auto;
    height: 100%;
    display: flex; align-items: center; gap: 2rem;
    padding: 0 1.5rem;
}
.logo { display: flex; align-items: baseline; gap: 2px; text-decoration: none; }
.logo-rust  { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--rust); letter-spacing: .1em; }
.logo-maps  { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; color: var(--text-secondary); letter-spacing: .05em; }

.nav-links  { display: flex; gap: .25rem; list-style: none; }
.nav-links a {
    font-family: var(--font-display); font-size: .95rem; font-weight: 600;
    color: var(--text-secondary); letter-spacing: .05em; text-transform: uppercase;
    padding: .4rem .9rem; border-radius: var(--radius-sm);
    transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--text-primary); background: var(--bg-elevated);
}
.nav-auth   { display: flex; gap: .5rem; margin-left: auto; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    font-family: var(--font-display); font-weight: 600; font-size: .9rem; letter-spacing: .04em;
    padding: .5rem 1.25rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    transition: background .2s, color .2s, border-color .2s, transform .1s;
    white-space: nowrap; text-transform: uppercase;
}
.btn:active { transform: scale(.97); }

.btn-primary {
    background: var(--accent); color: #0d0f14; border-color: var(--accent);
}
.btn-primary:hover { background: #ffb848; color: #0d0f14; }

.btn-rust {
    background: var(--rust); color: #fff; border-color: var(--rust);
}
.btn-rust:hover { background: var(--rust-hover); }

.btn-ghost {
    background: transparent; color: var(--text-secondary); border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-elevated); }

.btn-full { width: 100%; justify-content: center; }
.btn-lg   { padding: .75rem 1.5rem; font-size: 1.05rem; }

/* ── Flash ──────────────────────────────────────────────────────── */
.flash {
    max-width: 1400px; margin: .75rem auto; padding: .75rem 1.5rem;
    border-radius: var(--radius-md); font-size: .9rem;
    border-left: 3px solid;
}
.flash--success { background: rgba(74,232,122,.1); border-color: #4ae87a; color: #4ae87a; }
.flash--error   { background: rgba(232,93,74,.1);  border-color: var(--tier1); color: var(--tier1); }

/* ── Page content ───────────────────────────────────────────────── */
.page-content { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ── Footer ─────────────────────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}
.footer-inner {
    max-width: 1400px; margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex; align-items: center; gap: 2rem;
    font-size: .8rem; color: var(--text-muted);
}

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.25rem; }
.form-group label {
    font-family: var(--font-display); font-weight: 600; font-size: .85rem;
    letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: .6rem .9rem; border-radius: var(--radius-sm);
    font-size: .95rem; outline: none;
    transition: border-color .2s;
    width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="range"] {
    -webkit-appearance: none;
    width: 100%; height: 4px;
    background: var(--bg-hover); border-radius: 2px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--rust); border: 2px solid var(--text-primary); cursor: pointer;
}
.checkbox-label {
    display: flex; align-items: center; gap: .5rem;
    font-size: .9rem; color: var(--text-secondary); cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--rust); }

/* ── Accent text ────────────────────────────────────────────────── */
.accent { color: var(--rust); }

/* ── Gallery page ───────────────────────────────────────────────── */
.gallery-hero {
    text-align: center; padding: 3rem 0 2.5rem;
}
.gallery-hero h1 {
    font-family: var(--font-display); font-size: 3rem; font-weight: 700;
    letter-spacing: .04em; margin-bottom: .5rem;
}
.gallery-hero p { color: var(--text-secondary); margin-bottom: 1.5rem; }

.search-bar {
    display: flex; gap: .5rem; justify-content: center; max-width: 600px; margin: 0 auto;
}
.search-bar input { flex: 1; }

.gallery-layout {
    display: grid; grid-template-columns: 240px 1fr; gap: 2rem; margin-top: 2rem;
}

/* Filters sidebar */
.filters-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: fit-content;
    position: sticky; top: calc(var(--nav-h) + 1rem);
}
.filter-title {
    font-family: var(--font-display); font-size: 1.1rem; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-secondary); margin-bottom: 1.25rem;
    padding-bottom: .75rem; border-bottom: 1px solid var(--border);
}
.filters-sidebar label {
    font-family: var(--font-display); font-size: .8rem; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-muted); display: block; margin-bottom: .35rem; margin-top: .9rem;
}
.range-row { display: flex; align-items: center; gap: .5rem; }
.range-row span { color: var(--text-muted); }
.range-row input { width: 80px; }

/* Map grid */
.result-count { font-size: .85rem; color: var(--text-muted); margin-bottom: 1rem; }

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

/* Map card */
.map-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden; cursor: pointer;
    transition: border-color .2s, transform .2s, box-shadow .2s;
}
.map-card:hover {
    border-color: var(--rust-dim);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 20px var(--rust-glow);
}
.map-thumb {
    position: relative; aspect-ratio: 1; background: #111620;
    overflow: hidden;
}
.map-thumb img, .map-thumb canvas {
    width: 100%; height: 100%; object-fit: cover;
}
.map-badges {
    position: absolute; top: .5rem; left: .5rem;
    display: flex; gap: .3rem; flex-wrap: wrap;
}
.badge {
    font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    padding: 2px 6px; border-radius: 3px;
}
.badge--staging { background: rgba(74,154,232,.2); color: #4a9ae8; border: 1px solid #4a9ae8; }
.badge--barren  { background: rgba(232,168,58,.2); color: var(--accent); border: 1px solid var(--accent); }

.map-info { padding: .75rem; }
.map-meta { display: flex; justify-content: space-between; margin-bottom: .4rem; }
.map-seed { font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.map-size { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.map-stats { display: flex; gap: .75rem; font-size: .78rem; color: var(--text-muted); }

.empty-state {
    text-align: center; padding: 4rem; color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; font-size: 1.1rem; }

/* Pagination */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 1rem; margin-top: 2.5rem;
    font-size: .9rem; color: var(--text-secondary);
}

/* ── Generator page ─────────────────────────────────────────────── */
.generator-page {
    max-width: 600px; margin: 3rem auto;
}
.generator-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
}
.generator-card h1 {
    font-family: var(--font-display); font-size: 2.2rem; font-weight: 700;
    margin-bottom: .5rem; letter-spacing: .04em;
}
.subtitle { color: var(--text-secondary); margin-bottom: 2rem; font-size: .95rem; }

.gen-form { margin-bottom: 1.5rem; }

.seed-row { display: flex; gap: .5rem; }
.seed-row input { flex: 1; }

.size-ticks {
    display: flex; justify-content: space-between;
    font-size: .72rem; color: var(--text-muted);
    margin-top: .35rem; padding: 0 2px;
}
.form-row { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; }

.gen-progress { margin-top: 1.5rem; }
.progress-bar {
    background: var(--bg-elevated); border-radius: 4px; height: 6px; overflow: hidden;
    margin-bottom: .75rem;
}
.progress-fill {
    height: 100%; background: var(--rust); border-radius: 4px;
    width: 0; transition: width .4s ease;
}
#progress-msg { font-size: .9rem; color: var(--text-secondary); text-align: center; }

.size-presets {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    margin-top: 1.25rem; font-size: .8rem; color: var(--text-muted);
}
.preset-btn {
    background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text-secondary); padding: .3rem .6rem; border-radius: var(--radius-sm);
    cursor: pointer; font-size: .78rem; font-family: var(--font-display); font-weight: 600;
    transition: border-color .2s, color .2s;
}
.preset-btn:hover { border-color: var(--rust-dim); color: var(--text-primary); }

/* ── Map show page ──────────────────────────────────────────────── */
.map-page {}
.map-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.map-title {
    font-family: var(--font-display); font-size: 2.4rem; font-weight: 700;
    letter-spacing: .04em;
}
.map-subtitle { color: var(--text-secondary); font-size: .9rem; margin-top: .25rem; }
.map-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.viewer-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: stretch;
}
.viewer-col { min-width: 0; }

/* Le viewer est carré : hauteur = largeur de la colonne viewer-col */
#map-viewer {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: calc(100vh - var(--nav-h) - 100px);
    background: #0d1e2e;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
    cursor: crosshair;
}
#map-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: block;
}
#heatmap-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s;
}
#heatmap-canvas.active { opacity: .75; }
#monument-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.viewer-toolbar {
    display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
    background: var(--bg-card); border: 1px solid var(--border);
    border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: .6rem .75rem;
}
.tool-btn, .layer-btn {
    font-family: var(--font-display); font-size: .78rem; font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase;
    background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text-secondary); padding: .3rem .6rem; border-radius: 4px;
    cursor: pointer; transition: all .15s;
}
.tool-btn.active, .layer-btn.active {
    background: var(--rust); border-color: var(--rust); color: #fff;
}
.tool-btn:hover, .layer-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 .15rem; }
.toolbar-label { font-size: .75rem; color: var(--text-muted); font-family: var(--font-display); letter-spacing: .05em; text-transform: uppercase; }

/* Monument sidebar */
.monument-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    overflow-y: auto;
    /* stretch = même hauteur que le viewer */
    min-height: 200px;
}
.monument-sidebar h3 {
    font-family: var(--font-display); font-size: 1rem; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase;
    border-bottom: 1px solid var(--border); padding-bottom: .75rem; margin-bottom: 1rem;
    color: var(--text-secondary);
}
.monument-group { margin-bottom: 1.1rem; }
.monument-cat {
    font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: .4rem;
}
.monument-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem .5rem; border-radius: 4px;
    font-size: .85rem; cursor: pointer;
    transition: background .15s;
}
.monument-item:hover { background: var(--bg-hover); }
.mon-icon { font-size: .9rem; }

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-page {
    max-width: 440px; margin: 4rem auto;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
}
.auth-card h2 {
    font-family: var(--font-display); font-size: 1.8rem; font-weight: 700;
    margin-bottom: 1.5rem; letter-spacing: .04em;
}
.auth-form {}
.auth-switch {
    text-align: center; margin-top: 1.25rem; font-size: .88rem; color: var(--text-muted);
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .gallery-layout   { grid-template-columns: 1fr; }
    .filters-sidebar  { position: static; }
}
@media (max-width: 900px) {
    .viewer-layout    { grid-template-columns: 1fr; }
    .monument-sidebar { position: static; max-height: 300px; }
}
@media (max-width: 640px) {
    .gallery-hero h1  { font-size: 2rem; }
    .search-bar       { flex-direction: column; }
    .map-header       { flex-direction: column; }
    .nav-links        { display: none; }
}
