/* ==========================================================================
   Cheevio: styles

   Sections
     1. Design tokens
     2. Page basics, top bar, footer
     3. Buttons, search, segmented controls, progress bars, rarity
     4. Home
     5. Player: header, stats, highlights
     6. Player: games list
     7. One game: header and achievements
     8. Small screens
   ========================================================================== */


/* 1. Design tokens ------------------------------------------------------ */

:root {
  --bg: #000000;
  --panel: #070707;
  --panel-hover: #0d0d0d;
  --text: #f2f2f2;
  --text-soft: #a8a8a8;
  --text-muted: #6b6b6b;
  --line: #1f1f1f;
  --line-hover: #4a4a4a;

  --accent: #f5c542;      /* gold: the logo, perfect games */
  --progress: #60a5fa;    /* progress bars */

  /* Rarity, by the share of players who have an achievement. */
  --legendary: #f5c542;   /* under 1% */
  --epic: #c084fc;        /* under 5% */
  --rare: #60a5fa;        /* under 10% */
  --uncommon: #4cd964;    /* under 25% */
  --common: #8a8a8a;      /* the rest */

  --content-width: 64rem;
  color-scheme: dark;
}

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


/* 2. Page basics, top bar, footer --------------------------------------- */

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  color: var(--text);
  font-family: "Geom", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

a { color: inherit; }

main {
  flex: 1;
  width: min(100%, var(--content-width));
  padding: 1.5rem 0 4rem;
}

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

img.is-broken { visibility: hidden; }

.section-title { margin: 2.5rem 0 1rem; color: var(--text-soft); font-size: 1rem; font-weight: 500; }
.loading { color: var(--text-muted); font-size: 0.9rem; text-align: center; margin: 4rem 0; }

.topbar {
  width: min(100%, var(--content-width));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.logo-mark { width: 28px; height: 28px; }
.logo-text { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em; }

.site-footer {
  width: min(100%, var(--content-width));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1.25rem 0 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
}
.footer-links { display: inline-flex; align-items: center; gap: 0.6rem; }
.site-footer a { color: #5a5a5a; text-decoration: none; transition: color 0.2s; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--text-soft); outline: none; }
.footer-separator { color: #262626; }
.footer-note { color: #3f3f3f; }


/* 3. Buttons, search, segmented controls, progress bars, rarity -------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line-hover);
  border-radius: 999px;
  background: #000;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.8125rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.button:hover, .button:focus-visible { color: var(--text); border-color: var(--text-soft); outline: none; }
.button--primary { background: var(--text); border-color: var(--text); color: #000; font-weight: 500; }
.button--primary:hover, .button--primary:focus-visible { background: #fff; color: #000; }

.search { display: flex; gap: 0.5rem; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line-hover);
  border-radius: 999px;
  background: #000;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus { border-color: var(--text-soft); outline: none; }
.search--small { width: min(100%, 22rem); }
.search--small input { font-size: 0.8125rem; padding: 0.45rem 0.9rem; }
.search--small .button { padding: 0.45rem 0.9rem; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.segmented-button {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.segmented-button:hover, .segmented-button:focus-visible { color: var(--text-soft); border-color: var(--line-hover); outline: none; }
.segmented-button[aria-pressed="true"] { color: var(--text); border-color: var(--line-hover); background: #141414; }

.bar { position: relative; height: 0.35rem; border-radius: 999px; background: #1a1a1a; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--progress); transition: width 0.4s ease; }
.bar--perfect .bar-fill { background: var(--accent); }
.bar--big { height: 0.5rem; }
.bar--status { max-width: 22rem; margin: 0.5rem auto 0; }

.rarity { font-size: 0.8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: help; }
.rarity--legendary { color: var(--legendary); }
.rarity--epic { color: var(--epic); }
.rarity--rare { color: var(--rare); }
.rarity--uncommon { color: var(--uncommon); }
.rarity--common { color: var(--common); }

.message { max-width: 34rem; margin: 3rem auto; text-align: center; }
.message-title { margin: 0 0 0.75rem; font-size: 1.4rem; font-weight: 600; }
.message-text { margin: 0 0 1.5rem; color: var(--text-soft); font-size: 0.9rem; line-height: 1.55; }


/* 4. Home ---------------------------------------------------------------- */

.hero {
  max-width: 38rem;
  margin: clamp(3rem, 14vh, 8rem) auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero-title {
  margin: 0;
  font-size: clamp(2.75rem, 9vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 30%, var(--accent) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-tagline { margin: 0.75rem 0 2rem; color: var(--text-soft); font-size: 1rem; line-height: 1.55; }
.search--big { width: 100%; }
.search--big input { padding: 0.8rem 1.2rem; font-size: 0.95rem; }
.search--big .button { padding: 0.8rem 1.3rem; font-size: 0.875rem; }
.hero-note { margin: 1.25rem 0 0; color: var(--text-muted); font-size: 0.8rem; }
.hero-note a { color: var(--text-soft); }
.hero-note--warn { color: #ff6b6b; }

.again {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.25rem;
  padding: 0.35rem 1rem 0.35rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 0.85rem;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}
.again:hover, .again:focus-visible { color: var(--text); border-color: var(--line-hover); outline: none; }
.again-avatar { width: 1.75rem; height: 1.75rem; border-radius: 50%; background: #111; }


/* 5. Player: header, stats, highlights ---------------------------------- */

.player { display: flex; align-items: center; gap: 1.25rem; margin-top: 1rem; }
.player-avatar { width: 5rem; height: 5rem; border-radius: 0.6rem; background: #111; flex: none; }
.player-name { margin: 0; font-size: 1.75rem; font-weight: 600; overflow-wrap: anywhere; }
.player-links { margin: 0.4rem 0 0; font-size: 0.8125rem; }
.player-links a { color: var(--text-muted); text-decoration: none; }
.player-links a:hover { color: var(--text-soft); }

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 2rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
}
.stat-value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-muted); font-size: 0.78rem; }
.stat--perfect .stat-value { color: var(--accent); }

.status { text-align: center; }
.status-text { margin: 1.5rem 0 0; color: var(--text-muted); font-size: 0.8125rem; }
.status-text--warn { color: #ff9f3a; }

.highlights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2rem; }
.mini-list { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.mini {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem 0.45rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}
.mini:hover, .mini:focus-visible { border-color: var(--line-hover); background: var(--panel-hover); outline: none; }
.mini-icon { width: 2.25rem; height: 2.25rem; border-radius: 0.3rem; background: #111; }
.mini-text { display: grid; gap: 0.1rem; min-width: 0; }
.mini-name, .mini-game { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-name { font-size: 0.85rem; }
.mini-game { color: var(--text-muted); font-size: 0.75rem; }
.mini-side { display: grid; justify-items: end; gap: 0.1rem; }
.mini-when { color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; }


/* 6. Player: games list ------------------------------------------------- */

.games-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin: 2.5rem 0 1rem;
}
.games-head .section-title { margin: 0; }
.games-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.games-search, .games-sort {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #000;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.78rem;
}
.games-search { width: 11rem; }
.games-search:focus, .games-sort:focus { border-color: var(--line-hover); outline: none; }
.games-empty { color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.games-empty:empty { display: none; }

.game-list { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.game-row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 5.5rem;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem 0.55rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}
.game-row:hover, .game-row:focus-visible { border-color: var(--line-hover); background: var(--panel-hover); outline: none; }
.game-row--perfect { border-color: rgba(245, 197, 66, 0.25); }
.game-row-icon { width: 2.5rem; height: 2.5rem; border-radius: 0.3rem; background: #111; }
.game-row-main { display: grid; gap: 0.45rem; min-width: 0; }
.game-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; min-width: 0; }
.game-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.game-row-playtime { flex: none; color: var(--text-muted); font-size: 0.72rem; }
.game-row-side { display: grid; justify-items: end; gap: 0.1rem; font-variant-numeric: tabular-nums; }
.game-row-percent { font-size: 0.95rem; font-weight: 500; }
.game-row--perfect .game-row-percent { color: var(--accent); }
.game-row-count { color: var(--text-muted); font-size: 0.72rem; }


/* 7. One game: header and achievements ---------------------------------- */

.back {
  display: inline-block;
  margin: 0.5rem 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}
.back:hover, .back:focus-visible { color: var(--text-soft); outline: none; }

.game { display: grid; grid-template-columns: minmax(0, 23rem) minmax(0, 1fr); gap: 1.75rem; align-items: center; }
.game-art { width: 100%; aspect-ratio: 460 / 215; object-fit: cover; border-radius: 0.6rem; border: 1px solid var(--line); background: #111; }
.game-name { margin: 0 0 0.6rem; font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
.game-numbers { margin: 0 0 0.75rem; color: var(--text-soft); font-size: 0.875rem; }
.game-numbers strong { color: var(--text); font-weight: 600; }
.game-numbers .game-perfect { color: var(--accent); }
.game-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.25rem 0 0; }

.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin: -0.25rem 0 1rem; font-size: 0.75rem; }
.legend-item { cursor: help; }
.legend-item::before { content: "●"; margin-right: 0.35rem; }

.achievement-list { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.achievement {
  position: relative;
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem 0.6rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
}
.achievement-icon { width: 3rem; height: 3rem; border-radius: 0.3rem; background: #111; }
.achievement:not(.achievement--unlocked) .achievement-icon { opacity: 0.55; }
.achievement-text { display: grid; gap: 0.15rem; min-width: 0; }
.achievement-name { font-size: 0.9rem; }
.achievement:not(.achievement--unlocked) .achievement-name { color: var(--text-soft); }
.achievement-description { color: var(--text-muted); font-size: 0.78rem; line-height: 1.4; }
.achievement-side { display: grid; justify-items: end; gap: 0.15rem; }
.achievement-when { color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; }

/* Hidden achievements not unlocked yet: blurred until clicked. */
.achievement--secret { cursor: pointer; }
.achievement--secret > * { filter: blur(6px); user-select: none; }
.achievement--secret::after {
  content: "Hidden achievement · click to reveal";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-size: 0.8125rem;
}
.achievement--secret:hover, .achievement--secret:focus-visible { border-color: var(--line-hover); outline: none; }


/* 8. Small screens --------------------------------------------------------- */

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .highlights { grid-template-columns: minmax(0, 1fr); }
  .game { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  body { padding: 0 0.9rem; }
  .topbar { flex-wrap: wrap; }
  .search--small { width: 100%; }
  .search--big { flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-avatar { width: 4rem; height: 4rem; }
  .player-name { font-size: 1.4rem; }
  .game-row { grid-template-columns: 2.25rem minmax(0, 1fr) 4.5rem; gap: 0.75rem; }
  .game-row-playtime { display: none; }
  .achievement { grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: 0.75rem; }
  .achievement-icon { width: 2.5rem; height: 2.5rem; }
  .site-footer { justify-content: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}
