/* Ireland on the air.
 *
 * The interface is drawn as the margin of a printed map sheet: boxed key,
 * ruled edges, and the grid square set large the way a sheet number is.
 * One colour per programme, taken from map printing rather than a UI kit:
 * park green, the magenta of over-printed routes for summits, ochre for
 * flora and fauna areas, and grid blue for WAI squares.
 */

@font-face { font-family: "Overpass"; font-weight: 400; font-display: swap;
  src: url("../vendor/fonts/overpass-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 600; font-display: swap;
  src: url("../vendor/fonts/overpass-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 800; font-display: swap;
  src: url("../vendor/fonts/overpass-latin-800-normal.woff2") format("woff2"); }

:root {
  --ink: #10243a;
  --ink-soft: #46586b;
  --paper: #ffffff;
  --wash: #eaf0f4;
  --rule: #10243a;
  --grid: #1456b8;
  --pota: #17803d;
  --sota: #c2185b;
  --wwff: #a86a00;
  --warn-bg: #fff1c2;
  --warn-ink: #5c3b00;
  --edge: 2px;
  --gap: 10px;
  --tools-h: 52px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Overpass", "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.4; color: var(--ink); background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
h2, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: var(--grid); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--grid); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#app { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; }

/* ---- search bar ---------------------------------------------------- */
.bar { position: relative; z-index: 1100; background: var(--ink); padding: 8px var(--gap);
  padding-top: max(8px, env(safe-area-inset-top)); }
#q { width: 100%; height: 44px; padding: 0 12px; border: 0; border-radius: 0; background: var(--paper);
  font-weight: 600; }
#q::placeholder { color: var(--ink-soft); font-weight: 400; }
.results { position: absolute; left: var(--gap); right: var(--gap); top: 100%; background: var(--paper);
  border: var(--edge) solid var(--rule); border-top: 0; max-height: 55vh; overflow-y: auto; }
.results button { display: grid; grid-template-columns: 22px 7.5em 1fr; gap: 8px; align-items: center; width: 100%;
  min-height: 46px; padding: 6px 10px; border: 0; border-top: 1px solid var(--wash); background: none; text-align: left; }
.results li:first-child button { border-top: 0; }
.results button:hover, .results button:focus-visible { background: var(--wash); }
.results .r-ref { font-weight: 800; white-space: nowrap; }
.results .r-name { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .none { padding: 12px 10px; color: var(--ink-soft); }

/* ---- map ----------------------------------------------------------- */
#map { position: relative; z-index: 1; background: var(--wash); min-height: 0; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 11px; }
.leaflet-bar a { color: var(--ink); border-radius: 0 !important; }
.leaflet-bar { border: var(--edge) solid var(--rule) !important; border-radius: 0 !important; box-shadow: none !important; }

/* ---- boxes: key and sheet ------------------------------------------ */
.box { background: var(--paper); border: var(--edge) solid var(--rule); }

.key { position: absolute; z-index: 1000; right: var(--gap); top: 70px; width: min(300px, calc(100vw - 2 * var(--gap)));
  max-height: calc(100% - 150px); overflow-y: auto; padding: 12px 14px 14px; }
.key h2 { font-size: 1.125rem; font-weight: 800; margin-bottom: 6px; }
.key label { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.key input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }
.key-lines { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: .875rem; }
.key-lines li { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.key-base { margin: 10px 0 0; padding: 8px 0 0; border: 0; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 0 16px; }
.key-base legend { float: left; width: 100%; padding: 0; font-weight: 600; font-size: .875rem; }

/* programme symbols: one shape and one colour each */
.sym { display: inline-block; width: 18px; height: 18px; flex: none; }
.sym.pota { background: var(--pota); border-radius: 50%; }
.sym.sota { background: var(--sota); clip-path: polygon(50% 4%, 100% 96%, 0 96%); }
.sym.wwff { background: var(--wwff); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.sym.wai { border: 2px solid var(--grid); background:
  linear-gradient(var(--grid), var(--grid)) 50% 0 / 2px 100% no-repeat,
  linear-gradient(var(--grid), var(--grid)) 0 50% / 100% 2px no-repeat; }
.sym.county { height: 0; border-top: 2px dashed var(--ink); align-self: center; }
.line { display: inline-block; width: 30px; height: 12px; flex: none; }
.line.solid { border: 2.5px solid var(--ink); background: rgba(16, 36, 58, .1); }
.line.dashed { border: 2px dashed var(--ink); background: rgba(16, 36, 58, .06); }
.line.core { background: rgba(194, 24, 91, .45); }

.sheet { position: absolute; z-index: 900; left: var(--gap); right: var(--gap);
  bottom: calc(var(--tools-h) + env(safe-area-inset-bottom) + var(--gap)); max-height: 46%; overflow-y: auto;
  padding: 12px 14px; }
.sheet .hint { color: var(--ink-soft); }

/* position: the grid square is the sheet number */
.pos-title { font-size: .875rem; color: var(--ink-soft); margin-bottom: 6px; }
.pos { display: grid; grid-template-columns: auto 1fr; gap: 0 16px; align-items: center; }
.sq { font-weight: 800; font-size: 3.25rem; line-height: 1; letter-spacing: -.01em; color: var(--grid);
  padding-right: 16px; border-right: var(--edge) solid var(--rule); font-variant-numeric: tabular-nums; }
.sq small { display: block; font-size: .75rem; font-weight: 600; letter-spacing: 0; color: var(--ink-soft); margin-top: 4px; }
.pos-meta { font-variant-numeric: tabular-nums; }
.pos-meta .county { font-weight: 800; font-size: 1.125rem; }
.pos-meta div + div { margin-top: 1px; }
.pos-meta .k { color: var(--ink-soft); }
.pos-meta .ll { font-size: .875rem; overflow-wrap: anywhere; }

.inside { margin-top: 10px; border-top: 1px solid var(--rule); }
.inside li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start; padding: 8px 0;
  border-bottom: 1px solid var(--wash); }
.inside li:last-child { border-bottom: 0; padding-bottom: 0; }
.inside .sym { margin-top: 2px; }
.inside .out .sym { opacity: .35; }
.inside .dist { color: var(--ink-soft); }
.linkish { padding: 0; border: 0; background: none; font-weight: 800; color: var(--ink); text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; }
.none-inside { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--rule); color: var(--ink-soft); }

/* reference details */
.ref-head { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 10px; align-items: center; }
.ref-head h2 { font-size: 1.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ref-head .name { grid-column: 2 / 3; font-size: 1.0625rem; }
.ref-head .sym { width: 22px; height: 22px; }
.close { min-height: 40px; padding: 0 12px; border: var(--edge) solid var(--rule); background: var(--paper); font-weight: 600; cursor: pointer; }
.close:hover { background: var(--wash); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.facts dt { color: var(--ink-soft); }
.facts dd { font-weight: 600; }
.trust { margin-top: 10px; padding: 9px 11px; background: var(--wash); border-left: 4px solid var(--ink); }
.trust.exact { border-left-color: var(--pota); }
.trust.approx, .trust.estimate { border-left-style: dashed; }
.trust.check { background: var(--warn-bg); color: var(--warn-ink); border-left-color: var(--warn-ink); }
.trust strong { font-weight: 800; }
.links { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.back { margin-top: 10px; }

/* ---- tools --------------------------------------------------------- */
.tools { z-index: 1000; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--ink);
  padding-bottom: env(safe-area-inset-bottom); }
.tools button { height: var(--tools-h); border: 0; border-left: 1px solid rgba(255, 255, 255, .25); background: none;
  color: var(--paper); font-weight: 600; cursor: pointer; }
.tools button:first-child { border-left: 0; }
.tools button[aria-pressed="true"], .tools button[aria-expanded="true"] { background: var(--paper); color: var(--ink); }
.tools button:focus-visible { outline-color: var(--paper); outline-offset: -5px; }

/* ---- about --------------------------------------------------------- */
.about { width: min(640px, calc(100vw - 20px)); max-height: calc(100vh - 40px); padding: 18px 20px 22px;
  border: var(--edge) solid var(--rule); border-radius: 0; color: var(--ink); }
.about::backdrop { background: rgba(16, 36, 58, .55); }
.about form { float: right; margin: 0 0 8px 12px; }
.about h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.about h3 { font-size: 1.0625rem; font-weight: 800; margin: 16px 0 4px; }
.about p, .about li { max-width: 68ch; }
.about p + p { margin-top: 8px; }
.about ul { list-style: disc; padding-left: 20px; }
.about li { margin-top: 3px; }

/* ---- map furniture --------------------------------------------------- */
.mk { display: block; }
.mk svg { display: block; overflow: visible; }
.wai-label { color: var(--grid); font-weight: 800; font-size: 15px; line-height: 1; white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; pointer-events: none;
  transform: translate(-50%, -50%); font-variant-numeric: tabular-nums; }
.wai-label.big { font-size: 26px; opacity: .8; }
.me { width: 18px; height: 18px; border-radius: 50%; background: var(--grid); border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--ink); }
.tap { width: 14px; height: 14px; border: 3px solid var(--ink); border-radius: 50%; background: #fff; }

/* ---- wider screens: the sheet becomes a column down the left -------- */
@media (min-width: 900px) {
  #app { grid-template-columns: 380px 1fr; grid-template-rows: auto 1fr auto; }
  .bar { grid-column: 1; grid-row: 1; }
  #map { grid-column: 2; grid-row: 1 / 4; }
  .sheet { position: static; grid-column: 1; grid-row: 2; max-height: none; border-width: 0; padding: 16px 18px; }
  .tools { grid-column: 1; grid-row: 3; }
  .key { top: var(--gap); left: calc(380px + var(--gap)); right: auto; max-height: calc(100% - 2 * var(--gap)); }
  .results { max-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
  .leaflet-fade-anim .leaflet-tile, .leaflet-zoom-anim .leaflet-zoom-animated { transition: none !important; }
}
