/* Pune Grand Tour 2027 – bold race-event theme, phone first */
:root {
  --ink: #140a2b;          /* near-black purple: header, headings, route casing */
  --purple: #4b1b93;
  --purple-hi: #6a2fc4;
  --orange: #f26a21;       /* the one loud accent: selected stage, primary actions */
  --orange-dark: #d4540f;
  --paper: #f4f1ea;        /* warm page background */
  --card: #ffffff;
  --line: #e2ddd2;
  --muted: #6b6478;
  --closed: #d92d20;
  --soon: #f59e0b;
  --open: #1597d8;         /* route blue from the official maps */
  --done: #2e9e5b;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 500 15px/1.45 var(--body); color: var(--ink); background: var(--paper);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- header ---------- */
.top { flex: none; color: #fff; background: var(--ink); position: relative; z-index: 600; }
.top::before { /* diagonal slash from the tour artwork */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(112deg, transparent 0 62%, rgba(106,47,196,.55) 62% 78%, rgba(242,106,33,.9) 78% 81%, transparent 81%);
}
.brand { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 16px 4px; padding-top: max(10px, env(safe-area-inset-top)); }
.logo {
  font: 800 20px/1 var(--display); letter-spacing: .02em; background: var(--orange); color: #fff;
  padding: 7px 8px 6px; transform: skewX(-8deg); display: inline-flex; gap: 3px;
}
.logo i { font-style: normal; color: var(--ink); }
.brand h1 { font: 800 24px/1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.brand p { font-size: 12px; font-weight: 500; opacity: .78; margin-top: 2px; }

.stages { position: relative; display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 12px; scrollbar-width: none; scroll-snap-type: x proximity; }
.stages::-webkit-scrollbar { display: none; }
.stage-chip {
  flex: none; scroll-snap-align: center; display: flex; align-items: center; gap: 9px; min-height: 48px;
  border: 0; background: rgba(255,255,255,.1); color: #fff; padding: 5px 12px 5px 9px; cursor: pointer; text-align: left;
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
}
.stage-chip .num { font: 800 30px/1 var(--display); opacity: .55; font-variant-numeric: tabular-nums; }
.stage-chip .txt { display: flex; flex-direction: column; line-height: 1.15; }
.stage-chip .txt b { font: 700 13px/1.1 var(--display); text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.stage-chip .txt span { font-size: 13px; font-weight: 600; white-space: nowrap; }
.stage-chip:hover { background: rgba(255,255,255,.18); }
.stage-chip[aria-pressed="true"] { background: var(--orange); }
.stage-chip[aria-pressed="true"] .num { opacity: 1; color: var(--ink); }
.stage-chip[aria-pressed="true"] .txt b { opacity: 1; }
.flagstrip { position: relative; height: 8px; background: repeating-conic-gradient(#fff 0 25%, var(--ink) 0 50%) 0 0 / 8px 8px; }

/* ---------- layout: map on top, pull-up sheet below ---------- */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mapwrap { position: relative; flex: 0 0 44%; min-height: 200px; }
#map { position: absolute; inset: 0; background: #e6ebe4; }
.panel {
  flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; z-index: 500;
  background: var(--paper); margin-top: -14px; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 18px rgba(20,10,43,.22);
}
.sheetbody { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheetbody > * { flex: none; }
.handle { flex: none; border: 0; background: none; padding: 8px 16px 8px; cursor: pointer; width: 100%; text-align: left; }
.grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: #cfc8bb; margin: 0 auto 8px; }
.handlerow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.handlerow b { font: 700 17px/1.1 var(--display); text-transform: uppercase; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handlerow em { font: 700 13px/1 var(--display); font-style: normal; text-transform: uppercase; letter-spacing: .08em; color: var(--orange-dark); white-space: nowrap; }
/* sheet pulled down: the map takes the screen, only the handle stays */
body.sheet-down .mapwrap { flex: 1; }
body.sheet-down .panel { flex: none; }
body.sheet-down .sheetbody { display: none; }
body.sheet-down .handle { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  main { flex-direction: row-reverse; }
  .mapwrap, body.sheet-down .mapwrap { flex: 1; }
  .panel, body.sheet-down .panel { flex: 0 0 430px; margin-top: 0; border-radius: 0; box-shadow: 4px 0 18px rgba(20,10,43,.14); }
  .handle { display: none; }
  .sheetbody, body.sheet-down .sheetbody { display: flex; padding: 16px 16px 28px; }
  .brand { padding: 14px 20px 4px; }
  .stages { padding: 8px 20px 14px; }
  .brand h1 { font-size: 30px; }
}

/* ---------- map chrome ---------- */
.fab {
  position: absolute; right: 12px; bottom: 30px; z-index: 450; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; box-shadow: 0 3px 10px rgba(20,10,43,.4); cursor: pointer; display: grid; place-items: center;
}
.fab.on { background: var(--orange); }
.legend {
  position: absolute; left: 10px; bottom: 26px; z-index: 450; background: var(--ink); color: #fff;
  padding: 5px 10px; font: 700 12px/1.2 var(--display); letter-spacing: .06em; text-transform: uppercase; display: flex; gap: 12px;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 5px; border-radius: 3px; display: inline-block; }
.sw.closed { background: var(--closed); } .sw.soon { background: var(--soon); } .sw.open { background: var(--open); }
@media (min-width: 900px) { .fab { bottom: 20px; } .legend { bottom: 20px; } }
.leaflet-bottom.leaflet-left { margin-bottom: 44px; }
.leaflet-control-attribution { font-size: 10px; }
@media (max-width: 899px) { .leaflet-bottom.leaflet-right { margin-bottom: 14px; } .leaflet-bottom.leaflet-left { margin-bottom: 52px; } }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 16px 14px; position: relative; }
.card h2 { font: 800 24px/1.05 var(--display); text-transform: uppercase; letter-spacing: .01em; margin-bottom: 4px; }
.eyebrow { display: block; font: 700 12px/1.2 var(--display); text-transform: uppercase; letter-spacing: .14em; color: var(--orange-dark); margin-bottom: 2px; }
.hint { color: var(--muted); font-size: 13.500px; margin-bottom: 10px; }
.notice { border-left: 4px solid var(--soon); background: #fff7e6; color: #5c4200; padding: 10px 12px; font-size: 13px; }
.foot { color: var(--muted); font-size: 12px; padding: 0 2px; }
.foot a { color: var(--purple); font-weight: 600; }

/* stage hero */
.hero { background: var(--ink); color: #fff; border: 0; overflow: hidden; padding: 16px 14px 14px; }
.hero::after { content: ""; position: absolute; right: -30px; top: 0; height: 92px; width: 120px; background: linear-gradient(112deg, transparent 0 40%, rgba(106,47,196,.6) 40% 72%, var(--orange) 72% 78%, transparent 78%); pointer-events: none; }
.herohead { display: flex; align-items: flex-end; gap: 12px; position: relative; z-index: 1; }
.heronum { font: 800 76px/.78 var(--display); color: var(--orange); font-variant-numeric: tabular-nums; }
.herotitle .date { font: 700 13px/1.2 var(--display); text-transform: uppercase; letter-spacing: .12em; opacity: .75; display: block; }
.herotitle h2 { font-size: 28px; margin: 2px 0 0; padding-right: 40px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 14px 0 12px; background: rgba(255,255,255,.18); position: relative; z-index: 1; }
.stats div { background: var(--ink); padding: 8px 0 6px; }
.stats div + div { padding-left: 12px; }
.stats b { display: block; font: 800 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.stats span { font: 700 11px/1.2 var(--display); text-transform: uppercase; letter-spacing: .12em; opacity: .7; }
.ends { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; position: relative; z-index: 1; }
.ends li { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; }
.ends .pin { width: 30px; height: 30px; }
.ends .lbl { font: 700 12px/1.2 var(--display); text-transform: uppercase; letter-spacing: .1em; opacity: .7; display: block; }
.ends .name { font-weight: 600; font-size: 14.500px; line-height: 1.25; display: block; }
.hero .ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.hero .ghost:hover { border-color: #fff; background: rgba(255,255,255,.1); }

/* buttons */
.btn, .ghost {
  font: 700 14px/1 var(--display); text-transform: uppercase; letter-spacing: .08em; text-decoration: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; min-height: 40px; padding: 0 14px; border-radius: 3px;
}
.btn { background: var(--orange); color: #fff; border: 2px solid var(--orange); }
.btn:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.ghost { background: #fff; color: var(--ink); border: 2px solid var(--ink); }
.ghost:hover { background: var(--ink); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--purple); font-weight: 600; cursor: pointer; text-align: left; text-decoration: underline; }

/* closest place */
.homeactions { display: flex; gap: 8px; }
.homeactions .btn, .homeactions .ghost { flex: 1; min-height: 46px; }
.homesearch { display: flex; gap: 8px; margin-top: 8px; }
.homesearch input { flex: 1; min-width: 0; font-size: 16px; font-weight: 500; padding: 9px 10px; border: 2px solid var(--line); border-radius: 3px; background: #fff; }
.homesearch input:focus { outline: 0; border-color: var(--ink); }
.homeresults { list-style: none; margin: 8px 0 0; padding: 0; border: 2px solid var(--ink); border-radius: 3px; }
.homeresults li { padding: 10px; border-top: 1px solid var(--line); margin: 0; }
.homeresults li:first-child { border-top: 0; }
.homemsg { margin: 8px 0 0; }
.homestatus { margin: 12px 0 0; font-size: 13.500px; }
.nearest { list-style: none; margin: 0; padding: 0; }
.nearest li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.nearest li:first-child { margin-top: 8px; border-top: 2px solid var(--ink); }
.near { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 2px; background: none; border: 0; text-align: left; cursor: pointer; }
.near:hover, .near.sel { background: #f6f1ff; }
.near .nm { font: 700 16px/1.2 var(--display); text-transform: uppercase; letter-spacing: .03em; }
.near .meta { color: var(--muted); font-size: 13px; }
.near .dist { font: 800 24px/1 var(--display); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nearest .ghost { min-height: 38px; padding: 0 12px; }

/* time */
.timehead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.timehead strong { font: 800 44px/1 var(--display); font-variant-numeric: tabular-nums; text-transform: uppercase; }
#time { width: 100%; margin: 12px 0 4px; accent-color: var(--orange); height: 32px; }
.timescale { display: flex; justify-content: space-between; font-size: 12.500px; color: var(--muted); font-variant-numeric: tabular-nums; gap: 8px; }
#tsummary { color: var(--ink); font-weight: 700; text-align: center; }

/* closures list */
.sectors { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.sector {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 10px; align-items: center; width: 100%; min-height: 56px;
  padding: 9px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer;
}
.sector:hover, .sector.sel { background: #f6f1ff; }
.sector .bar { width: 6px; align-self: stretch; background: var(--open); }
.sector .nm { font-weight: 700; font-size: 14.500px; line-height: 1.25; }
.sector .meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pill { font: 700 12px/1 var(--display); text-transform: uppercase; letter-spacing: .08em; padding: 5px 7px 4px; white-space: nowrap; display: inline-block; }
.st-closed .bar { background: var(--closed); } .st-closed .pill { background: var(--closed); color: #fff; }
.st-soon .bar { background: var(--soon); } .st-soon .pill { background: var(--soon); color: var(--ink); }
.st-open .bar { background: var(--open); } .st-open .pill { background: #e1f1fb; color: #0b5c8a; }
.st-done .bar { background: var(--done); } .st-done .pill { background: #e2f5ea; color: #1d6b3d; }
.pill.best { background: var(--orange); color: #fff; margin-left: 4px; vertical-align: 2px; }

/* ---------- map markers and popup ---------- */
.endpin { display: grid; place-items: center; }
.endpin svg { filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.endlabel.leaflet-tooltip {
  background: var(--ink); color: #fff; border: 0; border-radius: 0; font: 800 13px/1 var(--display); letter-spacing: .1em;
  padding: 4px 8px 3px; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.endlabel.leaflet-tooltip::before { display: none; }
.arrow svg { display: block; }
.rider { background: var(--orange); color: #fff; border: 2px solid #fff; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 1px 5px rgba(0,0,0,.45); }
.me { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.22); }
#map.picking { cursor: crosshair; }
.leaflet-popup-content-wrapper { border-radius: 4px; border-top: 5px solid var(--orange); }
.leaflet-popup-content { margin: 12px 14px 14px; font: 500 14px/1.4 var(--body); color: var(--ink); min-width: 220px; }
.pop h3 { font: 800 20px/1.1 var(--display); text-transform: uppercase; margin-bottom: 2px; padding-right: 14px; }
.pop .sub { color: var(--muted); font-size: 12.500px; margin-bottom: 8px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 10px; font-size: 13px; }
.pop dt { color: var(--muted); } .pop dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pop .warn { font-size: 12.500px; color: #5c4200; background: #fff7e6; border-left: 3px solid var(--soon); padding: 6px 8px; margin-bottom: 10px; }
.pop .btn { width: 100%; color: #fff; min-height: 44px; }
.leaflet-bar a { color: var(--ink); }
