/* CSI Ascension Church Directory - global theme.
   Component-specific styling lives in each .razor.css file. */

:root {
    /* This page renders its own dark theme (see the dark block below), and says so here. Without
       it Chrome treats the page as light-only and runs its own automatic darkening over the top,
       which darkens by element size - so one chart's long bars went navy while its short bars,
       same CSS class, stayed blue. Declaring both schemes turns that pass off. Paired with the
       meta of the same name in index.html, which covers the first paint before CSS arrives. */
    color-scheme: light dark;

    /* --brand has two jobs that pull in opposite directions. In light mode it is a dark navy,
       used BOTH as a block of colour behind white text and as a foreground for links and icons.
       In dark mode a foreground has to be light, so --brand flips to a pale blue - and every
       panel that had been painting white text on it became white on pale blue. That is roughly
       2:1 against the 4.5:1 a body of text needs, and is what members were complaining they
       could not read.

       So the two jobs now have two tokens. --brand stays the foreground and keeps flipping;
       --brand-surface is the colour you put WHITE TEXT ON, and stays dark in both themes.
       Light mode is unchanged - the value is the same navy it always was.

       Buttons that read `background: var(--brand); color: var(--surface)` are a different
       pattern and are already right: light blue with dark text is how a dark theme is
       supposed to do a solid button. Leave those alone. */
    --brand: #14357E;
    --brand-surface: #14357E;
    --brand-2: #3F51B5;
    --brand-ink: #1A365D;
    --whatsapp: #25D366;
    --ground: #F0F4F8;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --line: #E2E8F0;
    --line-strong: #CBD5E1;
    --text: #1E293B;
    --text-soft: #475569;
    --text-mute: #64748B;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --ok: #1C7A50;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tabbar-h: 58px;
    --appbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --brand: #8FB2F4;
        /* Lifted a shade off the light-mode navy so the panel still separates from a near-black
           page, and still 12.6:1 under white - the existing pale eyebrow and body text come out
           at 8.4:1 and 10.2:1 on it, so nothing else on these panels had to be repainted. */
        --brand-surface: #16306B;
        --brand-2: #A8C3F7;
        --brand-ink: #C7D6F5;
        --ground: #0C121D;
        --surface: #141C2B;
        --surface-2: #111827;
        --line: #26303F;
        --line-strong: #333F55;
        --text: #E3E8F0;
        --text-soft: #B7C0CE;
        --text-mute: #8B94A5;
        --danger: #F87171;
        --danger-bg: #2A1616;
    }
}

* { box-sizing: border-box; }

/* App bar: when a page shows the back button (Shared/BackTo), it takes the emblem's place.
   Global rather than scoped, because it spans MainLayout and BackTo. */
.appbar:has(.appbar__back) .appbar__mark { display: none; }

html, body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
    background: var(--ground);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

h1:focus, h2:focus { outline: none; }

a { color: var(--brand-2); }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- boot splash ---------- */
.app-splash {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; background: var(--brand-surface); color: #fff; text-align: center; padding: 24px;
}
.app-splash__mark {
    width: 76px; height: 76px; border-radius: 50%;
    background: #fff;
    display: grid; place-items: center; color: #fff; margin-bottom: 10px;
}
.app-splash__title { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.app-splash__sub { font-size: .82rem; color: #C7D2FE; }
.app-splash__note { max-width: 260px; margin: 18px auto 0; font-size: .85rem; line-height: 1.45; color: #FDE68A; }

.loading-progress {
    position: relative; display: block; width: 5rem; height: 5rem; margin: 22px auto 0;
}
.loading-progress circle {
    fill: none; stroke: rgba(255,255,255,.25); stroke-width: .5rem;
    transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: #fff;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray .1s ease-in-out;
}
.loading-progress-text {
    position: absolute; inset: auto 0 -1.6rem 0; text-align: center;
    font-size: .72rem; color: #C7D2FE;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading the directory"); }

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

.blazor-error-boundary {
    background: #b32121; padding: 1rem; color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---------- Map marker content (created in js/maps.js, so it can't use scoped CSS) ---------- */
/* Strip Leaflet's default white divIcon box; sizes include borders so icon anchors land true. */
.leaflet-marker-icon.amap-divicon { background: none; border: none; }
.amap-divicon * { box-sizing: border-box; }
.amap-church {
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center;
    background: #B7791F; color: #fff;
    border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.amap-house {
    width: 36px; height: 36px; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);   /* square corner points straight down, onto the house */
    display: grid; place-items: center;
    background: #DC2626; color: #fff;
    border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.amap-house svg { transform: rotate(45deg); }
.amap-bubble {
    display: grid; place-items: center;
    border-radius: 50%;
    background: rgba(63, 81, 181, .55);
    border: 2px solid #fff;
    color: #fff; font: 700 .78rem/1 'Segoe UI', system-ui, sans-serif;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    cursor: pointer;
}
.amap-bubble--mid { background: rgba(20, 53, 126, .72); }
.amap-bubble--hi { background: rgba(12, 30, 82, .88); font-size: .9rem; }
/* Several nearby localities shown as one total - the outer ring says "tap to zoom in". */
.amap-bubble--group { box-shadow: 0 0 0 3px rgba(63, 81, 181, .35), 0 1px 4px rgba(0,0,0,.3); }
.amap-info { font: .84rem/1.4 'Segoe UI', system-ui, sans-serif; color: #1E293B; min-width: 150px; }
.amap-info strong { display: block; font-size: .92rem; }
.amap-info small { color: #64748B; }
