/* fuel.simonyou.dev — the cheapest petrol near you, and where the cycle is.
   One screen: controls, then the cheapest and a list on the left, a map on the right, the cycle below. */
:root {
  --font-sans: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: clamp(1rem, 3vw, 2.5rem);
}
:root[data-theme="day"] {
  color-scheme: light;
  --bg: #f2f0ea; --surface: #faf9f5; --ink: #1c1a16; --dim: #6a655c;
  --line: rgba(28, 26, 22, 0.12); --line-strong: rgba(28, 26, 22, 0.3);
  --accent: #b8410e; --cheap: #1d8a6b; --dear: #c0392b; --mid: #d3a017;
}
:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #12151a; --surface: #1a1f26; --ink: #e9ebee; --dim: #98a0aa;
  --line: rgba(233, 235, 238, 0.12); --line-strong: rgba(233, 235, 238, 0.3);
  --accent: #f08a4f; --cheap: #4fcf9f; --dear: #f0655a; --mid: #e6c14a;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: clamp(15px, 0.4vw + 10px, 18px); line-height: 1.45; font-variant-ligatures: none; transition: background-color 700ms ease, color 700ms ease; }
body { margin: 0; height: 100dvh; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; font-variation-settings: "opsz" 14; }
body > *, main > *, .side > * { min-width: 0; }
/* explicit rows: the discounts panel is display:none most of the time and must not shift the others */
.top { grid-row: 1; } .controls { grid-row: 2; } .discounts { grid-row: 3; } main { grid-row: 4; } .history { grid-row: 5; } .foot { grid-row: 6; }
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--line-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
p, h1 { margin: 0; }
ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem var(--gutter); font-family: var(--font-mono); font-size: 0.8rem; }
.brand { text-decoration: none; font-weight: 500; }
.top nav { display: flex; align-items: center; gap: 1.1rem; }
.top nav a { color: var(--dim); text-decoration: none; }
.top nav a:hover { color: var(--ink); }
.theme { color: var(--dim); background: transparent; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.22rem 0.75rem; cursor: pointer; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.1rem var(--gutter) 0.8rem; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg button { background: transparent; border: 0; border-radius: 999px; padding: 0.28rem 0.8rem; cursor: pointer; font-family: var(--font-mono); font-size: 0.78rem; color: var(--dim); }
.seg button.is-on { background: var(--ink); color: var(--bg); }
.seg:empty { display: none; }
.disc-btn { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.3rem 0.85rem; cursor: pointer; }
.disc-btn.is-on, .disc-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.discounts { margin: 0 var(--gutter) 0.8rem; display: grid; gap: 0.6rem; }
.disc-head { font-size: 0.85rem; color: var(--dim); line-height: 1.4; }
.disc-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.5rem; }
.disc-card { display: grid; gap: 0.45rem; background: var(--surface); border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.7rem 0.8rem; }
.disc-card.is-on { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.disc-card.is-off .stepper, .disc-card.is-off .brands-row { opacity: 0.5; }
.disc-top { display: flex; align-items: center; gap: 0.6rem; }
.disc-top input[type="checkbox"] { width: 1.25rem; height: 1.25rem; flex: none; accent-color: var(--accent); }
.disc-card .name { flex: 1; min-width: 0; font: inherit; font-weight: 600; font-size: 0.95rem; color: inherit; background: transparent; border: 0; border-bottom: 1px dashed transparent; padding: 0.1rem 0; }
.disc-card .name:focus { outline: none; border-bottom-color: var(--line-strong); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; width: max-content; }
.stepper button { width: 2.6rem; height: 2.2rem; border: 0; background: transparent; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink); }
.stepper button:hover { background: var(--bg); }
.stepper .cents { width: 3.2rem; text-align: center; font-family: var(--font-mono); font-size: 1rem; font-weight: 500; border: 0; background: transparent; color: var(--ink); -moz-appearance: textfield; appearance: textfield; padding: 0; }
.stepper .cents::-webkit-outer-spin-button, .stepper .cents::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { font-family: var(--font-mono); font-size: 0.72rem; color: var(--dim); padding-right: 0.7rem; }
.brands-row { display: grid; gap: 0.1rem; }
.brands-row .lbl { font-family: var(--font-mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.disc-card .brands { font: inherit; font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 0.4rem; padding: 0.35rem 0.5rem; min-width: 0; width: 100%; }
.disc-card .brands:focus { outline: none; border-color: var(--line-strong); }
.disc-card.costco { align-content: start; }
.disc-card .sub { font-size: 0.8rem; color: var(--dim); line-height: 1.35; }
.disc-add { font: inherit; font-size: 0.9rem; color: var(--dim); background: transparent; border: 1px dashed var(--line-strong); border-radius: 0.6rem; padding: 0.7rem 0.8rem; cursor: pointer; min-height: 4rem; }
.disc-add:hover { color: var(--ink); border-color: var(--ink); }
.disc-remove { justify-self: end; font: inherit; font-size: 0.72rem; color: var(--dim); background: transparent; border: 0; cursor: pointer; text-decoration: underline; padding: 0; }
.row .b { grid-column: 2 / 4; font-family: var(--font-mono); font-size: 0.68rem; color: var(--dim); }
.row .b s { opacity: 0.7; }
.board { font-family: var(--font-mono); font-size: 0.76rem; color: var(--dim); margin: -0.1rem 0 0.35rem; }
.status { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--dim); margin-left: auto; }
.live { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--dim); flex: none; }
.live.is-on { background: var(--cheap); }

main { display: grid; grid-template-columns: minmax(20rem, 27rem) minmax(0, 1fr); gap: 1rem; padding: 0 var(--gutter); min-height: 0; }
.side { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 0.6rem; min-height: 0; }
.hero { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 0.7rem; padding: 0.9rem 1.1rem 0.9rem; }
.eyebrow { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.price { font-size: clamp(2.6rem, 4.5vw, 4rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1; margin: 0.2rem 0 0.25rem; font-variation-settings: "opsz" 96; }
.price .unit { font-size: 0.4em; font-weight: 500; color: var(--dim); margin-left: 0.2em; letter-spacing: 0; }
.where { font-size: 0.95rem; line-height: 1.35; }
.where b { font-weight: 600; }
.cycle { margin-top: 0.5rem; font-size: 0.85rem; color: var(--dim); line-height: 1.35; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.cycle b { color: var(--ink); font-weight: 600; }
.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.list { overflow-y: auto; min-height: 0; display: grid; gap: 0.3rem; align-content: start; padding-right: 0.2rem; scrollbar-width: thin; }
.row { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) auto; gap: 0.1rem 0.7rem; align-items: center; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.45rem 0.7rem; cursor: pointer; }
.row:hover { border-color: var(--line-strong); }
.row.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.row .p { grid-row: 1 / 3; font-family: var(--font-mono); font-size: 1.05rem; font-weight: 500; color: #fff; background: var(--tone); border-radius: 0.4rem; text-align: center; padding: 0.35rem 0; }
.row .n { font-weight: 600; font-size: 0.92rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .d { font-family: var(--font-mono); font-size: 0.7rem; color: var(--dim); white-space: nowrap; }
.row .s { grid-column: 2 / 4; font-size: 0.78rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s .closed { color: var(--dear); }

.map-wrap { position: relative; min-height: 0; border-radius: 0.7rem; overflow: hidden; border: 1px solid var(--line); }
.map { position: absolute; inset: 0; background: var(--surface); }
.legend { position: absolute; left: 0.7rem; bottom: 0.7rem; z-index: 500; display: flex; align-items: center; gap: 0.4rem; font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink); background: color-mix(in srgb, var(--surface) 88%, transparent); border-radius: 999px; padding: 0.25rem 0.7rem; }
.lg-bar { width: 5rem; height: 0.5rem; border-radius: 999px; background: linear-gradient(90deg, var(--cheap), var(--mid), var(--dear)); }
[hidden] { display: none !important; }
.maplibregl-map { font-family: var(--font-sans); }
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 0.5rem; padding: 0.6rem 1.6rem 0.6rem 0.8rem; font-size: 0.85rem; line-height: 1.35; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.maplibregl-popup-content b { font-family: var(--font-mono); font-size: 1rem; }
.maplibregl-popup-close-button { color: var(--dim); font-size: 1.1rem; padding: 0 0.4rem; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.maplibregl-ctrl-attrib { font-size: 0.6rem; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--dim); }
.maplibregl-ctrl-attrib a { color: var(--dim); }
.maplibregl-ctrl-group { background: var(--surface) !important; }
.maplibregl-ctrl-group button { background: transparent !important; }
:root[data-theme="night"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.you { width: 14px; height: 14px; border-radius: 50%; background: #2b6cb0; border: 3px solid #fff; box-shadow: 0 0 0 2px #2b6cb0; }

.history { display: grid; grid-template-rows: auto 4.6rem auto; gap: 0.25rem; padding: 0.7rem var(--gutter) 0; }
.hist-axis { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.7rem; color: var(--dim); }
.hist { width: 100%; height: 100%; display: block; overflow: visible; }
.hist .med { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.hist .min { fill: none; stroke: var(--cheap); stroke-width: 1.2; stroke-dasharray: 3 3; }
.hist .base { stroke: var(--line); }
.hist .dot { fill: var(--accent); }

.foot { padding: 0.5rem var(--gutter) 0.9rem; font-size: 0.72rem; color: var(--dim); line-height: 1.45; }
.foot a { color: var(--dim); }

@media (max-width: 900px) {
  body { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto auto auto auto; }
  main { grid-template-columns: 1fr; }
  .list { max-height: 40vh; }
  .map-wrap { height: 50vh; }
  .status { margin-left: 0; width: 100%; }
  .controls { overflow-x: hidden; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; }
  .top nav a { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
