/* ===============================================================
   Urban Radar - dark mode, mobile first
   =============================================================== */

:root {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #1a2640;
    --surface-3: #243352;
    --border: rgba(255, 255, 255, .08);
    --text: #e8eefc;
    --muted: #8d9dbd;
    --accent: #22d3ee;
    --accent-ink: #04222a;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;

    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body { overflow: hidden; }

h1, h2, h3, p { margin: 0; }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.icon { width: 20px; height: 20px; flex: none; }
.icon--lg { width: 28px; height: 28px; }

/* ---------------------------------------------------------------
   Layout principal: topbar / status / hartă / card busolă
   --------------------------------------------------------------- */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(var(--safe-top) + 10px) 14px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 5;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    min-width: 0;
}
.brand__logo { width: 28px; height: 28px; flex: none; }
.brand__name {
    color: var(--text);
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--warning);
    font-weight: 700;
    cursor: pointer;
}
.chip span { color: var(--text); }

.lang {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}
.lang__btn {
    min-width: 44px;
    min-height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .5px;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.lang__btn[aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-ink);
}

/* Bara de stare */
.status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    background: #3a2f10;
    color: #fde9a8;
    font-size: .88rem;
    border-bottom: 1px solid rgba(251, 191, 36, .25);
    z-index: 5;
}
.status--error {
    background: #3b1717;
    color: #fecaca;
    border-bottom-color: rgba(248, 113, 113, .3);
}
.status--info {
    background: #10303a;
    color: #b6f0fb;
    border-bottom-color: rgba(34, 211, 238, .25);
}
.status__action {
    flex: none;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
}

/* Harta */
.map-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}
#map {
    position: absolute;
    inset: 0;
    background: var(--bg);
}

.map-controls {
    position: absolute;
    right: 12px;
    bottom: 34px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.fab {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: color .2s, background .2s;
}
.fab[aria-pressed="true"] { color: var(--accent); }
.fab:active { background: var(--surface-2); }

/* ---------------------------------------------------------------
   Card busolă
   --------------------------------------------------------------- */
.compass-card {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 14px 16px calc(var(--safe-bottom) + 14px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
    z-index: 5;
}

.dial {
    position: relative;
    flex: none;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 50%, var(--surface-3) 0 38%, var(--surface-2) 39% 100%);
    border: 2px solid var(--surface-3);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, .45);
}
.dial__ring {
    position: absolute;
    inset: 0;
    transition: transform .15s linear;
    will-change: transform;
}
.dial__ring span {
    position: absolute;
    font-size: .68rem;
    font-weight: 700;
    color: var(--muted);
}
.dial__n { top: 4px; left: 50%; transform: translateX(-50%); color: var(--danger) !important; }
.dial__s { bottom: 4px; left: 50%; transform: translateX(-50%); }
.dial__e { right: 7px; top: 50%; transform: translateY(-50%); }
.dial__w { left: 7px; top: 50%; transform: translateY(-50%); }

.dial__arrow {
    position: absolute;
    inset: 14px;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
    transition: transform .15s linear, opacity .2s;
    will-change: transform;
    filter: drop-shadow(0 2px 6px rgba(34, 211, 238, .45));
}
.dial__arrow-head { fill: var(--accent); }
.dial__arrow-hub { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.dial--idle .dial__arrow { opacity: .25; }
.dial--arrived .dial__arrow-head { fill: var(--success); }
.dial--arrived .dial__arrow { filter: drop-shadow(0 2px 8px rgba(52, 211, 153, .6)); }

.target { flex: 1 1 auto; min-width: 0; }
.target__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.target__label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--muted);
}
.target__auto {
    padding: 2px 10px;
    min-height: 26px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--accent);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
}
.target__title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.target__distance {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}
.target--arrived .target__distance { color: var(--success); }
.target__hint { margin-top: 2px; font-size: .8rem; color: var(--muted); min-height: 1.1em; }
.target__note { margin-top: 2px; font-size: .72rem; color: var(--warning); }

.target__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.progress {
    height: 6px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--success));
    transition: width .4s ease;
}

/* ---------------------------------------------------------------
   Butoane
   --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: .92rem;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: transform .1s, background .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--small { min-height: 36px; padding: 0 12px; font-size: .82rem; }
.btn--block { width: 100%; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

/* ---------------------------------------------------------------
   Sheet-uri (bottom sheet)
   --------------------------------------------------------------- */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(3, 7, 15, .6);
    backdrop-filter: blur(2px);
    animation: fade-in .2s ease;
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    max-width: 640px;
    max-height: 88vh;
    max-height: 88dvh;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
    box-shadow: var(--shadow);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
    touch-action: pan-y;
}
.sheet.is-open {
    transform: translateY(0);
    visibility: visible;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}
.sheet.is-dragging { transition: none; }

.sheet__handle {
    flex: none;
    width: 44px;
    height: 5px;
    margin: 10px auto 4px;
    border-radius: 999px;
    background: var(--surface-3);
    touch-action: none;
    position: relative;
}
/* zona de atingere mai mare pentru tragere */
.sheet__handle::before {
    content: "";
    position: absolute;
    inset: -14px -48px;
}
.sheet__close {
    position: absolute;
    top: 10px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
}
.sheet__body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 20px calc(var(--safe-bottom) + 24px);
    -webkit-overflow-scrolling: touch;
}
.sheet__title { margin: 8px 44px 4px 0; font-size: 1.4rem; line-height: 1.2; }
.sheet__meta { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.sheet__teaser { margin-top: 10px; color: var(--text); opacity: .9; }
.sheet__section {
    margin: 22px 0 10px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--muted);
}

.pill {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .8px;
    text-transform: uppercase;
    background: var(--surface-3);
    color: var(--warning);
}
.pill--unlocked { background: rgba(52, 211, 153, .15); color: var(--success); }

.lock-panel {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-top: 18px;
    padding: 14px;
    border: 1px dashed rgba(251, 191, 36, .4);
    border-radius: var(--radius);
    background: rgba(251, 191, 36, .06);
    color: var(--warning);
}
.lock-panel > div { flex: 1; min-width: 0; }
.lock-panel p { margin-top: 2px; color: var(--text); opacity: .85; font-size: .9rem; }

.story__text { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.audio audio { width: 100%; height: 44px; color-scheme: dark; }

.nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.nav-grid .btn:first-child { grid-column: 1 / -1; }

.coords {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding: 8px 8px 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.coords code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85rem;
    color: var(--muted);
    user-select: all;
    overflow-wrap: anywhere;
}

/* Lista de insigne */
.badge-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.badge-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    text-align: left;
    cursor: pointer;
}
.badge-item__medal {
    display: grid;
    place-items: center;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(52, 211, 153, .15);
    color: var(--success);
}
.badge-item__text { min-width: 0; }
.badge-item__title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-item__date { display: block; font-size: .8rem; color: var(--muted); }
.empty { margin-top: 24px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------
   Formular "Propunere obiectiv nou"
   --------------------------------------------------------------- */
.fab--accent { background: var(--accent); color: var(--accent-ink); }
.fab--accent:active { background: #67e8f9; }

.form { display: grid; gap: 16px; margin-top: 16px; }
.fs {
    display: grid;
    gap: 12px;
    min-width: 0;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.fs legend {
    padding: 0 8px;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--accent);
}
.form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { padding: 0 10px; font-size: .85rem; line-height: 1.2; }

.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.field input,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* >= 16px: iOS nu face zoom la focus */
}
.field textarea { resize: vertical; line-height: 1.45; }
.field input[type="file"] { padding: 8px; font-size: .9rem; }
.field input:focus,
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] { border-color: var(--danger); }
.field__error { font-size: .82rem; color: var(--danger); }
.form__hint { font-size: .8rem; color: var(--muted); min-height: 1.1em; }
.form__hint--error { color: var(--danger); }
.form__hint--ok { color: var(--success); }
.form__alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(248, 113, 113, .12);
    border: 1px solid rgba(248, 113, 113, .4);
    color: #fecaca;
    font-size: .9rem;
}
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Alegere punct pe harta */
.pick-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1500;
    display: grid;
    gap: 10px;
    max-width: 640px;
    margin: 0 auto;
    padding: 14px 16px calc(var(--safe-bottom) + 14px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .45);
}
.pick-bar__text { font-weight: 600; overflow-wrap: anywhere; }
.pick-bar__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.is-picking #map { cursor: crosshair; }
.pick-marker { background: none; border: 0; }
.pick-marker__pin {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    background: var(--accent);
    border: 3px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .6);
    transform: rotate(-45deg);
}

@media (max-width: 380px) {
    .form__grid,
    .btn-row { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------
   Intro
   --------------------------------------------------------------- */
.intro {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 30%, rgba(34, 211, 238, .18), transparent 55%),
        var(--bg);
}
.intro__card { width: 100%; max-width: 380px; text-align: center; }
.intro__logo { width: 96px; height: 96px; margin-bottom: 16px; color: var(--accent); animation: spin 14s linear infinite; }
.intro__card h2 { font-size: 1.7rem; margin-bottom: 10px; }
.intro__card p { color: var(--muted); margin-bottom: 22px; }
.intro__card .btn { min-height: 52px; font-size: 1rem; }
.intro__card .intro__fine { margin: 14px 0 0; font-size: .78rem; }

/* ---------------------------------------------------------------
   Toast
   --------------------------------------------------------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + 24px);
    z-index: 3000;
    max-width: min(92vw, 420px);
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text);
    font-size: .92rem;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow);
    transform: translateX(-50%);
    animation: toast-in .25s ease;
}
.toast--success { background: #0f3d2e; color: #b6f5dc; }

/* ---------------------------------------------------------------
   Leaflet: temă dark + markere personalizate
   --------------------------------------------------------------- */
.leaflet-container {
    background: var(--bg);
    font-family: var(--font);
    outline: 0;
}
.leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55);
}
.leaflet-control-attribution {
    background: rgba(11, 18, 32, .75) !important;
    color: var(--muted) !important;
    font-size: 10px;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

.user-marker { background: none; border: 0; }
.user-marker__dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: #3b82f6;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.user-marker__pulse {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: rgba(59, 130, 246, .5);
    animation: pulse 2s ease-out infinite;
}

.pin-wrap { background: none; border: 0; }
.pin {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--surface-3);
    color: var(--warning);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .55);
    transition: transform .2s;
}
.pin svg { width: 17px; height: 17px; }
.pin--unlocked { background: var(--success); color: #053323; }
.pin--collected { background: #0f3d2e; color: var(--success); border-color: var(--success); }
.pin.is-target { transform: scale(1.2); border-color: var(--accent); }
.pin.is-target::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: ping 1.8s ease-out infinite;
}

.target-line { stroke: var(--accent); }

/* ---------------------------------------------------------------
   Animații
   --------------------------------------------------------------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
    0%   { transform: scale(1); opacity: .8; }
    100% { transform: scale(3.4); opacity: 0; }
}
@keyframes ping {
    0%   { transform: scale(.8); opacity: .9; }
    100% { transform: scale(1.6); opacity: 0; }
}
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ---------------------------------------------------------------
   Ecrane mici / landscape
   --------------------------------------------------------------- */
@media (max-width: 360px) {
    .dial { width: 92px; height: 92px; }
    .target__distance { font-size: 1.6rem; }
    .brand__name { display: none; }
}

@media (orientation: landscape) and (max-height: 480px) {
    .topbar { padding-top: calc(var(--safe-top) + 4px); padding-bottom: 4px; }
    .compass-card { padding-top: 8px; padding-bottom: calc(var(--safe-bottom) + 8px); }
    .dial { width: 84px; height: 84px; }
    .target__actions { margin-top: 6px; }
    .sheet { max-height: 94dvh; }
}
