/* Board Game Shelf
   Idea: a walnut cabinet at night. Every row of games stands on a wooden ledge,
   and each game's name and numbers sit below it like a shelf label.
   Display type is Fraunces (self-hosted, SIL Open Font License); body is the system sans. */

@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --night: #14110e;      /* the room */
  --cabinet: #1d1915;    /* panels, dialog */
  --inset: #27211b;      /* inputs, raised bits */
  --line: #3a3129;
  --ledge-top: #5a4634;  /* shelf board, lit edge */
  --ledge: #33281e;      /* shelf board, face */
  --parchment: #f1e8d8;
  --dust: #a89c88;
  --marigold: #f0b03f;
  --marigold-ink: #241a05;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --gap: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-padding-top: 90px; }

body {
  margin: 0;
  background: var(--night);
  color: var(--parchment);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.muted { color: var(--dust); }
:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; }

/* ---------- header ---------- */
.top { padding: 36px 28px 18px; }
.top h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.top p { margin: 6px 0 0; }

/* ---------- controls ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 28px;
  background: rgba(20, 17, 14, 0.95);
  border-bottom: 1px solid var(--line);
}

.controls input[type="search"],
.controls select,
button {
  font: inherit;
  color: var(--parchment);
  background-color: var(--inset);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  min-height: 38px;
}
.controls input[type="search"] { flex: 1 1 170px; min-width: 150px; }
.controls input::placeholder { color: var(--dust); }
.controls select {
  max-width: 172px;
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a89c88' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.spacer { flex: 1 1 0; }

.check { display: inline-flex; align-items: center; gap: 7px; padding: 0 6px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--marigold); width: 16px; height: 16px; }

button { cursor: pointer; }
button:hover { background-color: #302921; }
button.primary {
  background-color: var(--marigold);
  border-color: var(--marigold);
  color: var(--marigold-ink);
  font-weight: 650;
  padding: 7px 18px;
  box-shadow: 0 2px 0 #a8741c;
}
button.primary:hover { background-color: #f6bd55; }
button.primary:active { transform: translateY(2px); box-shadow: none; }
button.ghost { background-color: transparent; }

.controls2 {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 34px;
  align-items: center;
  padding: 14px 28px 0;
}
.group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lbl { color: var(--dust); }
.seg { display: inline-flex; gap: 4px; }
.seg button {
  min-width: 38px;
  min-height: 34px;
  padding: 4px 0;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.seg button[aria-pressed="true"] {
  background-color: var(--marigold);
  border-color: var(--marigold);
  color: var(--marigold-ink);
  font-weight: 700;
}
input[type="range"] { width: 220px; accent-color: var(--marigold); }
#f-time-out { min-width: 104px; font-weight: 600; }
#clear { margin-left: auto; }

.count { margin: 18px 28px 0; font-size: 0.9rem; }

/* ---------- the shelf ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 34px var(--gap);
  padding: 18px 28px 56px;
}

.card { display: block; color: inherit; text-decoration: none; }

/* The square is only a stage. Whatever is inside stands on its bottom edge. */
.cover { position: relative; aspect-ratio: 1 / 1; }
.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 -1px 0 rgba(255, 255, 255, 0.05)) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}
.cover > img, .cover > .titlecard { transition: transform 0.16s ease; }
.card:hover .cover > img, .card:hover .cover > .titlecard,
.card:focus-visible .cover > img, .card:focus-visible .cover > .titlecard { transform: translateY(-7px); }

/* Text-only box, used until a real cover exists. Colour and height vary per game. */
.titlecard {
  --box: #4a5360;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 12px 11px 20px;
  border-radius: 3px 5px 0 0;
  color: #f6eedf;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.3) 0 8px, rgba(255, 255, 255, 0.07) 8px 9px, transparent 9px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 38%),
    var(--box);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.45);
}
.titlecard[data-size="1"] { top: 8%; }
.titlecard[data-size="2"] { top: 15%; }
.titlecard[data-tone="0"] { --box: #7a2e2a; }
.titlecard[data-tone="1"] { --box: #2e5d49; }
.titlecard[data-tone="2"] { --box: #2a4868; }
.titlecard[data-tone="3"] { --box: #8a6920; }
.titlecard[data-tone="4"] { --box: #5c3a5e; }
.titlecard[data-tone="5"] { --box: #23606a; }
.titlecard[data-tone="6"] { --box: #8c4d28; }
.titlecard[data-tone="7"] { --box: #4a5360; }
.titlecard .t {
  font-family: var(--display);
  font-size: 1.12rem;
  line-height: 1.16;
  font-weight: 600;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.titlecard .p {
  font-size: 0.72rem;
  color: rgba(246, 238, 223, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  position: absolute;
  z-index: 1;
  right: 7px;
  bottom: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(20, 17, 14, 0.86);
  color: var(--parchment);
}
.cover:has(.badge) .titlecard .p { padding-right: 34px; }

/* The ledge: one board under each game, wide enough to meet its neighbours. */
.info { position: relative; padding: 15px 2px 0; }
.info::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(var(--gap) / -2);
  right: calc(var(--gap) / -2);
  height: 6px;
  background: linear-gradient(var(--ledge-top) 0 1px, var(--ledge) 1px);
  box-shadow: 0 7px 9px rgba(0, 0, 0, 0.5);
}
.info h2 {
  margin: 0;
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.star { color: var(--marigold); }
.info p { margin: 1px 0 0; font-size: 0.8rem; color: var(--dust); }
.info .meta { display: flex; justify-content: space-between; gap: 8px; }
.info p.best { color: var(--marigold); }

.empty { text-align: center; color: var(--dust); padding: 60px 24px; }

footer { padding: 24px; border-top: 1px solid var(--line); text-align: center; font-size: 0.85rem; }
footer a { color: var(--dust); }
footer img { height: 34px; vertical-align: middle; }

/* ---------- detail ---------- */
dialog {
  width: min(900px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 0;
  color: var(--parchment);
  background: var(--cabinet);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
}
dialog[open] { animation: rise 0.16s ease-out; }
dialog::backdrop { background: rgba(8, 6, 4, 0.76); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.d-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 10px 8px 26px;
  background: var(--cabinet);
}
.d-bar .spacer { flex: 1; }
.d-bar a { color: var(--marigold); text-decoration: none; }
.d-bar a:hover { text-decoration: underline; }
.d-bar .picked { color: var(--dust); }
.d-close { width: 38px; padding: 0; font-size: 1.25rem; line-height: 1; border-radius: 999px; }

.d-body { display: grid; grid-template-columns: 250px 1fr; gap: 30px; padding: 4px 28px 30px; }
.d-cover { align-self: start; border-bottom: 6px solid var(--ledge); box-shadow: 0 8px 10px -4px rgba(0, 0, 0, 0.5); }
.d-cover .titlecard { top: 0; }
.d-cover .titlecard .t { font-size: 1.5rem; }

.d-main { min-width: 0; }
.d-main h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.d-main h2 .star { font-size: 0.7em; margin-left: 8px; }
.d-sub { margin: 6px 0 0; color: var(--dust); }
.d-main .tagline {
  margin: 16px 0 0;
  max-width: 34em;
  font-family: var(--display);
  font-size: 1.2rem;
  line-height: 1.4;
  color: #f6dfae;
}

.facts { display: flex; flex-wrap: wrap; gap: 12px 30px; margin: 20px 0 0; padding: 14px 0; list-style: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts .k { display: block; font-size: 0.8rem; color: var(--dust); }
.facts .v { font-weight: 600; font-size: 1.02rem; }

.d-main h3 { margin: 24px 0 8px; font-family: var(--display); font-size: 1.05rem; font-weight: 600; }
.d-main p { margin: 0 0 10px; max-width: 62ch; }
.desc p { color: #dcd3c3; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { font-size: 0.8rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--dust); }
.main-tags { margin-top: 14px; }
.main-tags span { color: var(--parchment); background: var(--inset); border-color: #4a3f34; }

.exp-list { list-style: none; margin: 0; padding: 0; }
.exp-list li + li { margin-top: 6px; }
.exp-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px 8px 8px;
  color: inherit;
  text-decoration: none;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.exp-list a:hover { border-color: var(--marigold); }
.exp-list .thumb { width: 46px; height: 46px; flex: none; border-radius: 4px; overflow: hidden; position: relative; }
.exp-list .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.exp-list .thumb .titlecard { top: 0; padding: 0; border-radius: 0; box-shadow: none; }
.exp-list .thumb .titlecard > * { display: none; }
.exp-list .name { font-weight: 600; }
.exp-list .sub { display: block; font-size: 0.8rem; color: var(--dust); font-weight: 400; }

.d-links { margin-top: 24px; }
.d-links a { color: var(--marigold); }

@media (max-width: 700px) {
  :root { --gap: 12px; }
  .top { padding: 22px 14px 10px; }
  .controls { padding: 10px 14px; position: static; }
  .controls select { flex: 1 1 140px; max-width: none; }
  .controls .spacer { display: none; }
  #pick { flex: 1 1 100%; }
  .controls2 { padding: 8px 14px 0; gap: 12px; }
  .controls2 .group { width: 100%; flex-wrap: nowrap; }
  .seg { flex: 1 1 auto; gap: 3px; }
  .seg button { flex: 1 1 0; min-width: 0; }
  input[type="range"] { flex: 1 1 120px; width: auto; }
  .count { margin: 12px 14px 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 28px var(--gap); padding: 14px 14px 40px; }
  .d-bar { padding-left: 16px; }
  .d-body { grid-template-columns: 1fr; padding: 0 16px 20px; gap: 18px; }
  .d-cover { width: min(210px, 58%); }
}

@media (prefers-reduced-motion: reduce) {
  .cover > img, .cover > .titlecard { transition: none; }
  .card:hover .cover > *, .card:focus-visible .cover > * { transform: none; }
  dialog[open] { animation: none; }
}
