/* BGnow portal: header, menu drawer, home page and the section-page frame.
   Light/dark follows the device, like the map page. Mobile first. */
:root {
  --pt-bg: #f2f5f9;
  --pt-card: #ffffff;
  --pt-text: #1c2733;
  --pt-muted: #64748b;
  --pt-border: #dbe3ee;
  --pt-accent: #1a5fb4;
  --pt-accent-text: #ffffff;
  --pt-pill: #e8eef7;
  --pt-shadow: 0 1px 3px rgba(20, 40, 70, .10), 0 4px 14px rgba(20, 40, 70, .06);
  --pt-header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pt-bg: #15181c;
    --pt-card: #1f2329;
    --pt-text: #eceff3;
    --pt-muted: #9aa5b4;
    --pt-border: #323841;
    --pt-accent: #5aa9dc;
    --pt-accent-text: #0e1a26;
    --pt-pill: #2a313a;
    --pt-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

body.pt-mode { background: var(--pt-bg); color: var(--pt-text); }
.pt-mode a { color: inherit; text-decoration: none; }
.pt-mode button { font: inherit; color: inherit; }

/* ---------- header ---------- */
.pt-header {
  position: sticky; top: 0; z-index: 1300;
  background: var(--pt-card); border-bottom: 1px solid var(--pt-border);
  box-shadow: var(--pt-shadow);
}
.pt-header-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 8px 14px;
}
.pt-brand { font-weight: 800; font-size: 21px; letter-spacing: -.5px; display: inline-flex; align-items: center; }
.pt-brand span { color: var(--pt-accent); }
.pt-brand .pt-logo { width: 30px; height: 30px; border-radius: 7px; flex: none; margin-right: 8px; }
.pt-brand .pt-wordmark { height: 30px; width: auto; display: block; }
.pt-brand picture { display: block; line-height: 0; }
.pt-pills {
  display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pt-pills::-webkit-scrollbar { display: none; }
.pt-pill {
  flex: none; padding: 7px 12px; border-radius: 999px; background: var(--pt-pill);
  font-size: 14px; white-space: nowrap; border: 1px solid transparent;
}
.pt-pill:hover { border-color: var(--pt-accent); }
.pt-pill.active { background: var(--pt-accent); color: var(--pt-accent-text); font-weight: 700; }
.pt-header-actions { display: flex; gap: 6px; margin-left: auto; }
.pt-menubtn, .pt-iconbtn {
  border: 1px solid var(--pt-border); background: var(--pt-pill); border-radius: 10px;
  padding: 8px 12px; cursor: pointer; font-size: 15px; min-height: 40px;
}
.pt-menubtn:hover, .pt-iconbtn:hover { border-color: var(--pt-accent); }

/* phone: brand + menu on the first row, popular pills scroll on their own row */
@media (max-width: 760px) {
  .pt-header-row { padding: 6px 10px; gap: 6px 8px; }
  .pt-brand { order: 1; font-size: 19px; }
  .pt-header-actions { order: 2; margin-left: auto; }
  .pt-pills { order: 3; width: 100%; flex: none; padding-bottom: 2px; }
  .pt-pill { padding: 9px 13px; font-size: 14px; min-height: 40px; display: inline-flex; align-items: center; }
  .pt-menubtn span { display: none; }
  .pt-menubtn { min-width: 44px; min-height: 44px; font-size: 18px; }
}

/* ---------- drawer ---------- */
.pt-drawer[hidden] { display: none; }
.pt-drawer { position: fixed; inset: 0; z-index: 2000; }
.pt-drawer-backdrop { position: absolute; inset: 0; background: rgba(8, 14, 24, .55); }
.pt-drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: var(--pt-card); color: var(--pt-text); overflow-y: auto;
  padding: 14px 14px 30px; box-shadow: -8px 0 30px rgba(0, 0, 0, .35);
  -webkit-overflow-scrolling: touch;
}
.pt-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 16px; }
.pt-search {
  width: 100%; box-sizing: border-box; padding: 12px 14px; font-size: 16px; /* 16px stops iOS zoom */
  border: 1px solid var(--pt-border); border-radius: 12px; background: var(--pt-bg); color: var(--pt-text);
}
.pt-results { margin-top: 8px; }
.pt-groups { margin-top: 10px; }
.pt-group { border-top: 1px solid var(--pt-border); padding: 4px 0; }
.pt-group summary { cursor: pointer; padding: 12px 4px; font-weight: 700; list-style: none; }
.pt-group summary::-webkit-details-marker { display: none; }
.pt-group summary::after { content: "▾"; float: right; color: var(--pt-muted); }
.pt-group[open] summary::after { content: "▴"; }
.pt-drawer-link { display: block; padding: 12px 10px; border-radius: 10px; font-size: 15px; }
.pt-drawer-link:hover { background: var(--pt-pill); }
.pt-drawer-link.active { background: var(--pt-accent); color: var(--pt-accent-text); font-weight: 700; }
.pt-fullmap { margin-top: 12px; border-top: 1px solid var(--pt-border); padding-top: 14px; color: var(--pt-muted); }
.pt-empty { color: var(--pt-muted); padding: 10px 4px; }

/* ---------- home ---------- */
.pt-container { max-width: 1280px; margin: 0 auto; padding: 18px 14px 40px; }
.pt-hero h1 { font-size: clamp(24px, 4.5vw, 36px); line-height: 1.15; margin: 8px 0 6px; font-weight: 800; letter-spacing: -.5px; }
.pt-hero p { color: var(--pt-muted); margin: 0 0 16px; font-size: 16px; max-width: 60ch; }
.pt-h2 { font-size: 18px; font-weight: 800; margin: 26px 0 10px; }
.pt-now { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pt-now:empty { display: none; }
.pt-now-item { background: var(--pt-card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--pt-shadow); display: block; }
.pt-now-item small { color: var(--pt-muted); display: block; font-size: 12px; }
.pt-now-item b { font-size: 22px; font-weight: 800; }
.pt-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pt-grid-lg { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 560px) { .pt-grid, .pt-grid-lg { grid-template-columns: 1fr; } }
.pt-card {
  display: block; background: var(--pt-card); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--pt-shadow); border: 1px solid transparent; transition: transform .12s, border-color .12s;
}
.pt-card:hover { border-color: var(--pt-accent); transform: translateY(-1px); }
.pt-card-head { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; }
.pt-card-icon { font-size: 26px; line-height: 1; }
.pt-card p { margin: 6px 0 0; color: var(--pt-muted); font-size: 13px; line-height: 1.4; }
.pt-stat { margin-top: 8px; font-weight: 700; font-size: 14px; color: var(--pt-accent); min-height: 0; }
.pt-stat:empty { display: none; }
.pt-card-lg { padding: 18px; }
.pt-card-lg .pt-card-head { font-size: 18px; }
.pt-note { color: var(--pt-muted); font-size: 12px; margin-top: 30px; }

/* ---------- section page frame (the map page inside the portal) ---------- */
.pt-sectionbar {
  position: sticky; top: var(--pt-header-h); z-index: 1250;
  background: var(--pt-card); border-bottom: 1px solid var(--pt-border);
}
.pt-sectionbar-row {
  max-width: 1280px; margin: 0 auto; padding: 8px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
}
.pt-sectiontitle { font-weight: 800; font-size: 17px; }
.pt-sectiondesc { color: var(--pt-muted); font-size: 13px; flex: 1 1 260px; min-width: 0; }
.pt-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pt-chip {
  border: 1px solid var(--pt-border); background: var(--pt-pill); border-radius: 999px;
  padding: 7px 13px; cursor: pointer; font-size: 14px; min-height: 40px;
}
.pt-chip.active { background: var(--pt-accent); color: var(--pt-accent-text); border-color: var(--pt-accent); font-weight: 700; }
.pt-fullmaplink { font-size: 13px; color: var(--pt-muted); margin-left: auto; white-space: nowrap; }
@media (max-width: 760px) {
  .pt-sectionbar { position: static; }
  .pt-sectiondesc { display: none; }
}

/* the map page inside a section: the old topbar keeps only the freshness note, filters and locate button */
body.pt-mode #rc-app { height: calc(100vh - var(--pt-top-offset, 0px)); height: calc(100dvh - var(--pt-top-offset, 0px)); min-height: 320px; }
body.pt-mode #rc-menu-toggle { display: none !important; }
body.pt-mode #rc-controls { display: flex !important; }
body.pt-mode #rc-layers { display: contents; }
body.pt-mode #rc-layers button[data-layer] { display: none; }
@media (max-width: 760px) {
  /* on a phone the page scrolls, the map has a fixed comfortable height */
  body.pt-mode #rc-app { height: 68vh; height: 68dvh; }
}

/* ---------- trip planner panel ---------- */
.tp { position: fixed; left: 12px; top: calc(var(--pt-top-offset, 0px) + 12px); width: 380px; max-height: calc(100vh - var(--pt-top-offset, 0px) - 30px);
      z-index: 1100; background: var(--pt-card); color: var(--pt-text); border-radius: 14px; box-shadow: 0 4px 22px rgba(0,0,0,.3);
      display: flex; flex-direction: column; overflow: hidden; font: 14px/1.35 system-ui, sans-serif; }
.tp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; font-size: 15px; }
.tp-min { border: 0; background: var(--pt-pill); color: inherit; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; font-size: 16px; }
.tp-body { padding: 4px 12px 12px; overflow: auto; position: relative; }
.tp.tp-minimized .tp-body { display: none; }
.tp-field { display: flex; align-items: center; gap: 6px; }
.tp-dot { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tp-dot.from { background: #2e7d32; } .tp-dot.to { background: #c62828; }
.tp-in { flex: 1; min-width: 0; box-sizing: border-box; padding: 10px 11px; border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-bg); color: var(--pt-text); font-size: 16px; }
.tp-ico { border: 1px solid var(--pt-border); background: var(--pt-pill); color: inherit; border-radius: 10px; width: 40px; height: 40px; cursor: pointer; font-size: 17px; flex: none; }
.tp-ico.active { background: var(--pt-accent); color: var(--pt-accent-text); }
.tp-swaprow { display: flex; padding-left: 4px; }
.tp-swap { border: 0; background: none; color: var(--pt-muted); cursor: pointer; font-size: 18px; padding: 0 6px; }
.tp-suggest { position: absolute; left: 12px; right: 12px; z-index: 6; background: var(--pt-card); border: 1px solid var(--pt-border); border-radius: 10px; box-shadow: 0 8px 22px rgba(0,0,0,.3); max-height: 260px; overflow: auto; }
.tp-suggest[hidden] { display: none; }
.tp-suggest button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; }
.tp-suggest button:hover { background: var(--pt-pill); }
.tp-when { display: flex; gap: 6px; margin: 8px 0; }
.tp-when select, .tp-when input { padding: 9px 10px; border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-bg); color: var(--pt-text); font-size: 14px; }
.tp-go { width: 100%; padding: 12px; border: 0; border-radius: 12px; background: var(--pt-accent); color: var(--pt-accent-text); font-weight: 800; font-size: 15px; cursor: pointer; }
.tp-hint, .tp-note { color: var(--pt-muted); font-size: 12px; margin-top: 6px; padding: 4px 2px; }
.tp-results { margin-top: 8px; }
.tp-card { border: 2px solid var(--pt-border); border-radius: 12px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; background: var(--pt-card); }
.tp-card.sel { border-color: var(--pt-accent); }
.tp-card-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.tp-card-top b { font-size: 17px; }
.tp-tag { font-style: normal; font-size: 11px; background: var(--pt-pill); padding: 1px 8px; border-radius: 999px; }
.tp-tag.live { background: #e6f4ea; color: #1b5e20; }
.tp-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.tp-chip { display: inline-block; min-width: 30px; text-align: center; padding: 2px 8px; border-radius: 10px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.tp-arrow { color: var(--pt-muted); }
.tp-meta { color: var(--pt-muted); font-size: 12px; }
.tp-steps { margin-top: 8px; border-top: 1px solid var(--pt-border); padding-top: 6px; }
.tp-steps[hidden] { display: none; }
.tp-step { display: flex; gap: 8px; padding: 5px 0; font-size: 13px; }
.tp-sico { flex: none; min-width: 34px; }
.tp-late { color: #1b5e20; font-size: 11px; } .tp-late.bad { color: #b71c1c; }
.tp-pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); color: #fff; font-weight: 800; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
.tp-pin span { transform: rotate(45deg); }
@media (max-width: 760px) {
  .tp { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 62vh; }
  .tp-in { font-size: 16px; }
}
.pt-city small { opacity: .75; font-weight: 400; margin-left: 2px; }
.tp-travel { display: flex; gap: 6px; margin: 8px 0 0; }
.tp-tv { flex: 1; padding: 8px 6px; border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-bg); color: var(--pt-text); font-size: 13px; cursor: pointer; }
.tp-tv.active { background: var(--pt-accent); color: var(--pt-accent-text); border-color: var(--pt-accent); font-weight: 700; }

/* ---------- home: planner call-to-action, freshness, favourites ---------- */
.pt-cta {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 52px;
  background: var(--pt-accent); color: var(--pt-accent-text) !important; border-radius: 14px;
  padding: 12px 20px; font-weight: 800; font-size: 18px; box-shadow: var(--pt-shadow);
}
.pt-cta span { font-weight: 400; font-size: 14px; opacity: .85; }
.pt-h2-note { font-weight: 400; color: var(--pt-muted); font-size: 12px; }
.pt-now-item em { display: block; font-style: normal; color: var(--pt-muted); font-size: 11px; margin-top: 2px; }
.pt-ago { color: var(--pt-muted); font-weight: 400; font-size: 11px; }
.pt-cardbox { position: relative; }
.pt-cardbox .pt-card { height: 100%; box-sizing: border-box; padding-right: 44px; }
.pt-fav {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: var(--pt-muted); font-size: 20px; cursor: pointer;
}
.pt-fav:hover, .pt-fav.on { color: #e0a800; background: var(--pt-pill); }
.pt-soon { color: var(--pt-muted); font-size: 13px; margin-top: 22px; }

/* side panels (Sofia delays/stops, city delays) must start below the portal header, not under it */
body.pt-mode .sp { top: calc(var(--pt-top-offset, 0px) + 12px); max-height: calc(100vh - var(--pt-top-offset, 0px) - 30px); }
@media (max-width: 760px) {
  body.pt-mode .sp { top: auto; max-height: 52vh; }
}
