/* ===== ui-fixes.css — portable UI fixes for the Gold Map Plus series =====
   Load LAST (after every other stylesheet). Self-contained: no other file depends on it.
   1. Smaller text footprint, never smaller text   2. Clear z-index scale
   3. Map-tap closes everything (JS)               4. Pinch / A-/A+ text zoom (JS)
   + Find Gold button, cash-register sound toggle.

   Z-INDEX SCALE (root stacking context)
     0        #map (fixed => its own stacking context: tiles, panes, Leaflet popups 700,
              Leaflet controls 1000, MapLibre #map3d 800 all live INSIDE it)
     1050     .note info cards
     1100     .ctrl toolbar (Layer / Base selects, A-/A+, volume)
     1150     #panel side / bottom sheet, docked Layers control (closed)
     1200     #top title bar
     2600     #detail full-screen site page
     10040    hints (#allOffHint)
     10045    Find Gold button
     10050    tool stack, full-screen and GPS buttons
     12000    coin burst (pointer-events:none)
     20000    OPEN DROPDOWNS: Layers menu (re-parented to <body> while open), legend dot popover
     20010    toasts that must sit over menus
*/
:root{--uf-z-menu:20000;--uf-z-fab:10045;--uf-ts:1;--uf-base:15px}
@media (max-width:720px){:root{--uf-base:16px}}

/* ---------- 2. Z-INDEX ---------- */
.ox-ctl.uf-menu-open{box-shadow:0 10px 32px rgba(10,10,11,.28)!important;z-index:var(--uf-z-menu)!important;font-family:var(--sans,Inter,system-ui,sans-serif)}
#dotpop{z-index:var(--uf-z-menu)!important}
body:not(.night) .ox-ctl.uf-menu-open{background:#fff!important}
body.night .ox-ctl.uf-menu-open{background:#161b24!important}
body>.ox-ctl{font:inherit;font-family:var(--sans,Inter,system-ui,sans-serif)}

/* ---------- 1. TEXT FOOTPRINT (never under 14 px) ---------- */
/* popups: text size from the shared scale, capped height, scroll inside */
.leaflet-popup-content{font-size:calc(var(--uf-base) * var(--uf-ts))!important;line-height:1.42}
.maplibregl-popup-content{font-size:calc(var(--uf-base) * var(--uf-ts))!important;line-height:1.42}
.leaflet-popup-content,.maplibregl-popup-content .pp,.maplibregl-popup-content>div{
  max-height:min(46vh,430px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;touch-action:pan-y}
body.uf-big .leaflet-popup-content,body.uf-big .maplibregl-popup-content .pp,body.uf-big .maplibregl-popup-content>div{max-height:min(62vh,620px)}
.leaflet-popup-content{margin:10px 12px 8px!important}
.leaflet-popup-content-wrapper{padding:0!important}
.pp h4{font-size:1.25em!important;margin:2px 64px 4px 0!important;line-height:1.15!important}
.pp .pp-badges{margin-bottom:4px!important}
.pp-row{margin:4px 0!important}
.pp td{padding:3px 4px!important}
/* small labels inside popups / panels: floor 14 px */
.leaflet-popup-content .k,.leaflet-popup-content .small,.leaflet-popup-content small,.leaflet-popup-content .sub,
.leaflet-popup-content .n,.leaflet-popup-content .gb,.leaflet-popup-content .fchip,.leaflet-popup-content .disc,
.leaflet-popup-content td,.leaflet-popup-content li,.leaflet-popup-content .rules,.leaflet-popup-content .pp-badges *,
.maplibregl-popup-content .k,.maplibregl-popup-content .small,.maplibregl-popup-content small,.maplibregl-popup-content .sub,
.maplibregl-popup-content .n,.maplibregl-popup-content .gb,.maplibregl-popup-content td,.maplibregl-popup-content li{font-size:max(14px,.88em)!important}
.pp-row .k,.pp-stats .k{letter-spacing:.04em!important}
/* stacked label/value rows on phone: label above value, full width */
@media (max-width:720px){
  .leaflet-popup-content table,.leaflet-popup-content tbody,.leaflet-popup-content tr,.leaflet-popup-content td,
  .maplibregl-popup-content table,.maplibregl-popup-content tbody,.maplibregl-popup-content tr,.maplibregl-popup-content td{display:block;width:auto!important}
  .leaflet-popup-content td:first-child,.maplibregl-popup-content td:first-child{border-bottom:0!important;padding-bottom:0!important;font-weight:600}
  .leaflet-popup{max-width:94vw}
  .leaflet-popup-content{max-width:calc(94vw - 26px)}
}
/* "More" collapse */
.uf-hid{display:none!important}
.leaflet-popup-content *,.maplibregl-popup-content *{overflow-wrap:anywhere}
.leaflet-popup-content .gb,.maplibregl-popup-content .gb{white-space:normal!important;max-width:100%}
.uf-more{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;min-height:40px;margin:6px 0 2px;padding:6px 10px;
  border:1px solid #c9ced6;border-radius:10px;background:#f4f5f7;color:#1f2329;font:600 max(14px,.95em)/1.2 var(--sans,system-ui,sans-serif);cursor:pointer}
.uf-more:focus-visible{outline:2px solid #0f8f84;outline-offset:2px}
.uf-clamp{max-height:7.6em;overflow:hidden;-webkit-mask-image:linear-gradient(180deg,#000 62%,transparent);mask-image:linear-gradient(180deg,#000 62%,transparent)}
/* in-popup A-/A+ (fallback for pinch) */
.uf-tz{position:absolute;top:6px;right:38px;display:flex;gap:2px;z-index:2}
.uf-tz button{min-width:34px;height:30px;padding:0 6px;border:1px solid #c9ced6;background:#fff;color:#1f2329;border-radius:8px;font:700 14px/1 var(--sans,system-ui,sans-serif);cursor:pointer}
.uf-tz button:disabled{opacity:.45}
.maplibregl-popup-content{position:relative;padding-top:40px!important}
.leaflet-popup-content-wrapper{position:relative}
.leaflet-popup-content-wrapper .leaflet-popup-content:not(:has(.pp-badges)){padding-top:28px}
.leaflet-popup-content .pp-badges{margin-right:112px!important;min-height:30px}
.leaflet-container a.leaflet-popup-close-button{width:30px!important;height:30px!important;font-size:22px!important;line-height:28px!important;top:6px!important;right:6px!important}

/* panel: shorter sheet on phone, compact tabs, text >= 15-16 px */
#panel .body,#pbody{font-size:calc(var(--uf-base) * var(--uf-ts))!important}
#panel .tabs button{font-size:14px!important;padding:9px 4px!important;letter-spacing:.04em!important}
#panel h3{font-size:14px!important;letter-spacing:.06em!important;margin:10px 0 6px!important}
#pbody .small,#pbody small,#pbody .sub,#pbody .rk,#pbody .lg-row,#pbody label,#pbody td,#pbody li{font-size:max(14px,.9em)!important}
#pbody{padding-top:8px!important}
@media (max-width:720px){#panel{height:50vh!important;height:50dvh!important}}
#dotpop{font-size:calc(var(--uf-base) * var(--uf-ts))!important;max-height:min(60vh,520px)!important}
#dotpop .rk,#dotpop .dp-lyr,#dotpop small{font-size:max(14px,.85em)!important}
#detail .dt-body{font-size:calc(var(--uf-base) * var(--uf-ts))!important}

/* toolbar + controls: no text under 14 px */
#top .ttl small{font-size:14px!important;letter-spacing:.04em!important}
@media (max-width:720px){#top .ttl{font-size:16px!important}}
#top .ttl .brand,#top .ttl .brand em,#top .ttl .brand *{font-size:max(14px,1em)!important}
#top a.btn,#top .btn{font-size:14px!important;padding-top:6px;padding-bottom:6px}
#top .fee,#top .fee *{font-size:14px!important}
.ctrl .layersel span,.ctrl .vol,.ctrl .vol *{font-size:14px!important}
.ox-ctl,.ox-ctl label.ox-row,.ox-ctl .ox-grp-h,.ox-ctl .small,.ox-ctl small,.ox-ctl .caveat,.ox-ctl .ox-leg{font-size:max(14px,1em)!important}
#allOffHint,#locMsg,.v3d-note,#lyrload,.note{font-size:14px!important}
.leaflet-control-scale-line{font-size:14px!important;line-height:1.2!important}
/* attribution: compact "i" chip, tap to read (keeps credits, 14 px when open) */
.leaflet-control-attribution{font-size:14px!important;line-height:1.35!important;max-width:min(92vw,520px)}
.leaflet-control-attribution:not(.uf-open){font-size:0!important;width:30px;height:30px;padding:0!important;border-radius:50% 0 0 0;overflow:hidden;cursor:pointer;background:rgba(255,255,255,.85)!important}
.leaflet-control-attribution:not(.uf-open)::after{content:"i";display:block;font:700 16px/30px Georgia,serif;text-align:center;color:#1f2329}
.maplibregl-ctrl-attrib-inner{font-size:14px!important}
/* 3D credits: collapsed to the (i) button on phone; tap it to read */
@media (max-width:720px){.maplibregl-ctrl-attrib:not(.uf-open) .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib:not(.uf-open){min-height:24px;min-width:24px}}

/* ---------- Find Gold ---------- */
#ufFindGold{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:var(--uf-z-fab);
  min-height:50px;padding:0 26px;border-radius:999px;border:2px solid #5e3d06;cursor:pointer;
  background:linear-gradient(180deg,#ffe58a 0%,#f2c14e 45%,#c98a12 100%);color:#1a1200;font:800 17px/1 var(--sans,Inter,system-ui,sans-serif);letter-spacing:.02em;
  box-shadow:0 4px 14px rgba(94,61,6,.45),inset 0 1px 0 rgba(255,255,255,.7);display:flex;align-items:center;gap:8px;white-space:nowrap;touch-action:manipulation}
#ufFindGold:focus-visible{outline:3px solid #0f8f84;outline-offset:3px}
#ufFindGold[aria-busy="true"]{filter:saturate(1.2) brightness(1.05);cursor:progress}
#ufFindGold .uf-fg-ico{width:20px;height:20px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff6cf 0,#f2c14e 40%,#a86f12 85%);box-shadow:0 0 0 1.5px #5e3d06}
@media (max-width:720px){body:not(.panel-hidden) #ufFindGold,body.uf-has-pop #ufFindGold{display:none}}
#detail.open~#ufFindGold,body.fs-detail #ufFindGold{display:none}
body.measuring #ufFindGold{display:none}
/* pulse glow (scale/opacity driven by Web Animations API from ui-fixes.js) */
.uf-pulsing{will-change:transform,filter;transform-origin:50% 50%}
.lucky-mark.uf-fg-on{z-index:9999!important;opacity:1!important}
/* sound toggle in the tool stack */
#ufSoundBtn[aria-pressed="false"]{opacity:.6}
