/* ================= RoadWorthy theme =================
   Dark default (night driving), warm-cream light mode (daytime dash use).
   Brand coral-red is deliberately warmer than the flagged/warning red,
   and premium gold is distinct from the traffic-light yellow. */

:root, html[data-theme="dark"] {
    --bg: #0F0F0F;
    --surface: #191917;
    --surface-2: #232320;
    --border: #33322e;
    --text: #F5F1E8;
    --muted: #A39D90;

    --brand: #FF6242;           /* warm coral — brand accent */
    --brand-ink: #1a0c08;
    --gold: #E5B94E;            /* premium gold: staff pick badge */
    --gold-deep: #C9A227;

    --tier-green: #3DC46C;
    --tier-yellow: #FFB020;     /* legend yellow ≠ premium gold */
    --tier-red: #E5484D;        /* flagged — cooler than brand coral */
    --tier-gray: #8B8B8B;

    --shadow: 0 6px 24px rgba(0,0,0,.5);
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg: #FAF5EB;
    --surface: #FFFFFF;
    --surface-2: #F1EADC;
    --border: #E2D9C6;
    --text: #26221B;
    --muted: #6E675A;

    --brand: #E84E2E;
    --brand-ink: #ffffff;
    --gold: #B8860B;
    --gold-deep: #96700a;

    --tier-green: #1E8E4B;
    --tier-yellow: #B97F00;
    --tier-red: #C62828;
    --tier-gray: #8B8B8B;

    --shadow: 0 6px 24px rgba(60,50,30,.15);
    color-scheme: light;
}

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1:focus { outline: none; }

/* ---------- app shell ---------- */
.rw-shell { display: flex; flex-direction: column; min-height: 100dvh; }
.rw-main { flex: 1; }

.rw-header {
    display: flex; align-items: center; gap: .75rem;
    padding: .5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.rw-header .logo { height: 34px; width: 34px; border-radius: 8px; }
.rw-header .wordmark { font-weight: 800; font-size: 1.15rem; letter-spacing: .3px; color: var(--text); }
.rw-header .spacer { flex: 1; }
.rw-header .header-links { display: flex; gap: .15rem; align-items: center; }
.rw-header a.nav-link { color: var(--text); padding: .35rem .6rem; border-radius: 8px; font-weight: 600; }
.rw-header a.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.rw-header a.nav-link.active { color: var(--brand); }

.rw-bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: .3rem env(safe-area-inset-right) calc(.3rem + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
.rw-bottom-nav a {
    flex: 1; text-align: center; color: var(--muted);
    font-size: .7rem; font-weight: 600; padding: .25rem 0;
}
.rw-bottom-nav a .ico { display: block; font-size: 1.25rem; line-height: 1.2; }
.rw-bottom-nav a.active { color: var(--brand); }
.rw-bottom-nav a:hover { text-decoration: none; }

@media (max-width: 800px) {
    .rw-bottom-nav { display: flex; }
    .rw-header .header-links { display: none; }
    .rw-main.with-tabs { padding-bottom: 64px; }
}

/* ---------- buttons, chips, badges ---------- */
.rw-btn {
    display: inline-block; border: 0; cursor: pointer; font-weight: 700;
    background: var(--brand); color: var(--brand-ink);
    padding: .6rem 1.2rem; border-radius: 999px; font-size: 1rem;
}
.rw-btn:hover { filter: brightness(1.08); text-decoration: none; }
.rw-btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.rw-btn.small { padding: .35rem .8rem; font-size: .85rem; }
.rw-btn:disabled { opacity: .5; cursor: default; }

.rw-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .3rem .7rem; border-radius: 999px; cursor: pointer;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); font-size: .82rem; font-weight: 600;
    user-select: none; white-space: nowrap;
}
.rw-chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.rw-chip.gold.on { background: var(--gold); color: #201800; border-color: var(--gold); }

.rw-badge {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .72rem; font-weight: 700; letter-spacing: .2px;
    padding: .18rem .55rem; border-radius: 6px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.rw-badge.validator { border-color: var(--brand); color: var(--brand); background: transparent; }
.rw-badge.road-tested { border-color: var(--tier-green); color: var(--tier-green); background: transparent; }
.rw-badge.staff { border-color: var(--gold); color: var(--gold); background: transparent; }

/* score pill: "88 · 214 ratings" confidence display */
.rw-score {
    display: inline-flex; align-items: center; gap: .4rem;
    font-weight: 800; border-radius: 999px; padding: .25rem .75rem; font-size: .95rem;
    color: #fff;
}
.rw-score.green { background: var(--tier-green); color: #06230f; }
.rw-score.yellow { background: var(--tier-yellow); color: #241a00; }
.rw-score.red { background: var(--tier-red); }
.rw-score.new { background: var(--tier-gray); color: #fff; }
.rw-score .count { font-weight: 500; font-size: .78rem; opacity: .85; }

.rw-open { font-size: .8rem; font-weight: 700; }
.rw-open.open { color: var(--tier-green); }
.rw-open.closed { color: var(--tier-red); }
.rw-open.unknown { color: var(--muted); font-weight: 500; }

/* ---------- cards ---------- */
.rw-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: .9rem 1rem;
    box-shadow: var(--shadow);
}
.rw-card + .rw-card { margin-top: .6rem; }
.rw-card .title-row { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.rw-card .title-row .name { font-weight: 800; font-size: 1.05rem; color: var(--text); }
.rw-card .meta { color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.rw-card .badge-row { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.rw-card .detour { font-weight: 800; font-size: .95rem; }
.rw-card .detour.short { color: var(--tier-green); }
.rw-card .detour.long { color: var(--tier-yellow); }

/* ---------- forms ---------- */
.rw-input, .rw-select, .rw-textarea {
    width: 100%; box-sizing: border-box;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    padding: .55rem .8rem; font-size: 1rem; font-family: inherit;
}
.rw-input:focus, .rw-select:focus, .rw-textarea:focus {
    outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand);
}
.rw-label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .25rem; }

.rw-page { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.rw-page-wide { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* ================= explore (map + list) ================= */
.explore-wrap {
    position: relative;
    height: calc(100dvh - 53px);
    display: flex; flex-direction: column;
    overflow: hidden;
}
@media (max-width: 800px) { .explore-wrap { height: calc(100dvh - 53px - 58px); } }

.explore-top {
    z-index: 20; padding: .55rem .75rem .4rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: .45rem;
    position: relative;
}
.explore-search-row { display: flex; gap: .5rem; align-items: center; }
.explore-search-row .rw-input { flex: 1; }
.search-pop {
    position: absolute; z-index: 100; left: .75rem; right: .75rem; top: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); max-height: 45dvh; overflow: auto;
}
.search-pop .hit { padding: .55rem .8rem; cursor: pointer; display: flex; gap: .5rem; align-items: center; }
.search-pop .hit:hover { background: var(--surface-2); }
.search-pop .hit .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.search-pop .section { padding: .3rem .8rem; font-size: .7rem; text-transform: uppercase; color: var(--muted); letter-spacing: .8px; }

.route-bar { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.route-bar .rw-input { flex: 1; min-width: 130px; }
.route-context {
    display: flex; align-items: center; gap: .6rem; font-size: .82rem; color: var(--muted);
    padding: .1rem .15rem; flex-wrap: wrap;
}
.route-context b { color: var(--text); }

.chip-row { display: flex; gap: .4rem; overflow-x: auto; padding: .1rem .05rem .25rem; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.explore-body { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }

.view-toggle {
    position: absolute; z-index: 30; top: .7rem; right: .7rem;
    display: flex; border-radius: 999px; overflow: hidden;
    border: 1px solid var(--border); background: var(--surface);
    box-shadow: var(--shadow);
}
.view-toggle button {
    border: 0; background: transparent; color: var(--text);
    font-weight: 700; font-size: .85rem; padding: .45rem .9rem; cursor: pointer;
}
.view-toggle button.on { background: var(--brand); color: var(--brand-ink); }

.list-panel {
    position: absolute; inset: 0; z-index: 25; overflow-y: auto;
    background: var(--bg); padding: .75rem .75rem 4rem; display: none;
}
.list-panel.visible { display: block; }

.map-legend {
    position: absolute; z-index: 26; left: .7rem; bottom: 1.6rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    padding: .45rem .65rem; font-size: .72rem; color: var(--muted);
    display: flex; flex-direction: column; gap: .22rem;
    box-shadow: var(--shadow);
}
.map-legend .row { display: flex; align-items: center; gap: .45rem; }
.map-legend .dot { width: 11px; height: 11px; border-radius: 50%; }

.maplibregl-popup-content {
    background: var(--surface) !important; color: var(--text) !important;
    border-radius: 12px !important; box-shadow: var(--shadow) !important;
    padding: .8rem .9rem !important; min-width: 210px;
}
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { color: var(--muted) !important; font-size: 1.2rem; }

.rw-toast {
    position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
    bottom: 80px; background: var(--surface); border: 1px solid var(--border);
    color: var(--text); border-radius: 12px; padding: .7rem 1.1rem;
    box-shadow: var(--shadow); font-weight: 600; max-width: 90vw;
}

/* ================= profile page ================= */
.profile-hero { border-radius: 16px; overflow: hidden; margin-bottom: 1rem; background: var(--surface-2); }
.profile-hero img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.profile-title { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.profile-title h1 { margin: .2rem 0; font-size: 1.7rem; }
.profile-section { margin-top: 1.4rem; }
.profile-section h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: .5rem; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .7rem; }
.review-grid .rev img { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; }
.review-grid .rev .txt { font-size: .85rem; margin-top: .3rem; }
.review-grid .rev .who { font-size: .75rem; color: var(--muted); }

.verify-box { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* ================= landing ================= */
.hero {
    text-align: center; padding: 3.5rem 1rem 2.5rem;
    background:
        radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent),
        var(--bg);
}
.hero img.logo { width: 110px; height: 110px; border-radius: 24px; box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); margin: .9rem 0 .4rem; font-weight: 900; }
.hero .tagline { color: var(--muted); font-size: 1.15rem; max-width: 34rem; margin: 0 auto 1.4rem; }
.hero .validators { color: var(--muted); font-size: .9rem; margin-top: 1rem; }
.hero .validators b { color: var(--text); }

.feature-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem; max-width: 1000px; margin: 1.5rem auto; padding: 0 1rem;
}
.feature-grid .f { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.1rem; }
.feature-grid .f .ico { font-size: 1.6rem; }
.feature-grid .f h3 { margin: .5rem 0 .3rem; font-size: 1.02rem; }
.feature-grid .f p { color: var(--muted); font-size: .88rem; margin: 0; }

.rw-footer {
    border-top: 1px solid var(--border); color: var(--muted);
    font-size: .78rem; text-align: center; padding: 1.2rem 1rem 2rem; margin-top: 2rem;
}
.rw-footer a { color: var(--muted); text-decoration: underline; }

/* ---------- bootstrap-era compatibility for Identity pages ---------- */
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { color: var(--muted); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--tier-red); }
.validation-message { color: var(--tier-red); }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem .7rem;
    position: fixed; width: 100%; z-index: 1000; color: #111;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
