/*
 * Light chrome over a full-bleed map, in the family of ../RainRadar/: floating
 * rounded controls with a soft shadow, a legend strip along the bottom, and
 * nothing opaque covering the map that does not have to be.
 */

:root {
    --ink: #1c1d1f;
    --muted: #6b7076;
    --panel: rgba(255, 255, 255, 0.92);
    --edge: rgba(0, 0, 0, 0.09);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
    --accent: #0a6ed1;
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: #eae6de;
    color: var(--ink);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

body {
    display: flex;
    flex-direction: column;
    /* The map has to fill what is left after the ad, and on a phone the
     * browser chrome makes 100vh a promise it does not keep. */
    height: 100dvh;
    -webkit-user-select: none;
    user-select: none;
}

/* --- ad ------------------------------------------------------------------ */

#promo {
    flex: 0 0 auto;
    width: 100%;
    text-align: center;
    overflow: hidden;
    background: #f2efe9;
    border-bottom: 1px solid var(--edge);
}

.adslot_1 { width: 100%; height: 50px; }
@media (min-width: 500px) { .adslot_1 { height: 90px; } }
@media (max-width: 319px) { #promo { display: none; } }

/* --- map ----------------------------------------------------------------- */

#stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

#map { position: absolute; inset: 0; }

/* The zoom buttons sit under the floating bar, not behind it. */
.maplibregl-ctrl-top-right { top: 104px; }
@media (min-width: 620px) { .maplibregl-ctrl-top-right { top: 62px; } }

.maplibregl-ctrl-attrib, .maplibregl-ctrl-bottom-left { display: none; }

/* --- top bar ------------------------------------------------------------- */

#bar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: calc(100% - 20px);
    max-width: 560px;
    pointer-events: none;
}

#bar > * { pointer-events: auto; }

.seg {
    display: flex;
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 999px;
    box-shadow: var(--shadow);
    padding: 3px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.seg button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    padding: 6px 20px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.seg button.on {
    background: var(--accent);
    color: #fff;
}

.seg button:not(.on):hover { color: var(--ink); }

.picker {
    display: flex;
    align-items: stretch;
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.picker .step {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0 12px;
    cursor: pointer;
    flex: 0 0 auto;
}

.picker .step:hover:not(:disabled) { color: var(--accent); }
.picker .step:disabled { opacity: .3; cursor: default; }

.picker .step svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

/* The arrows point at older and newer, not at left and right, so in Arabic
 * they have to turn round with the text. */
[dir="rtl"] .picker .step svg { transform: scaleX(-1); }

#frame {
    appearance: none;
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
    text-align-last: center;
    padding: 9px 4px;
    cursor: pointer;
    direction: inherit;
    /* A long Hijri-plus-Gregorian label has to shrink rather than be cut. */
    font-size: 13px;
}

@media (min-width: 420px) { #frame { font-size: 14px; } }
@media (min-width: 560px) { #frame { font-size: 15px; } }

#frame:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* --- locate -------------------------------------------------------------- */

#locate {
    position: absolute;
    bottom: 96px;
    inset-inline-end: 12px;
    z-index: 5;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--edge);
    border-radius: 50%;
    background: var(--panel);
    box-shadow: var(--shadow);
    color: var(--muted);
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#locate:hover { color: var(--accent); }
#locate.on { color: var(--accent); }

#locate svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

#locate svg circle:first-of-type { fill: currentColor; stroke: none; }
#locate svg .ring { opacity: .55; }

/* --- legend -------------------------------------------------------------- */

#foot {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    z-index: 5;
    padding: 0 0 8px;
    background: linear-gradient(to top, rgba(255, 255, 255, .88), rgba(255, 255, 255, 0));
    pointer-events: none;
}

#legend {
    display: flex;
    margin: 0 10px 4px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
    pointer-events: auto;
    direction: ltr;
}

#legend span {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
    white-space: nowrap;
    overflow: hidden;
}

/* The first two steps are pale enough that white text on them is unreadable. */
#legend span.dark { color: #222; text-shadow: none; }

#credit {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--muted);
    padding-bottom: env(safe-area-inset-bottom);
}

#credit button {
    appearance: none;
    border: 0;
    background: none;
    font: inherit;
    color: var(--muted);
    text-decoration: underline;
    cursor: pointer;
    pointer-events: auto;
    padding: 2px 6px;
}

/* --- loading ------------------------------------------------------------- */

#loading {
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 2px;
    z-index: 6;
    overflow: hidden;
    background: rgba(0, 0, 0, .12);
}

#loading i {
    display: block;
    height: 100%;
    width: 40%;
    background: var(--accent);
    animation: sweep 1.1s linear infinite;
}

@keyframes sweep {
    from { transform: translateX(-100%); }
    to   { transform: translateX(350%); }
}

/* --- toast --------------------------------------------------------------- */

/*
 * Sits above the legend and below the locate button, so it covers neither. A
 * dark pill on a light page reads as something passing through rather than a
 * part of the furniture -- which is the whole point of it not being an alert().
 */
#toast {
    position: absolute;
    bottom: 56px;
    left: 50%;
    z-index: 7;
    /* max-content, or the pill is only as wide as it can shrink to: an absolutely
     * positioned box offset by left:50% gets half the container as its available
     * width, and a one-line hint then wraps to three. */
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(28, 29, 31, .88);
    color: #fff;
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
    transition: opacity .28s ease, transform .28s ease;
}

#toast[hidden] { display: none; }

#toast.on {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Someone who has asked for less motion gets the message, not the slide. */
@media (prefers-reduced-motion: reduce) {
    #toast { transition: opacity .01s; transform: translateX(-50%); }
    #toast.on { transform: translateX(-50%); }
}

/* --- popup --------------------------------------------------------------- */

.maplibregl-popup-content {
    border-radius: 12px;
    box-shadow: var(--shadow);
    /* Symmetric, so the centred value stays centred while clearing the close
     * button -- which MapLibre pins to the right in both directions. */
    padding: 10px 34px;
    font: inherit;
}

/* MapLibre's default is an 18px glyph. That is not a target a thumb can hit. */
.maplibregl-popup-close-button {
    width: 30px;
    height: 30px;
    font-size: 19px;
    line-height: 28px;
    color: var(--muted);
    border-radius: 0 12px 0 10px;
}

.maplibregl-popup-close-button:hover {
    background: rgba(0, 0, 0, .06);
    color: var(--ink);
}

.pop { text-align: center; direction: inherit; }
.pop b { font-size: 20px; display: block; line-height: 1.25; }
.pop .where { font-size: 11px; color: var(--muted); direction: ltr; }
.pop .tag {
    display: inline-block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #8a6d00;
    background: #fff3cd;
    border-radius: 4px;
    padding: 1px 6px;
}

/* --- about --------------------------------------------------------------- */

#about {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, .45);
    display: grid;
    place-items: center;
    padding: 16px;
}

#about[hidden] { display: none; }

.sheet {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    padding: 18px 20px 14px;
    max-width: 460px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    -webkit-user-select: text;
    user-select: text;
}

.sheet h2 { margin: 0 0 8px; font-size: 18px; }
.sheet p { margin: 0 0 10px; font-size: 14px; color: #3a3d42; }
.sheet a { color: var(--accent); }

.sheet button {
    appearance: none;
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
