/* ==========================================================================
   Loot Finder mobile layer. Phone rules live only inside the media query
   below (<= 768px, or a phone held sideways). Desktop is unchanged; outside
   the query only the hidden Feedback & Requests modal is styled.
   ========================================================================== */
.lf-tabbar, .lf-more, .lf-sheet { display: none; }

/* ---------- Feedback & Requests modal (all widths, hidden until opened) ---------- */
.lf-fb[hidden] { display: none !important; }
.lf-fb { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px; }
.lf-fb-backdrop { position: absolute; inset: 0; background: rgba(5, 2, 12, 0.72); opacity: 0; transition: opacity 0.18s; }
.lf-fb-panel {
  position: relative; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--card, #1a1030); color: var(--text, #fff4fb); border: 1px solid rgba(255, 120, 200, 0.35);
  border-radius: 20px; padding: 20px 18px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(16px); opacity: 0; transition: transform 0.18s, opacity 0.18s; overscroll-behavior: contain;
}
.lf-fb.is-open .lf-fb-backdrop { opacity: 1; }
.lf-fb.is-open .lf-fb-panel { transform: none; opacity: 1; }
.lf-fb-panel h2 { margin: 0 44px 6px 0; font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: 0.04em; font-size: 1.6rem; color: var(--gold, #ffb347); }
.lf-fb-sub { margin: 0 0 14px; color: var(--muted, #d4c4e4); font-size: 0.92rem; line-height: 1.45; }
.lf-fb-x { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 1.6rem; cursor: pointer; }
.lf-fb-types { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.lf-fb-types legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; padding: 0; }
.lf-fb-types label { position: relative; display: inline-flex; }
.lf-fb-types input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.lf-fb-types span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2, #140c24); border: 1px solid var(--line, rgba(255,120,200,.2)); color: var(--muted, #d4c4e4); font-size: 0.9rem; font-weight: 600;
}
.lf-fb-types input:checked + span { background: var(--mint, #22e3d3); color: #041a18; border-color: transparent; }
.lf-fb-types input:focus-visible + span { outline: 3px solid var(--pink, #ff3d9a); outline-offset: 2px; }
.lf-fb-field { display: grid; gap: 6px; margin: 0 0 12px; font-weight: 600; font-size: 0.9rem; }
.lf-fb-field small { font-weight: 400; color: var(--muted, #d4c4e4); }
.lf-fb-field textarea, .lf-fb-field input {
  width: 100%; font: inherit; font-weight: 400; font-size: 16px; color: var(--text, #fff4fb); background: var(--bg-2, #140c24);
  border: 1px solid var(--line, rgba(255,120,200,.2)); border-radius: 12px; padding: 12px 14px; min-height: 44px; resize: vertical;
}
.lf-fb-field textarea:focus, .lf-fb-field input:focus { outline: none; box-shadow: 0 0 0 2px var(--mint, #22e3d3); }
.lf-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.lf-fb-err { margin: 0 0 10px; color: var(--danger, #ff6b86); font-size: 0.9rem; }
.lf-fb-send, .lf-fb-done button {
  width: 100%; min-height: 50px; border: 0; border-radius: 14px; cursor: pointer; font: inherit; font-weight: 700; font-size: 1.05rem;
  background: var(--sunset, #ff3d9a); color: #1b0718; box-shadow: 0 0 18px rgba(255, 61, 154, 0.4);
}
.lf-fb-send:disabled { opacity: 0.6; }
.lf-fb-note { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted, #d4c4e4); text-align: center; }
.lf-fb-done { text-align: center; padding: 8px 0 0; }
.lf-fb-done h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 2rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mint, #22e3d3); }
.lf-fb-done p { margin: 0 0 14px; color: var(--muted, #d4c4e4); line-height: 1.5; }
.lf-fb-done .lf-fb-copy { background: transparent; color: var(--mint, #22e3d3); border: 1px solid var(--mint, #22e3d3); box-shadow: none; margin-bottom: 10px; font-size: 0.95rem; min-height: 44px; }
html.lf-modal-open, html.lf-modal-open body { overflow: hidden; }

/* ========================================================================== */
@media (max-width: 768px), (pointer: coarse) and (max-height: 500px) {
  /* ---------- Bottom tab bar replaces the top nav ---------- */
  body .site-nav { display: none !important; }
  .lf-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1400;
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background: rgba(14, 6, 28, 0.97); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 2px solid transparent; border-image: var(--sunset) 1;
  }
  .lf-tabbar > a, .lf-tabbar > button {
    flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 6px 2px 5px; border: 0; background: none; color: var(--muted); text-decoration: none; cursor: pointer;
    font: 600 0.7rem/1 var(--font, system-ui), system-ui, sans-serif; letter-spacing: 0.02em; -webkit-tap-highlight-color: transparent;
  }
  .lf-tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .lf-tabbar [aria-current="page"], .lf-tabbar .is-current { color: var(--mint); }
  .lf-tabbar [aria-current="page"] svg, .lf-tabbar .is-current svg { filter: drop-shadow(0 0 6px rgba(34, 227, 211, 0.7)); }
  .lf-tabbar [aria-expanded="true"] { color: var(--gold); }
  .app { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  /* keep the host's "Published with deed.page" badge clear of the tab bar */
  a[data-deed-badge] { bottom: calc(var(--lf-tab, 58px) + 8px) !important; }
  a[data-deed-report] { bottom: calc(var(--lf-tab, 58px) + 36px) !important; }
  .to-top { bottom: calc(var(--lf-tab, 58px) + 40px) !important; }

  /* ---------- More menu (bottom sheet) ---------- */
  .lf-more:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 1350; }
  .lf-more-backdrop { position: absolute; inset: 0; background: rgba(5, 2, 12, 0.6); opacity: 0; transition: opacity 0.18s; }
  .lf-more-panel {
    position: absolute; left: 0; right: 0; bottom: var(--lf-tab, 58px); max-height: calc(100dvh - var(--lf-tab, 58px) - 24px); overflow: auto;
    background: var(--card); border: 1px solid rgba(255, 120, 200, 0.35); border-bottom: 0; border-radius: 20px 20px 0 0;
    padding: 4px 12px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    transform: translateY(24px); opacity: 0; transition: transform 0.18s, opacity 0.18s; box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55);
  }
  .lf-more.is-open .lf-more-backdrop { opacity: 1; }
  .lf-more.is-open .lf-more-panel { transform: none; opacity: 1; }
  .lf-more-panel .lf-grab { grid-column: 1 / -1; }
  .lf-more-panel > a, .lf-more-panel > button {
    display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px; border-radius: 14px;
    background: var(--bg-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; cursor: pointer;
    font: 600 0.95rem/1.15 var(--font, system-ui), system-ui, sans-serif; text-align: left;
  }
  .lf-more-panel > a[aria-current="page"] { border-color: var(--mint); color: var(--mint); }
  .lf-more-panel .lf-more-wide { grid-column: 1 / -1; }
  .lf-more-panel .lf-more-kofi { grid-column: 1 / -1; justify-content: center; background: var(--sunset); color: #1b0718; border: 0; box-shadow: 0 0 16px rgba(255, 61, 154, 0.45); }
  .lf-more-social { grid-column: 1 / -1; display: flex; gap: 8px; }
  .lf-more-social a { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
  .lf-more-social svg { width: 18px; height: 18px; fill: currentColor; }
  .lf-more-head { grid-column: 1 / -1; margin: 4px 2px 0; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

  .lf-grab { display: grid; place-items: center; height: 22px; }
  .lf-grab span { display: block; width: 42px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.35); }

  /* ---------- Tap targets (44px) ---------- */
  .type-chips button, .check, .ux-btn, .view-toggle button, .mature-toggle, .sm-view button, .nearby-btn,
  .area-pick select, .controls select, .filter-row select, .has-code, .sm-sel select, .pt-jump a, .fit-jump a, .area-toggle { min-height: 44px; }
  a.watch-how { display: inline-flex; align-items: center; min-height: 44px; }
  .map-card .close, #card-close { min-width: 44px; min-height: 44px; }
  .leaflet-touch .leaflet-bar a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 22px !important; }
  .foot a, .info-body a, .sources a, .social-links a { display: inline-block; padding-top: 10px; padding-bottom: 10px; }
  .kofi-foot a, .social-foot a, .social-links a { min-height: 44px; }
  .foot .sources li { margin: 0; }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into the search box */

  /* ---------- Sticky search + one-line filter row (all pages) ---------- */
  .controls {
    position: sticky; top: 0; z-index: 900;
    margin-left: -14px; margin-right: -14px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    background: rgba(11, 7, 22, 0.96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .controls .search input { min-height: 46px; }
  .lf-chiprow {
    display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    margin: 0 -12px; padding: 0 12px 2px; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  .lf-chiprow::-webkit-scrollbar { display: none; }
  .lf-chiprow > * { display: flex !important; flex-wrap: nowrap !important; gap: 8px !important; flex: 0 0 auto !important; align-items: center; margin: 0 !important; overflow: visible !important; width: auto !important; grid-column: auto !important; }
  .lf-chiprow > *[hidden] { display: none !important; }
  .lf-chiprow > :last-child { padding-right: 24px; }
  .lf-chiprow button, .lf-chiprow label, .lf-chiprow select { flex: 0 0 auto; white-space: nowrap; }
  .lf-chiprow .area-pick select { width: auto; max-width: 62vw; }
  .lf-chiprow > .ux-row { order: -1; } /* brand + area pickers first on phones */
  .lf-chiprow .brand-pick select { max-width: 60vw; padding-left: 10px; padding-right: 6px; }
  .lf-chiprow .sm-sel { display: inline-flex; align-items: center; gap: 6px; }
  .lf-chiprow .sm-sel select { width: auto; }

  /* ================= Map pages: full-screen map + results sheet ================= */
  html:has(body.lf-m), body.lf-m { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body.lf-m { position: fixed; inset: 0; width: 100%; }
  body.lf-m .app { padding: 0; min-height: 0; max-width: none; }
  body.lf-m .controls {
    position: fixed; top: 0; left: 0; right: 0; margin: 0; z-index: 1300; border-radius: 0;
    padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  }
  body.lf-m .controls .more-filters:not([hidden]) {
    position: absolute; top: calc(100% + 6px); left: 8px; right: 8px; z-index: 2; margin: 0;
    display: grid; grid-template-columns: 1fr; gap: 10px; padding: 12px; max-height: 60dvh; overflow: auto;
    background: var(--card); border: 1px solid rgba(255, 120, 200, 0.35); border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  }
  body.lf-m .workspace { display: block !important; min-height: 0 !important; margin: 0; }
  html body.lf-m .map-wrap, html body.lf-m.has-sheet .map-wrap {
    display: block !important; position: fixed !important; left: 0 !important; right: 0 !important;
    top: var(--lf-top, 120px) !important; bottom: var(--lf-tab, 58px) !important;
    height: auto !important; min-height: 0 !important; max-height: none !important; z-index: 1 !important;
    margin: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  }
  body.lf-m #map { height: 100% !important; min-height: 0 !important; border-radius: 0 !important; }
  body.lf-m .view-toggle, body.lf-m .to-top { display: none !important; }
  /* map credits: small, top right under "Area names", never under a sheet */
  html body.lf-m .map-wrap .leaflet-bottom.leaflet-right { top: 62px !important; bottom: auto !important; }
  body.lf-m .leaflet-control-attribution { max-width: 68vw; font-size: 9px !important; line-height: 1.3; padding: 2px 6px !important; margin: 0 8px 0 0 !important; border-radius: 8px; opacity: 0.85; text-align: right; }

  /* pin card: above the tab bar, below the search bar */
  html body.lf-m .map-card.is-sheet {
    position: absolute !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    height: min(var(--sheet-h, 58dvh), calc(100% - 8px)) !important; max-height: calc(100% - 8px) !important;
    padding-bottom: 10px !important;
  }
  html body.lf-m .map-card.is-sheet:not(.is-expanded) { height: min(var(--sheet-h, 58dvh), 60%) !important; }

  /* results sheet */
  body.lf-m .lf-sheet {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: var(--lf-tab, 58px); z-index: 1100;
    height: 48dvh; max-height: calc(100dvh - var(--lf-top, 120px) - var(--lf-tab, 58px));
    background: var(--bg-2); border: 1px solid rgba(255, 120, 200, 0.35); border-bottom: 0; border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.55);
    transition: height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: height;
  }
  body.lf-m .lf-sheet[data-state="full"] { border-radius: 0; border-left: 0; border-right: 0; }
  body.lf-m .lf-sheet.is-dragging { transition: none; }
  body.lf-m .lf-sheet.is-away { transform: translateY(calc(100% + 30px)); pointer-events: none; visibility: hidden; transition: transform 0.26s, visibility 0s 0.26s; }
  .lf-sheet-head {
    flex: 0 0 auto; display: grid; grid-template-columns: 1fr 44px; align-items: center; column-gap: 8px;
    padding: 0 12px 8px 16px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  }
  .lf-sheet-head .lf-grab { grid-column: 1 / -1; }
  .lf-sheet-title { min-width: 0; }
  .lf-sheet-title h2 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase; font-size: 1.3rem; line-height: 1.1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lf-sheet-title .status { margin: 3px 0 0 !important; padding: 0 !important; font-size: 0.78rem; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .lf-sheet-toggle { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); display: grid; place-items: center; cursor: pointer; }
  .lf-sheet-toggle span { width: 10px; height: 10px; border-left: 2.5px solid currentColor; border-top: 2.5px solid currentColor; transform: translateY(2px) rotate(45deg); transition: transform 0.2s; }
  .lf-sheet-toggle[data-dir="down"] span { transform: translateY(-2px) rotate(225deg); }
  .lf-sheet-body {
    flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: hidden; overscroll-behavior: contain;
    padding: 2px max(12px, env(safe-area-inset-right, 0px)) 24px max(12px, env(safe-area-inset-left, 0px));
  }
  .lf-sheet[data-state="full"] .lf-sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
  body.lf-m .lf-sheet-body .list-wrap { max-height: none !important; overflow: visible !important; padding: 0 !important; display: block !important; }
  body.lf-m .lf-sheet-body > .top { margin-top: 18px; min-height: 210px; }
  body.lf-m .lf-sheet-body > .howto { margin: 4px 0 12px; }
  body.lf-m .lf-sheet-body > .foot { margin-bottom: 8px; }
  body.lf-m .lf-sheet-body > :first-child { margin-top: 0; }
}

/* ---------- One-time Add to Home Screen hint (phones only, dismissible) ---------- */
.lf-hint {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--lf-tab, 58px) + 10px); z-index: 1500;
  display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 10px; border-radius: 16px;
  background: rgba(26, 16, 48, 0.97); border: 1px solid rgba(34, 227, 211, 0.45); color: var(--text, #fff4fb);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55); font-size: 0.88rem; line-height: 1.35;
}
.lf-hint img { border-radius: 8px; flex: 0 0 auto; }
.lf-hint span { flex: 1 1 auto; }
.lf-hint-go { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--mint, #22e3d3); color: #041a18; font: inherit; font-weight: 700; cursor: pointer; }
.lf-hint-x { width: 44px; height: 44px; flex: 0 0 44px; border: 0; background: transparent; color: inherit; font-size: 1.4rem; cursor: pointer; border-radius: 50%; }
@media (prefers-reduced-motion: reduce) {
  body.lf-m .lf-sheet, .lf-fb-panel, .lf-fb-backdrop, .lf-more-panel, .lf-more-backdrop { transition: none !important; }
}
