/* Kar — live transport map. Builds on /shared/tokens.css and /shared/base.css.
   --accent comes from the network's theme (Siliana: wheat gold). */

:root { --accent: var(--kairouan); --accent-ink: #4A3410; --panel-w: 400px; }
html, body { height: 100%; }
body.map-page { overflow: hidden; }

/* ---------- Map ---------- */
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-top-right, .maplibregl-ctrl-top-left { top: 56px; }
.maplibregl-ctrl-group { border-radius: var(--r-sm) !important; box-shadow: var(--shadow-sm) !important; }
.map-top { position: fixed; z-index: 5; top: 12px; inset-inline-end: 12px; display: flex; gap: 8px; align-items: center; }
.map-top .lang { background: var(--bg); box-shadow: var(--shadow-sm); }
.fab { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg); display: grid; place-items: center; }
.fab .ico { width: 22px; height: 22px; }
.fab.on { background: var(--accent); color: var(--accent-ink); }
.map-tools { position: fixed; z-index: 5; inset-inline-end: 12px; bottom: calc(var(--sheet-peek, 34vh) + 16px); display: grid; gap: 8px; transition: bottom .25s; }
@media (min-width: 900px) { .map-tools { bottom: 32px; } }

/* ---------- Panel: left column on desktop, bottom sheet on phones ---------- */
.panel {
  position: fixed; z-index: 6; background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 900px) {
  .panel { top: 12px; bottom: 12px; inset-inline-start: 12px; width: var(--panel-w); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
  .sheet-handle { display: none; }
}
@media (max-width: 899px) {
  .panel { left: 0; right: 0; bottom: 0; height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 30px rgba(29, 36, 51, .18);
    transform: translateY(calc(92vh - var(--sheet-h, 34vh))); transition: transform .28s cubic-bezier(.25,.8,.25,1); touch-action: none; }
  .panel.dragging { transition: none; }
}
.sheet-handle { padding: 10px 0 4px; display: grid; place-items: center; cursor: grab; flex-shrink: 0; border: 0; background: none; width: 100%; }
.sheet-handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
.panel-head { padding: 12px 16px 10px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 24px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-row .logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex-shrink: 0; }
.brand-row .logo svg { width: 26px; height: 26px; }
.brand-row b { display: block; font-size: var(--fs-lg); line-height: 1.15; }
.brand-row small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.brand-row .grow { flex: 1; min-width: 0; }
.search-pill { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: var(--fs-md); text-align: start; }
.search-pill .ico { color: var(--text); }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: var(--r-sm); }
.tabs button { flex: 1; min-height: 38px; border: 0; background: none; border-radius: 9px; font-weight: 500; font-size: var(--fs-sm); color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.view-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.view-head h2 { flex: 1; font-size: var(--fs-lg); font-weight: 600; line-height: 1.25; min-width: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; flex-shrink: 0; }
.icon-btn .ico { width: 20px; height: 20px; }
:root[dir="rtl"] .flip { transform: scaleX(-1); }
.sec { padding: 14px 16px 4px; display: grid; gap: 10px; }
.sec h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }

/* ---------- Line badges and rows ---------- */
.badge { --c: var(--door); display: inline-grid; place-items: center; min-width: 40px; height: 30px; padding: 0 8px; border-radius: 9px; background: var(--c); color: #fff; font-weight: 700; font-size: var(--fs-sm); flex-shrink: 0; letter-spacing: .01em; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.badge.lg { min-width: 54px; height: 40px; font-size: var(--fs-lg); border-radius: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; width: 100%; border: 0; background: none; text-align: start; color: inherit; }
button.row:hover { background: var(--surface); }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 500; line-height: 1.3; }
.row .grow small { display: block; color: var(--muted); font-size: var(--fs-xs); line-height: 1.35; }
.row .end { text-align: end; font-size: var(--fs-sm); flex-shrink: 0; }
.row .end small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.row + .row { border-top: 1px solid var(--line); }
.group-title { padding: 14px 16px 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--nabeul); margin-inline-end: 4px; box-shadow: 0 0 0 0 color-mix(in srgb, var(--nabeul) 60%, transparent); animation: live 2s infinite; vertical-align: 1px; }
.sched-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 2px dashed var(--muted); margin-inline-end: 4px; vertical-align: 0; }
@keyframes live { 70% { box-shadow: 0 0 0 7px transparent; } }
.delay { font-weight: 600; font-size: var(--fs-xs); }
.delay.late { color: var(--brand); }
.delay.ok { color: var(--nabeul); }

/* ---------- Line detail ---------- */
.line-hero { padding: 16px; display: grid; gap: 12px; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, var(--bg)), var(--bg)); }
.line-hero .ends { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; }
.stats b { display: block; font-size: var(--fs-lg); line-height: 1.2; }
.stats span { color: var(--muted); font-size: var(--fs-xs); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface); border-radius: var(--r-sm); }
.seg button { border: 0; background: none; border-radius: 9px; min-height: 40px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); padding: 0 6px; }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.next-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-md); background: var(--surface); }
.next-card .big { font-size: var(--fs-2xl); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; direction: ltr; }
.timeline { list-style: none; margin: 0; padding: 0 16px; }
.timeline li { position: relative; display: flex; gap: 12px; align-items: center; padding: 8px 0 8px 0; min-height: 44px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 10px; top: 0; bottom: 0; width: 4px; background: var(--c); opacity: .9; }
.timeline li:first-child::before { top: 50%; }
.timeline li:last-child::before { bottom: 50%; }
.timeline .dot { position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); border: 4px solid var(--c); flex-shrink: 0; }
.timeline .station .dot { width: 24px; height: 24px; background: var(--c); box-shadow: inset 0 0 0 4px var(--bg); }
.timeline .grow { flex: 1; min-width: 0; }
.timeline .grow b { font-weight: 500; }
.timeline .t { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); text-align: end; direction: ltr; }
.timeline .t s { color: var(--muted); font-size: var(--fs-xs); margin-inline-end: 4px; }
.timeline .bus-here { position: absolute; z-index: 2; inset-inline-start: -2px; width: 28px; height: 28px; border-radius: 9px; background: var(--c); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.25); transform: translateY(-50%); }
.timeline .bus-here .ico { width: 18px; height: 18px; }
.timeline .bus-here.ghost { opacity: .55; }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; padding: 0 16px; }
.times span { text-align: center; padding: 6px 0; border-radius: 8px; background: var(--surface); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); direction: ltr; }
.times span.past { opacity: .4; }
.times span.nextt { background: var(--c); color: #fff; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px; }
.chips button { border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-pill); padding: 6px 12px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.actions { display: flex; gap: 8px; padding: 12px 16px; flex-wrap: wrap; }
.note { margin: 8px 16px; padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--accent) 16%, var(--bg)); font-size: var(--fs-xs); color: var(--text); display: flex; gap: 8px; }
.note a { color: inherit; }

/* ---------- Planner ---------- */
.plan-form { display: grid; gap: 10px; padding: 14px 16px; }
.plan-form .pair { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.plan-form .swap { width: 44px; height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; }
.journey { margin: 8px 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); display: grid; gap: 10px; width: calc(100% - 32px); background: var(--bg); text-align: start; }
.journey:hover { border-color: var(--text); }
.journey .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.journey .top b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; direction: ltr; }
.journey .legs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Alerts ---------- */
.alert { margin: 10px 16px 0; padding: 12px 14px; border-radius: var(--r-sm); display: flex; gap: 10px; font-size: var(--fs-sm); background: color-mix(in srgb, var(--djerba) 14%, var(--bg)); }
.alert.warning { background: color-mix(in srgb, var(--kairouan) 20%, var(--bg)); }
.alert.disruption { background: color-mix(in srgb, var(--brand) 14%, var(--bg)); }
.alert b { display: block; }

/* ---------- Landmark card ---------- */
.story { padding: 18px 16px; display: grid; gap: 10px; }
.story .art { height: 140px; border-radius: var(--r-md); background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 35%, var(--bg)), var(--surface)); display: grid; place-items: center; font-size: 64px; }
.story p { color: var(--muted); line-height: 1.6; }

/* ---------- Network chooser, drive and admin pages ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 24px 16px 80px; display: grid; gap: 18px; }
.page h1 { font-size: var(--fs-2xl); font-weight: 600; }
.net-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.net-card { display: grid; gap: 8px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: inherit; background: var(--bg); position: relative; overflow: hidden; }
.net-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: var(--c); }
.net-card:hover { border-color: var(--text); }
.net-card h2 { font-size: var(--fs-xl); font-weight: 600; }
.drive-big { display: grid; gap: 14px; padding: 20px; border-radius: var(--r-lg); background: var(--surface); }
.drive-big .code { font-size: 3rem; font-weight: 700; line-height: 1; }
.drive-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drive-stat div { background: var(--bg); border-radius: var(--r-sm); padding: 10px; }
.drive-stat b { display: block; font-size: var(--fs-xl); }
.drive-stat span { font-size: var(--fs-xs); color: var(--muted); }
.trip-list { display: grid; gap: 8px; }
.trip-list button { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--bg); text-align: start; width: 100%; }
.trip-list button[aria-pressed="true"] { border-color: var(--door); background: var(--sidi-wash); }
.trip-list .time { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; min-width: 70px; }
.card table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.card th { text-align: start; color: var(--muted); font-weight: 500; padding: 6px; border-bottom: 1px solid var(--line); }
.card td { padding: 6px; border-bottom: 1px solid var(--line); }
.card td .input { min-height: 38px; padding: 6px 10px; }
