/* ==========================================================================
   Santa Clara City Cemetery Kiosk
   Lightweight styling for a Raspberry Pi 4 / Chromium touch kiosk.
   No animations beyond a single loading spinner; large touch targets.
   ========================================================================== */

:root {
    --navy-900: #071a33;
    --navy-800: #0b2545;
    --navy-700: #13315c;
    --navy-600: #1c4173;
    --green:    #2f9e57;
    --green-dark: #1f7a41;
    --ink:      #10233d;
    --paper:    #ffffff;
    --muted:    #55688a;
    --ring:     rgba(47, 158, 87, 0.55);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--navy-900);
    color: var(--paper);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Kiosk: prevent long-press selection / callouts on a touch screen. */
body {
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#kiosk {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ---------- SHARED BUTTON ---------- */
.btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font-weight: 800;
    border-radius: 999px;
    color: #fff;
    padding: 16px 28px;
    font-size: clamp(18px, 1.6vw, 24px);
    min-height: 60px;
    white-space: nowrap;
}

.btn:focus-visible { outline: 4px solid var(--ring); outline-offset: 2px; }
.btn:active { transform: scale(0.98); }

.btn--home  { background: var(--navy-700); }
.btn--reset { background: var(--green); }

/* ---------- LANDING SCREEN ---------- */
.home {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: clamp(24px, 3.5vh, 56px) clamp(24px, 3vw, 64px);
    background:
        radial-gradient(1200px 600px at 50% -10%, var(--navy-600) 0%, transparent 60%),
        linear-gradient(160deg, var(--navy-800) 0%, var(--navy-900) 100%);
}

.home.is-hidden { display: none; }

.home__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(14px, 2vh, 28px);
    flex: 1;
    width: 100%;
    justify-content: center;
}

.home__eyebrow {
    margin: 0;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-size: clamp(14px, 1.2vw, 20px);
    font-weight: 700;
    color: var(--green);
}

.home__title {
    margin: 0;
    font-size: clamp(48px, 6vw, 104px);
    line-height: 1.02;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.home__subtitle {
    margin: 0;
    font-size: clamp(20px, 2vw, 36px);
    color: #b9c8de;
    font-weight: 500;
}

.home__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: clamp(32px, 3.5vw, 72px);
    width: min(2000px, 96vw);
    flex: 1;
    margin: clamp(24px, 3vh, 48px) 0 clamp(16px, 2vh, 32px);
}

.home__launch {
    appearance: none;
    border: none;
    cursor: pointer;
    background: var(--green);
    color: #fff;
    border-radius: 40px;
    padding: clamp(56px, 6vh, 112px) clamp(44px, 4vw, 88px);
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 1.6vh, 28px);
    text-align: left;
    justify-content: center;
    min-height: 0;
    box-shadow: 0 32px 64px -22px rgba(0, 0, 0, 0.65);
}

.home__launch--alt { background: var(--navy-600); }
.home__launch:focus-visible { outline: 6px solid var(--ring); outline-offset: 6px; }
.home__launch:active { transform: scale(0.99); }

.home__launch-title { font-size: clamp(48px, 4.6vw, 104px); font-weight: 800; line-height: 1.03; }
.home__launch-desc { font-size: clamp(24px, 2.1vw, 46px); font-weight: 500; opacity: 0.92; }

.home__footer {
    margin: 0;
    color: #7f93b3;
    font-size: clamp(13px, 1vw, 17px);
    letter-spacing: 0.04em;
}

/* ---------- MAP VIEWER + RESERVATIONS ---------- */
.viewer,
.reservations {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    background: var(--navy-900);
}

.viewer.is-active,
.reservations.is-active { display: flex; }

.toolbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: clamp(12px, 1.6vw, 24px);
    padding: clamp(10px, 1.4vh, 18px) clamp(14px, 2vw, 28px);
    background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
    box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

/* ---------- SEARCH ---------- */
.search {
    position: relative;
    flex: 1;
    max-width: 720px;
}

.search__input {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 16px 20px;
    font-size: clamp(20px, 1.8vw, 28px);
    font-weight: 600;
    color: var(--ink);
    background: #fff;
    min-height: 60px;
}

.search__input:focus-visible { outline: 4px solid var(--ring); outline-offset: 2px; }

.search__results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 8px;
    list-style: none;
    background: #fff;
    color: var(--ink);
    border-radius: 14px;
    box-shadow: 0 24px 48px -18px rgba(0, 0, 0, 0.7);
    max-height: 52vh;
    overflow-y: auto;
    z-index: 1200;
    -webkit-overflow-scrolling: touch;
}

.search__result {
    padding: 16px 18px;
    border-radius: 10px;
    font-size: clamp(18px, 1.5vw, 24px);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.search__result:hover,
.search__result.is-active { background: #eef2f8; }

.search__result-status {
    font-weight: 600;
    color: var(--muted);
    font-size: 0.85em;
}

.search__empty {
    padding: 16px 18px;
    font-size: clamp(16px, 1.4vw, 22px);
    color: var(--muted);
}

/* ---------- STAGE / MAP ---------- */
.stage {
    position: relative;
    flex: 1;
    min-height: 0;
}

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

/* Leaflet uses lower z-indexes; keep our chrome above it. */
.leaflet-container { font: inherit; }

/* ---------- OVERLAYS (loading + error) ---------- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 24px;
    text-align: center;
}

.overlay[hidden] { display: none; }

.overlay--loading { background: rgba(7, 26, 51, 0.72); }
.overlay--error   { background: rgba(7, 26, 51, 0.9); }

.overlay__text {
    margin: 0;
    font-size: clamp(22px, 2vw, 34px);
    font-weight: 700;
    max-width: 800px;
}

.overlay--error .overlay__text { color: #ffd7d2; }

.spinner {
    width: 72px;
    height: 72px;
    border: 8px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- LEGEND ---------- */
.legend {
    position: absolute;
    left: clamp(12px, 1.5vw, 24px);
    bottom: clamp(12px, 1.5vh, 24px);
    z-index: 800;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 16px 32px -16px rgba(0, 0, 0, 0.7);
    max-width: 46vw;
}

.legend__title {
    margin: 0 0 10px;
    font-size: clamp(15px, 1.2vw, 20px);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.legend__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.legend__item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(15px, 1.3vw, 21px);
    font-weight: 600;
}

.legend__swatch {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid #1a1a1a;
}

/* ---------- POPUP ---------- */
.leaflet-popup-content-wrapper {
    border-radius: 16px;
    padding: 4px;
}

.leaflet-popup-content {
    margin: 16px 18px;
    font-size: clamp(15px, 1.2vw, 19px);
    line-height: 1.4;
    color: var(--ink);
    min-width: 260px;
}

.popup__title {
    margin: 0 0 12px;
    font-size: clamp(19px, 1.5vw, 26px);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.popup__badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.7em;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.popup__grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    margin: 0 0 12px;
}

.popup__grid dt { font-weight: 700; color: var(--muted); }
.popup__grid dd { margin: 0; font-weight: 700; }

.popup__section-title {
    margin: 12px 0 8px;
    font-size: clamp(15px, 1.2vw, 19px);
    font-weight: 800;
    border-top: 1px solid #e2e8f2;
    padding-top: 12px;
}

.popup__burials { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }

.popup__burial {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: #f4f6fa;
    border-radius: 8px;
}

.popup__burial-name { font-weight: 800; }
.popup__burial-name .vet {
    margin-left: 8px;
    font-size: 0.8em;
    color: var(--green-dark);
    font-weight: 800;
}
.popup__burial-dates { color: var(--muted); font-size: 0.9em; font-weight: 600; }

.popup__muted { color: var(--muted); font-style: italic; }

.popup__vet-notes {
    margin: 0 0 12px;
    color: var(--ink);
    font-size: 0.95em;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Larger, touch-friendly Leaflet zoom controls + close button. */
.leaflet-touch .leaflet-bar a {
    width: 52px;
    height: 52px;
    line-height: 52px;
    font-size: 28px;
}

.leaflet-popup-close-button {
    width: 36px !important;
    height: 36px !important;
    font-size: 28px !important;
    line-height: 34px !important;
}

/* ---------- GRAVE-ID LABELS ---------- */
/* Permanent number centered on each grave. No tooltip box; white text with a
   dark halo so it stays legible over the satellite imagery. Sized "just big
   enough to read" — tune font-size (and LABEL_MIN_ZOOM in app.js) together. */
.leaflet-tooltip.grave-label {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    color: #fff;
    font-weight: 800;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
    text-shadow:
        0 0 2px #000,
        0 0 2px #000,
        0 0 3px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}

/* Centered labels don't need the tooltip arrow. */
.leaflet-tooltip.grave-label::before {
    display: none;
}

/* ---------- RESERVATIONS CALENDAR ---------- */
.toolbar--cal { justify-content: flex-start; }

.cal__head {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 2vw, 40px);
}

.cal__month {
    font-size: clamp(24px, 2.4vw, 40px);
    font-weight: 800;
    color: #eaf1fb;
    min-width: clamp(220px, 20vw, 380px);
    text-align: center;
}

.cal__nav {
    appearance: none;
    border: none;
    cursor: pointer;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--navy-600);
    color: #fff;
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    display: grid;
    place-items: center;
}

.cal__nav:active { transform: scale(0.94); }
.cal__nav:focus-visible { outline: 4px solid var(--ring); }

.cal {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #eef2f8;
    color: var(--ink);
}

.cal__dows {
    flex: none;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #d7deea;
}

.cal__dow {
    background: #f7f9fc;
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding: clamp(8px, 1vh, 14px) 0;
    font-size: clamp(14px, 1.2vw, 20px);
}

.cal__grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    gap: 1px;
    background: #d7deea;
    overflow: hidden;
}

.cal__day {
    background: #fff;
    padding: clamp(4px, 0.6vh, 10px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    min-height: 0;
}

.cal__day--muted { background: #f4f6fa; }
.cal__day--muted .cal__daynum { color: #b3bfd0; }

.cal__daynum {
    align-self: flex-end;
    font-size: clamp(16px, 1.4vw, 26px);
    font-weight: 800;
    color: #33445e;
}

.cal__day--today .cal__daynum {
    background: var(--green);
    color: #fff;
    border-radius: 999px;
    min-width: 1.7em;
    height: 1.7em;
    display: inline-grid;
    place-items: center;
}

.cal__event {
    font-size: clamp(12px, 1vw, 18px);
    line-height: 1.2;
    color: #fff;
    background: var(--navy-600);
    border-radius: 8px;
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.cal__event .t { font-weight: 800; margin-right: 6px; }

.cal__more { font-size: clamp(12px, 1vw, 16px); font-weight: 700; color: var(--muted); }

.cal__msg {
    grid-column: 1 / -1;
    padding: 32px;
    text-align: center;
    font-size: clamp(18px, 1.6vw, 26px);
    color: var(--muted);
    background: #fff;
}

/* ---------- EVENT DETAIL MODAL ---------- */
.event-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 3vw, 48px);
    background: rgba(7, 26, 51, 0.78);
    opacity: 0;
    pointer-events: none;
}

.event-modal.is-open { opacity: 1; pointer-events: auto; }

.event-modal__card {
    background: #fff;
    color: var(--ink);
    border-radius: 24px;
    padding: clamp(24px, 3vw, 48px);
    width: 100%;
    max-width: min(640px, 100%);
    box-shadow: 0 40px 80px -24px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 2vh, 28px);
}

.event-modal__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.event-modal__badge {
    display: inline-flex;
    align-items: center;
    background: var(--green);
    color: #fff;
    font-size: clamp(14px, 1.2vw, 20px);
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 22px;
    border-radius: 999px;
}

.event-modal__close {
    appearance: none;
    border: none;
    cursor: pointer;
    background: #eef2f8;
    color: var(--ink);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 36px;
    line-height: 1;
    display: grid;
    place-items: center;
}

.event-modal__close:active { transform: scale(0.94); }

.event-modal__rows {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 1.6vh, 20px);
}

.event-modal__row { display: flex; flex-direction: column; gap: 2px; }

.event-modal__label {
    font-size: clamp(13px, 1vw, 16px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.event-modal__value { font-size: clamp(18px, 1.5vw, 26px); font-weight: 700; }
