:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #444444;
  --accent: #0b4f9c;
  --focus: #c2410c;
  --panel: #f2f2f2;
  --map-water: #0d2a4a;
  --map-land: #e8e2c8;
  --map-current: #ffd400;
  --map-border: #1b1b1b;
  --map-trail: #ff7a3d;
  --map-cursor: #e0001b;
  --map-cursor-halo: #ffffff;
  --street-road: #ffffff;
  --street-path: #7a5c00;
  --street-place: #0b4f9c;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114;
    --fg: #f2f2f2;
    --muted: #c4c4c4;
    --accent: #8cc4ff;
    --focus: #ffb37a;
    --panel: #1d1f24;
    --map-water: #000000;
    --map-land: #4a4a4a;
    --map-current: #ffd400;
    --map-border: #9a9a9a;
    --map-cursor-halo: #ffffff;
    --street-road: #d8d8d8;
    --street-path: #ffd400;
    --street-place: #8cc4ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101114;
  --fg: #f2f2f2;
  --muted: #c4c4c4;
  --accent: #8cc4ff;
  --focus: #ffb37a;
  --panel: #1d1f24;
  --map-water: #000000;
  --map-land: #4a4a4a;
  --map-border: #9a9a9a;
  --street-road: #d8d8d8;
  --street-path: #ffd400;
  --street-place: #8cc4ff;
  color-scheme: dark;
}

/* High contrast: yellow on black, and white on black. */
:root[data-theme="yellow"] {
  --bg: #000000;
  --fg: #ffff00;
  --muted: #ffff00;
  --accent: #ffff00;
  --focus: #00ffff;
  --panel: #000000;
  --map-water: #000000;
  --map-land: #333300;
  --map-current: #ffff00;
  --map-border: #ffff00;
  --map-trail: #00ffff;
  --map-cursor: #ff0000;
  --map-cursor-halo: #ffffff;
  --street-road: #ffff00;
  --street-path: #00ffff;
  --street-place: #ffffff;
  color-scheme: dark;
}

:root[data-theme="white"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #ffffff;
  --accent: #ffffff;
  --focus: #ffff00;
  --panel: #000000;
  --map-water: #000000;
  --map-land: #3a3a3a;
  --map-current: #ffff00;
  --map-border: #ffffff;
  --map-trail: #ffff00;
  --map-cursor: #ff0000;
  --map-cursor-halo: #ffffff;
  --street-road: #ffffff;
  --street-path: #ffff00;
  --street-place: #00ffff;
  color-scheme: dark;
}

:root[data-theme="yellow"] button, :root[data-theme="white"] button { border-width: 3px; font-weight: 700; }
:root[data-theme="yellow"] :focus-visible, :root[data-theme="white"] :focus-visible { outline-width: 6px; }
:root[data-theme="yellow"] a, :root[data-theme="white"] a { color: var(--fg); }

/* Text size. */
:root[data-text="large"] { font-size: 125%; }
:root[data-text="xl"] { font-size: 150%; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.125rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

#intro {
  max-width: 40rem;
  margin: 0 auto;
  padding: 3rem 16px;
}

h1 { font-size: 2.25rem; margin: 0 0 1rem; }

.small { color: var(--muted); font-size: 1rem; }

a { color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

#intro label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }

#intro label.check { font-weight: 400; display: flex; gap: 0.5rem; align-items: center; }

#intro select { width: 100%; padding: 0.4rem; }

#intro-tilt-row .small { display: block; margin-top: 0.25rem; }

input[type="checkbox"] { width: 1.4rem; height: 1.4rem; }

[hidden] { display: none !important; }

button, select, input {
  font: inherit;
  color: inherit;
}

button {
  background: var(--accent);
  color: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 6px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}

button[disabled] { opacity: 0.5; cursor: progress; }

button[aria-pressed="true"] {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

#steer-status { margin: 0.75rem 0 0; font-weight: 700; }

#start { font-size: 1.3rem; padding: 0.8rem 1.6rem; margin: 0.5rem 0 1rem; }

#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(55vh, 1fr) auto;
  overflow-y: auto;
}

#panel {
  padding: 0.5rem 16px 1.5rem;
  background: var(--panel);
}

#panel h2 { font-size: 1.15rem; margin: 1rem 0 0.5rem; }

#panel input[type="range"] { width: 100%; height: 2rem; accent-color: var(--accent); }

#step-value { margin: 0; font-weight: 700; }

#panel .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.5rem;
}

#panel .grid button { font-size: 1rem; padding: 0.45rem 0.6rem; }

#panel .move { grid-template-columns: repeat(3, 1fr); }
#panel .move [data-move="0"] { grid-column: 2; }
#panel .move [data-move="270"] { grid-column: 1; }
#panel .move [data-move="90"] { grid-column: 3; }
#panel .move [data-move="180"] { grid-column: 2; }

@media (min-width: 900px) {
  #app {
    grid-template-columns: 1fr 20rem;
    grid-template-rows: auto 1fr;
    overflow: hidden;
  }
  #toolbar { grid-column: 1 / -1; }
  #panel { overflow-y: auto; }
}

#app[hidden] { display: none; }

#toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 16px;
  background: var(--panel);
}

#toolbar .brand { font-weight: 700; margin-right: auto; }

#toolbar button { font-size: 1rem; padding: 0.35rem 0.8rem; }

#map {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--map-water);
}

#map:focus-visible { outline-offset: -4px; }

#map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#map-canvas[hidden] { display: none; }

#map-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  margin: 0;
  padding: 0.6rem 1rem;
  background: #000000;
  color: #ffffff;
  border: 3px solid #ffd400;
  border-radius: 8px;
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 700;
}

#map-caption:empty { display: none; }

/* Visual Assist off: the place name is still there for screen readers. */
body:not(.visual-assist) #map-caption { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

dialog {
  width: min(36rem, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--fg);
  border-radius: 10px;
  padding: 1.25rem;
}

dialog::backdrop { background: rgb(0 0 0 / 0.6); }

dialog h2 { margin-top: 0; }

dialog label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }

dialog label.check { font-weight: 400; }

dialog input[type="text"], dialog select { width: 100%; padding: 0.4rem; }

dialog select[size] { margin-top: 0.75rem; }

.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* Keep a dialog's buttons on screen however long its content is. */
dialog .buttons {
  position: sticky;
  bottom: -1.25rem;
  background: var(--bg);
  padding: 0.75rem 0 1.25rem;
}

@media (pointer: coarse) {
  button { min-height: 44px; }
}

table { border-collapse: collapse; width: 100%; font-size: 1rem; }

th, td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--muted); vertical-align: top; }

td:first-child { white-space: nowrap; font-weight: 600; }


.picker-label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }
input.picker { width: 100%; height: 2rem; accent-color: var(--accent); }
.picker-value { margin: 0 0 0.5rem; font-weight: 700; }
#panel .panel-section label.check { display: flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
#panel .panel-section button, #panel [data-steer-only] button { font-size: 1rem; margin: 0.25rem 0; }

.buttons.stack { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; }


.place-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.place-links a { padding: 0.4rem 0.8rem; border: 2px solid var(--accent); border-radius: 6px; font-size: 1rem; }

/* Journey planner: each box on its own line, full width. */
#journey-section label[for^="journey-"]:not(.picker-label) { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }
#journey-section input[type="text"] { display: block; width: 100%; box-sizing: border-box; padding: 0.4rem; font-size: 1rem; }
#journey-section button { margin-top: 0.5rem; }

/* Information and Settings: a heading that is a button. */
.expander-heading { margin: 1rem 0 0.5rem; }
.expander { font: inherit; font-weight: 700; background: none; color: var(--fg); border: 0; padding: 0.25rem 0; min-height: 44px; cursor: pointer; text-align: left; }
.expander { text-decoration: underline; text-underline-offset: 0.2em; }

/* The step text says what to do; the list's own numbers are enough on screen. */
ol.steps { padding-left: 1.5rem; }
ol.steps li { margin: 0.4rem 0; }

.result-list { list-style: none; padding: 0; margin: 0.5rem 0; max-height: 50vh; overflow-y: auto; }
.result-list li { margin: 0.25rem 0; }
.result-list button { width: 100%; text-align: left; font-size: 1rem; padding: 0.45rem 0.6rem; }

/* The toolbar: the buttons used most, and More for the rest. */
#toolbar-more { display: contents; }
#toolbar-more[hidden] { display: none !important; }

/* Visual Assist off: no big empty map area; the controls come straight after the toolbar. */
body:not(.visual-assist) #app { grid-template-rows: auto auto auto; }
body:not(.visual-assist) #map { min-height: 2.5rem; height: 2.5rem; }

/* Text boxes take the theme's colours, with a clear border. */
input[type="text"] { background: var(--bg); color: var(--fg); border: 2px solid var(--muted); border-radius: 4px; padding: 0.35rem 0.5rem; }

.menu-text p { margin: 0.2rem 0; }
.menu-text h5 { margin: 0.8rem 0 0.2rem; font-size: 1rem; }
.menu-dishes { margin: 0; padding-left: 1.2rem; }
.menu-dishes li { margin: 0.15rem 0; }

/* Menus where you are, and Menus nearby. */
#venue-choices { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; margin-top: 1rem; }
#venue-choices .result-list { margin: 0; }
#venue-menu h3 { margin-bottom: 0.4rem; }

/* Starter and Expert: Expert shows more. */
:root[data-level="starter"] [data-expert] { display: none !important; }
.switch { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; min-height: 44px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 3.2rem; height: 1.8rem; margin: 0; border-radius: 1rem;
  background: var(--muted); border: 2px solid var(--fg); position: relative; cursor: pointer; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 1.3rem; height: 1.3rem; border-radius: 50%;
  background: var(--bg); transition: transform 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(1.35rem); }
.key { font-weight: 400; }
@media (pointer: coarse) { .key { display: none; } }

/* GPS monitor status, in the top bar while the monitor is on. */
#gps-panel { flex-basis: 100%; border: 2px solid var(--fg); border-radius: 8px; padding: 0.5rem 0.75rem; }
#gps-panel h2 { margin: 0 0 0.25rem; font-size: 1.1rem; }
#gps-status { margin: 0 0 0.5rem; padding-left: 1.2rem; }
#gps-panel[hidden] { display: none; }

/* Colours and Text size: radio buttons. */
.radios { border: 0; margin: 0.75rem 0 0; padding: 0; }
.radios legend { font-weight: 600; padding: 0; margin-bottom: 0.25rem; }
.radio { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; cursor: pointer; }
.radio input { width: 1.4rem; height: 1.4rem; margin: 0; accent-color: var(--accent); }

/* Starter on a phone or tablet: big compass buttons, easy to find and tap. */
@media (pointer: coarse) {
  :root[data-level="starter"] #panel .move { gap: 0.5rem; }
  :root[data-level="starter"] #panel .move button { min-height: 22vw; max-height: 8rem; font-size: 1.4rem; font-weight: 700; }
}
