:root {
  --bg: #fafafa;
  --fg: #111;
  --muted: #999;
  --line: #e5e5e5;
  --on: #111;
  --hl: #eee;
  --danger: #c0392b;
  --cell: 22px;
}

/* Dark: system setting unless the switch says light, or the switch says dark (theme.js) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111;
    --fg: #eee;
    --muted: #666;
    --line: #2a2a2a;
    --on: #eee;
    --hl: #1e1e1e;
    --danger: #e0685a;
  }
}
:root[data-theme="dark"] {
  --bg: #111;
  --fg: #eee;
  --muted: #666;
  --line: #2a2a2a;
  --on: #eee;
  --hl: #1e1e1e;
  --danger: #e0685a;
}

* { box-sizing: border-box; }

/* Keep space for the scrollbar, so the page does not shift when the picker makes it taller */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  padding: 40px 16px;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Shrink to the grid width, centered */
.wrap { width: max-content; max-width: 100%; margin: 0 auto; }

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

h1 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: .04em; text-transform: uppercase; }
#stats { margin: 0 0 0 auto; color: var(--muted); }

.scroll { overflow-x: auto; }

table { border-collapse: collapse; }

th {
  font-weight: 400;
  color: var(--muted);
  padding: 0 4px;
}

thead th {
  height: 44px;
  vertical-align: bottom;
  padding-bottom: 4px;
  width: var(--cell);
  font-size: 11px;
  position: sticky;
  top: 0;
  background: var(--bg);
}

.flag { display: block; font-size: 12px; line-height: 1; margin-bottom: 4px; }

tbody th { text-align: right; padding-right: 12px; }
/* Year at the top of its row, like the coins (taller rows: fitRowHeights in app.js) */
#grid tbody th { vertical-align: top; }

td { padding: 2px; }

/* Grid: 2 px between cells, in rows and columns */
#grid td { padding: 1px; }
#grid thead th { padding-left: 1px; padding-right: 1px; }

/* All view: cells as narrow as a group of 3 coins, so the columns sit closer */
#grid.all { --cell-w: 16px; }
#grid.all .cell,
#grid.all td.na::after,
#grid.all thead th { width: var(--cell-w); }
/* Row height from fitRowHeights() in app.js: 22 px, taller only for rows with more coins */
#grid.all .cell,
#grid.all td.na::after { height: var(--cell-h, 22px); }

.cell {
  display: block;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.cell:hover { border-color: var(--muted); }
.cell.on { background: var(--on); border-color: var(--on); }

td.na::after {
  content: '';
  display: block;
  width: var(--cell);
  height: var(--cell);
}

.year, .country {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.year:hover, .country:hover { color: var(--fg); }

tr.sel { background: var(--hl); }
tr.sel th { color: var(--fg); font-weight: 600; }
tr.sel .cell { border-color: var(--muted); }
tr.sel .cell.on { border-color: var(--on); }

.col { background: var(--hl); }
th.col { color: var(--fg); font-weight: 600; }
td.col .cell { border-color: var(--muted); }
td.col .cell.on { border-color: var(--on); }

/* Row and column cross: the target cell */
tr.sel td.col .cell { border-color: var(--fg); border-width: 2px; }

/* All view: each cell shows its coins as small thumbnails (decision 6) */
#grid.all .cell {
  display: grid;
  place-items: start; /* coins from the top left, so columns and rows line up */
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font: inherit;
}
#grid.all .cell:hover { box-shadow: inset 0 0 0 1px var(--muted); }
#grid.all tr.sel td.col .cell,
#grid.all .cell.open { box-shadow: inset 0 0 0 2px var(--fg); }
#grid.all .cell:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; }
/* No coins in the catalog */
#grid.all .cell:empty::before { content: '–'; }

#grid.all .coin-slots {
  display: grid;
  /* 3 × N full-size coins; the row grows to fit N (fitRowHeights) */
  grid-template-columns: repeat(3, 4.25px);
  gap: 1px;
}
/* Missing: a plain grey dot. No filter or opacity: on ~4500 coins they freeze each repaint for 0.4–1 s */
#grid.all .mini-coin {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--line);
}
/* Owned: the national-side photo; the ECB common face covers coins with no photo.
   No outline (2026-11-27). Normal mode: a checked coin (same design owned) looks the same */
#grid.all .mini-coin.owned,
#grid.all .mini-coin.checked {
  background: var(--img, none) center / cover, url("euro-icon.jpg") var(--face) center / 800% 100%;
}

/* Grid and picker side by side; picker stays in view while scrolling */
.layout { display: flex; gap: 40px; align-items: flex-start; }

/* Picker coins are drawn to scale: 2 € = 112 px (decision 14). Keep in sync with PICKER_MAX in app.js */
#picker {
  --coin-max: 112px;
  --cell: var(--coin-max);
  background: var(--bg); /* backdrop for the coin image blend */
  position: sticky;
  top: 24px;
  min-width: 400px;
  flex: none;
}

#picker h2 { font-size: 13px; font-weight: 600; margin: 0 0 16px; }
#picker .hint { color: var(--muted); margin: 0; }
#picker tbody th { text-align: left; padding: 0 6px 4px; }
#picker td { text-align: center; }
/* Center each scaled coin in a 2 € box, so value labels line up */
#picker .cell { margin: calc((var(--coin-max) - var(--cell)) / 2) auto; }
/* Fixed column width (a 2 € coin + padding), so coins do not shift between cells */
#picker td { padding: 2px 6px; width: calc(var(--coin-max) + 12px); }

/* Coin value under each circle */
/* Padding, not margin: a margin would merge with the coin's centering margin, so rows with a 2 € coin were 3 px taller */
.val { display: block; font-size: 10px; line-height: 1; padding: 3px 0; color: var(--muted); }

/* Gap between mints */
#picker tbody tr:first-child > * { padding-top: 10px; }

/* Coin exists only in sets: dashed ring with a 1 px gap, like the selected ring */
.cell.set { outline: 1px dashed var(--muted); outline-offset: 1px; }
.cell.set:not(.on) { border-color: transparent; }

@media (max-width: 1160px) {
  .layout { flex-direction: column; }
  #picker { position: relative; width: auto; }
}

/* Coin popover: the only place that adds or removes a coin */
.pop {
  position: absolute;
  z-index: 10;
  transform: translateX(-50%);
  padding: 20px 24px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
  white-space: nowrap;
}

.pop[hidden] { display: none; }
.pop p { margin: 0 0 16px; }
.pop .name { margin-bottom: 6px; } /* the coin name sits close to its button */
.pop .name + .added { margin-top: 0; }
.pop .added { margin-top: -4px; color: var(--muted); font-size: 11px; }
.pop .same-design { margin: -8px 0 12px; color: var(--muted); font-size: 11px; text-align: center; }
.pop .same-design a { color: inherit; }
.pop .same-design a:hover { color: var(--fg); }

.action {
  font: inherit;
  padding: 4px 10px;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 4px;
  cursor: pointer;
}

.action.remove {
  color: var(--danger);
  background: transparent;
  border-color: var(--danger);
}

/* Selected coin: a ring with a 1 px gap, so the coin image stays whole */
#picker .cell.open { outline: 1px solid var(--fg); outline-offset: 1px; }

/* Coin thumbnails: the image is a layer (::before), so fading it keeps rings and outlines sharp */
.cell.img {
  position: relative;
  border-color: transparent;
}
.cell.img::before {
  content: '';
  position: absolute;
  inset: 0;
  /* Whole photo, no round mask: the coin edge details stay visible.
     Multiply drops the white photo background on the light page. */
  background: var(--img) center / contain no-repeat;
  mix-blend-mode: multiply;
  filter: grayscale(1);
  opacity: .35;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cell.img::before { mix-blend-mode: normal; border-radius: 50%; }
}
:root[data-theme="dark"] .cell.img::before { mix-blend-mode: normal; border-radius: 50%; }
.cell.img:hover::before { opacity: .7; }
.cell.img.on { background: none; border-color: var(--on); }
.cell.img.on::before { filter: none; opacity: 1; }
/* Picker: missing coins keep their color, so a coin is easy to find by its look; only faded */
#picker .cell.img::before { filter: none; }

/* 2x the first version (2026-11-27): the photo is the point of the popover */
.pop img { display: block; width: 240px; height: 240px; margin: 0 auto 16px; border-radius: 50%; }
/* The photo copy that flies between the coin and the popover (openPop / closePop in app.js) */
.pop-ghost { position: fixed; z-index: 11; margin: 0; border-radius: 50%; pointer-events: none; will-change: transform, opacity; }


/* Mode switch: Normal · Nightmare, the active one dark (like the theme switch) */
#mode { display: flex; gap: 2px; margin-left: 16px; color: var(--muted); }
#mode button { font: inherit; padding: 0 4px; color: var(--muted); background: none; border: 0; cursor: pointer; }
#mode button:hover, #mode button[aria-pressed="true"] { color: var(--fg); }

/* Same design (.same): missing, but I own another coin of the same design. Picker: a ≈ badge at the bottom right, both modes.
   Checked (.checked, Normal mode): counts as owned. Grid: looks owned (the rule with .owned above); picker: photo in full color */
#picker .cell.img.checked::before { opacity: 1; }
#picker .cell.same { position: relative; }
#picker .cell.same::after {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: 1px solid var(--fg);
  border-radius: 10px;
  background: var(--fg);
  color: var(--bg);
  font: 11px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  content: '≈';
}

/* Theme switch: three small icons, the active one dark */
#theme { display: flex; gap: 2px; margin-left: 16px; }
#theme button {
  font: inherit;
  padding: 0 4px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}
#theme button:hover, #theme button[aria-pressed="true"] { color: var(--fg); }

/* Source credit for the ECB coin images (ADR 0006) */
footer { margin-top: 32px; font-size: 11px; color: var(--muted); }
footer a { color: inherit; }

/* Link to the history page, next to the title */
header .nav { margin-left: 16px; color: var(--muted); text-decoration: none; }
header .nav:hover { color: var(--fg); }

/* History page: days newest first, one line per coin */
.history { width: min(640px, 100%); }
.history h1 a { color: inherit; text-decoration: none; }
.history section { margin-bottom: 24px; }
.history h2 { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.history ul { list-style: none; margin: 0; padding: 0; }
.history li a { display: flex; align-items: center; gap: 12px; padding: 3px 0; color: inherit; text-decoration: none; }
.history li a:hover > span:first-of-type { text-decoration: underline; }
.history li img, .history li .noimg { width: 42px; height: 42px; flex: none; border-radius: 50%; }
.history li .noimg { border: 1px solid var(--line); }
.history .muted { color: var(--muted); }

/* Changes are only in this browser: the server could not save collection.json (ADR 0009) */
#stats[data-disk="offline"]::after { content: ' · not saved to disk'; color: var(--danger); }
