/* GeoMuster styles. Plain CSS, no build step. Mobile-first. */

:root {
    --ink: #1b1f1d;
    --paper: #ffffff;
    --accent: #1f3b2d;
    --muted: #5b6660;
    --radius: 12px;
    --touch: 48px; /* minimum touch target */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    color: var(--ink);
    background: var(--paper);
}

button { font: inherit; min-height: var(--touch); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.2rem; margin: 28px 0 12px; }
.muted { color: var(--muted); }

/* Ordinary pages */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    min-height: 56px;
    background: var(--accent);
    color: #fff;
}
.topbar a, .topbar .link-button { color: #fff; }
.topbar .brand { font-weight: 600; font-size: 1.15rem; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar form { margin: 0; }
.page { max-width: 640px; margin: 0 auto; padding: 16px; }

.notice {
    padding: 12px 16px;
    border-radius: var(--radius);
    background: #e6f2ea;
}

/* Forms */
.form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form label { font-weight: 600; margin-top: 10px; }
.form label.check { font-weight: normal; display: flex; align-items: center; gap: 10px; min-height: var(--touch); }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=tel],
.form input[type=date], .form textarea, select {
    font: inherit;
    min-height: var(--touch);
    padding: 8px 12px;
    border: 1px solid #b8c2bc;
    border-radius: 8px;
}
.form input[type=checkbox] { width: 22px; height: 22px; }
.form .button { margin-top: 16px; }
.error { color: #b00020; margin: 2px 0 0; }

.button {
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.button-danger { background: #9b2226; }
.link-button {
    min-height: auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

/* Lists */
.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #e3e7e4;
}
.row-link { color: inherit; text-decoration: none; min-height: var(--touch); }
.row-link:hover { background: #f4f6f5; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.heading-row .button { display: inline-flex; align-items: center; min-height: var(--touch); text-decoration: none; }
select { background: #fff; }
.row-actions form { margin: 0; }
.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: #e6f2ea;
    font-size: 0.8rem;
}

/* ---- Full-screen map page ---- */
.map-page { overflow: hidden; }
.small { font-size: 0.875rem; }
.pre-line { white-space: pre-line; }

.map-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 8px;
    padding-top: env(safe-area-inset-top);
    background: var(--accent);
    color: #fff;
}
.map-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.icon-button {
    width: var(--touch);
    height: var(--touch);
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
}
.chip {
    flex: none;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.chip-ok { background: #16a34a; }
.chip-warn { background: #ca8a04; }
.chip-bad { background: #dc2626; }

.map-page #map {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
}
#map.is-placing { cursor: crosshair; }
/* Keep Leaflet's bottom controls (zoom, attribution) above the action bar */
.map-page .leaflet-bottom { bottom: calc(54px + env(safe-area-inset-bottom)); }

.fab {
    position: fixed;
    right: 10px;
    bottom: calc(148px + env(safe-area-inset-bottom));
    z-index: 1000;
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #1d4ed8;
    font-size: 1.6rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    gap: 8px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
}
/* Slim like keyboard keys (Tony): 40 px buttons and menu items, full width of their slot. */
.action-slot { position: relative; flex: 1; display: flex; }
.action-bar .action { flex: 1; min-height: 40px; padding: 0 8px; font-size: 1rem; }
.action-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    min-width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}
.action-menu-right { left: auto; right: 0; }
.action-menu button {
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    color: var(--ink);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.action-menu button:last-child { border-bottom: 0; }
.action-menu button:disabled { color: #9ca3af; cursor: default; }
.badge {
    display: inline-block;
    min-width: 20px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.8rem;
    line-height: 20px;
    text-align: center;
}
.button-slim { min-height: 40px; }
.button:disabled { opacity: 0.6; cursor: wait; }
.button-light { background: #e8ece9; color: var(--ink); }

.placing-banner {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    border-radius: var(--radius);
    background: #fff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Bottom sheet: only shown for an action or a selected waypoint */
.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    max-height: 70vh;
    overflow-y: auto;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--paper);
    box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.25);
}
.sheet h2 { margin: 4px 0 10px; padding-right: 44px; }
.sheet-close { position: absolute; top: 6px; right: 6px; color: var(--muted); }
.sheet-option { display: block; width: 100%; margin-bottom: 8px; }
.sheet .form { margin-bottom: 0; }
.coord-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.coord-row input { width: 100%; }
.coords { font-variant-numeric: tabular-nums; }
.row-actions.wrap { flex-wrap: wrap; }
.conflict {
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #fff4e5;
}

/* ☰ drawer */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.4);
}
.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: min(320px, 85vw);
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    overflow-y: auto;
    background: var(--paper);
    box-shadow: 2px 0 14px rgba(0, 0, 0, 0.3);
}
.drawer h2 { margin: 0 0 4px; padding-right: 44px; }
.drawer > a, .drawer .link-button {
    display: flex;
    align-items: center;
    min-height: var(--touch);
    font-size: 1.05rem;
}
.drawer form { margin: 0; }
.drawer-close { position: absolute; top: 8px; right: 8px; color: var(--muted); }

.toast {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1400;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: var(--radius);
    background: #1b1f1d;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Search panel, under the top bar */
.search-panel {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    z-index: 1150;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 10px 12px 12px;
    background: var(--paper);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.search-row { display: flex; gap: 6px; align-items: center; }
.search-row input {
    flex: 1;
    min-width: 0;
    min-height: var(--touch);
    padding: 8px 12px;
    border: 1px solid #b8c2bc;
    border-radius: 8px;
    font: inherit;
}
.search-row .icon-button { color: var(--muted); font-size: 1.2rem; }
.search-help { margin: 8px 2px 0; }
.search-result {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid #e3e7e4;
    border-radius: 8px;
    background: #fff;
    text-align: left;
    cursor: pointer;
}
.search-result:hover { background: #f4f6f5; }
.found-icon { background: none; border: 0; }

/* Coordinates block: Lat/Lng, USNG, UTM */
.coords {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    margin: 8px 0 12px;
    font-variant-numeric: tabular-nums;
}
.coords dt { color: var(--muted); }
.coords dd { margin: 0; }

.action-bar .action-finding { background: #c2410c; }
.action-bar .action { padding: 0 6px; font-size: 1rem; line-height: 1.15; }
.status-buttons .is-current { outline: 3px solid #16a34a; outline-offset: -3px; }
.placing-banner { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
.placing-banner > .row-actions { justify-content: flex-end; flex-wrap: wrap; }
.drawer h3 { margin: 14px 0 4px; font-size: 1rem; }

/* Team positions: reports, never live. Fresh = recent report, stale = greyed. */
.team-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 0;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}
.team-row:disabled { cursor: default; }
.team-row.is-done strong { color: #6b7280; text-decoration: line-through; }
.team-phone { display: inline-block; margin: 0 0 6px 44px; }

/* Message board: full screen under the top bar */
.board-panel {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1150;
    display: flex;
    flex-direction: column;
    padding: 0 12px calc(8px + env(safe-area-inset-bottom));
    background: var(--paper);
}
.board-head { display: flex; align-items: center; justify-content: space-between; }
.board-head h2 { margin: 8px 0; }
.board-pinned { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.board-pin {
    min-height: 36px;
    padding: 4px 10px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
}
.board-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.msg { margin: 0 0 8px; padding: 8px 10px; border-radius: var(--radius); background: #f1f5f2; }
.msg-mine { background: #e3efe7; }
.msg-important { border-left: 4px solid #dc2626; }
.msg-meta { margin: 0 0 2px; font-size: 0.85rem; color: var(--muted); }
.msg-meta .tag { margin-left: 4px; }
.msg-body { margin: 0; }
.msg-actions { display: flex; gap: 14px; }
.msg-actions .link-button { min-height: 32px; padding: 0; font-size: 0.85rem; }
.board-compose textarea { width: 100%; font: inherit; padding: 8px; border: 1px solid #c9d1cc; border-radius: 8px; }
.board-compose-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; }
.board-note { margin: 4px 0 0; }

/* Project email (same panel as the board) */
.mail-new { width: 100%; margin-bottom: 8px; }
.mail-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 0;
    border-radius: var(--radius);
    background: #f1f5f2;
    text-align: left;
    cursor: pointer;
}
.mail-to { margin-top: 6px; }
.mail-rcpt { margin-right: 8px; white-space: nowrap; }
.rcpt-sent { color: #15803d; }
.rcpt-failed { color: #b00020; font-weight: 600; }
.mail-to-head { display: flex; align-items: center; justify-content: space-between; }
.mail-picks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.mail-pick { min-height: 36px; }
.mail-compose input[type=text], .mail-compose textarea { width: 100%; }
.team-row-text { display: flex; flex-direction: column; }
.team-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.team-fresh { background: #0f766e; }
.team-stale { background: #9ca3af; color: #1f2937; border-style: dashed; border-color: #4b5563; }
.team-none { background: #e5e7eb; color: #6b7280; box-shadow: none; }
.team-icon { background: none; border: 0; }

/* Status tags */
.tag-new { background: #ffedd5; }
.tag-reviewed { background: #fed7aa; }
.tag-significant { background: #fecaca; font-weight: 700; }
.tag-dismissed { background: #e5e7eb; color: #4b5563; }
.tag-not_started { background: #dbeafe; }
.tag-in_progress { background: #fef3c7; }
.tag-partial { background: #ffedd5; }
.tag-searched { background: #dcfce7; }
.status-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.status-buttons .button { min-height: 44px; font-size: 0.95rem; }

.area-label {
    background: rgba(255, 255, 255, 0.85);
    border: 0;
    box-shadow: none;
    font-weight: 600;
    padding: 1px 6px;
}
.area-label::before { display: none; }

/* Guidance */
.guidance {
    margin: 8px 0 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #f1f5f3;
}
.guidance p { margin: 4px 0 0; }
.guidance-main { display: flex; align-items: center; gap: 12px; font-size: 1.05rem; }
.guidance-arrow {
    display: inline-block;
    font-size: 2rem;
    line-height: 1;
    color: #1d4ed8;
    transition: transform 0.2s linear;
}

/* Notes & photos */
.attachments { margin-top: 16px; border-top: 1px solid #e3e7e4; padding-top: 4px; }
.attachments h3 { font-size: 1rem; margin: 8px 0; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.photo-grid figcaption { display: flex; justify-content: space-between; gap: 4px; }
.note { padding: 6px 0; border-bottom: 1px solid #eef1ef; }
.note p { margin: 2px 0; }
.note-form { display: flex; gap: 6px; align-items: flex-end; margin: 8px 0; }
.note-form textarea {
    flex: 1;
    font: inherit;
    padding: 8px 10px;
    border: 1px solid #b8c2bc;
    border-radius: 8px;
}
.file-button { display: inline-flex; align-items: center; min-height: var(--touch); cursor: pointer; }
.finding-icon.is-dismissed { opacity: 0.6; }
.link-button.small { font-size: 0.875rem; }

/* Waypoint symbols */
.wp-icon { background: none; border: 0; }
.wp-icon svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.wp-icon.is-selected svg { transform: scale(1.3); }

@media (min-width: 768px) {
    .sheet {
        left: 12px;
        right: auto;
        bottom: 12px;
        width: 400px;
        border-radius: var(--radius);
    }
    .action-bar {
        left: 12px;
        right: auto;
        bottom: 12px;
        width: 400px;
        border-radius: var(--radius);
    }
    .map-page .leaflet-bottom.leaflet-right { bottom: 0; }
    .search-panel { left: auto; right: 12px; top: 60px; width: 440px; border-radius: var(--radius); }
}
