/* bierrating stylesheet. One file, no build step; fonts and scripts are bundled (no external requests).
   Layout of this file: fonts, theme tokens (light and dark), base, layout, components, pages.
   The order matters: a later rule of equal weight wins. Search for "---- " to jump between sections. */

/* ---- Fonts ---- */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist.981055687324.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono.b058178d7f30.woff2") format("woff2");
}

/* ---- Theme tokens ----
   Brand: beer yellow with near-black ink. On yellow the ink is 11:1; --muted is still 6:1, so no text on the
   page needs opacity tricks. Dark applies when the browser prefers it unless the user switched to light, or when
   the user switched to dark (theme.js sets data-theme). */
:root {
  color-scheme: light;
  --font-text: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --bg: #facc15;
  --card: #fff8d6;
  --field: #fffdf0;
  --text: #1f1d14;
  --muted: #5a5330;
  --border: #1f1d14;
  --line: #d9b90f;
  --accent: #1f1d14;
  --on-accent: #facc15;
  --good: #1e6b2e;
  --bad: #a3271d;
  --warn: #8a5300;
  --hover: #fdeb8a;
  --heat-pos: 30, 107, 46;
  --heat-neg: 163, 39, 29;
  --radius: 1rem;
  --toast-gap: 0.625rem; /* between the edge of a toast, its icon, its text and its x: all the same */
  --icon-line: 1.4px; /* the line width of every icon, whatever its size (the sprite does not scale it) */
  --control-h: 2.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14120a;
    --card: #1e1b0f;
    --field: #14120a;
    --text: #f6efcf;
    --muted: #b3aa7d;
    --border: #5b5326;
    --line: #35301a;
    --accent: #facc15;
    --on-accent: #14120a;
    --good: #7fd18f;
    --bad: #ff8d83;
    --warn: #fbbf24;
    --hover: #2c2812;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14120a;
  --card: #1e1b0f;
  --field: #14120a;
  --text: #f6efcf;
  --muted: #b3aa7d;
  --border: #5b5326;
  --line: #35301a;
  --accent: #facc15;
  --on-accent: #14120a;
  --good: #7fd18f;
  --bad: #ff8d83;
  --warn: #fbbf24;
  --hover: #2c2812;
}

/* ---- Base ---- */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
}

h2 {
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

p {
  margin: 0 0 0.75rem;
}

.mono,
td.num,
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- Layout ---- */
.wrap {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.site-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.logo {
  font: 600 clamp(1.5rem, 5vw, 2.25rem) var(--font-mono);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.nav a,
.nav button {
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.nav a:hover,
.nav button:hover,
.nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--on-accent);
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 2rem;
  font-size: 0.875rem;
}

/* ---- Language switch ---- */
.lang {
  display: inline-flex;
  gap: 0.25rem;
}

.lang button {
  min-height: 2rem;
  padding: 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.lang button[aria-current="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---- Components ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
}

.grid-2 > .card {
  margin-bottom: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.pills .label {
  color: var(--muted);
  font-size: 0.875rem;
  margin-right: 0.25rem;
}

.pill {
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
}

.pill:hover {
  background: var(--hover);
}

.pill[aria-current="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.5rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--hover);
}

td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}

td.rank {
  width: 2.5rem;
  color: var(--muted);
}

.bar {
  display: inline-block;
  width: 3.5rem;
  height: 0.5rem;
  border-radius: 99px;
  background: var(--line);
  vertical-align: middle;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.btn,
button.btn {
  min-height: var(--control-h);
  padding: 0 1rem;
  border: 1px solid var(--accent);
  border-radius: 0.6rem;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 1rem var(--font-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.15);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
  min-height: var(--control-h);
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--field);
  color: var(--text);
  font: inherit;
  max-width: 100%;
}

textarea {
  width: 100%;
  min-height: 8rem;
  font-family: var(--font-mono);
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

form.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

/* ---- Icons (Lucide, static/icons.svg) ---- */
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
}

/* ---- Notices: what the server says. With JavaScript toasts.js turns each into a toast; without it they stay here ---- */
.notices:empty {
  display: none;
}

.form-error,
.form-warn,
.form-ok {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.form-error {
  color: var(--bad);
}

.form-warn {
  color: var(--warn);
}

.form-ok {
  color: var(--good);
}

.mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  vertical-align: middle;
  border: 0;
  border-radius: 0.25rem;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.mini:hover {
  color: var(--text);
}

.mini .icon {
  width: 0.875rem;
  height: 0.875rem;
  vertical-align: 0;
}

/* ---- Toasts: a message is shown at the bottom of the window; a success fades away, errors stay (ported from dero) ---- */
.toasts {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 1rem;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0 1rem;
  pointer-events: none; /* only the toasts themselves take clicks */
}

.toasts .toast {
  display: flex;
  align-items: center;
  gap: calc(var(--toast-gap) - 0.045rem); /* (the letters of the text have a little space of their own at both ends) */
  font-size: 0.875rem;
  line-height: 1.5;
  pointer-events: auto;
  max-width: min(100%, 38rem);
  margin: 0;
  padding: 0.5rem var(--toast-gap); /* the same room on every side of the content */
  border: 1px solid color-mix(in srgb, currentColor 45%, var(--card)); /* its text colour, muted (green, amber, red) */
  border-radius: 0.5rem;
  background: var(--card);
  box-shadow: 0 0 16px color-mix(in srgb, currentColor 26%, transparent); /* a soft glow in the colour of the kind */
  animation: toast-in 0.14s ease-out;
}

.toasts .toast.leaving {
  animation: toast-out 0.14s ease-in forwards;
}

.toasts .toast > span {
  min-width: 0;
}

.toasts .toast.bump {
  animation: toast-bump 0.25s ease-out;
}

.toast-close {
  position: relative;
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  margin: 0;
} /* just the x itself, cropped to its lines: the edge of the toast is as far from it as from the text */

.toast-close::before {
  content: "";
  position: absolute;
  inset: -0.5rem;
} /* (a bigger target to click) */

.toast-close .icon {
  width: 100%;
  height: 100%;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.625rem);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(0.375rem);
  }
}

@keyframes toast-bump {
  50% {
    transform: scale(1.025);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toasts .toast,
  .toasts .toast.leaving {
    animation-duration: 0.01s;
  }
}

.chip {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  margin: 0.1rem 0.25rem 0.1rem 0;
}

.tiles {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  margin-bottom: 1rem;
}

.tile {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
}

.tile b {
  display: block;
  font: 600 1.6rem var(--font-mono);
}

.tile span {
  font-size: 0.8rem;
  color: var(--muted);
}

.chart {
  position: relative;
  height: 14rem;
}

.heat {
  text-align: center;
  background: rgba(var(--rgb, var(--heat-pos)), calc(var(--a, 0) * 0.55));
}

.empty {
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
}

.ok {
  color: var(--good);
}

.no {
  color: var(--bad);
}

/* ---- Pages: beer ---- */
.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.hero .rank {
  font: 600 2.5rem var(--font-mono);
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 0.8rem;
  padding: 0.25rem 0.9rem;
}

.hero .score {
  font: 700 clamp(3rem, 12vw, 4.5rem) var(--font-mono);
  line-height: 1;
}

/* ---- Pages: console and live ---- */
.grid-entry input[type="number"] {
  width: 4rem;
  text-align: center;
}

.grid-entry td {
  white-space: nowrap;
}

.live-head {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

.qr {
  max-width: 13rem;
  color: var(--text);
}

.qr svg {
  width: 100%;
  height: auto;
  background: #fff;
  color: #000;
  border-radius: 0.5rem;
}

.code-big {
  font: 700 clamp(5rem, 30vw, 9rem) var(--font-mono);
  line-height: 1;
  text-align: center;
}

.joincode {
  font: 700 2rem var(--font-mono);
  letter-spacing: 0.2em;
}

.state {
  display: inline-block;
  padding: 0 0.6rem;
  border-radius: 99px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---- Pages: phone ---- */
.phone .wrap {
  max-width: 28rem;
}

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

.scale input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scale label {
  display: grid;
  place-items: center;
  min-height: 3.5rem;
  border: 2px solid var(--border);
  border-radius: 0.8rem;
  background: var(--field);
  color: var(--text);
  font: 700 1.5rem var(--font-mono);
  cursor: pointer;
}

.scale input:checked + label {
  background: var(--accent);
  color: var(--on-accent);
}

.scale input:focus-visible + label {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

.phone select {
  width: 100%;
  min-height: 3rem;
}

.phone .btn {
  width: 100%;
  min-height: 3.25rem;
  margin-top: 0.75rem;
}

.names {
  display: grid;
  gap: 0.5rem;
}

.names button {
  min-height: 3.25rem;
  font-size: 1.1rem;
}
