/* Drift Maps — the wall of roads (/library.html).
   Loads AFTER brand.css (+ night.css when present). The page is one
   full-screen map (MapLibre globe; Leaflet when WebGL is missing) with
   overlays: header, brand/counter, bottom bar of filters, and a side panel
   that is either the results list or one road's card. Every overlay sits
   above the map's own stacking context (#map is z-index 0). */

:root { --top: 68px; --bar: 120px; }   /* measured by library.js: header stack + bottom bar */
html, body { height: 100%; }
body.wall { margin: 0; overflow: hidden; background: #08090B; }
body.wall::before { display: none; }          /* brand.css contour grid: the map is the grid */
.wall [hidden] { display: none !important; }
.wall a:hover { text-decoration: none; }

/* ---------- map ---------- */
#map { position: fixed; inset: 0; z-index: 0; background: #08090B; }   /* space behind the globe */
.map-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 85% 80% at 50% 45%, transparent 45%, rgba(14, 15, 18, .7) 100%);
}

/* MapLibre chrome (globe path) */
.maplibregl-map { font-family: var(--body); }
.maplibregl-canvas:focus { outline: none; }
.maplibregl-ctrl-bottom-left { bottom: calc(var(--bar) + 8px); left: 12px; z-index: 4; }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl { margin: 0 0 8px 0; }
.maplibregl-ctrl-attrib {
  background: rgba(14, 15, 18, .75) !important; color: var(--gravel) !important;
  font: 10px/1.4 var(--mono) !important; padding: 3px 7px !important; border-radius: 4px;
}
.maplibregl-ctrl-attrib a { color: var(--gravel) !important; text-decoration: none; }
.maplibregl-ctrl-attrib a:hover { color: var(--chalk) !important; }
.maplibregl-ctrl-group {
  background: var(--basalt) !important; border: 1px solid var(--contour); border-radius: 6px !important;
  box-shadow: none !important; overflow: hidden;
}
.maplibregl-ctrl-group button {
  width: 32px !important; height: 32px !important; background: var(--basalt) !important;
  border-bottom: 1px solid var(--contour) !important;
}
.maplibregl-ctrl-group button:last-child { border-bottom: 0 !important; }
.maplibregl-ctrl-group button:hover { background: #1c1f25 !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(.9); }
.maplibregl-ctrl button:not(:disabled):hover { background-color: #1c1f25 !important; }

/* Leaflet chrome (flat fallback) */
.leaflet-container { background: var(--asphalt); font-family: var(--body); }
.flat #map { background: var(--asphalt); }
.leaflet-tile-pane { filter: saturate(.35) brightness(.72) contrast(1.08); }
.leaflet-overlay-pane path.road { transition: stroke-opacity .25s ease, stroke-width .2s ease, stroke .2s ease; }
.leaflet-overlay-pane path:focus { outline: none; }
.leaflet-overlay-pane path.new { animation: blinkin 1.1s ease 7; }
@keyframes blinkin { 0%, 100% { stroke-opacity: .15; } 50% { stroke-opacity: 1; stroke: #FFD08A; } }
.leaflet-control-attribution {
  background: rgba(14, 15, 18, .75) !important; color: var(--gravel) !important;
  font: 10px/1.4 var(--mono) !important; padding: 3px 7px !important;
}
.leaflet-control-attribution a { color: var(--gravel) !important; }
.leaflet-bottom.leaflet-right { bottom: var(--bar); }
.leaflet-bottom.leaflet-left { bottom: calc(var(--bar) + 8px); }
.leaflet-bar { border: 1px solid var(--contour) !important; box-shadow: none !important; border-radius: 6px !important; overflow: hidden; }
.leaflet-bar a {
  background: var(--basalt) !important; color: var(--chalk) !important;
  border-bottom: 1px solid var(--contour) !important;
  width: 32px !important; height: 32px !important; line-height: 30px !important;
}
.leaflet-bar a:hover { background: #1c1f25 !important; }
.leaflet-bar a:last-child { border-bottom: 0 !important; }

/* ---------- tooltip (both renderers share the inner markup) ---------- */
.leaflet-tooltip.tt, .gl-tt {
  background: var(--basalt); border: 1px solid var(--contour); color: var(--chalk);
  border-radius: 8px; padding: 10px 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  font: 12px/1.45 var(--body); white-space: nowrap;
}
.gl-tt { position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none; will-change: transform; }
.leaflet-tooltip.tt::before { display: none; }
.tt .nm, .gl-tt .nm { font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: -.01em; display: flex; gap: 8px; align-items: center; }
.tt .row, .gl-tt .row { font-family: var(--mono); font-size: 11px; color: var(--chalk); margin-top: 4px; letter-spacing: .02em; }
.tt .row.m, .gl-tt .row.m { color: var(--gravel); }
.tt .amber, .gl-tt .amber { color: var(--sodium); }
.tt .ok, .gl-tt .ok { color: var(--signal); }

/* ---------- top stack: free-month banner + header ---------- */
.topstack { position: fixed; top: 0; left: 0; right: 0; z-index: 12; pointer-events: none; }
.topstack > * { pointer-events: auto; }
.wall .free-month {
  background: var(--sodium); color: var(--asphalt); font-family: var(--body);
  font-size: .9rem; line-height: 1.5; padding: 10px 24px; text-align: center;
}
.wall .free-month b { font-weight: 600; }
.wall .free-month a { color: var(--asphalt); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }

/* Header: the night.css .nr-header markup, pinned over the map. These
   rules out-rank night.css's (which may or may not be loaded) so the bar
   looks the same either way: transparent, fading into the map. */
.wall .nr-header {
  position: relative; top: auto; z-index: auto;
  background: linear-gradient(180deg, rgba(14, 15, 18, .88) 0%, rgba(14, 15, 18, .55) 60%, rgba(14, 15, 18, 0) 100%);
  border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.wall .nr-header .row { display: flex; align-items: center; gap: 24px; height: 68px; padding: 0 20px; max-width: none; }
.wall .nr-header .mark svg { width: 30px; height: 30px; }
.wall .nr-header .mark .word { font-size: .85rem; letter-spacing: .18em; }
.wall .nr-header .links { display: flex; gap: 22px; }
.wall .nr-header .links a {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gravel); transition: color .15s ease;
}
.wall .nr-header .links a:hover, .wall .nr-header .links a[aria-current="page"] { color: var(--chalk); }
.wall .nr-header .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.wall .nr-header .actions { display: flex; align-items: center; gap: 10px; margin-left: 0; }
.wall .nr-header .btn { padding: 8px 14px; font-size: .84rem; }
.wall .nr-header .btn-quiet { padding: 8px 4px; }
.wall .nr-header .actions .mono { font-size: .74rem; }
.wall .nr-header .cta-build .p { font-family: var(--mono); font-weight: 500; opacity: .8; }
/* auth.js paints a second amber button (Get started / Start free week); on
   this page the one amber door is "Build yours", so that one goes ghost. */
.wall .nr-header .actions .btn-primary { background: transparent; color: var(--chalk); border-color: var(--contour); }
.wall .nr-header .actions .btn-primary:hover { border-color: var(--gravel); background: rgba(255, 255, 255, .03); }

/* ---------- brand overlay: claim + honest counter ---------- */
.ov { position: fixed; z-index: 5; }
.brand-ov { top: calc(var(--top) + 6px); left: 20px; max-width: min(400px, calc(100vw - 40px)); pointer-events: none; }
.brand-ov > * { pointer-events: auto; }
.brand-ov p { margin: 0; color: var(--gravel); font-size: .86rem; line-height: 1.5; max-width: 38ch; text-shadow: 0 1px 8px rgba(14, 15, 18, .9); }
.counter {
  margin-top: 10px; font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gravel); display: flex; align-items: center; gap: 8px;
}
.counter b { font-family: var(--display); font-size: 1.9rem; letter-spacing: -.02em; color: var(--chalk); font-weight: 700; line-height: 1; transition: color .3s; }
.counter b.tick { color: var(--sodium); }
.queue {
  margin-top: 6px; font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gravel); display: flex; align-items: baseline; gap: 8px;
}
.queue b { font-family: var(--display); font-size: 1.25rem; letter-spacing: -.02em; color: var(--sodium); font-weight: 700; line-height: 1; }
.wall .live {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--taillight);
  box-shadow: 0 0 10px var(--taillight); margin: 0; animation: blink 1.4s infinite;
}
@keyframes blink { 50% { opacity: .25; } }
.lib-status { margin-top: 8px; font-family: var(--mono); font-size: .74rem; color: var(--gravel); letter-spacing: .04em; }
.lib-status.err { color: var(--taillight); }
.toast { margin-top: 8px; font-family: var(--mono); font-size: .72rem; color: var(--gravel); letter-spacing: .04em; opacity: 0; transform: translateY(-4px); transition: .4s ease; }
.toast.on { opacity: 1; transform: none; }
.toast b { color: var(--sodium); font-weight: 500; }

/* ---------- bottom bar: filters + search ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 16px 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(14, 15, 18, 0) 0%, rgba(14, 15, 18, .92) 40%);
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
/* Desktop: the filter group's children flow straight into the bar, two
   rows — list toggle + search + country + sort, then the tag chips. Phones
   fold the same group into a popover behind the Filters chip. */
.bar .filters { display: contents; }
.bar #listToggle { order: 1; }
.bar .search { order: 2; }
.bar #country { order: 3; }
.bar #chips { order: 5; flex: 1 1 100%; }
.bar .bar-legal { order: 6; }
.chips { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gravel);
  background: var(--basalt); border: 1px solid var(--contour); border-radius: 999px; padding: 7px 12px;
  cursor: pointer; white-space: nowrap; transition: .15s;
}
.chip:hover { color: var(--chalk); border-color: var(--gravel); }
.chip.on { color: var(--sodium); border-color: var(--sodium); }
.chip .n { opacity: .55; margin-left: 5px; }
.bar .lbl { font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gravel); margin-right: -4px; }
.bar select {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; color: var(--chalk);
  background: var(--basalt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A919D' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--contour); border-radius: 999px; padding: 7px 30px 7px 12px; cursor: pointer;
  appearance: none; -webkit-appearance: none; max-width: 230px;
}
.bar select:hover, .bar select:focus { border-color: var(--gravel); outline: none; }
.bar select.on { color: var(--sodium); border-color: var(--sodium); }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--basalt); border: 1px solid var(--contour);
  border-radius: 8px; padding: 0 10px; height: 34px; flex: 1 1 200px; max-width: 320px;
}
.search:focus-within { border-color: var(--gravel); }
.search svg { flex: none; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--chalk); font-size: .86rem; font-family: var(--body); }
.search input::placeholder { color: var(--gravel); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.bar .ftoggle { display: none; }
.bar-legal { flex: 1 1 100%; margin: 0; font-family: var(--mono); font-size: .6rem; color: var(--gravel); opacity: .7; letter-spacing: .02em; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- side panel: results list or one road's card ---------- */
.panel {
  position: fixed; z-index: 8; top: calc(var(--top) + 8px); right: 20px; bottom: calc(var(--bar) + 30px);
  width: 360px; max-width: calc(100vw - 40px);
  background: var(--basalt); border: 1px solid var(--contour); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55); display: flex; flex-direction: column;
  transform: translateX(24px); opacity: 0; pointer-events: none; transition: .28s ease;
}
.panel.open { transform: none; opacity: 1; pointer-events: auto; }
.panel .view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.panel[data-view="list"] .view.list, .panel[data-view="card"] .view.card { display: flex; }
.panel .x, .panel .back {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--contour); background: transparent;
  color: var(--gravel); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; flex: none;
}
.panel .x:hover, .panel .back:hover { color: var(--chalk); border-color: var(--gravel); }
.panel .head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--contour); }
.panel .head .t { flex: 1; font-family: var(--mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gravel); }
.panel .head .t b { color: var(--chalk); font-weight: 500; }
.panel .scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }

/* list rows */
.rows { list-style: none; margin: 0; padding: 6px 0; }
.rows li button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 16px;
  background: transparent; border: 0; color: var(--chalk); cursor: pointer; font-family: var(--body);
}
.rows li button:hover, .rows li button.cur { background: rgba(255, 164, 59, .07); }
.rows .nm { flex: 1; min-width: 0; font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .nm.nomark { color: var(--gravel); }
.rows .meta { font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; color: var(--gravel); white-space: nowrap; }
.rows .meta .sc { color: var(--sodium); }
.rows .meta .sc.top { color: var(--signal); }
.rows .empty { padding: 18px 16px; font-family: var(--mono); font-size: .76rem; color: var(--gravel); line-height: 1.6; }

/* card */
.cbody { padding: 14px 16px 16px; }
.card-eyebrow { font-family: var(--mono); font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; color: var(--sodium); }
.cbody h2 { font-family: var(--display); font-size: 1.4rem; letter-spacing: -.02em; line-height: 1.12; margin: 6px 0 4px; }
.cbody h2 a { color: inherit; }
.cbody h2 a:hover { color: var(--sodium); }
.where { font-family: var(--mono); font-size: .72rem; color: var(--gravel); letter-spacing: .04em; }
.outline {
  position: relative; margin: 12px 0 10px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--contour);
  background: repeating-radial-gradient(circle at 80% 0%, transparent 0 34px, #14161b 34px 35px), #0A0B0E;
}
.outline .layout { position: absolute; inset: 0; display: grid; place-items: center; padding: 40px 20px 20px; }
.outline .layout img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 7px rgba(255, 255, 255, .28)); }
.outline .ph { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 1.9rem; color: #2A2E36; letter-spacing: .08em; }
.lib-score {
  position: absolute; bottom: 10px; right: 10px; padding: 3px 9px; border-radius: 999px;
  background: rgba(10, 11, 14, .82); border: 1px solid var(--contour); backdrop-filter: blur(6px);
  font-family: var(--mono); font-size: .74rem; letter-spacing: .05em; color: var(--sodium);
}
.lib-score.top { color: var(--signal); }
.lib-thumbs { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.lib-thumbs button {
  display: flex; gap: 5px; align-items: center; padding: 3px 10px; cursor: pointer; border-radius: 999px;
  background: rgba(10, 11, 14, .82); border: 1px solid var(--contour); backdrop-filter: blur(6px);
  font-family: var(--mono); font-size: .74rem; color: var(--gravel); transition: .15s ease;
}
.lib-thumbs button:hover { border-color: var(--gravel); color: var(--chalk); }
.lib-thumbs button.on { color: var(--sodium); border-color: #4a3a1c; }
.lib-thumbs button:disabled { opacity: .6; cursor: wait; }
.lib-line { font-size: .86rem; color: var(--gravel); margin: 0 0 10px; line-height: 1.5; }
.lib-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.lib-tags .tchip {
  padding: 2px 9px; border-radius: 999px; cursor: pointer; background: transparent; border: 1px solid var(--contour);
  font-family: var(--mono); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; color: #6f7683; transition: .15s ease;
}
.lib-tags .tchip:hover { border-color: var(--gravel); color: var(--chalk); }
.lib-tags .tchip.used { color: var(--gravel); }
.lib-tags .tchip.mine { color: var(--sodium); border-color: #4a3a1c; }
.lib-tags .tchip:disabled { opacity: .6; cursor: wait; }
.cbody .lib-dl { width: 100%; font-size: .88rem; padding: 10px 14px; }
.cbody .lib-dl.none { color: #5c6270; border-color: var(--contour); cursor: default; pointer-events: none; }
.lib-note { margin: 10px 0 0; font-size: .76rem; color: #6f7683; line-height: 1.6; }
.lib-note .mono { font-size: .72rem; color: var(--gravel); }
.lib-comments { border-top: 1px solid var(--contour); margin-top: 14px; padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.lib-comments .ch { font-family: var(--mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gravel); }
.lib-comment { font-size: .84rem; color: var(--chalk); line-height: 1.5; }
.lib-comment .who { display: block; font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; color: #6f7683; margin-bottom: 2px; }
.lib-comment-empty { font-size: .82rem; color: #6f7683; margin: 0; }
.lib-comment-form { display: flex; gap: 8px; align-items: flex-start; }
.lib-comment-form textarea {
  flex: 1; min-width: 0; resize: vertical; min-height: 38px; padding: 8px 11px; background: #0A0B0E;
  border: 1px solid var(--contour); border-radius: 8px; color: var(--chalk); font: inherit; font-size: .84rem; line-height: 1.4;
}
.lib-comment-form textarea:focus { outline: none; border-color: var(--gravel); }
.lib-comment-form .btn { padding: 8px 14px; font-size: .82rem; }

/* ---------- phones ---------- */
@media (max-width: 860px) { .wall .nr-header .links { display: none; } }
@media (max-width: 720px) {
  .brand-ov p { display: none; }
  .counter b { font-size: 1.5rem; }
  .leaflet-bottom.leaflet-left { display: none; }
  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-group { display: none; }   /* pinch zooms; the attribution stays */
  .maplibregl-ctrl-bottom-left { bottom: calc(var(--bar) + 4px); left: 8px; }
  .gl-tt { display: none; }                                              /* no hover on touch; the card is the detail */
  .bar-legal { display: none; }
  .bar { gap: 8px; padding: 8px 12px 10px; flex-wrap: nowrap; }
  .search { max-width: none; height: 40px; }
  .chip { padding: 11px 14px; min-height: 40px; }                        /* >= 40 px tap targets */
  .bar select { padding: 11px 30px 11px 12px; min-height: 40px; }
  .bar .ftoggle { display: inline-flex; align-items: center; }
  .bar .filters {
    display: none; position: fixed; left: 12px; right: 12px; bottom: 64px; padding: 10px;
    background: var(--basalt); border: 1px solid var(--contour); border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .55); align-items: flex-start; flex-direction: column; gap: 8px;
    max-width: calc(100vw - 24px); box-sizing: border-box;
  }
  .bar .filters.open { display: flex; }
  .bar .filters .chips { max-width: 100%; flex: none; }
  .bar .filters #country { max-width: 100%; }
  .bar .ftoggle { order: 1; }
  .panel {
    top: auto; right: 0; left: 0; bottom: 0; width: auto; max-width: none; max-height: 72vh;
    border-radius: 14px 14px 0 0; border-bottom: 0; transform: translateY(24px);
  }
  .panel.open { transform: none; }
  .panel .x, .panel .back { width: 40px; height: 40px; }
  .rows li button { min-height: 44px; }
}
@media (max-width: 480px) {
  .wall .nr-header .row { padding: 0 12px; gap: 12px; }
  .wall .nr-header .right { gap: 6px; }
  .wall .nr-header .actions { gap: 4px; }
  .wall .nr-header .btn { padding: 8px 10px; font-size: .8rem; }
  .wall .nr-header .cta-build .p { display: none; }
  .wall .nr-header .actions .auth-up { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .wall .live, .leaflet-overlay-pane path.new { animation: none; }
  .panel, .toast, .leaflet-overlay-pane path.road { transition: none; }
}
