/* Rubo's Tools theme: every page links this file and theme.js. */

:root {
  --ground: #f4f5f2;
  --surface: #ffffff;
  --ink: #14171c;
  --ink-2: #464d5a;
  --ink-3: #626a78;
  --rule: #dcdfdb;
  --rule-strong: #b9bdb8;

  --line-e: #1f72b6;   /* Everyday */
  --line-m: #20843d;   /* Money */
  --line-t: #ec7a16;   /* Text & dev */
  --line-h: #f1bf2a;   /* Health & life */
  --on-e: #ffffff;
  --on-m: #ffffff;
  --on-t: #1c1003;
  --on-h: #1c1603;

  --c: var(--ink);
  --on: var(--ground);

  --focus: #1f72b6;
  --danger: #b42a22;
  --warn: #a35b00;
  --ok: #1d7a46;
  --syn-key: #7a3fb0;
  --syn-str: #1d7a46;
  --syn-num: #a8550c;
  --syn-lit: #2b5fa8;
  --shadow: 0 1px 2px rgb(20 23 28 / .06), 0 8px 24px -12px rgb(20 23 28 / .18);

  --sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, monospace;

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1320px;
  --radius: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1216;
    --surface: #171b21;
    --ink: #eef0f2;
    --ink-2: #b3b9c3;
    --ink-3: #8f97a4;
    --rule: #272c34;
    --rule-strong: #3a414c;
    --line-e: #4d9fe2;
    --line-m: #3fb463;
    --line-t: #f28d35;
    --line-h: #f2c94a;
    --on-e: #07131f;
    --on-m: #04140a;
    --focus: #4d9fe2;
    --danger: #ff8a80;
    --warn: #f0b45a;
    --ok: #6fd39a;
    --syn-key: #c9a2f2;
    --syn-str: #8fdcae;
    --syn-num: #f5ad74;
    --syn-lit: #8db8f2;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0f1216;
  --surface: #171b21;
  --ink: #eef0f2;
  --ink-2: #b3b9c3;
  --ink-3: #8f97a4;
  --rule: #272c34;
  --rule-strong: #3a414c;
  --line-e: #4d9fe2;
  --line-m: #3fb463;
  --line-t: #f28d35;
  --line-h: #f2c94a;
  --on-e: #07131f;
  --on-m: #04140a;
  --focus: #4d9fe2;
  --danger: #ff8a80;
  --warn: #f0b45a;
  --ok: #6fd39a;
  --syn-key: #c9a2f2;
  --syn-str: #8fdcae;
  --syn-num: #f5ad74;
  --syn-lit: #8db8f2;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
  color-scheme: dark;
}

[data-line="e"] { --c: var(--line-e); --on: var(--on-e); }
[data-line="m"] { --c: var(--line-m); --on: var(--on-m); }
[data-line="t"] { --c: var(--line-t); --on: var(--on-t); }
[data-line="h"] { --c: var(--line-h); --on: var(--on-h); }

/* Base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule-strong) var(--ground); }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
::selection { background: color-mix(in oklab, var(--focus) 28%, transparent); color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
h1, h2, h3 { margin: 0; line-height: 1.12; text-wrap: balance; letter-spacing: -.015em; }
p { margin: 0; }
[hidden] { display: none !important; }
kbd, code, .mono { font-family: var(--mono); font-size: .9em; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: .05em .4em;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
  text-align: center;
  line-height: 1.4;
}
.wrap {
  width: 100%; max-width: var(--max); margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--ink); color: var(--ground); padding: 8px 14px; border-radius: 6px; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Line badge: the round letter disc used for every category */

.badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  background: var(--c);
  color: var(--on);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
}
.code {
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .02em;
}

/* Header */

.site-head { border-bottom: 1px solid var(--rule); background: var(--ground); }
.site-head .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand svg { width: 28px; height: 28px; }
.lines-nav { display: flex; gap: 4px; margin-left: 8px; }
.lines-nav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.lines-nav a:hover { background: color-mix(in oklab, var(--c) 14%, transparent); color: var(--ink); }
.lines-nav a[aria-current="true"] { background: color-mix(in oklab, var(--c) 18%, transparent); color: var(--ink); }
.lines-nav .badge { font-size: .78rem; }
.head-end { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.clock { font-family: var(--mono); font-size: .92rem; color: var(--ink-2); white-space: nowrap; }
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.theme-toggle:hover { border-color: var(--rule-strong); color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

@media (max-width: 900px) {
  .lines-nav .label { display: none; }
  .lines-nav a { padding: 6px; }
}
@media (max-width: 640px) {
  .site-head .wrap { flex-wrap: wrap; gap: 0 12px; min-height: 56px; }
  .lines-nav {
    order: 3; flex: 1 0 100%; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter) 10px;
    overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  }
  .lines-nav::-webkit-scrollbar { display: none; }
  .lines-nav a { flex: none; padding: 6px 12px 6px 6px; min-height: 44px; background: var(--surface); border: 1px solid var(--rule); }
  .lines-nav .label { display: inline; }
  .clock { display: none; }
  .theme-toggle { width: 44px; height: 44px; }
}

/* Front page: intro and search */

.intro { padding-block: clamp(36px, 6vw, 72px) clamp(28px, 4vw, 44px); }
.intro .wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px 56px; align-items: end; }
.intro h1 { font-size: clamp(2.2rem, 1.4rem + 3.2vw, 4.1rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.02; }
.intro p { margin-top: 16px; max-width: 44ch; font-size: 1.12rem; color: var(--ink-2); }

.finder { position: relative; }
.finder label { display: block; font-weight: 700; margin-bottom: 8px; }
.finder-field { position: relative; }
.finder-field svg { position: absolute; left: 18px; top: 50%; translate: 0 -50%; width: 22px; height: 22px; color: var(--ink-3); pointer-events: none; }
.finder input {
  width: 100%;
  height: 64px;
  padding: 0 64px 0 54px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 1.15rem var(--sans);
  box-shadow: var(--shadow);
  transition: box-shadow .25s var(--ease);
}
.finder input::placeholder { color: var(--ink-3); }
.finder input:focus { outline: none; box-shadow: var(--shadow), 0 0 0 4px color-mix(in oklab, var(--focus) 30%, transparent); }
.finder input::-webkit-search-cancel-button { display: none; }
.finder-field kbd { position: absolute; right: 20px; top: 50%; translate: 0 -50%; }
.finder-status { margin-top: 10px; min-height: 1.55em; font-size: .92rem; color: var(--ink-3); }

@media (max-width: 860px) {
  .intro .wrap { grid-template-columns: 1fr; gap: 24px; }
  .finder-field kbd { display: none; }
  .finder input { padding-right: 20px; }
}
@media (max-width: 640px) {
  .intro { padding-block: 28px 12px; }
  .tool-head { padding-top: 20px; }
  .line-strip { margin-top: 20px; }
}

/* Front page: the line map */

.map { padding-bottom: clamp(48px, 7vw, 96px); }
.map .wrap { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.map .wrap::before { content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter); height: 2px; background: var(--ink); }
.line { padding: 22px 24px 8px; border-right: 1px solid var(--rule); scroll-margin-top: 16px; }
.line:first-child { padding-left: 0; }
.line:nth-child(4) { border-right: 0; padding-right: 0; }
.line-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.line-head .badge { font-size: 1.15rem; }
.line-head h2 { font-size: 1.3rem; font-weight: 800; }
.line-head .count { margin-left: auto; font-size: .85rem; color: var(--ink-3); }

.stops { list-style: none; margin: 0; padding: 0; position: relative; }
.stops li { position: relative; }
/* the rail */
.stops li::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 8px;
  background: var(--c);
  transition: opacity .3s var(--ease);
}
.stops li:first-child::before { top: 20px; border-radius: 4px 4px 0 0; }
.stops li:last-child::before { bottom: calc(100% - 20px); border-radius: 0 0 4px 4px; }

.stop {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  column-gap: 14px;
  padding: 9px 10px 13px 0;
  text-decoration: none;
  border-radius: 8px;
  transition: opacity .3s var(--ease);
}
.stop::before {   /* station dot */
  content: "";
  grid-row: 1 / span 2;
  width: 22px; height: 22px;
  margin: 1px 0 0 4px;
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--ink);
  position: relative;
  z-index: 1;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), scale .3s var(--ease);
}
.stop-name { font-weight: 700; font-size: 1.05rem; line-height: 1.35; }
.stop-desc { grid-column: 2 / span 2; font-size: .9rem; line-height: 1.4; color: var(--ink-2); }
.stop .code { align-self: start; margin-top: 3px; }
.stop:hover .stop-name { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 2px; }
.stop:hover::before, .stop.is-active::before { background: var(--c); border-color: var(--ink); scale: 1.12; }
.stop.is-active { background: color-mix(in oklab, var(--c) 12%, transparent); }
.stop:focus-visible { outline-offset: 0; }

/* search filtering: the route lights up, the rest recedes */
.map.is-filtering .stops li::before { opacity: .22; }
.map.is-filtering .stop:not(.is-match) { opacity: .28; }
.map.is-filtering .stop.is-match::before { background: var(--c); }
.map-empty { display: none; grid-column: 1 / -1; padding: 20px 0 0; color: var(--ink-2); }
.map.is-empty .map-empty { display: block; }

@media (max-width: 1100px) {
  .map .wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line:nth-child(2) { border-right: 0; padding-right: 0; }
  .line:nth-child(3) { padding-left: 0; border-top: 1px solid var(--rule); }
  .line:nth-child(4) { border-top: 1px solid var(--rule); }
}
@media (max-width: 640px) {
  .map .wrap { grid-template-columns: 1fr; }
  .line, .line:nth-child(n) { padding-inline: 0; border-right: 0; }
  .line + .line { border-top: 1px solid var(--rule); }
}

/* Tool pages */

.tool-head {
  background: color-mix(in oklab, var(--c) 13%, var(--ground));
  border-bottom: 1px solid color-mix(in oklab, var(--c) 30%, var(--ground));
  padding-block: clamp(24px, 4vw, 40px) 0;
}
.tool-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.tool-title .badge { font-size: 1.5rem; }
.tool-title h1 { font-size: clamp(2rem, 1.5rem + 2vw, 3rem); font-weight: 800; letter-spacing: -.03em; }
.tool-title .code { font-size: .95rem; color: var(--ink-2); }
.tool-lede { margin-top: 10px; max-width: 60ch; font-size: 1.08rem; color: var(--ink-2); }

/* the line strip: where this tool sits on its line */
.line-strip { margin-top: 28px; overflow-x: auto; scrollbar-width: none; }
.line-strip::-webkit-scrollbar { display: none; }
@media (max-width: 640px) {
  .line-strip { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); mask-image: linear-gradient(90deg, transparent, #000 14px, #000 85%, transparent); }
  .tool-title { gap: 12px; }
  .tool-title .badge { font-size: 1.15rem; }
  .tool-lede { font-size: 1rem; }
  .panel { padding: 14px; border-radius: 14px; }
}
.line-strip ol { list-style: none; margin: 0; padding: 0 0 18px; display: flex; min-width: max-content; }
.line-strip li { position: relative; padding-right: 36px; }
.line-strip li::before {
  content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 6px; background: var(--c);
}
.line-strip li:last-child { padding-right: 0; }
.line-strip li:last-child::before { right: auto; width: 20px; }
.line-strip a, .line-strip span { position: relative; display: flex; flex-direction: column; gap: 8px; font-size: .88rem; color: var(--ink-2); text-decoration: none; }
.line-strip a::before, .line-strip span::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 4px solid var(--ink);
  box-sizing: border-box;
}
.line-strip a:hover { color: var(--ink); text-decoration: underline; }
.line-strip [aria-current="page"] { color: var(--ink); font-weight: 700; }
.line-strip [aria-current="page"]::before { background: var(--c); }

.tool-body { padding-block: clamp(28px, 5vw, 56px) clamp(48px, 7vw, 88px); }
.tool-body .wrap { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
@media (max-width: 860px) { .tool-body .wrap { grid-template-columns: minmax(0, 1fr); } }
/* text-heavy tools: wide panel, notes in a narrow column, stacked below 1100px */
.tool-body.is-wide .wrap { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .tool-body.is-wide .wrap { grid-template-columns: minmax(0, 1fr) 336px; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.notes { max-width: 62ch; }
.notes h2 { font-size: 1.25rem; font-weight: 800; margin: 32px 0 10px; }
.notes h2:first-child { margin-top: 4px; }
.notes p, .notes li { color: var(--ink-2); }
.notes p + p { margin-top: 10px; }
.notes ul { padding-left: 1.2em; margin: 0; }
.keys { width: 100%; border-collapse: collapse; font-size: .95rem; }
.keys td { padding: 8px 0; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.keys td:first-child { width: 40%; }
.next-stop {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 32px;
  padding: 10px 16px 10px 10px; border: 1px solid var(--rule-strong); border-radius: 999px;
  text-decoration: none; font-weight: 700; background: var(--surface);
  transition: border-color .2s var(--ease), translate .3s var(--ease);
}
.next-stop:hover { border-color: var(--c); }
.next-stop:hover svg { translate: 3px 0; }
.next-stop svg { width: 18px; height: 18px; transition: translate .3s var(--ease); }
.next-stop small { white-space: nowrap; }
.next-stop small { font-weight: 400; color: var(--ink-3); font-size: .85rem; }

/* Buttons and inputs shared by tools */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 600 1rem var(--sans);
  cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), translate .1s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { translate: 0 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--c); border-color: var(--c); color: var(--on); }
.btn-primary:hover { background: color-mix(in oklab, var(--c) 86%, black); border-color: transparent; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: .95rem; }
.input {
  height: 48px; padding: 0 14px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 500 1.05rem var(--sans);
}
.input::placeholder, textarea::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklab, var(--focus) 28%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.error { color: var(--danger); font-size: .9rem; }

/* Ad slots: reserved space so ads never push content around.
   Paste the network's tag inside .ad-slot; while it is empty a quiet placeholder shows. */

.ad { display: grid; gap: 6px; justify-items: center; }
.ad-label { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.ad-slot { width: 100%; display: grid; place-items: center; overflow: hidden; }
.ad-slot:empty {
  border: 1px dashed var(--rule-strong); border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in oklab, var(--rule) 45%, transparent) 10px 11px);
}
.ad-banner .ad-slot { max-width: 728px; min-height: 90px; }
.ad-rect .ad-slot { max-width: 336px; min-height: 280px; }
.ad-page { padding-block: 0 clamp(40px, 6vw, 72px); }
@media (max-width: 760px) {
  .ad-banner .ad-slot { max-width: 336px; min-height: 100px; }
}

/* Footer */

.site-foot { border-top: 2px solid var(--ink); padding-block: 28px 36px; font-size: .92rem; color: var(--ink-2); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: center; }
.foot-lines { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; margin: 0; padding: 0; }
.foot-lines a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.foot-lines a:hover { text-decoration: underline; }
.foot-lines .badge { font-size: .7rem; }
.site-foot .fine { margin-left: auto; color: var(--ink-3); }
@media (max-width: 640px) { .site-foot .fine { margin-left: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
.notes-ad { margin-top: 40px; justify-items: start; }
@media (max-width: 860px) { .notes-ad { justify-items: center; } }
