/* ============================================================
   BOARD GAMES DIGITAL — main stylesheet
   ============================================================ */

@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/fredoka-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
}

/* ---------- design tokens ---------- */
:root {
  --cream:       #E8F1FB;
  --cream-deep:  #CFE0F2;
  --surface:     #FFFFFF;
  --ink:         #14152E;
  --ink-soft:    #4F517A;
  --muted:       #8B8EA8;
  --hair:        #BFD4EA;

  --red:    #EB5757;
  --yellow: #F2B736;
  --green:  #1F9D74;
  --blue:   #3275DC;
  --pink:   #DB4A78;
  --purple: #6B5BE2;

  --shadow-card:
    0 0 0 1px rgba(20,21,46,0.06),
    0 1px 2px -1px rgba(20,21,46,0.08),
    0 8px 24px -10px rgba(20,21,46,0.15);

  --shadow-pop:
    0 0 0 1px rgba(20,21,46,0.08),
    0 2px 0 0 rgba(20,21,46,0.08),
    0 12px 32px -12px rgba(20,21,46,0.25);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --font-display: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background-color: #cfd9e4;
  background-image: url("../images/background-boardgamesdigital.jpg");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

img { max-width: 100%; display: block; }

.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 48px);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  top: -100px; left: 12px;
  z-index: 999;
  background: var(--ink);
  color: var(--cream);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: relative;
  padding-top: clamp(20px, 3vw, 36px);
  padding-bottom: clamp(24px, 4vw, 44px);
}

.top-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: clamp(16px, 2vw, 28px);
}
.cta-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue);
  color: #fff;
  border: 0;
  padding: 11px 18px 11px 16px;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.005em;
  box-shadow:
    0 0 0 1px rgba(20,21,46,0.06),
    0 2px 0 0 rgba(20,21,46,0.18),
    0 8px 18px -8px rgba(50,117,220,0.6);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.cta-add:hover {
  background: #2362c7;
  transform: translateY(-1px);
}
.cta-add:active { transform: translateY(0); }
.cta-plus {
  font-family: var(--font-display);
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1;
  margin-top: -2px;
}
@media (max-width: 420px) {
  .cta-add { font-size: 0.88rem; padding: 10px 14px; }
}

.display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  text-wrap: balance;
  max-width: 22ch;
}
.display .word {
  display: inline-block;
  margin-right: 0.18em;
}
.display .word-1 { color: var(--ink); }
.display .word-2 { color: var(--blue); }
.display .word-3 { color: var(--ink); }

.lede {
  font-size: clamp(1rem, 1.6vw, 1.1rem);
  line-height: 1.55;
  max-width: 62ch;
  margin: 0;
  color: var(--ink-soft);
}
.lede strong {
  color: var(--ink);
  background: rgba(242,183,54,0.55);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ============================================================
   CONTROLS
   ============================================================ */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: stretch;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
@media (max-width: 720px) {
  .controls { padding: 14px; gap: 12px; }
}

.search-wrap {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 16px;
  color: var(--muted);
  pointer-events: none;
}
#search {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 14px 16px 14px 48px;
  border: none;
  background: var(--cream);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--hair);
  color: var(--ink);
}
#search::placeholder { color: var(--muted); }
#search:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin: 0;
  border: 0;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.pill {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--cream);
  color: var(--ink-soft);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  box-shadow: inset 0 0 0 1px var(--hair);
}
.pill:hover { color: var(--ink); background: var(--cream-deep); }
.pill.is-active {
  background: var(--ink);
  color: var(--cream);
  box-shadow: 0 2px 0 0 rgba(20,21,46,0.15);
}
.pill[data-value="free"].is-active   { background: var(--green); }
.pill[data-value="paid"].is-active   { background: var(--blue); }
.pill[data-value="light"].is-active  { background: var(--green); }
.pill[data-value="medium"].is-active { background: var(--yellow); color: var(--ink); }
.pill[data-value="heavy"].is-active  { background: var(--red); }

.count-line {
  margin: 0 4px 16px;
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.count-line span { font-weight: 700; color: var(--ink); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 80px;
}
.table-wrap:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }

.games-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.games-table thead {
  background: var(--cream-deep);
}
.games-table th {
  text-align: left;
  padding: 0;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 2px solid var(--hair);
  white-space: nowrap;
}
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none; border: 0;
  font: inherit; color: inherit;
  padding: 16px 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.sort-btn:hover { color: var(--blue); }
.sort-btn .arrow {
  display: inline-block;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  opacity: 0.25;
  transition: opacity .15s, transform .15s;
}
.sort-btn[data-direction="asc"] .arrow,
.sort-btn[data-direction="desc"] .arrow {
  opacity: 1;
  color: var(--blue);
}
.sort-btn[data-direction="asc"] .arrow  { border-bottom: 6px solid currentColor; }
.sort-btn[data-direction="desc"] .arrow { border-top: 6px solid currentColor; }

.col-num   { text-align: right; }
.col-num .sort-btn { justify-content: flex-end; }
.col-rank, .col-weight, .col-price { width: 1%; }

.games-table tbody tr {
  cursor: pointer;
  transition: background .12s ease;
  border-bottom: 1px solid var(--hair);
}
.games-table tbody tr:last-child { border-bottom: 0; }
.games-table tbody tr:hover { background: var(--cream); }
.games-table tbody tr:focus-within { background: var(--cream); }

.games-table td {
  padding: 14px;
  vertical-align: middle;
}
.games-table td.col-num { text-align: right; }

/* rank cell — chunky display number */
.rank-num {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink);
}
.rank-num .hash {
  font-size: 0.85em;
  color: var(--muted);
  margin-right: 1px;
}

/* game name + arrow */
.game-name {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-wrap: balance;
}
.game-name::after {
  content: "↗";
  font-family: var(--font-display);
  color: var(--muted);
  transition: transform .15s ease, color .15s ease;
  font-size: 0.95em;
}
.games-table tbody tr:hover .game-name::after {
  color: var(--blue);
  transform: translate(2px, -2px);
}
.publisher {
  color: var(--ink-soft);
  font-size: 0.92rem;
  white-space: nowrap;
}

/* BGG rating pill (color tier by rating) */
.rating {
  display: inline-block;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--cream-deep);
  color: var(--ink);
  min-width: 48px;
  text-align: center;
}
.rating[data-tier="excellent"] { background: #C9F0E1; color: #0E5B43; }
.rating[data-tier="good"]      { background: #FCE9C0; color: #8A6020; }
.rating[data-tier="ok"]        { background: #FBD9D9; color: #8A2424; }

/* App rating with star */
.app-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--ink);
}
.app-rating::before {
  content: "★";
  color: var(--yellow);
  font-size: 1.05em;
}
.app-rating.is-missing { color: var(--muted); font-weight: 500; }
.app-rating.is-missing::before { display: none; }

/* weight bars */
.weight {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.weight i {
  display: block;
  width: 5px;
  height: 18px;
  border-radius: 2px;
  background: var(--ink);
  opacity: 0.18;
}
.weight[data-tier="light"]  i.on { background: var(--green); opacity: 1; }
.weight[data-tier="medium"] i.on { background: var(--yellow); opacity: 1; }
.weight[data-tier="heavy"]  i.on { background: var(--red); opacity: 1; }
.weight .value {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-left: 6px;
  font-weight: 600;
}

/* price */
.price {
  display: inline-block;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  background: var(--cream-deep);
  color: var(--ink);
  white-space: nowrap;
}
.price.is-free {
  background: #D9F2E7;
  color: #0E5B43;
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ---------- mobile cards ---------- */
@media (max-width: 820px) {
  .games-table thead { display: none; }
  .games-table, .games-table tbody { display: block; width: 100%; }
  .games-table tbody tr {
    padding: 16px 18px 18px;
    border-bottom: 1px solid var(--hair);
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 14px;
    row-gap: 6px;
    align-items: center;
  }
  .games-table tbody td { padding: 0; border: 0; display: block; }
  .games-table tbody td.col-rank  { grid-column: 1; grid-row: 1 / span 2; align-self: start; padding-top: 2px; }
  .games-table tbody td.col-name  { grid-column: 2; grid-row: 1; }
  .games-table tbody td.col-price { grid-column: 3; grid-row: 1; text-align: right; }
  .games-table tbody td.col-pub   { grid-column: 2 / span 2; grid-row: 2; }
  .games-table tbody td.col-pub .publisher { white-space: normal; }
  .games-table tbody td.col-bgg,
  .games-table tbody td.col-weight,
  .games-table tbody td.col-app {
    grid-row: 3;
    display: inline-flex;
    align-items: center;
  }
  .games-table tbody td.col-bgg    { grid-column: 1 / span 1; padding-top: 6px; }
  .games-table tbody td.col-weight { grid-column: 2 / span 1; padding-top: 6px; }
  .games-table tbody td.col-app    { grid-column: 3 / span 1; padding-top: 6px; justify-content: flex-end; }
  .games-table .rank-num { font-size: 1.1rem; }
  .game-name { font-size: 1rem; }
}
@media (max-width: 480px) {
  .games-table tbody tr { column-gap: 10px; }
  .weight i { width: 4px; height: 14px; }
  .weight .value { display: none; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--cream-deep);
  padding: clamp(40px, 6vw, 72px) 0 clamp(32px, 5vw, 56px);
  border-top: 2px dashed rgba(20,21,46,0.12);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 4vw, 64px);
}
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0 0 16px;
}
.legend {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px 16px;
  margin: 0;
  align-items: center;
}
.legend dt { margin: 0; }
.legend dd { margin: 0; font-size: 0.95rem; color: var(--ink-soft); }
.legend dd strong { color: var(--ink); }
.legend a { color: var(--blue); }

.legend-pill {
  display: inline-block;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 0.88rem;
}
.legend-rank   { font-family: var(--font-display); }
.legend-rating { background: #C9F0E1; color: #0E5B43; }
.legend-app::before { content: "★ "; color: var(--yellow); }
.legend-bars {
  display: inline-flex; gap: 3px;
}
.legend-bars i {
  display: block; width: 5px; height: 18px;
  border-radius: 2px; background: var(--yellow);
}
.legend-bars i.off { background: var(--ink); opacity: 0.18; }

.micro {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 24px;
}
.micro.micro-tight { margin-top: 4px; }
.micro a { color: var(--blue); }

/* ============================================================
   MODAL — "Add game to list"
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 21, 46, 0.55);
  backdrop-filter: blur(2px);
  animation: modalFade .15s ease;
}
.modal[hidden] { display: none; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: #fff;
  width: 100%;
  max-width: 460px;
  padding: clamp(24px, 4vw, 36px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  position: relative;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.4vw, 1.7rem);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.modal-intro {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 36ch;
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.7rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .12s ease, color .12s ease;
}
.modal-close:hover { background: var(--cream); color: var(--ink); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  margin-bottom: 6px;
}
.field .req { color: var(--blue); }
.field .opt { color: var(--muted); font-weight: 400; }
.field input,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--cream);
  padding: 12px 14px;
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--hair);
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--blue);
}

.botcheck { position: absolute; left: -9999px; opacity: 0; pointer-events: none; }

.modal-submit {
  width: 100%;
  margin-top: 6px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(20,21,46,0.06),
    0 2px 0 0 rgba(20,21,46,0.18);
  transition: background .15s ease, transform .12s ease;
}
.modal-submit:hover:not(:disabled) { background: #2362c7; transform: translateY(-1px); }
.modal-submit:disabled { opacity: 0.6; cursor: wait; }

.form-status {
  margin: 14px 0 0;
  font-size: 0.92rem;
  min-height: 1.2em;
  color: var(--ink-soft);
}
.form-status.is-success { color: var(--green); font-weight: 600; }
.form-status.is-error   { color: var(--red); }

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