/* ── ekokrati design system ──────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

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

:root {
    --bg:           #f2f0eb;
    --surface:      #fafaf8;
    --border:       #d8d5ce;
    --text:         #1a1a18;
    --muted:        #7a7870;
    --accent:       #2d6a4f;
    --accent-h:     #1b4332;
    --accent-dim:   #d8eedd;
    --danger:       #b5322a;
    --success:      #2a7a52;
    --warning-bg:   #fef3c7;
    --warning-text: #92400e;
    --mono:         'IBM Plex Mono', monospace;
    --sans:         'IBM Plex Sans', sans-serif;
    --radius:       3px;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 0;
}

.container { max-width: 700px; margin: 0 auto; padding: 2.5rem 1rem 4rem; }

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 48px;
    padding: 0 1.5rem;
    background: var(--text);
    color: white;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-nav {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.65rem;
}
.header-nav a { color: #aaa; text-decoration: none; }
.header-nav a:hover { color: white; }
.nav-signout { background: none; border: none; padding: 0; color: #aaa; font: inherit; cursor: pointer; }
.nav-signout:hover { color: white; }

.site-header .wordmark {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    color: white;
    letter-spacing: -0.02em;
}

.site-header .wordmark span { color: var(--accent-dim); }

.site-header .breadcrumb {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: #999;
}

.site-header .breadcrumb a {
    color: #ccc;
    text-decoration: none;
}

.site-header .breadcrumb a:hover { color: white; }

/* ── Page title ──────────────────────────────────────────────────────────── */

.page-title {
    font-family: var(--mono);
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 2rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-title {
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* ── Form elements ───────────────────────────────────────────────────────── */

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }

input[type="text"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--sans);
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.12s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

select:disabled { background: var(--bg); color: var(--muted); }

.hint {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.2rem;
    font-family: var(--mono);
}

.params-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ── Mode toggle ─────────────────────────────────────────────────────────── */

.mode-toggle {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.mode-btn {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: none;
    border-right: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.mode-btn:last-child { border-right: none; }
.mode-btn.active { background: var(--text); color: #fff; }
.mode-btn:hover:not(.active) { background: var(--bg); }
.mode-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mode-btn.restored { color: var(--accent); font-style: italic; }
.mode-btn.restored::after { content: ' ✓'; font-style: normal; }

/* ── File drop ───────────────────────────────────────────────────────────── */

.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}

.file-drop:hover, .file-drop.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.file-drop input[type="file"] {
    position: absolute; inset: 0; opacity: 0;
    cursor: pointer; width: 100%; height: 100%;
}

.file-drop .drop-icon  { font-size: 1.4rem; margin-bottom: 0.4rem; position: relative; z-index: 1; pointer-events: none; }
.file-drop .drop-label { font-size: 0.8rem; color: var(--muted); font-family: var(--mono); position: relative; z-index: 1; pointer-events: none; }
.file-drop .drop-fname { font-size: 0.8rem; font-weight: 600; color: var(--accent); margin-top: 0.4rem; font-family: var(--mono); position: relative; z-index: 1; pointer-events: none; }
.file-drop.has-file .drop-icon  { display: none; }
.file-drop.has-file .drop-label { display: none; }
.file-drop.has-file .drop-fname { margin-top: 0; }

.file-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ── Basemap selector (shared: map.html, compare.html) ─────────────────── */
.basemap-btns { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.btn-basemap {
    padding: 0.25rem 0.55rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.12s;
}
.btn-basemap:hover          { border-color: var(--accent); color: var(--accent); }
.btn-basemap.active         { background: var(--accent); border-color: var(--accent); color: white; }
.btn-basemap:disabled       { opacity: 0.35; cursor: not-allowed; }
.btn-basemap:disabled:hover { border-color: var(--border); color: var(--muted); }
.layer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.72rem; padding: 0.2rem 0.5rem;
    border-radius: 99px; font-weight: 500; font-family: var(--mono);
}

.badge.loading { background: var(--warning-bg); color: var(--warning-text); }
.badge.ok      { background: var(--accent-dim); color: var(--accent-h); }
.badge.error   { background: #fee2e2; color: var(--danger); }

/* ── Quiet action links (secondary navigation, contextual actions) ───────── */

.link-quiet {
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.link-quiet:hover { color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--text);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--mono);
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: 0.02em;
}

.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    display: inline-block;
    padding: 0.45rem 1rem;
    background: var(--text);
    color: white;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--mono);
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.btn-secondary:hover { background: var(--accent); }

/* ── Status panel ────────────────────────────────────────────────────────── */

.status-panel {
    display: none;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-left: 4px solid var(--accent);
}

.status-panel.error  { border-left-color: var(--danger); }
.status-panel.done   { border-left-color: var(--success); }
.status-panel.running { border-left-color: var(--accent); }
.status-panel.info   { border-left-color: var(--muted); }

.density-warning {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}
.density-warning.caution {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-left: 4px solid #f59e0b;
}
.density-warning.strong {
    background: #fee2e2;
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

.time-estimate {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.time-estimate.low-confidence {
    font-style: italic;
}

.usage-banner {
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.usage-banner.warning {
    background: #fff8e1;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}
.usage-banner.blocked {
    background: #fef2f2;
    border-left: 4px solid var(--danger);
    color: #991b1b;
}

.status-title  { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.15rem; }
.status-detail { font-size: 0.78rem; color: var(--muted); font-family: var(--mono); }

/* ── Results ─────────────────────────────────────────────────────────────── */

.results-panel { display: none; margin-top: 1rem; }

.results-panel pre {
    background: #1a1a18;
    color: #c8c5be;
    padding: 1rem;
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.75rem;
    overflow-x: auto;
    max-height: 420px;
    line-height: 1.5;
}

/* ── Animations ──────────────────────────────────────────────────────────── */

.progress-dots::after {
    content: '';
    animation: dots 1.2s steps(3, end) infinite;
}

@keyframes dots {
    0%   { content: ''; }
    33%  { content: '.'; }
    66%  { content: '..'; }
    100% { content: '...'; }
}

/* ── Progress bar ────────────────────────────────────────────────────────── */

.progress-bar {
    display: none;
    height: 3px;
    background: var(--border);
    border-radius: 99px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 1s linear;
    width: 0%;
}

.elapsed-timer {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* ── Mobile gate ──────────────────────────────────────────────────────────── */

.mobile-gate {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    text-align: center;
    gap: 0.75rem;
}

.mobile-gate-mark {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.mobile-gate-mark span { color: var(--accent); }

.mobile-gate-msg {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    max-width: 260px;
    line-height: 1.5;
}

.mobile-gate-hint {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
    max-width: 240px;
    line-height: 1.6;
}


@media (max-width: 600px) {
    .mobile-gate { display: flex; }
}
