/* ============================================================
   MitStadt — Civic Botany
   System-Stack, Mobile-First, kein Build, keine externen Fonts
   ============================================================ */

:root {
    /* — Farben ——————————————————————————————————— */
    --c-ink:        #1a1a17;            /* fast schwarz, leicht warm */
    --c-ink-soft:   #4a4a45;
    --c-ink-mute:   #767169;
    --c-ink-fade:   #b6b1a6;
    --c-paper:      #f4f0e6;            /* kreidiges Off-White, Hintergrund */
    --c-paper-pure: #faf8f1;            /* Cards */
    --c-line:       #1a1a17;            /* Strich-Schwarz */
    --c-line-soft:  rgba(26, 26, 23, .15);
    --c-line-faint: rgba(26, 26, 23, .08);

    --c-brand:      #1a4d2e;            /* Mossgrün */
    --c-brand-deep: #0f3520;
    --c-brand-soft: #d8e6dd;
    --c-brand-tint: #e7eee9;
    --c-accent:     #c43d2c;            /* gedämpftes Krapprot — sparsam */

    --c-sev-low:      #ffd54f;
    --c-sev-medium:   #ff9800;
    --c-sev-high:     #f4511e;
    --c-sev-critical: #b71c1c;

    --c-status-ok:    #1a4d2e;
    --c-status-warn:  #c97f1e;
    --c-status-info:  #45607a;

    /* — Typografie ——————————————————————————————— */
    --font-display: "Charter", "Iowan Old Style", "Sitka Text",
                    "Georgia", "Cambria", ui-serif, serif;
    --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI",
                    "Helvetica Neue", "Arial Nova", sans-serif;
    --font-mono:    "SF Mono", "Cascadia Code", "Roboto Mono",
                    "JetBrains Mono", ui-monospace, monospace;

    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: 1.375rem;
    --fs-xl: 1.875rem;
    --fs-2xl: 2.5rem;
    --fs-3xl: 3.25rem;

    /* — Spacing ————————————————————————————————— */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4.5rem;

    /* — Shape ——————————————————————————————————— */
    --r-sm: 3px;
    --r-md: 6px;
    --r-lg: 10px;

    --shadow-sm: 0 1px 0 rgba(26, 26, 23, .08);
    --shadow-md: 0 2px 0 rgba(26, 26, 23, .12);

    --content-max: 1080px;
    --narrow-max:  640px;
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

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

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--c-ink);
    background-color: var(--c-paper);
    /* Subtile Papier-Textur — zwei feine Punktraster */
    background-image:
        radial-gradient(rgba(26, 26, 23, .04) 1px, transparent 1px),
        radial-gradient(rgba(26, 26, 23, .025) 1px, transparent 1px);
    background-size: 18px 18px, 7px 7px;
    background-position: 0 0, 9px 9px;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--c-ink);
    margin: 0 0 var(--sp-4) 0;
    line-height: 1.15;
}

h1 { font-size: clamp(1.875rem, 4.5vw, var(--fs-3xl)); font-weight: 700; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

p  { margin: 0 0 var(--sp-3) 0; }

a {
    color: var(--c-brand);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    text-decoration-color: rgba(26, 77, 46, .35);
    transition: text-decoration-color .15s ease;
}
a:hover { text-decoration-color: var(--c-brand); }

code, pre, .mono { font-family: var(--font-mono); }

hr {
    border: 0;
    border-top: 1px solid var(--c-line);
    margin: var(--sp-5) 0;
}

/* ============================================================
   Layout
   ============================================================ */

.app-header {
    background: var(--c-paper);
    color: var(--c-ink);
    padding: var(--sp-4) var(--sp-4);
    border-bottom: 1px solid var(--c-line);
    position: sticky;
    top: 0;
    z-index: 50;
    /* dünner zweiter Strich darunter — typografische Geste */
    box-shadow: 0 4px 0 -3px var(--c-line);
}

.app-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
    max-width: var(--content-max);
    margin: 0 auto;
}

.app-header .brand {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--c-ink);
    text-decoration: none;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: baseline;
    gap: 0.4em;
}
.app-header .brand::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--c-brand);
    border-radius: 50%;
    margin-right: 0.15em;
    transform: translateY(-1px);
}
.app-header .brand span {
    font-weight: 400;
    color: var(--c-ink-soft);
    font-style: italic;
    font-size: 0.92em;
}

.app-nav {
    display: flex;
    gap: var(--sp-1);
    align-items: center;
    flex-wrap: wrap;
    font-size: var(--fs-sm);
}

.app-nav .nav-link {
    color: var(--c-ink-soft);
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: var(--r-sm);
    font-weight: 500;
    border: 1px solid transparent;
    transition: color .12s, border-color .12s;
}
.app-nav .nav-link:hover {
    color: var(--c-ink);
    border-color: var(--c-line-soft);
}
.app-nav .nav-link[aria-current="page"] {
    color: var(--c-ink);
    border-color: var(--c-line);
    background: var(--c-paper-pure);
}

.app-nav .nav-user {
    border-left: 1px solid var(--c-line-soft);
    padding-left: var(--sp-3);
    margin-left: var(--sp-2);
    color: var(--c-brand-deep);
    font-weight: 600;
}

.app-nav .nav-btn {
    background: transparent;
    border: 1px solid var(--c-line);
    color: var(--c-ink);
    padding: 0.35rem 0.85rem;
    min-height: 0;
    border-radius: var(--r-sm);
    font: inherit;
    font-size: var(--fs-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.app-nav .nav-btn:hover {
    background: var(--c-ink);
    color: var(--c-paper);
}

.app-main {
    padding: var(--sp-5) var(--sp-4) var(--sp-8);
    max-width: var(--content-max);
    margin: 0 auto;
}

.container-narrow {
    max-width: var(--narrow-max);
    margin: 0 auto;
}

/* ============================================================
   Cards — Eckmarker statt Schatten
   ============================================================ */

.card {
    background: var(--c-paper-pure);
    border: 1px solid var(--c-line);
    padding: var(--sp-5);
    margin-bottom: var(--sp-4);
    position: relative;
}
/* Vier kleine Eckmarker — wie auf Vermessungsplänen */
.card::before, .card::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    border: 2px solid var(--c-brand);
    background: var(--c-paper-pure);
    pointer-events: none;
}
.card::before { top: -5px; left: -5px;
    border-right: 0; border-bottom: 0; }
.card::after  { bottom: -5px; right: -5px;
    border-left: 0; border-top: 0; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    padding: 0.7em 1.25em;
    min-height: 2.6em;
    background: var(--c-brand);
    color: var(--c-paper);
    border: 1px solid var(--c-brand);
    border-radius: var(--r-sm);
    font: 600 var(--fs-sm)/1.1 var(--font-body);
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s, transform .04s;
    text-align: center;
}
.btn:hover    { background: var(--c-brand-deep); border-color: var(--c-brand-deep); color: var(--c-paper); }
.btn:active   { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-block { display: flex; width: 100%; }

.btn-secondary {
    background: var(--c-paper-pure);
    color: var(--c-ink);
    border-color: var(--c-line);
}
.btn-secondary:hover {
    background: var(--c-ink);
    color: var(--c-paper);
    border-color: var(--c-ink);
}

.btn-ghost {
    background: transparent;
    color: var(--c-ink-soft);
    border-color: var(--c-line-soft);
}
.btn-ghost:hover {
    color: var(--c-ink);
    border-color: var(--c-line);
    background: var(--c-paper-pure);
}

/* ============================================================
   FAB — bleibt als floating action button, aber gedämpfter
   ============================================================ */

.fab {
    position: fixed;
    bottom: var(--sp-5);
    right: var(--sp-5);
    z-index: 40;
    box-shadow: 0 4px 0 var(--c-brand-deep), 0 6px 16px rgba(0,0,0,.18);
    padding: 0.85em 1.4em;
}

/* ============================================================
   Forms
   ============================================================ */

.field {
    margin-bottom: var(--sp-4);
}
.field label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--c-ink);
    margin-bottom: var(--sp-1);
    letter-spacing: 0.01em;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="datetime-local"],
.field input[type="file"],
.field select,
.field textarea,
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 0.65em 0.8em;
    border: 1px solid var(--c-line);
    border-radius: var(--r-sm);
    background: var(--c-paper-pure);
    color: var(--c-ink);
    font: inherit;
    font-size: var(--fs-base);
    transition: border-color .12s, box-shadow .12s;
}
.field textarea { resize: vertical; min-height: 5rem; }
.field input:focus,
.field select:focus,
.field textarea:focus,
input:focus {
    outline: 0;
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px var(--c-brand-soft);
}
.field input[readonly] { background: var(--c-paper); color: var(--c-ink-soft); }

/* ============================================================
   Listen — Eintrag mit Hairline & Hover-Strich
   ============================================================ */

.list { list-style: none; padding: 0; margin: 0; }

.list-card {
    background: var(--c-paper-pure);
    border: 1px solid var(--c-line-soft);
    border-left: 3px solid var(--c-line-soft);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-2);
    transition: border-color .15s, transform .04s;
}
.list-card:hover {
    border-color: var(--c-line);
    border-left-color: var(--c-brand);
}
.list-card a { color: inherit; text-decoration: none; }
.list-card a:hover { color: var(--c-brand-deep); }
.list-card strong { font-weight: 600; }

/* ============================================================
   KPI — kleine Vermessungstafel
   ============================================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--sp-3);
    margin: var(--sp-4) 0;
}

.kpi {
    background: var(--c-paper-pure);
    border: 1px solid var(--c-line);
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
    position: relative;
    text-align: left;
}
/* Eck-Markierungen oben links und unten rechts */
.kpi::before, .kpi::after {
    content: "";
    position: absolute;
    width: 6px; height: 6px;
    background: var(--c-brand);
}
.kpi::before { top: -3px; left: -3px; }
.kpi::after  { bottom: -3px; right: -3px; }

.kpi-value {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--c-ink);
    line-height: 1;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums lining-nums;
}
.kpi-label {
    font-size: var(--fs-xs);
    color: var(--c-ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: var(--sp-2);
    font-weight: 600;
}

/* ============================================================
   Badge — Status-Pille mit Punkt
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--c-ink);
    background: var(--c-paper-pure);
    border: 1px solid var(--c-line);
    padding: 0.25em 0.65em;
    border-radius: 999px;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}
.badge::before {
    content: "";
    width: 0.55em; height: 0.55em;
    border-radius: 50%;
    background: var(--c-ink-soft);
}

.badge-sev-low::before      { background: var(--c-sev-low); }
.badge-sev-medium::before   { background: var(--c-sev-medium); }
.badge-sev-high::before     { background: var(--c-sev-high); }
.badge-sev-critical::before { background: var(--c-sev-critical); }

/* Status-Varianten — Klassen optional, sonst Default */
.badge-active::before     { background: var(--c-status-ok); }
.badge-pending::before    { background: var(--c-status-warn); }
.badge-resolved::before   { background: var(--c-brand); }
.badge-escalated::before  { background: var(--c-accent); }
.badge-available::before  { background: var(--c-status-ok); }
.badge-sponsored::before  { background: var(--c-ink-mute); }

/* ============================================================
   Map-Container
   ============================================================ */

.map-container {
    width: 100%;
    height: 60vh;
    min-height: 380px;
    border: 1px solid var(--c-line);
    background: var(--c-paper-pure);
    overflow: hidden;
    position: relative;
    /* iPad-Touch-Robustheit: vertikales Page-Scrollen ueber der Karte
       erlauben (touch-action), damit Page-Pan an die Karte nicht
       eingefangen wird. Tap-Gesten auf Layer bleiben unveraendert. */
    touch-action: pan-y;
}
.map-container canvas {
    /* MapLibre-Canvas ueberschreibt touch-action des Containers — wir
       lassen Pinch+Pan, was MapLibre selbst handhabt. */
    touch-action: none;
}
/* Eckmarker auf der Karte — wie ein eingerahmter Plan */
.map-container::before, .map-container::after {
    content: "";
    position: absolute;
    width: 14px; height: 14px;
    border: 2px solid var(--c-ink);
    pointer-events: none;
    z-index: 4;
}
.map-container::before { top: 6px; left: 6px;
    border-right: 0; border-bottom: 0; }
.map-container::after  { bottom: 6px; right: 6px;
    border-left: 0; border-top: 0; }

.map-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    padding: var(--sp-2);
    border: 1px solid var(--c-line-soft);
    background: var(--c-paper-pure);
}

.map-toolbar .btn {
    padding: 0.5em 0.9em;
    min-height: 2.2em;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.map-toolbar .btn[aria-pressed="true"] {
    background: var(--c-ink);
    color: var(--c-paper);
    border-color: var(--c-ink);
}
.map-toolbar .btn[aria-pressed="false"] {
    background: var(--c-paper-pure);
    color: var(--c-ink-soft);
    border-color: var(--c-line-soft);
}

.map-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-line-soft);
    border-top: 0;
    background: var(--c-paper-pure);
    align-items: center;
}

.field-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0;
    font-size: var(--fs-xs);
}

.field-inline > span {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--c-ink-soft);
}

.field-inline select {
    padding: 0.35em 0.6em;
    font-size: var(--fs-xs);
    border: 1px solid var(--c-line-soft);
    background: var(--c-paper);
    color: var(--c-ink);
}

/* ============================================================
   Hero — Public-Map und ähnliche Eingangsseiten
   ============================================================ */

.hero {
    margin-bottom: var(--sp-5);
}
.hero-eyebrow {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--c-ink-soft);
    margin-bottom: var(--sp-2);
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}
.hero-eyebrow::before {
    content: "";
    width: 24px; height: 1px;
    background: var(--c-ink);
}
.hero h1 {
    font-size: clamp(2rem, 5vw, var(--fs-3xl));
    margin-bottom: var(--sp-3);
}
.hero h1 em {
    font-style: italic;
    font-weight: 500;
    color: var(--c-brand);
}
.hero-lede {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    color: var(--c-ink-soft);
    line-height: 1.4;
    max-width: 38em;
    margin-bottom: var(--sp-5);
}

/* ============================================================
   Section-Titel — wiederverwendbar
   ============================================================ */

.section-title {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    margin: var(--sp-6) 0 var(--sp-3);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--c-line);
}
.section-title h2 {
    margin: 0;
    font-size: var(--fs-lg);
}
.section-title .count {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--c-ink-mute);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-left: auto;
}

/* ============================================================
   Empty-State
   ============================================================ */

.empty {
    padding: var(--sp-5);
    text-align: center;
    color: var(--c-ink-soft);
    border: 1px dashed var(--c-line-soft);
    background: transparent;
}
.empty strong {
    display: block;
    color: var(--c-ink);
    font-family: var(--font-display);
    font-size: var(--fs-md);
    margin-bottom: var(--sp-2);
}

/* ============================================================
   Stepper — Report-Create und ähnliche Workflows
   ============================================================ */

.stepper {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    margin: var(--sp-5) 0;
    border-top: 1px solid var(--c-line);
    border-bottom: 1px solid var(--c-line);
    background: var(--c-paper-pure);
}
.stepper .step {
    padding: var(--sp-3);
    border-right: 1px solid var(--c-line-soft);
    display: grid;
    grid-template-rows: auto auto;
    align-items: start;
    gap: var(--sp-1);
    position: relative;
}
.stepper .step:last-child { border-right: 0; }

.stepper .step-num {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.1em;
    color: var(--c-ink-mute);
}
.stepper .step-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--c-ink-soft);
    font-size: var(--fs-base);
}
.stepper .step.active .step-num {
    color: var(--c-brand);
}
.stepper .step.active .step-title {
    color: var(--c-ink);
}
.stepper .step.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0; right: 0;
    height: 3px;
    background: var(--c-brand);
}

/* ============================================================
   Bottom-Sheet (Karten-Klick)
   ============================================================ */

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: var(--c-paper-pure);
    border-top: 1px solid var(--c-line);
    border-left: 1px solid var(--c-line);
    border-right: 1px solid var(--c-line);
    padding: var(--sp-4);
    z-index: 1000;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 -8px 0 -6px var(--c-line),
                0 -2px 24px rgba(0,0,0,.08);
    animation: sheet-up .2s ease;
}
@keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* ============================================================
   Snap-Toggle (Section-Editor)
   ============================================================ */

.snap-toggle .snap-dot {
    display: inline-block;
    width: 0.55em; height: 0.55em;
    border-radius: 50%;
    background: var(--c-ink-fade);
    transition: background .15s, box-shadow .15s;
}
.snap-toggle[aria-pressed="true"] .snap-dot {
    background: var(--c-brand);
    box-shadow: 0 0 0 3px var(--c-brand-soft);
}

/* ============================================================
   Helpers
   ============================================================ */

.muted, .text-muted { color: var(--c-ink-soft); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }

/* Action-Row im Header bzw. Profil */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin: var(--sp-3) 0 var(--sp-5);
}

/* ============================================================
   Responsiv
   ============================================================ */

@media (max-width: 600px) {
    .app-header { padding: var(--sp-3); }
    .app-main   { padding: var(--sp-4) var(--sp-3) var(--sp-7); }
    .card       { padding: var(--sp-4); }
    .stepper    { grid-template-columns: 1fr; }
    .stepper .step { border-right: 0; border-bottom: 1px solid var(--c-line-soft); }
    .stepper .step:last-child { border-bottom: 0; }
    .stepper .step.active::after { left: 0; right: auto; bottom: 0; top: 0;
        width: 3px; height: auto; }
    .map-container { height: 60vh; min-height: 360px; }
    /* Karten-Toolbar wickelt sich um, Buttons werden mindestens 44px hoch
       (Apple/Google-Touch-Target-Empfehlung). */
    .map-toolbar {
        flex-wrap: wrap;
        gap: .35rem;
    }
    .map-toolbar .btn {
        flex: 1 1 auto;
        min-height: 44px;
        font-size: var(--fs-sm);
    }
    /* GPS-Block in /activity/new/ optisch prominenter */
    #track-section [style*="border:1px dashed"] {
        padding: 1rem !important;
    }
    #track-section #gps-start, #track-section #gps-stop {
        flex: 1 1 calc(50% - .25rem);
        min-height: 48px;
        font-size: 1.05em;
    }
    /* Form-Felder Touch-friendly */
    input[type="text"], input[type="email"], input[type="password"],
    input[type="number"], input[type="datetime-local"], select, textarea {
        min-height: 44px;
        font-size: 16px; /* iOS zoomt sonst beim Fokus */
    }
}
