/* frenmaps: direction B "Floating panel" (light) + direction C "Night road" tokens as the automatic dark theme.
   Brand: the Contour mark's green family (#1B5E20 / #4CAF50 / #A5D6A7), ink #0E1116 (landing tokens).
   Green is used for fills, lines and rings, never as small text on white (2.8:1); labels on green are #06130A (8:1). */

@font-face { font-family: "Manrope"; font-weight: 200 800; font-display: swap; src: url(fonts/manrope-latin-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-weight: 200 800; font-display: swap; src: url(fonts/manrope-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans Condensed"; font-weight: 800; font-display: swap; src: url(fonts/fira-sans-condensed-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans Condensed"; font-weight: 800; font-display: swap; src: url(fonts/fira-sans-condensed-latin-ext-800-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light dark;
  --panel-w: 392px;
  --ink: #0e1116;
  --dim: #586070;
  --line: rgba(14, 17, 22, .09);
  --panel: rgba(255, 255, 255, .95);
  --panel-solid: #ffffff;
  --field-bg: #ffffff;
  --field-line: rgba(14, 17, 22, .12);
  --accent: #4caf50;
  --on-accent: #06130a;
  --accent-line: #2e9e4f;
  --ring: rgba(76, 175, 80, .3);
  --hover: rgba(76, 175, 80, .13);
  --ico-bg: rgba(14, 17, 22, .06);
  --promo-bg: rgba(14, 17, 22, .045);
  --promo-line: rgba(14, 17, 22, .08);
  --btn-bg: #ffffff;
  --ctl-bg: rgba(255, 255, 255, .94);
  --shadow: 0 0 0 1px rgba(14, 17, 22, .05), 0 2px 6px rgba(14, 17, 22, .1), 0 12px 32px rgba(14, 17, 22, .16);
  --err: #b42318;
  --focus: #1d4ed8;
  --unit-on-bg: #ffffff;
  --unit-on-ink: #0e1116;
  --grab: rgba(14, 17, 22, .22);
  --pop-ease: cubic-bezier(.2, .7, .2, 1);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f4f8;
    --dim: #9aa2b1;
    --line: #2a3040;
    --panel: rgba(14, 17, 22, .96);
    --panel-solid: #0e1116;
    --field-bg: #161a22;
    --field-line: #2a3040;
    --accent-line: #4caf50;
    --hover: #1e2330;
    --ico-bg: #1e2330;
    --promo-bg: #161a22;
    --promo-line: #2a3040;
    --btn-bg: #161a22;
    --ctl-bg: #161a22;
    --shadow: 0 0 0 1px #2a3040, 0 8px 24px rgba(0, 0, 0, .55);
    --err: #ff8a80;
    --focus: #8ab4ff;
    --unit-on-bg: #f2f4f8;
    --grab: #3a4256;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #e9ecef; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { body { background: #0e1116; } }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.ic { flex: none; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; z-index: 30; background: var(--panel-solid); color: var(--ink); padding: .5rem .75rem; }
.skip:focus { left: .5rem; top: .5rem; }

.app { position: relative; height: 100dvh; overflow: hidden; --sheet-h: 0px; }
.stage { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }

/* ---- the floating panel (desktop) ---- */
.panel {
  position: absolute; left: 16px; top: 16px; width: var(--panel-w); max-height: calc(100% - 32px); z-index: 4;
  display: flex; flex-direction: column; border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden;
}
.p-top { padding: 14px 14px 8px; }
.sheet { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.grab { display: none; }
.p-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 14px; overscroll-behavior: contain; }
.p-foot { padding: 8px 14px 12px; }
.view:not([hidden]) { animation: viewin .18s var(--pop-ease); }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- fields, combobox, results ---- */
.combo { position: relative; }
.field {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px 0 14px; border-radius: 12px;
  background: var(--field-bg); color: var(--dim); border: 1px solid var(--field-line); box-shadow: 0 1px 2px rgba(14, 17, 22, .08);
  transition: border-color .15s, box-shadow .15s;
}
.field:hover { border-color: var(--dim); }
.field:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--ring); }
.field input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 500 15.5px/1 "Manrope", system-ui, sans-serif;
}
.field input::placeholder { color: var(--dim); }
.field input::-webkit-search-cancel-button { display: none; }
.combo ul { list-style: none; margin: 6px 0 0; padding: 0; }
.combo li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; cursor: pointer; transition: background .12s; }
.combo li[aria-selected="true"], .combo li:hover { background: var(--hover); }
.combo li:active { background: var(--ico-bg); }
.rico { width: 40px; height: 40px; border-radius: 50%; background: var(--ico-bg); display: grid; place-items: center; color: var(--ink); }
.rt { display: flex; flex-direction: column; min-width: 0; }
.opt-name { font-weight: 700; font-size: 15.5px; }
.opt-detail { font-size: 13px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo li.combo-msg { display: block; padding: 10px; font-size: 14px; color: var(--dim); cursor: default; }
.combo li.combo-msg:hover { background: none; }

/* ---- buttons ---- */
.btn {
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--btn-bg); color: var(--ink);
  font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  box-shadow: 0 1px 2px rgba(14, 17, 22, .08); transition: background .12s, transform .08s, box-shadow .12s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.icobtn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--ico-bg); color: var(--ink);
  display: grid; place-items: center; padding: 0; flex: none; transition: background .12s, transform .08s;
}
.icobtn:hover { background: var(--hover); }
.icobtn:active { transform: scale(.94); }
.icobtn.sm { width: 32px; height: 32px; }
.linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--dim); text-decoration: underline; cursor: pointer; font-size: 12.5px; margin: 6px 0 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- place card ---- */
.place { padding: 6px 2px 12px; }
.place h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.015em; }
.place p { margin: 2px 0 0; color: var(--dim); font-size: 14.5px; }
.place .row { margin-top: 16px; }
.place .btn.primary { flex: 1; }

/* ---- route form: dot / dotted line / pin rail ---- */
.rfields { display: grid; grid-template-columns: 22px minmax(0, 1fr) 36px; gap: 8px; align-items: stretch; }
.rail { display: flex; flex-direction: column; align-items: center; padding: 18px 0 14px; color: var(--accent-line); }
.rail .dot { width: 10px; height: 10px; border-radius: 50%; border: 2.5px solid var(--ink); display: block; }
.rail .line { flex: 1; width: 0; border-left: 2px dotted var(--dim); margin: 4px 0; }
.rinputs { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ractions { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.rinputs .field { height: 45px; }

/* ---- directions: sticky ETA header, tools row, icon steps ---- */
.status { margin: 6px 2px; color: var(--dim); font-size: 14px; min-height: 1.2em; }
.status:empty { display: none; }
.status.err { color: var(--err); }
.skel i { display: block; height: 14px; border-radius: 7px; margin: 14px 2px; background: linear-gradient(90deg, var(--ico-bg), var(--hover), var(--ico-bg)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel i:nth-child(2) { width: 82%; } .skel i:nth-child(3) { width: 64%; } .skel i:nth-child(4) { width: 90%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.eta-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px 8px; }
.eta { margin: 0; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.eta .big { font: 800 42px/1 "Fira Sans Condensed", "Manrope", sans-serif; letter-spacing: .01em; }
.eta .sub { font-size: 16px; font-weight: 600; color: var(--dim); white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 8px; }
.units { display: inline-flex; padding: 2px; gap: 2px; border-radius: 10px; background: var(--ico-bg); }
.units button { border: 0; background: transparent; color: var(--dim); font-weight: 700; font-size: 12.5px; height: 28px; padding: 0 10px; border-radius: 8px; transition: background .12s; }
.units button[aria-checked="true"] { background: var(--unit-on-bg); color: var(--unit-on-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps button {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 10px 4px; background: none; border: 0; color: inherit; border-radius: 10px; transition: background .12s;
}
.steps button:hover { background: var(--hover); }
.steps button:active { background: var(--ico-bg); }
.sico { width: 32px; height: 32px; border-radius: 50%; background: var(--ico-bg); display: grid; place-items: center; color: var(--ink); }
.steps li:first-child .sico { background: var(--accent); color: var(--on-accent); }
.stxt { font-size: 14.5px; line-height: 1.35; }
.stxt b { font-weight: 800; }
.step-dist { font-size: 13px; font-weight: 600; color: var(--dim); white-space: nowrap; }

/* ---- the slot: AdSense block at the scroll end (150 px clear), house promo pinned (wide) or at the scroll end (phone) ---- */
.slot { padding-top: 0; }
.slot-ad[data-filled="true"]::before { content: ""; display: block; height: 9.5rem; }
.slot-ad[data-filled="false"] .slot-label { display: none; }
.slot-label { margin: 0 0 .25rem; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.promo { padding: 10px 12px 6px; border-radius: 16px; background: var(--promo-bg); border: 1px solid var(--promo-line); }
.p-body > .promo { margin: 12px 0 14px; } /* phone: flows right after the content; js/layout.js pushes it fully below the fold when it would straddle the edge */
.promo-label { margin: 0 0 2px; font-size: 12px; font-weight: 600; color: var(--dim); }
.promo ul { list-style: none; margin: 0; padding: 0; }
.promo li + li { border-top: 1px solid var(--promo-line); }
.promo a { display: flex; align-items: center; gap: 12px; padding: 7px 0; color: var(--dim); text-decoration: none; transition: color .12s; }
.promo a:hover { color: var(--ink); }
.promo img { border-radius: 8px; flex: none; }
.promo .pt { flex: 1; display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; line-height: 1.3; }
.promo strong { font-size: 14px; font-weight: 700; color: var(--ink); letter-spacing: .01em; }

/* ---- the map overlay: control stack (right), notice, logo ---- */
.stack { position: absolute; right: 16px; top: 16px; z-index: 3; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.popwrap { position: relative; }
.ctl {
  width: 44px; height: 44px; border: 0; padding: 0; display: grid; place-items: center; background: var(--ctl-bg); color: var(--ink);
  border-radius: 12px; box-shadow: var(--shadow); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  transition: background .12s, transform .08s;
}
.ctl:hover { background: var(--panel-solid); }
.ctl:active { transform: scale(.96); }
.ctl-3d { font: 800 13px/1 "Manrope", sans-serif; letter-spacing: .02em; }
.ctl-3d[aria-pressed="true"], .ctl-3d[aria-pressed="true"]:hover { background: var(--accent); color: var(--on-accent); }
.ctl[aria-expanded="true"] { background: var(--hover); }
.ctl-group { display: flex; flex-direction: column; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.ctl-group .ctl { box-shadow: none; border-radius: 0; }
.ctl-group .ctl + .ctl { border-top: 1px solid var(--line); }
.pop {
  position: absolute; right: 54px; top: 0; display: flex; gap: 6px; padding: 10px; border-radius: 18px; background: var(--panel-solid); box-shadow: var(--shadow);
}
.pop:not([hidden]) { animation: popin .16s var(--pop-ease); transform-origin: top right; }
@keyframes popin { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.pop button { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; font-weight: 600; font-size: 12px; color: var(--dim); }
.pop img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; border: 2px solid transparent; outline: 2px solid transparent; transition: outline-color .12s; }
.pop button:hover img { outline-color: var(--line); }
.pop [aria-checked="true"] img { border-color: var(--panel-solid); outline: 2px solid var(--accent-line); }
.pop [aria-checked="true"] { color: var(--ink); }

.notice {
  position: absolute; top: 16px; left: calc(var(--panel-w) + 32px); z-index: 3; margin: 0; max-width: 18rem;
  background: rgba(14, 17, 22, .86); color: #fff; padding: .45rem .7rem; border-radius: 10px; font-size: 13px;
}

/* The logo: the FREN Safety Contour mark + the FRENmaps wordmark, bottom-LEFT of the map where Google puts its own (right of the panel). */
.logo {
  position: absolute; left: var(--corner-left, calc(var(--panel-w) + 32px)); bottom: 10px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 5px; border-radius: 9px; background: var(--ctl-bg); color: var(--ink); text-decoration: none; opacity: .94;
  box-shadow: 0 0 0 1px rgba(14, 17, 22, .06), 0 1px 4px rgba(14, 17, 22, .12); transition: opacity .12s, left .2s var(--pop-ease);
}
.logo:hover { opacity: 1; background: var(--panel-solid); }
.logo img { display: block; width: 22px; height: 22px; }
.wm { display: inline-flex; align-items: baseline; gap: 1px; }
.wm .fren { font: 800 14px/1 "Fira Sans Condensed", sans-serif; letter-spacing: .06em; }
.wm .maps { font: 600 13px/1 "Manrope", sans-serif; color: var(--dim); letter-spacing: -.01em; margin-left: 1px; }
.maplibregl-ctrl-bottom-left { left: var(--corner-left, calc(var(--panel-w) + 32px)); bottom: 42px; transition: left .2s var(--pop-ease); }
.maplibregl-ctrl-scale { background: var(--ctl-bg); color: var(--ink); border-color: var(--dim); }

/* The credit strip: one very tiny line, bottom-right, white on 60 % black (R-125-45). */
.credits { position: absolute; right: 0; bottom: 0; z-index: 3; max-width: 100%; display: flex; justify-content: flex-end; }
.credit-strip {
  display: flex; align-items: center; gap: .2rem; max-width: 100%;
  font: 400 9px/1.1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #fff; background: rgba(0, 0, 0, .6); padding: 1.5px 4px; border: 0; cursor: pointer; text-align: left;
  direction: ltr;
}
.credit-strip img { height: 12px; width: auto; }
.credit-strip .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.credit-strip .own { white-space: nowrap; flex: none; }
.credits { bottom: var(--sheet-h); }

/* ---- map pins (DOM markers): start = ink ring, destination / place = action-green pin ---- */
.mk-from { width: 18px; height: 18px; border-radius: 50%; background: var(--panel-solid); border: 4px solid var(--ink); box-shadow: var(--shadow); }
.mk-pin { width: 28px; height: 34px; color: var(--accent-line); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
.mk-pin svg { display: block; }
.mk-pin .core { fill: #ffffff; }

/* ---- credit dialog ---- */
.sheet-dialog { border: 0; border-radius: 16px; padding: 1.1rem 1.2rem; max-width: min(34rem, 92vw); background: var(--panel-solid); color: var(--ink); box-shadow: 0 16px 48px rgba(0, 0, 0, .35); }
.sheet-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-dialog h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.sheet-dialog .cr { margin: 0 0 .8rem; direction: ltr; }
.sheet-dialog .cr img { height: 28px; width: auto; display: block; margin-bottom: .25rem; }
.sheet-dialog .cr p { margin: 0; }
.sheet-dialog a { color: var(--focus); }

/* ---- phone: full-bleed map, floating search pill, bottom sheet with three detents ---- */
@media (max-width: 720px) {
  .panel { inset: 0; width: auto; max-height: none; background: none; box-shadow: none; border-radius: 0; overflow: visible; pointer-events: none; }
  .p-top { position: absolute; left: 10px; right: 10px; top: 10px; padding: 6px; border-radius: 18px; background: var(--panel-solid); box-shadow: var(--shadow); pointer-events: auto; }
  .sheet {
    position: absolute; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); border-radius: 24px; background: var(--panel-solid); box-shadow: var(--shadow);
    pointer-events: auto; overflow: hidden; transition: height .22s var(--pop-ease);
  }
  .sheet.dragging { transition: none; }
  .app[data-view="search"] .sheet { display: none; }
  .grab { display: block; padding: 10px 0 8px; cursor: grab; touch-action: none; flex: none; }
  .grab span { display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--grab); margin: 0 auto; }
  .p-body { padding: 0 14px; }
  .p-foot { padding: 0 14px; }
  .stack { right: 10px; top: 84px; }
  .app[data-view="route"] .stack { top: 188px; }
  .pop { right: 54px; }
  .notice { left: 10px; top: auto; bottom: calc(var(--sheet-h) + 48px); }
  .logo { left: 10px; bottom: calc(var(--sheet-h) + 10px); }
  .maplibregl-ctrl-bottom-left { left: 0; bottom: calc(var(--sheet-h) + 44px); }
  .rfields { grid-template-columns: 22px minmax(0, 1fr) 36px; }
  .eta .big { font-size: 34px; }
}

/* ---- print: only the directions sheet (title, summary, route map, credits, numbered steps) ---- */
#print-sheet { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .app, .skip, dialog { display: none !important; }
  #print-sheet { display: block; color: #000; }
  #print-sheet h1 { font-size: 16pt; margin: 0 0 .3rem; }
  #print-sheet .print-summary { font-size: 12pt; font-weight: 700; margin: 0 0 .6rem; }
  #print-sheet img { width: 100%; max-height: 110mm; object-fit: contain; border: 1px solid #999; }
  #print-sheet .print-credits { font-size: 7.5pt; margin: .2rem 0 .8rem; color: #333; }
  #print-sheet ol { padding-left: 1.6rem; margin: 0; }
  #print-sheet li { padding: .25rem 0; border-bottom: 1px solid #ddd; break-inside: avoid; }
  #print-sheet li .print-dist { float: right; margin-left: 1rem; color: #333; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
