/* Costle: a plain statistical report. */
:root {
  --bg: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #666660;
  --rule: #D9D9D4;
  --rule-strong: #1A1A1A;
  --band: #F4F4F1;
  --accent: #1B3A6B;
  --good: #1F7A3E;
  --good-bg: #E8F3EB;
  --bad: #A8321E;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --col: 600px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* ---------- masthead ---------- */
.masthead {
  max-width: var(--col);
  margin: 0 auto;
  padding: 20px 16px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--rule-strong);
  padding-bottom: 10px;
}
.wordmark { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 18px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link {
  font: 500 14px var(--sans);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: none;
  border-radius: 3px;
}
.nav-link:hover { color: var(--ink); background: var(--band); }
.nav-link[aria-current="page"] { color: var(--ink); font-weight: 600; }
.auth { position: relative; }
#auth-btn[hidden] { display: none; }
body[data-signed-in="yes"] #auth-btn { color: var(--accent); }
.auth-menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--rule-strong); border-radius: 3px; padding: 10px 12px; min-width: 220px; z-index: 30; text-align: left; }
.auth-menu[hidden] { display: none; }
.auth-name { font-weight: 600; font-size: 14px; }
.auth-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 8px; }
.nav-link:focus-visible, .btn:focus-visible, .unit-btn:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- report ---------- */
.report { max-width: var(--col); margin: 0 auto; padding: 22px 16px 60px; }
.report-head { margin-bottom: 18px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 2px; line-height: 1.25; }
.report-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13.5px; }
.report-question { margin: 12px 0 0; font-size: 15px; }

table { width: 100%; border-collapse: collapse; }
th { font-weight: 500; font-size: 12.5px; color: var(--muted); text-align: left; padding: 6px 0; border-bottom: 1px solid var(--rule-strong); }
td { padding: 8px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.num { text-align: right; }
.prices td.price { font-weight: 600; white-space: nowrap; padding-left: 16px; }
.prices tfoot td { border-top: 1px solid var(--rule-strong); border-bottom: 0; padding-top: 10px; }
.prices tfoot .price.hot { color: var(--bad); }
.prices tfoot .price.cool { color: var(--good); }

/* controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin: 14px 0 22px;
  font-size: 13.5px;
  color: var(--muted);
}
.ctl { display: flex; align-items: center; gap: 8px; }
#currency-select {
  font: 400 13.5px var(--sans);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 4px 6px;
  max-width: 220px;
}
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.unit-btn {
  font: 400 13px var(--sans);
  background: #fff;
  color: var(--muted);
  border: 0;
  padding: 4px 10px;
  cursor: pointer;
}
.unit-btn + .unit-btn { border-left: 1px solid var(--rule); }
.unit-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- guessing ---------- */
.guess-form { display: flex; gap: 8px; }
.guess-form[hidden] { display: none; }
.search { position: relative; flex: 1; }
#guess-input {
  width: 100%;
  font: 400 15px var(--sans);
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
}
#guess-input::placeholder { color: #9A9A94; }
#guess-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn {
  font: 500 14.5px var(--sans);
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 8px 16px;
  cursor: pointer;
}
.btn:hover { background: #142D54; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.copied { background: var(--good); border-color: var(--good); }

.suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  margin: 0; padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
}
.suggestions li { display: flex; align-items: center; gap: 8px; padding: 7px 11px; cursor: pointer; font-size: 14px; }
.suggestions li .sub { color: var(--muted); font-size: 12.5px; margin-left: auto; text-align: right; }
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: var(--band); }

.guesses-left { margin: 8px 0 14px; font-size: 13px; color: var(--muted); }

.guesses th:nth-child(3), .guesses td.dir { text-align: center; width: 64px; }
.guesses td.name { font-weight: 500; }
.guesses td.name .flag { margin-right: 6px; }
.guesses td.dist { white-space: nowrap; color: var(--muted); }
.guesses td.dir svg { width: 18px; height: 18px; vertical-align: middle; }
.guesses td.cost { font-size: 13.5px; }
.guesses td.cost.cheaper { color: var(--good); }
.guesses td.cost.pricier { color: var(--bad); }
.guesses td.cost.same, .guesses td.cost.unknown { color: var(--muted); }
.guesses td.pct { font-weight: 600; }
.guesses tr.correct td { background: var(--good-bg); }
.guesses tr.placeholder td { color: #B5B5AF; }
.guesses tr.print td { animation: print 260ms ease-out; }
@keyframes print { from { opacity: 0; } to { opacity: 1; } }

/* ---------- end of game ---------- */
.end-panel { margin-top: 22px; padding-top: 16px; border-top: 2px solid var(--rule-strong); }
.end-panel h2 { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.end-panel .answer { font-size: 16px; margin: 0; }
.end-panel .sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 12px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.answer-lines summary { cursor: pointer; font-size: 14px; color: var(--accent); }
.answer-lines table { margin-top: 8px; }
.answer-lines td { font-size: 13.5px; padding: 5px 0; }
.answer-photo { margin: 16px 0 0; }
.answer-photo[hidden] { display: none; }
.answer-photo img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; border: 1px solid var(--rule); }
.answer-photo figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.answer-about { margin: 10px 0 0; font-size: 14px; line-height: 1.55; }
.answer-photo a { color: var(--accent); }
.next-in { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

.foot-note { color: var(--muted); font-size: 12.5px; margin-top: 28px; border-top: 1px solid var(--rule); padding-top: 10px; }

/* ---------- dialogs ---------- */
.dialog { border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0; max-width: 440px; width: calc(100% - 32px); background: #fff; color: var(--ink); }
.dialog::backdrop { background: rgba(0,0,0,0.35); }
.dialog-body { padding: 22px 22px 18px; margin: 0; font-size: 14.5px; line-height: 1.5; }
.dialog-body h2 { margin: 0 0 10px; font-size: 18px; }
.dialog-body p { margin: 0 0 10px; }
.dialog-body ul { margin: 0 0 10px; padding-left: 20px; }
.dialog-body li { margin-bottom: 4px; }
.dialog-fine { color: var(--muted); font-size: 13px; }
.dialog-body .btn { margin-top: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-grid .n { font-size: 22px; font-weight: 600; display: block; }
.stat-grid .l { font-size: 12px; color: var(--muted); }
.dist-row { display: grid; grid-template-columns: 1.4em 1fr; gap: 8px; align-items: center; margin-bottom: 4px; font-size: 13px; }
.dist-bar { background: var(--rule); color: var(--ink); padding: 1px 6px; min-width: 1.6em; text-align: right; font-weight: 500; }
.dist-bar.today { background: var(--accent); color: #fff; }

@media (max-width: 520px) {
  body { font-size: 14px; }
  .guesses th:nth-child(4), .guesses td.cost { display: none; }
  .guesses td.name .cost-inline { display: block; font-size: 12.5px; font-weight: 400; }
  .guesses td.name .cost-inline.cheaper { color: var(--good); }
  .guesses td.name .cost-inline.pricier { color: var(--bad); }
  .guesses td.name .cost-inline.same, .guesses td.name .cost-inline.unknown { color: var(--muted); }
}
@media (min-width: 521px) { .cost-inline { display: none; } }
@media (prefers-reduced-motion: reduce) { .guesses tr.print td { animation: none; } }
