/* --- Knapper --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 550;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; }

.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--ghost   { background: none; border-color: var(--border); }
.btn--block   { width: 100%; }

/* --- Kort og lister --- */

.card {
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stack { display: grid; gap: var(--sp-3); }

/* --- Tomme tilstander --- */

.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-dim);
}
.empty__title { margin: 0 0 var(--sp-2); color: var(--text); font-size: 1.05rem; font-weight: 600; }
.empty__body  { margin: 0; }

/* --- Innlogging --- */

.login {
  display: grid;
  gap: var(--sp-5);
  place-content: center;
  justify-items: center;
  min-height: 70dvh;
  text-align: center;
}
.login__icon { width: 96px; height: 96px; border-radius: 22%; }
.login__lead { max-width: 30ch; margin: 0; color: var(--text-dim); }

/* --- Toasts --- */

.toasts {
  position: fixed;
  inset: auto var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)) var(--sp-4);
  z-index: 20;
  display: grid;
  gap: var(--sp-2);
  justify-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.toast--error { background: var(--danger); color: #fff; }

.toast__action {
  flex: none;
  min-height: 32px;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.18);
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* --- Laster --- */

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Trykkbare kort (samlingsliste) --- */

.card--tap {
  display: grid;
  gap: var(--sp-1);
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.card--tap:active { background: var(--surface-2); }
.card__title { font-size: 1.05rem; font-weight: 600; }
.card__meta  { color: var(--text-dim); font-size: 0.9rem; }

/* --- Søk og sortering --- */

.search {
  position: sticky;
  top: calc(var(--appbar-h) + env(safe-area-inset-top));
  z-index: 5;
  display: flex;
  gap: var(--sp-2);
  margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg);
}

.search__input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.search__sort {
  min-height: var(--tap);
  padding: 0 var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.listcount { margin: 0 0 var(--sp-2); color: var(--text-dim); font-size: 0.85rem; }

/* --- Spillrad --- */

.game {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.game:active { background: var(--surface-2); }

.game__thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.game__thumb img { width: 100%; height: 100%; object-fit: cover; }
.game__placeholder { font-size: 24px; opacity: 0.55; }

.game__body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.game__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game__meta { color: var(--text-dim); font-size: 0.85rem; }

.game__rating {
  flex: none;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* --- Detaljvisning --- */

.detail__image {
  width: 100%;
  max-height: 40dvh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.detail__title { font-size: 1.3rem; }
.detail__meta  { margin: var(--sp-2) 0 0; color: var(--text-dim); }

.row { display: flex; justify-content: space-between; gap: var(--sp-3); }
.row__label { color: var(--text-dim); }
.row__value { text-align: right; }

/* --- Rating 1-10 --- */

.rating__head { display: flex; justify-content: space-between; align-items: baseline; }
.rating__mine { font-weight: 650; font-variant-numeric: tabular-nums; }

.rating {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-2);
}

.rating__btn {
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.rating__btn--on {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
.rating__hint { margin: 0; color: var(--text-dim); font-size: 0.85rem; }

/* --- Skjema --- */

.field { display: grid; gap: var(--sp-1); }
.field__label { color: var(--text-dim); font-size: 0.9rem; }
.field__input {
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* --- Dialog --- */

.dialog {
  width: min(420px, calc(100vw - 2 * var(--sp-4)));
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }

/* --- Flytende handlingsknapp --- */

.fab {
  position: fixed;
  right: var(--sp-4);
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 8;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 28px;
  line-height: 1;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.fab:active { transform: translateY(1px); }

/* --- Diverse --- */

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger-text { color: var(--danger); }
.error { color: var(--danger); }

/* --- Bunnavigasjon --- */

.tab {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: var(--sp-2) 0;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 0.72rem;
  cursor: pointer;
}
.tab--on { color: var(--accent); font-weight: 650; }
.tab__icon { font-size: 20px; line-height: 1; }

/* --- Filterchips --- */

.filters {
  display: flex;
  gap: var(--sp-2);
  margin: 0 calc(var(--sp-4) * -1) var(--sp-3);
  padding: 0 var(--sp-4);
  overflow-x: auto;
  /* Filterraden kan rulle sidelengs; siden skal aldri gjøre det. */
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  min-height: 36px;
  max-width: 60vw;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.chip--on {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.chip--clear { border-style: dashed; color: var(--text-dim); }

/* --- Steder --- */

.place {
  display: flex;
  align-items: stretch;
  gap: var(--sp-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.place__main {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
  padding: var(--sp-3);
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.place__main:active { background: var(--surface-2); }
.place__name  { font-weight: 600; }
.place__count { color: var(--text-dim); font-size: 0.85rem; }

.place__actions { display: flex; align-items: center; padding-right: var(--sp-2); }

.iconbtn {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 17px;
  cursor: pointer;
}
.iconbtn:active { background: var(--surface-2); }

/* --- Skjema- og tekstdetaljer --- */

.formsection {
  margin: var(--sp-3) 0 calc(var(--sp-2) * -1);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lead { margin: 0 0 var(--sp-3); color: var(--text-dim); }
.hint { margin: 0; color: var(--text-dim); font-size: 0.85rem; }
.hint a { color: var(--accent); }

.card__heading {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game__place { color: var(--text-dim); font-size: 0.8rem; }

/* FAB og toasts må løftes over bunnavigasjonen når den er synlig, ellers
   ligger de delvis bak den. */
body:has(.tabs:not([hidden])) .fab {
  bottom: calc(var(--tabs-h) + var(--sp-3) + env(safe-area-inset-bottom));
}
body:has(.tabs:not([hidden])) .toasts {
  bottom: calc(var(--tabs-h) + var(--sp-3) + env(safe-area-inset-bottom));
}

/* --- Tilstandsnivåer i innstillinger --- */

.level {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--border);
}
.level:last-of-type { border-bottom: 0; }
.level__label { flex: 1; min-width: 0; }
.level__badge {
  flex: none;
  padding: 2px var(--sp-2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.72rem;
}

/* --- Store valgknapper (legg til spill) --- */

.bigchoice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bigchoice:active { background: var(--surface-2); }
.bigchoice__icon { flex: none; font-size: 26px; line-height: 1.2; }
.bigchoice__body { display: grid; gap: var(--sp-1); }
.bigchoice__title { font-size: 1.05rem; font-weight: 650; }
.bigchoice__desc { color: var(--text-dim); font-size: 0.9rem; }

/* --- Treff i BGG-søket --- */

.game__add {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 20px;
}
.game--busy { opacity: 0.5; pointer-events: none; }

/* --- Medlemmer --- */

.member {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
.member:last-child { border-bottom: 0; }

.member__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-2);
  font-weight: 650;
}
.member__avatar img { width: 100%; height: 100%; object-fit: cover; }

.member__body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.member__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member__meta { color: var(--text-dim); font-size: 0.85rem; }

.member__actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }

textarea.field__input { padding: var(--sp-2) var(--sp-3); line-height: 1.4; resize: vertical; }

/* --- Deltakervelger --- */

.people__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }

.people { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Store trykkflater: dette fylles ut ved spillbordet, ofte med én hånd. */
.person {
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.person--on {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
}

/* --- Spillelogg --- */

.monthhead {
  margin: var(--sp-4) 0 calc(var(--sp-1) * -1);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.monthhead:first-child { margin-top: 0; }

.play {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.play__thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.play__thumb img { width: 100%; height: 100%; object-fit: cover; }

.play__body { display: grid; gap: var(--sp-1); flex: 1; min-width: 0; }
.play__top { display: flex; justify-content: space-between; gap: var(--sp-2); align-items: baseline; }
.play__game { font-weight: 600; }
.play__date { flex: none; color: var(--text-dim); font-size: 0.8rem; }

.play__people { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); font-size: 0.88rem; }
.play__player { color: var(--text-dim); }
.play__winner { font-weight: 650; }

.play__notes {
  margin: var(--sp-1) 0 0;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-style: italic;
}

/* --- Statistikk --- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: var(--sp-2);
}

.stat {
  display: grid;
  gap: 2px;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}
.stat__value {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  /* Lange beløp skal krympe, ikke sprenge ruten. */
  overflow-wrap: anywhere;
}
.stat__label { color: var(--text-dim); font-size: 0.75rem; }
