/* ==========================================================================
   Where's a Bear — Stylesheet
   Plain CSS, no framework. Organized top-to-bottom the way the page reads:
   variables → resets → header → map layout → sidebar → modals → forms →
   badges → profile → auth pages → responsive tweaks.
   ========================================================================== */

/* ---- Design tokens (colors pulled from the logo: cream, dark brown,
   mustard warning-sign yellow, forest green for nature/safety accents) --- */
:root {
    --cream:        #f6e6d4;
    --brown-dark:   #2b1d12;
    --brown:        #4a3221;
    --brown-mid:    #6b4b30;
    --mustard:      #f0b429;
    --mustard-dark: #c98a12;
    --forest:       #3f6b3a;
    --forest-dark:  #2c4a29;
    --danger:       #b3341c;
    --ice-blue:     #4a7a96; /* polar bear accent — cold/arctic to stand apart from the earthy browns */
    --white:        #ffffff;
    --gray-light:   #e7ddd0;
    --shadow:       0 4px 14px rgba(43, 29, 18, 0.18);
    --radius:       10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--brown-dark);
    background: var(--cream);
}

h1, h2, h3 { color: var(--brown-dark); margin-top: 0; }

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

.muted { color: var(--brown-mid); font-size: 0.88rem; }

/* ---- Header / nav -------------------------------------------------- */
.site-header {
    background: var(--brown-dark);
    border-bottom: 4px solid var(--mustard);
}
.site-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.6rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--cream) !important;
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }

.main-nav { display: flex; align-items: center; gap: 1.1rem; }
.main-nav a { color: var(--cream); font-weight: 500; }
.main-nav a:hover { color: var(--mustard); text-decoration: none; }
.nav-cta {
    background: var(--mustard);
    color: var(--brown-dark) !important;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-weight: 700;
}
.nav-cta:hover { background: var(--mustard-dark); }

/* ---- Buttons (shared across the whole app) -------------------------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: var(--radius);
    padding: 0.65rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.btn-block { width: 100%; }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-primary { background: var(--forest); color: var(--white); }
.btn-primary:hover { background: var(--forest-dark); }
.btn-secondary { background: var(--gray-light); color: var(--brown-dark); }
.btn-secondary:hover { background: #d9cbb8; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #8f2914; }
/* A low-emphasis "danger" action (reporting content) — reads as a plain
   text link until hovered, so it doesn't visually compete with the
   primary actions on the pin detail card. */
.btn-link-danger { background: none; color: var(--danger); padding: 0.35rem 0.4rem; }
.btn-link-danger:hover { text-decoration: underline; }

/* ---- Map layout ------------------------------------------------------ */
.map-app {
    display: flex;
    height: calc(100vh - 68px); /* full height minus header */
}

.map-sidebar {
    width: 340px;
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--gray-light);
    overflow-y: auto;
    padding: 1rem;
}
.sidebar-section {
    padding-bottom: 1.2rem;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--gray-light);
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.sidebar-hint { font-size: 0.85rem; color: var(--brown-mid); margin: 0.3rem 0 0.6rem; }

.view-toggle { display: flex; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--gray-light); }
.toggle-btn {
    flex: 1;
    padding: 0.55rem 0.4rem;
    border: none;
    background: var(--white);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--brown-mid);
}
.toggle-btn.active { background: var(--forest); color: var(--white); }

select, input[type="text"], input[type="email"], input[type="password"],
input[type="datetime-local"], input[type="file"], textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    font-size: 0.92rem;
    background: var(--white);
    color: var(--brown-dark);
    margin-bottom: 0.75rem;
}
label { font-weight: 600; font-size: 0.85rem; display: block; margin-bottom: 0.25rem; }

.map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

.fab-ping-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    background: var(--mustard);
    color: var(--brown-dark);
    border: none;
    padding: 0.85rem 1.3rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow);
    cursor: pointer;
}
.fab-ping-btn:hover { background: var(--mustard-dark); }

.btn-toggle-sidebar {
    display: none;
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 500;
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}

/* "?" button that reopens the tutorial modal — sits next to the ping
   button so it's easy to find whenever someone feels lost. */
.btn-help {
    position: absolute;
    bottom: 24px;
    left: 24px;
    z-index: 500;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--white);
    color: var(--brown-dark);
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.btn-help:hover { background: var(--gray-light); }

/* ---- Species tag chips (used in sidebar + popups) -------------------- */
.species-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.4rem;
    color: var(--white);
}
.species-black_bear   { background: var(--brown); }
.species-grizzly_bear { background: var(--mustard-dark); }
.species-polar_bear   { background: var(--ice-blue); }
.species-unknown      { background: var(--brown-mid); }

.migration-row { margin-bottom: 0.7rem; font-size: 0.88rem; }

/* ---- Area check result box -------------------------------------------- */
.area-check-result {
    background: var(--gray-light);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.87rem;
    margin-top: 0.6rem;
}
.risk-badge {
    display: inline-block;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    color: var(--white);
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
}
.risk-low      { background: var(--forest); }
.risk-moderate { background: var(--mustard-dark); }
.risk-high     { background: var(--danger); }

.safety-tip-list { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.safety-tip-list li { margin-bottom: 0.3rem; font-size: 0.87rem; }

/* ---- Modals ------------------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(43, 29, 18, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3vh 1rem;
    overflow-y: auto;
    z-index: 1000;
}
/* IMPORTANT: the plain `.modal-overlay` rule above and the browser's
   built-in `[hidden] { display: none }` rule have the EXACT same CSS
   specificity (one class vs. one attribute selector), so without this
   more-specific override, `.modal-overlay` wins and the `hidden`
   attribute set by JS (see app.js's showModal()/hideModal()) is
   silently ignored — the modal would render open all the time. */
.modal-overlay[hidden] {
    display: none;
}
.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow);
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--brown-mid);
}
.modal-close:hover { color: var(--brown-dark); }

/* A bit more breathing room for the tutorial modal's longer content. */
.modal-box-wide { max-width: 560px; }

/* ---- Pin popup / detail modal content ---------------------------------- */
.pin-photo { width: 100%; border-radius: 8px; margin-bottom: 0.6rem; max-height: 220px; object-fit: cover; }
.pin-meta { font-size: 0.85rem; color: var(--brown-mid); margin-bottom: 0.6rem; }
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--gray-light);
}

/* ---- Tutorial modal ----------------------------------------------------- */
.tutorial-steps { margin: 0.75rem 0 1rem; }
.tutorial-step { margin-bottom: 0.9rem; }
.tutorial-step strong { display: block; margin-bottom: 0.15rem; }
.tutorial-step p { margin: 0; font-size: 0.88rem; color: var(--brown-mid); }

.species-legend { margin: 0.5rem 0 1rem; }
.species-legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}
.species-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(43, 29, 18, 0.25);
}

/* ---- Alerts -------------------------------------------------------------*/
.alert {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 0.9rem;
}
.alert-error { background: #fbe4de; color: var(--danger); border: 1px solid #f0b6a5; }

/* ---- Auth pages ---------------------------------------------------------*/
.auth-page {
    display: flex;
    justify-content: center;
    padding: 4rem 1rem;
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
}
.auth-sub { color: var(--brown-mid); font-size: 0.9rem; margin-bottom: 1.2rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.9rem; }

/* ---- Profile page ---------------------------------------------------- */
.profile-page { max-width: 800px; margin: 0 auto; padding: 2rem 1.2rem; }
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.profile-stat { text-align: right; }
.stat-number { display: block; font-size: 1.8rem; font-weight: 800; color: var(--forest-dark); }
.stat-label { font-size: 0.8rem; color: var(--brown-mid); }

.badge-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--white);
    margin-top: 0.3rem;
}
.badge-newcomer   { background: var(--brown-mid); }
.badge-scout      { background: var(--forest); }
.badge-whisperer  { background: var(--mustard-dark); }
.badge-legend     { background: var(--danger); }

.badge-ladder { font-size: 0.83rem; color: var(--brown-mid); margin-bottom: 1.5rem; }

.my-sightings-list { display: flex; flex-direction: column; gap: 0.8rem; }
.my-sighting-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 0.7rem;
}
.my-sighting-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.my-sighting-info { flex: 1; }

/* ---- Footer ------------------------------------------------------------ */
.site-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.78rem;
    color: var(--brown-mid);
    background: var(--white);
    border-top: 1px solid var(--gray-light);
}
.disclaimer { font-size: 0.72rem; margin-top: 0.2rem; }

/* ---- Responsive: stack sidebar as a slide-over panel on small screens - */
@media (max-width: 820px) {
    .map-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 600;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }
    .map-sidebar.open { transform: translateX(0); }
    .btn-toggle-sidebar { display: block; }
    .map-app { position: relative; }
}
