/* York 10K planner. Graphite theme, branding/theme/tokens.css. */

:root {
  --bg:        #161514;
  --panel:     #1d1c1a;
  --panel2:    #262523;
  --border:    #383630;
  --well:      #100f0e;
  --text:      #dcdad2;
  --dim:       #8f8d83;
  --accent:    #e0a63d;
  --hot:       #3fc6dc;
  --on-accent: #131110;
  --danger:    #e25b4a;

  /* functional map colours, deliberately clear of the accents */
  --c-route:  #ffd23f;   /* the course itself, from the GPX */
  --c-course: #ff6b57;
  --c-shut:   #b8564c;
  --c-amber:  #c79bf0;
  --c-open:   #5ec27a;
  --c-walk:   #3fc6dc;

  --r-pick:   #3fc6dc;
  --r-good:   #5ec27a;
  --r-ok:     #7f9fd0;
  --r-avoid:  #93706a;

  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --disp: Bahnschrift, "DIN Alternate", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 18px; }

h1, h2, h3 { font-family: var(--disp); font-weight: 400; letter-spacing: .01em; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* ── header ─────────────────────────────────────────────────────────────── */

.top {
  /* Above Leaflet, whose controls default to z-index 1000 and were drawing
     over the header on the Map tab. */
  position: sticky; top: 0; z-index: 1100;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.top .wrap:first-child {
  display: flex; align-items: center; gap: 18px;
  padding-top: 12px; padding-bottom: 10px;
}
.title { flex: 1 1 auto; min-width: 0; }
.top h1 { margin: 0; font-size: 1.5rem; line-height: 1.1; }
.sub { margin: 2px 0 0; color: var(--dim); font-size: .8rem; }

.count {
  font-family: var(--disp); font-size: 1.05rem; line-height: 1.15;
  text-align: right; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.count small { display: block; font-family: var(--sans); font-size: .62rem;
  letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }

/* Eight tabs do not fit a phone. Fade the right edge so it is obvious the strip
   scrolls, and drop the fade once you reach the end. */
.tabstrip { position: relative; }
.tabstrip::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 34px;
  pointer-events: none; opacity: 1; transition: opacity .15s;
  background: linear-gradient(to right, rgba(29,28,26,0), var(--panel) 78%);
}
.tabstrip.at-end::after { opacity: 0; }
/* position:relative so button.offsetLeft is measured against the scroll box.
   No scroll-behavior:smooth here: it defers programmatic scrollLeft writes, so
   the strip never moves and the edge fade reads the wrong value. */
.tabs { position: relative; display: flex; gap: 2px; overflow-x: auto;
        scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; appearance: none; background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--dim); font: inherit; font-size: .85rem;
  padding: 9px 14px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ── tabs ───────────────────────────────────────────────────────────────── */

.tab { display: none; padding: 22px 0 60px; }
.tab.on { display: block; }
#map.tab { padding: 0; }

.lede { max-width: 62ch; color: var(--text); }
.lede p { margin: 0 0 14px; }
.tab .wrap > p { max-width: 74ch; }

h2 { font-size: 1.15rem; margin: 30px 0 10px; }
h3 { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase;
     color: var(--dim); margin: 0 0 8px; font-family: var(--sans); font-weight: 600; }

.foot { color: var(--dim); font-size: .82rem; max-width: 66ch; margin-top: 24px; }
.hint { color: var(--dim); font-size: .78rem; margin: 8px 0 0; }

/* ── summary cards: 2px amber keyline left ──────────────────────────────── */

.cards { display: grid; gap: 10px; margin: 20px 0 26px;
         grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--panel2);
  border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px;
}
.card .k { font-size: .65rem; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
.card strong { font-family: var(--disp); font-size: 1.15rem; font-weight: 400; }
.card .v { font-size: .84rem; color: var(--dim); }

.callout {
  background: var(--panel2); border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0; padding: 12px 14px; margin: 18px 0;
  font-size: .9rem;
}

/* ── filter chips ───────────────────────────────────────────────────────── */

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
           margin: 0 0 14px; padding-top: 4px; }
.lab { font-size: .65rem; letter-spacing: .09em; text-transform: uppercase;
       color: var(--dim); margin-right: 4px; }
.sortlab { margin-left: 14px; }
.chip {
  appearance: none; background: var(--panel2); color: var(--dim);
  border: 1px solid var(--border); border-radius: 0;
  font: 600 .72rem/1 var(--sans); letter-spacing: .07em; text-transform: uppercase;
  padding: 7px 11px; cursor: pointer;
}
.chip:hover { background: rgba(224,166,61,.08); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ── site list ──────────────────────────────────────────────────────────── */

.sitelist { display: flex; flex-direction: column; gap: 8px; }

.site {
  background: var(--panel2);
  border-left: 2px solid var(--rank);
  border-radius: 0 3px 3px 0;
  padding: 12px 14px;
  cursor: pointer;
}
.site:hover { background: #2c2b28; }
.site.open { background: #2c2b28; }

.site-head { display: flex; align-items: baseline; gap: 12px; }
.site-name { font-family: var(--disp); font-size: 1.08rem; flex: 1 1 auto; min-width: 0; }
.site-meta { font-size: .68rem; letter-spacing: .07em; text-transform: uppercase;
             color: var(--dim); }
.site-walk { font-family: var(--disp); font-size: 1.35rem; font-variant-numeric: tabular-nums;
             color: var(--rank); white-space: nowrap; }
.site-walk small { font-family: var(--sans); font-size: .6rem; letter-spacing: .08em;
                   text-transform: uppercase; color: var(--dim); margin-left: 3px; }

.site-sub { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px;
            font-size: .78rem; color: var(--dim); }
.site-sub b { color: var(--text); font-weight: 600; }

.site-body { display: none; margin-top: 12px; padding-top: 12px;
             border-top: 1px solid var(--border); font-size: .87rem; }
.site.open .site-body { display: block; }
.site-body p { margin: 0 0 10px; max-width: 78ch; }
.site-body dl { margin: 0; max-width: 78ch; display: grid;
                grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .84rem; }
.site-body dt { color: var(--dim); font-size: .65rem; letter-spacing: .09em;
                text-transform: uppercase; padding-top: 3px; }
.site-body dd { margin: 0; }
.site-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.btn {
  appearance: none; display: inline-block; text-decoration: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  font: 600 .72rem/1 var(--sans); letter-spacing: .07em; text-transform: uppercase;
  padding: 8px 12px; cursor: pointer;
}
.btn:hover { background: rgba(224,166,61,.08); border-color: var(--accent); }
.btn.primary { background: var(--hot); border-color: var(--hot); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.1); }

/* ── map ────────────────────────────────────────────────────────────────── */

.maprow { display: flex; height: calc(100vh - 108px); min-height: 460px; }
#leaflet { flex: 1 1 auto; background: var(--well); }
.leaflet-container { background: var(--well); font: inherit; }
/* Dark map out of the standard raster tiles. Filter each tile, not the pane:
   filtering the pane makes one huge composited layer and Chrome drops squares
   out of it while panning. Contrast above 1 is load-bearing: invert alone
   leaves street names as mid-grey on mid-grey and the map reads as washed out. */
.dark-map .leaflet-tile {
  filter: invert(1) hue-rotate(180deg) brightness(.88) contrast(1.28) saturate(.55);
}

.mapside {
  flex: 0 0 288px; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--border);
  padding: 14px 16px 40px;
}
.side-sec { margin-bottom: 22px; }

.tog { display: flex; align-items: center; gap: 9px; padding: 4px 0;
       font-size: .87rem; cursor: pointer; }
.tog input { accent-color: var(--accent); width: 15px; height: 15px; }

.clock { font-family: var(--disp); font-size: 2rem; line-height: 1;
         font-variant-numeric: tabular-nums; margin-bottom: 6px; }
#clock { width: 100%; accent-color: var(--hot); }
.scale { display: flex; justify-content: space-between; font-size: .65rem;
         color: var(--dim); font-variant-numeric: tabular-nums; }

.key { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.key li { display: flex; align-items: center; gap: 9px; padding: 3px 0; }
.sw { width: 20px; height: 3px; flex: 0 0 20px; }
.sw.route  { background: var(--c-route); height: 5px; }
.sw.course { background: var(--c-course); height: 5px; }
.sw.shut   { background: var(--c-shut); }
.sw.amber  { background: var(--c-amber); }
.sw.open   { background: var(--c-open); }
.sw.walk   { background: var(--c-walk); height: 4px; }

#sel .selname { font-family: var(--disp); font-size: 1.1rem; }
#sel .selwalk { color: var(--hot); font-family: var(--disp); font-size: 1.5rem;
                font-variant-numeric: tabular-nums; }
#sel dl { margin: 8px 0 0; font-size: .8rem; }
#sel dt { color: var(--dim); font-size: .62rem; letter-spacing: .09em;
          text-transform: uppercase; margin-top: 7px; }
#sel dd { margin: 1px 0 0; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 2px; box-shadow: none;
}
.leaflet-popup-content { margin: 10px 12px; font-size: .85rem; }
.leaflet-popup-content b { font-family: var(--disp); font-weight: 400; font-size: 1.02rem; }
.leaflet-popup-content .pw { color: var(--hot); font-variant-numeric: tabular-nums; }
.leaflet-popup-close-button { color: var(--dim) !important; }
.leaflet-control-zoom a {
  background: var(--panel2); color: var(--text); border-color: var(--border);
}
.leaflet-control-zoom a:hover { background: var(--panel); color: var(--accent); }
.leaflet-control-attribution {
  background: rgba(22,21,20,.85) !important; color: var(--dim) !important;
  font-size: .65rem;
}
.leaflet-control-attribution a { color: var(--dim) !important; }

.pin {
  border: 2px solid var(--well); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}
.flag {
  font: 600 .58rem/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent); color: var(--on-accent);
  border: 1px solid var(--well); padding: 3px 5px; white-space: nowrap;
}
.flag.hot { background: var(--hot); }

/* ── the plan ───────────────────────────────────────────────────────────── */

.planner { background: var(--panel2); border-left: 2px solid var(--accent);
           border-radius: 0 3px 3px 0; padding: 14px 16px; margin: 18px 0 14px; }
.pfields { display: grid; gap: 12px 18px;
           grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.pfield { display: flex; flex-direction: column; gap: 5px; }
.pfield select, .pfield input {
  background: var(--well); color: var(--text); border: 1px solid var(--border);
  font: inherit; font-size: .88rem; padding: 7px 9px; width: 100%;
}
.pfield select:focus, .pfield input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.withunit { position: relative; display: block; }
.withunit em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
               font-style: normal; font-size: .7rem; color: var(--dim); pointer-events: none; }
.withunit input { padding-right: 38px; }

.leaveby { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 16px;
           padding-top: 14px; border-top: 1px solid var(--border); }
.leaveby .big { font-family: var(--disp); font-size: 2rem; line-height: 1;
                font-variant-numeric: tabular-nums; color: var(--hot); }
.leaveby .big small { display: block; font-family: var(--sans); font-size: .6rem;
  letter-spacing: .09em; text-transform: uppercase; color: var(--dim); margin-top: 4px; }

.note { border-left: 2px solid var(--border); background: var(--panel2);
        border-radius: 0 3px 3px 0; padding: 10px 13px; margin: 0 0 8px; font-size: .87rem; }
.note.ok   { border-left-color: var(--c-open); }
.note.warn { border-left-color: var(--accent); }
.note.bad  { border-left-color: var(--danger); }

.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.tl { display: flex; gap: 14px; padding: 0 0 0 2px; position: relative; }
.tl::before { content: ''; position: absolute; left: 61px; top: 0; bottom: 0;
              width: 1px; background: var(--border); }
.tl:first-child::before { top: 14px; }
.tl:last-child::before  { bottom: calc(100% - 14px); }
.tl-t { flex: 0 0 52px; text-align: right; font-family: var(--disp); font-size: 1.05rem;
        font-variant-numeric: tabular-nums; color: var(--accent); padding-top: 6px; }
.tl-b { flex: 1 1 auto; padding: 6px 0 14px 20px; position: relative; }
.tl-b::before { content: ''; position: absolute; left: -4px; top: 12px;
                width: 9px; height: 9px; border-radius: 50%;
                background: var(--panel); border: 2px solid var(--accent); }
.tl.gun .tl-t { color: var(--hot); font-size: 1.35rem; }
.tl.gun .tl-b::before { background: var(--hot); border-color: var(--hot);
                        width: 11px; height: 11px; left: -5px; }
.tl-b b { display: block; font-weight: 600; font-size: .93rem; }
/* Direct child only: the provenance tag is a span too, nested inside the <b>,
   and display:block was stretching it across the row. */
.tl-b > span { display: block; color: var(--dim); font-size: .82rem; margin-top: 2px;
               max-width: 62ch; }
.tl-b b { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.kmpin {
  display: grid; place-items: center; width: 22px; height: 22px;
  background: var(--c-route); color: var(--on-accent); border: 2px solid var(--well);
  border-radius: 50%; font: 600 .7rem/1 var(--sans); font-variant-numeric: tabular-nums;
}

.side-rule { height: 1px; background: var(--border); margin: 10px 0 8px; }
.selacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
#lyr-fade { width: 88px; accent-color: var(--accent); }

/* ── pace and spectator ─────────────────────────────────────────────────── */

.pacer { background: var(--panel2); border-left: 2px solid var(--accent);
         border-radius: 0 3px 3px 0; padding: 14px 16px; margin: 18px 0 8px; }
.pacefield { display: flex; align-items: center; gap: 10px; }
#target {
  background: var(--well); color: var(--text); border: 1px solid var(--border);
  font: 400 1.5rem/1 var(--disp); font-variant-numeric: tabular-nums;
  padding: 6px 10px; width: 6ch;
}
#target:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#target.bad { border-color: var(--danger); color: var(--danger); }

.quick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.warn { color: var(--danger); font-size: .85rem; }

.paceout { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 16px;
           padding-top: 14px; border-top: 1px solid var(--border); }
.paceout .big { font-family: var(--disp); font-size: 1.7rem; line-height: 1.1;
                font-variant-numeric: tabular-nums; color: var(--hot); }
.paceout .big small { display: block; font-family: var(--sans); font-size: .6rem;
  letter-spacing: .09em; text-transform: uppercase; color: var(--dim); margin-top: 3px; }

#splittable td:first-child { font-family: var(--disp); color: var(--accent);
  font-variant-numeric: tabular-nums; width: 1%; }
#splittable tr.fin td { border-top: 1px solid var(--accent); }
#splittable tr.fin td:first-child { color: var(--hot); }

.spots { display: grid; gap: 8px; margin-top: 12px;
         grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.spot { background: var(--panel2); border-left: 2px solid var(--hot);
        border-radius: 0 3px 3px 0; padding: 12px 14px; }
.spot { border-left-color: var(--border); }
.spot.sure { border-left-color: var(--hot); }
.spot-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.spot-name { font-family: var(--disp); font-size: 1.05rem; flex: 1 1 auto; }
.spot-walk { font-size: .65rem; letter-spacing: .07em; text-transform: uppercase;
             color: var(--dim); }
.passes { display: flex; gap: 18px; margin: 8px 0 6px; }
.pass { display: flex; flex-direction: column; }
.pass b { font-family: var(--disp); font-weight: 400; font-size: 1.3rem;
          color: var(--hot); font-variant-numeric: tabular-nums; }
.pass b { color: var(--text); }
.spot.sure .pass b { color: var(--hot); }
.pass { font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.spot p { margin: 0 0 10px; font-size: .84rem; color: var(--dim); }

.linkrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }

/* ── provenance tags ────────────────────────────────────────────────────── */

.src {
  display: inline-block; font: 600 .58rem/1 var(--sans); letter-spacing: .07em;
  text-transform: uppercase; padding: 3px 5px; white-space: nowrap;
  border: 1px solid; border-radius: 2px;
}
.src.order    { color: #7fd694; border-color: #3f6b4c; background: rgba(94,194,122,.10); }
.src.rfa      { color: #7fb6e0; border-color: #3f5d75; background: rgba(127,159,208,.10); }
.src.measured { color: #7fb6e0; border-color: #3f5d75; background: rgba(127,159,208,.10); }
.src.guide    { color: var(--accent); border-color: #6b5527; background: rgba(224,166,61,.10); }
.src.press    { color: var(--accent); border-color: #6b5527; background: rgba(224,166,61,.10); }
.src.guess    { color: #c9a89f; border-color: #5c4741; background: rgba(147,112,106,.14); }

.tl-b b .src { font-weight: 600; }

.srckey { margin-top: 14px; display: grid; gap: 7px; max-width: 74ch; }
.srcrow { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: start;
          font-size: .82rem; color: var(--dim); }

#timetable td:last-child { width: 1%; white-space: nowrap; }

/* ── tables ─────────────────────────────────────────────────────────────── */

.tablewrap { overflow-x: auto; border: 1px solid var(--border); background: var(--well); }
table { border-collapse: collapse; width: 100%; font-size: .84rem; min-width: 520px; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border);
         vertical-align: top; }
th { font-size: .62rem; letter-spacing: .09em; text-transform: uppercase;
     color: var(--dim); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
tbody tr:hover { background: rgba(224,166,61,.08); }
td:nth-child(3), td:nth-child(4) { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.plain { min-width: 380px; }
table.plain td:first-child { font-family: var(--disp); color: var(--accent);
  font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; }

/* ── route images ───────────────────────────────────────────────────────── */

figure { margin: 22px 0; }
figure img { width: 100%; height: auto; display: block; background: #fff;
             border: 1px solid var(--border); }
/* The route map is portrait and would run to 1300px at full width. */
figure img.tall { width: auto; max-width: 100%; max-height: 82vh; margin: 0 auto; }
figcaption { color: var(--dim); font-size: .78rem; margin-top: 6px; }

/* ── narrow ─────────────────────────────────────────────────────────────── */

@media (max-width: 780px) {
  .top .wrap:first-child { gap: 10px; }
  .top h1 { font-size: 1.25rem; }
  .count { font-size: .9rem; }
  /* The subtitle wrapped to two lines and pushed the tab strip down a third of
     the way to the fold. The date is the only part worth the space. */
  .sub .also { display: none; }

  /* Splits is a four column table whose whole point is the last two columns.
     At 520px min-width they sit off-screen behind a scrollbar, so let the
     "where" column wrap instead and keep the times visible. */
  #splittable, #timetable { min-width: 0; }
  #splittable td:nth-child(2) { white-space: normal; word-break: break-word; }
  #splittable th, #splittable td { padding: 7px 8px; }

  /* The source tag was being clipped off the right edge. Drop it under the
     text rather than making the reader scroll sideways for it. */
  #timetable td { padding: 7px 8px; }
  #timetable tr { display: grid; grid-template-columns: 52px 1fr; }
  #timetable td:first-child { grid-row: span 2; }
  #timetable td:nth-child(2) { border-bottom: 0; padding-bottom: 2px; }
  #timetable td:last-child { width: auto; padding-top: 0; }
  .srcrow { grid-template-columns: 84px 1fr; }
  .maprow { flex-direction: column; height: auto; }
  #leaflet { height: 62vh; min-height: 340px; flex: none; }
  .mapside { flex: none; width: 100%; border-left: 0; border-top: 1px solid var(--border); }
  .site-head { flex-wrap: wrap; }
  .site-walk { order: 3; }
}
