/* ==========================================================================
   FDP calculator — the abtx.ca look (same as the weather site's beta):
   pure black, white type, the logo's grey light-to-dark fade,
   Archivo Black / Space Grotesk / Space Mono, thin lines, square corners, no shadows.
   Dark is the default; [data-theme="light"] on <html> switches to light.
   ========================================================================== */
:root {
  --fade-start: #efefef; --fade-end: #212121;          /* same fade as the abtx.ca logo */
  --grad: linear-gradient(var(--fade-start), var(--fade-end));
  --ink: #ffffff; --ink-2: #a3a3a3; --ink-3: #8a8a8a;
  --bg: #000000; --card: #0e0e0e; --rule: #2b2b2b; --block: #1a1a1a; --block-rule: #333333;
  --warn: #f5b454; --warn-bg: #231806;
  --bad: #ff6b6b; --bad-bg: #2a0e0e;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, Consolas, monospace;
  --display: "Archivo Black", "Space Grotesk", sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  /* cursor (js/cursor.js): dot colour, swell colour, trail colour */
  --cur: #ffffff; --accent-l: #efefef; --accent-r: #efefef; --sky: #e6e6e6;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --fade-start: #111111; --fade-end: #9a9a9a;          /* the logo's fade, readable on white */
  --ink: #000000; --ink-2: #555555; --ink-3: #6b6b6b;
  --bg: #ffffff; --card: #f5f5f5; --rule: #dedede; --block: #ececec; --block-rule: #d0d0d0;
  --warn: #9a5b00; --warn-bg: #fbefdd;
  --bad: #c0262d; --bad-bg: #fcecec;
  --cur: #000000; --accent-l: #212121; --accent-r: #212121; --sky: #3a3a3a;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--bg); scrollbar-width: none; }      /* the page still scrolls; the bar is hidden */
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar: logo + title left, dark/light switch right ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 8px max(clamp(16px, 2.4vw, 32px), env(safe-area-inset-right)) 8px max(clamp(16px, 2.4vw, 32px), env(safe-area-inset-left));
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand h1 { margin: 0; font: 400 22px/1.1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.brand h1 span { color: var(--ink-2); }

/* logo + pop-up (js/skin.js draws the dots) */
.logo-wrap { position: relative; display: flex; flex: none; }
.abtx-logo { display: grid; place-items: center; width: 40px; height: 44px; margin: -4px 0 -4px -8px; padding: 0; border: 0; background: none; cursor: pointer; }
.abtx-logo .logo { width: 28px; height: auto; display: block; overflow: visible; }
.abtx-logo .dot { transform-box: fill-box; transform-origin: center; }
.abtx-pop {
  position: absolute; top: calc(100% + 10px); left: -8px; z-index: 40; width: max-content; max-width: min(320px, calc(100vw - 32px));
  padding: 14px 16px; background: color-mix(in oklab, var(--bg) 94%, transparent); border: 1px solid var(--rule);
  font: 12px/1.7 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  transform-origin: 16px 0; animation: abtx-pop-in .35s var(--ease);
}
@keyframes abtx-pop-in { from { opacity: 0; transform: scale(.92) translateY(-4px); } to { opacity: 1; transform: none; } }
.abtx-pop p { margin: 0 0 12px; color: var(--ink-2); }
.abtx-pop a {
  display: inline-flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 14px; border: 1px solid var(--ink-3);
  color: var(--ink); text-decoration: none; letter-spacing: .14em; white-space: nowrap; transition: background-color .25s, color .25s, border-color .25s;
}
.abtx-pop a svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s var(--ease); }
.abtx-pop a:hover, .abtx-pop a:focus-visible { background: var(--ink); color: var(--bg); border-color: var(--ink); outline: none; }
.abtx-pop a:hover svg { transform: translate(3px, -3px); }

/* ---------- sliders (js/skin.js): a solid block under the chosen option; the text flips colour under it.
   Built white-on-black; in light mode the whole control is inverted so it reads black-on-white. ---------- */
.seg, .theme-switch .track { position: relative; isolation: isolate; display: inline-flex; gap: 4px; padding: 0; background: #000; touch-action: none; }
.seg { outline: 1px solid #2b2b2b; }
.seg button {
  position: relative; z-index: 1; min-height: 30px; padding: 0 14px; border: 0; border-radius: 0;
  background: transparent; color: #fff; mix-blend-mode: difference; opacity: .7; cursor: pointer;
  font: 500 12px var(--sans); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; transition: opacity .3s;
}
.seg button.on, .seg button:hover { opacity: 1; }
.seg-pill, .theme-switch .thumb {
  position: absolute; z-index: 0; top: 0; bottom: 0; left: 0; width: 0; background: #fff; pointer-events: none;
  transition: transform .35s var(--ease), width .35s var(--ease);
}
.dragging .seg-pill, .dragging .thumb { transition: none; }
.seg.dragging, .seg.dragging button, .track.dragging, .track.dragging .opt { cursor: grabbing; }
.theme-switch { flex: none; display: inline-flex; align-items: center; min-height: 44px; margin: -4px 0; padding: 0; border: 0; background: none; cursor: pointer; }
.theme-switch .track { height: 36px; }
.theme-switch .opt { position: relative; z-index: 1; display: grid; place-items: center; width: 38px; height: 36px; mix-blend-mode: difference; opacity: .85; }
.theme-switch .ico { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-switch:hover .opt { opacity: 1; }
:root[data-theme="light"] .seg, :root[data-theme="light"] .theme-switch .track { filter: invert(1); }

/* theme: everything switches in the same frame, the page cross-fades as a whole */
html.theme-snap *, html.theme-snap *::before, html.theme-snap *::after { transition: none !important; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }

/* ---------- the two sections: side by side when wide, stacked when narrow ---------- */
.cols {
  flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px;
  padding: 28px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}
.col { display: grid; gap: 0; align-content: start; min-width: 0; max-width: 640px; width: 100%; margin: 0 auto; }
@media (min-width: 1000px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; padding-left: clamp(24px, 2.4vw, 32px); padding-right: clamp(24px, 2.4vw, 32px); }
  .col { max-width: none; margin: 0; }
  .col:first-child { padding-right: clamp(24px, 2.6vw, 40px); }
  .col + .col { padding-left: clamp(24px, 2.6vw, 40px); border-left: 1px solid var(--rule); }
}
.col-title { margin: 0 0 12px; font: 400 26px/1.1 var(--display); letter-spacing: .04em; text-transform: uppercase; }

/* ---------- panels ---------- */
.panel { border: 1px solid var(--rule); padding: 14px; display: grid; gap: 14px; min-width: 0; }
/* boxes stacked in a column join into one: the lower box drops its top line, so each join is a single divider */
.col .panel + .panel { border-top: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
label.lab { font: 11px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
input[type="text"] {
  width: 100%; min-width: 0; font: 400 22px var(--mono); letter-spacing: .04em; color: var(--ink);
  background: transparent; border: 1px solid var(--rule); border-radius: 0; padding: 11px 14px;
  -webkit-appearance: none; appearance: none; transition: border-color .25s;
}
input[type="text"]:hover { border-color: var(--ink-3); }
input[type="text"]::placeholder { color: var(--ink-3); opacity: .55; }
input[type="text"]:focus { outline: none; border-color: var(--ink); }
input[type="text"][aria-invalid="true"] { border-color: var(--bad); background: var(--bad-bg); }
.req { margin: 0; font: 700 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--bad); }
.hint { position: relative; margin: 0; font-size: 14px; color: var(--ink-2); }
.hint:empty { display: none; }
.hint.bad { color: var(--bad); }
.sample { margin: 0; font-size: 13px; color: var(--ink-2); }

.switches { display: flex; flex-wrap: wrap; gap: 12px 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
.sw { min-width: 0; }
.sw-box { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; margin: 0; }

/* result blocks (max FDP, next start): a dimmed block — dark grey in dark mode, light grey in light mode */
.result, .next { padding: 0; gap: 0; overflow: hidden; }
.headline { background: var(--block); color: var(--ink); padding: 14px; display: grid; gap: 4px; }
.headline .k { font: 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.headline .v { min-height: 1em; font: 400 60px/1 var(--display); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.headline .v small { font: 700 20px var(--mono); margin-left: 8px; color: var(--ink-2); letter-spacing: .04em; }
.headline .s { font-size: 14px; color: var(--ink-2); }
.headline .s:empty { display: none; }
/* +1 (next day): same size and grey as the time-zone letters beside it */
.day { font: 700 12px var(--mono); color: var(--ink-2); margin-left: 4px; letter-spacing: .04em; }
.headline .v .day { font-size: 20px; margin-left: 8px; }
.headline .s .day { font: inherit; color: inherit; margin-left: 4px; }

/* FDP End, local and Zulu, inside the max FDP block; the UTC note under them */
.ends { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--block-rule); }
.end { display: grid; gap: 2px; min-width: 0; }
.end .t { min-height: 1.05em; font: 400 34px/1.05 var(--display); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.end .t small { font: 700 13px var(--mono); margin-left: 6px; color: var(--ink-2); letter-spacing: .04em; }
.end .t .day { font-size: 13px; margin-left: 6px; }
.offset { margin-top: 8px; font-size: 13px; color: var(--ink-2); }

/* table row: the chosen cell is the solid block */
.rule { gap: 10px; }
.rule h2 { margin: 0; font: 400 17px/1.3 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.rule .meta { margin: 0; font-size: 14px; color: var(--ink-2); }
/* the chosen cell is a solid block (.cell-pill, js/motion.js) that slides between cells like the sliders;
   without the script the chosen cell is simply filled */
.cells { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cell { position: relative; z-index: 1; border: 1px solid var(--rule); padding: 10px; display: grid; gap: 2px; color: var(--ink); }
.cell .c { font-size: 12px; color: inherit; opacity: .6; }
.cell .hrs { font: 400 20px var(--mono); }
.cell.sel { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.cell.sel .c { opacity: .75; font-weight: 500; }
.has-pill .cell.sel { background: transparent; }
.cell-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; }   /* cut to the boxes' shapes by js/motion.js */
.cell-pill { position: absolute; left: 0; top: 0; background: var(--ink); }

.ctl { padding: 14px; display: grid; gap: 14px; border-bottom: 1px solid var(--rule); }
.detail { padding: 12px 14px 14px; display: grid; gap: 10px; }
.err { padding: 14px; color: var(--ink-2); font-size: 14px; }   /* the "enter the FDP Start first" note: same grey as the text above it */
.detail .err { padding: 0; }
.basis { margin: 0; font-size: 14px; color: var(--ink-2); max-width: 65ch; }
.flag { border: 1px solid var(--warn); background: var(--warn-bg); color: var(--warn); padding: 10px 12px; font-size: 14px; font-weight: 500; margin: 0; }
.flag.illegal { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.flag.banner { font: 700 13px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
noscript .flag { margin: 16px; }

.foot { border-top: 1px solid var(--rule); padding: 8px max(clamp(16px, 2.4vw, 32px), env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(clamp(16px, 2.4vw, 32px), env(safe-area-inset-left)); }
.foot p { margin: 0; font: 11px/1.6 var(--sans); letter-spacing: .02em; color: var(--ink-2); }

/* ---------- abtx.ca cursor: dot + faint trail (mouse/trackpad only; js/cursor.js) ---------- */
html.own-cursor, html.own-cursor * { cursor: none !important; }
html.own-cursor :is(input[type=text], textarea, [contenteditable]) { cursor: text !important; }
.cur-trail { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2147483646; }
.cur-dot { position: fixed; left: 0; top: 0; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--cur); pointer-events: none; z-index: 2147483647;
  transition: scale .22s var(--ease), background-color .22s, opacity .2s; }
.cur-dot.hot { scale: 2.1; }
.cur-dot.off { opacity: 0 !important; }

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .brand { gap: 12px; }
  .brand h1 { font-size: 17px; }
  .col-title { font-size: 22px; }
  .headline .v { font-size: 52px; }
  .end .t { font-size: 26px; }
  .seg button { padding: 0 12px; font-size: 11px; letter-spacing: .1em; }
}
@media (prefers-reduced-motion: reduce) {
  .seg-pill, .theme-switch .thumb, .seg button { transition: none; }
}

/* ---------- motion (js/motion.js) ---------- */
/* opening: the page stays hidden until the animation starts; while the lines fly in, the real borders are hidden */
html.intro body { opacity: 0; }
html.intro-lines :is(.topbar, .foot, .panel, .ctl, .switches, .cell, .col, input[type="text"]) { border-color: transparent !important; }
.intro-layer { position: absolute; left: 0; top: 0; overflow: hidden; pointer-events: none; z-index: 60; }
.intro-line { position: absolute; }
.intro-line .tip { position: absolute; top: -1px; bottom: -1px; width: 80px; pointer-events: none; }
.intro-line .tip.l { right: 0; background: linear-gradient(90deg, transparent, var(--ink)); }
.intro-line .tip.r { left: 0; background: linear-gradient(270deg, transparent, var(--ink)); }
/* changing digits: the new digit fades in while the old one fades out over it, in place */
.dg { position: relative; display: inline-block; }
.dg .o { position: absolute; left: 0; top: 0; pointer-events: none; }
