/* The board's look, on water.css: a hue per card, numbers in the same pixel
   font as `ak quota board`, tick bars, and amber or red once an allowance
   runs out. */

*, *::before, *::after { box-sizing: border-box }

:root {
  --hue: #0969da;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --heat0: #ebedf0;
  --heat1: #aceebb;
  --heat2: #4ac26b;
  --heat3: #2da44e;
  --heat4: #116329;
  --cell: 13px;
  --action: #0969da;
  --on-action: #fff;
  --mono: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Neutral grey behind the pages, not water.css's blue-black, so the
   colourful cards and the green calendar sit on quiet ground. */
@media (prefers-color-scheme: dark) {
  :root {
    --background-body: #17191c;
    --background: #24272c;
    --background-alt: #1d2024;
    --border: #35393f;
    --text-main: #e2e4e7;
    --text-muted: #9ba1a9;
    --links: #58a6ff;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --heat0: #232830;
    --heat1: #0e4429;
    --heat2: #006d32;
    --heat3: #26a641;
    --heat4: #4ae168;
    --action: #2f81f7;
    --on-action: #fff;
  }
}

/* A card keeps its colour across reloads, hashed from its key as on the board. */
.hue-0 { --hue: #0969da }
.hue-1 { --hue: #8250df }
.hue-2 { --hue: #1a7f37 }
.hue-3 { --hue: #bf3989 }
.hue-4 { --hue: #0a7d8c }
.hue-5 { --hue: #953800 }

@media (prefers-color-scheme: dark) {
  .hue-0 { --hue: #58a6ff }
  .hue-1 { --hue: #a371f7 }
  .hue-2 { --hue: #3fb950 }
  .hue-3 { --hue: #db61a2 }
  .hue-4 { --hue: #39c5cf }
  .hue-5 { --hue: #f0883e }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: 'Avenir Next', Avenir, ui-sans-serif, system-ui, -apple-system,
    'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  max-width: 66rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
}
main { flex: 1 }

.mono, code, pre, .num { font-family: var(--mono); font-variant-numeric: tabular-nums }
.right { text-align: right }
.lede { color: var(--text-muted); font-size: 1.05rem; margin: .1rem 0 1.5rem }
.note { color: var(--text-muted); font-size: .82rem; margin: .35rem 0 }
.bad { color: var(--bad) }
.dim { color: var(--text-muted) }

/* Header: the brand, the pages as quiet tabs, and the way out. */
.logo { display: block; image-rendering: pixelated }
header.top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
header.top .brand { display: flex; align-items: center; font-weight: 700; letter-spacing: .01em }
header.top nav { display: flex; gap: .2rem; flex: 1 }
header.top nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: .2rem .65rem;
  border-radius: 6px;
  font-weight: 500;
}
header.top nav a:hover { color: var(--text-bright); background: var(--background) }
header.top nav a.on { color: var(--text-bright); font-weight: 600; background: var(--background) }
form.logout { margin: 0 }

/* The title, what the page is, and the page's own control on the right. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem }
.page-head .tabs { margin-top: .35rem }

/* A section heading with a rule to the right, as the TUI draws it. */
h1 { font-size: 1.65rem; font-weight: 550; letter-spacing: -.01em; margin: 0 0 .25rem }
/* The nav already names the page; the heading stays for a screen reader. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
h2 {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .02em;
  margin: 2.5rem 0 .6rem;
}
h2::after { content: ""; flex: 1; height: 1px; background: var(--border) }
.h2-note { font-weight: 400; font-size: .76rem; letter-spacing: 0; text-transform: none; color: var(--text-muted) }
h3 { font-size: .95rem; margin: 0 0 .8rem }

/* Cards: the board's, as a grid. */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem }
@media (max-width: 46rem) {
  .cards, .panels { grid-template-columns: 1fr }
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem 1.3rem;
  background: var(--background-alt);
}
.card-head { display: flex; align-items: baseline; gap: .5rem; font-size: 1.05rem }
.card-head .mark { color: var(--hue); font-size: .75rem }
.sub { color: var(--text-muted); font-size: .82rem; margin: .1rem 0 .5rem }
.card-foot { margin-top: auto; padding-top: .8rem; display: flex; justify-content: flex-end }
.spacer { flex: 1 }
/* The card is the link; its own controls sit above it. */
.card .open { position: absolute; inset: 0; border-radius: 10px }
.card .open:focus-visible { outline: 2px solid var(--action); outline-offset: -2px }
.card:has(.open:hover) { border-color: var(--text-muted) }
.card-foot { position: relative; z-index: 1 }
.card-head .when { color: var(--text-muted); font-size: .78rem; font-variant-numeric: tabular-nums }
.targets { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .2rem }
.targets .go { font-size: .82rem; color: var(--text-main); overflow-wrap: break-word }

/* One allowance: name and reset left, the share used as a pixel number
   right, a tick bar under them. */
.meter {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: .75rem;
  align-items: end;
  margin-top: .55rem;
}
.meter-name { display: flex; align-items: baseline; gap: .5rem; font-size: .9rem }
.meter-name .when { color: var(--text-muted); font-size: .78rem }
.value { display: flex; align-items: flex-end; gap: .15rem; color: var(--hue); line-height: 1 }
.pix { height: 1rem; width: auto; fill: currentColor; shape-rendering: crispEdges }
.pct { font-size: .7rem; color: var(--text-muted); line-height: 1 }
.meter.high .value { color: var(--warn) }
.meter.spent .value { color: var(--bad) }

.ticks { grid-column: 1 / -1; position: relative; height: .5rem; margin-top: .45rem }
.ticks::before, .ticks::after { content: ""; position: absolute; inset: 0 }
.ticks::before { background: repeating-linear-gradient(90deg, var(--border) 0 2px, transparent 2px 5px) }
.ticks::after { width: var(--fill); background: repeating-linear-gradient(90deg, var(--hue) 0 2px, transparent 2px 5px) }
.meter.high .ticks::after { background: repeating-linear-gradient(90deg, var(--warn) 0 2px, transparent 2px 5px) }
.meter.spent .ticks::after { background: repeating-linear-gradient(90deg, var(--bad) 0 2px, transparent 2px 5px) }

/* A form is behind a +, so the page shows its information first. The + is a
   pill, the same shape as the chips in the tables it sits under. */
details.add {
  display: block;
  margin: 1.5rem 0 0;
  padding: 0;
  border-radius: 0;
  background: none;
}
details.add > summary {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  list-style: none;
  margin: 0;
  padding: .38rem .9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--background-alt);
  color: var(--text-main);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
details.add > summary::-webkit-details-marker { display: none }
details.add > summary::before {
  content: "+";
  font-family: var(--mono);
  font-weight: 700;
  color: var(--links);
}
details.add[open] > summary::before { content: "−" }
details.add > summary:hover { border-color: var(--links); color: var(--text-bright) }
details.add[open] > summary { margin-bottom: 1.1rem }

/* Panels hold forms; the gate is a login page on its own. */
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start }
.panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  background: var(--background-alt);
}
.panel.narrow { max-width: 34rem }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; align-items: start }
/* Forms: one control look through the pages; the select's arrow is drawn
   with gradients because the CSP refuses water.css's data: URI. */
.stack { display: flex; flex-direction: column; gap: .8rem; margin: 0 }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: var(--text-muted) }
.stack input, .stack select, .stack textarea { margin: 0 }
.stack > button, .panel button:not(.link) {
  align-self: flex-start;
  padding: .4rem 1.2rem;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  cursor: pointer;
}
.stack > button:hover, .panel button:not(.link):hover { filter: brightness(1.1) }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem }
.checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem }
label.check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  color: var(--text-main);
}
label.check input, .checks input[type='checkbox'] { width: auto; margin: 0 }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .9rem; margin: 0 }
legend { color: var(--text-muted); font-size: .82rem; padding: 0 .3rem }
input:not([type='checkbox']):not([type='radio']),
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .6rem;
  background: var(--background);
  color: var(--text-main);
  font: inherit;
  font-size: .92rem;
}
textarea { resize: vertical; min-height: 5rem }
select {
  appearance: none;
  padding-right: 2.1rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.15rem) calc(50% + 1px),
    calc(100% - .8rem) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 1px;
}
input[type='checkbox'], input[type='radio'] { width: 15px; height: 15px; margin: 0; accent-color: var(--action) }
::placeholder { color: var(--text-muted); opacity: 1 }
button.link {
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--links);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
button.link:hover { text-decoration: underline }
button.link.bad { color: var(--bad) }

/* The gate: what AK is on the left, the way in on the right. */
.gate {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 3.5rem;
  align-items: center;
  max-width: 58rem;
  margin: 0 auto;
  min-height: 74vh;
}
.gate-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.6rem }
.gate-note { color: var(--text-muted); font-size: .85rem }
.hero h1 { font-size: 2.1rem; line-height: 1.18; margin: 0 0 .9rem; letter-spacing: -.01em }
.hero p { color: var(--text-muted); font-size: 1rem; margin: 0 }
.hero ul { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; gap: .55rem; font-size: .9rem }
.hero li { display: flex; align-items: baseline; gap: .55rem }
.hero li::before { content: "■"; color: var(--action); font-size: .55rem }
.gate .panel { padding: 1.8rem 1.8rem 1.9rem }
.gate .panel h2 { display: block; font-size: 1.25rem; margin: 0 0 .35rem }
.gate .panel h2::after { content: none }
.gate .lede { font-size: .9rem; margin: 0 0 1.3rem }
.gate .stack { gap: 1rem }
.gate .stack > button { width: 100%; align-self: stretch; padding: .6rem 1.2rem; font-size: 1rem }
.gate .flash { font-size: .85rem; margin-bottom: .9rem }
.gate .hint {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem;
  margin: 1.3rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .78rem;
}
.gate .hint code { font-size: .8rem; color: var(--text-main) }
.gate pre { margin: 0; padding: .7rem .9rem; border-radius: 8px; background: var(--background); font-size: .85rem }

@media (max-width: 50rem) {
  .gate { grid-template-columns: 1fr; gap: 2rem; min-height: 0; padding-top: 2rem }
  .hero h1 { font-size: 1.7rem }
}

/* Tiles: one headline number each. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; margin: 1.25rem 0 0 }
.tile {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .95rem 1.1rem;
  background: var(--background-alt);
}
.tile-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted) }
.tile-value { display: flex; align-items: flex-end; gap: .25rem; line-height: 1.2; padding: .1rem 0 }
.tile-value .pix { height: 1.55rem; color: var(--text-bright) }
.tile-unit { font-size: 1.05rem; color: var(--text-muted); margin-bottom: .1rem }
.tile-note { font-size: .78rem; color: var(--text-muted) }

/* Usage a day: GitHub's year, one column a week, one row a weekday, the
   months above the columns they start. */
.heat { display: flex; gap: .5rem; align-items: flex-start }
.heat-days {
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: 3px;
  align-items: center;
  padding-top: 1.15rem;
  color: var(--text-muted);
  font-size: .66rem;
  text-align: right;
}
.heat-main { min-width: 0; display: flex; flex-direction: column; gap: .35rem; overflow-x: auto }
.heat-months {
  display: grid;
  gap: 3px;
  font-size: .66rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.heat-months span { white-space: nowrap }
.heat-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cell);
  grid-template-rows: repeat(7, var(--cell));
  gap: 3px;
}
.heat-cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: 0;
  background: var(--heat0);
  display: inline-block;
  transition: filter .1s linear;
}
.heat-grid .heat-cell:hover { filter: brightness(1.35) }
.heat-cell.l-1 { visibility: hidden }
.heat-cell.l1 { background: var(--heat1) }
.heat-cell.l2 { background: var(--heat2) }
.heat-cell.l3 { background: var(--heat3) }
.heat-cell.l4 { background: var(--heat4) }
.heat-legend { display: flex; align-items: center; gap: .45rem; margin: .15rem 0 0; font-size: .78rem; color: var(--text-muted) }
.heat-legend .value { display: flex; align-items: flex-end; gap: .15rem; color: var(--ok) }
.heat-legend .value .pix { height: 1.3rem }
.heat-legend .unit { font-size: .9rem; color: var(--ok); margin-bottom: .1rem }
.heat-legend .note { margin: 0 }
.heat-legend .spacer { flex: 1 }
/* Tabs above a page's own content. */
.tabs { display: flex; gap: .2rem }
.tabs a { color: var(--text-muted); text-decoration: none; padding: .15rem .6rem; border-radius: 6px; font-size: .88rem }
.tabs a.on { color: var(--text-bright); font-weight: 600; background: var(--background) }

/* Tables: faint headings, a hairline under every row, numbers on the right. */
table.grid { table-layout: auto; border-collapse: collapse; width: 100%; margin: .5rem 0 0; font-size: .88rem }
table.grid th {
  padding: .5rem .6rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
table.grid td { padding: .62rem .6rem; border-bottom: 1px solid var(--background); vertical-align: baseline }
table.grid tbody tr:nth-child(even) { background: none }
table.grid tbody tr:hover { background: var(--background-alt) }
table.routes th:nth-child(1) { width: 9rem }
table.routes th:nth-child(2) { width: 6rem }
table.routes th:nth-child(3) { width: 8rem }
table.routes th:last-child { width: 5rem }
td.bar-cell { width: 8rem }
.bar { height: .45rem; width: var(--w); min-width: 3px; background: var(--links); border-radius: 999px; opacity: .7 }

.chip {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 .55rem;
  margin: 0 .25rem .15rem 0;
  font-family: var(--mono);
  font-size: .78rem;
}

/* A token is shown once, so it gets a box of its own. */
.issued {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  border: 1px solid var(--links);
  border-radius: 10px;
  padding: .9rem 1rem;
  margin-bottom: 1rem;
  background: var(--background-alt);
}
.issued code { font-size: .95rem; word-break: break-all; user-select: all }
.select { user-select: all }

.foot {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .78rem;
}
.foot .mono { font-size: .78rem }
.foot a { color: var(--text-muted); text-decoration: none }
.foot a:hover { color: var(--text-bright); text-decoration: underline }
.flash { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .85rem; background: var(--background-alt) }
.flash.bad { border-color: var(--bad); color: var(--bad) }
.empty { color: var(--text-muted); border: 1px dashed var(--border); border-radius: 10px; padding: 1rem; text-align: center }

@media (max-width: 40rem) {
  body { padding: 0 1rem 3rem }
  .logo { display: block; image-rendering: pixelated }
header.top { flex-wrap: wrap; gap: .5rem 1rem }
  header.top nav { order: 3; width: 100% }
  td.bar-cell { display: none }
}
