@import url('/display/base.css');
@import url('/display/game-chooser.css');
@import url('/shared/settings.css');

/* base.css centers a single fixed screen (built for the display) — this page
   is a plain scrollable list instead. */
html, body { overflow: auto; }
#app { display: block; overflow: visible; justify-content: initial; align-items: initial; }

/* Type steps, identical in daily.css: the DESIGN.md ramp (label 12, body
   14, title 18, numeral 44) plus the in-between steps the hubs use. */
:root {
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-display: clamp(28px, 6vw, 32px);
  --fs-numeral: 44px;
}

:root {
  --bg-gradient:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--muted) 11%, transparent) 0 1.5px, transparent 1.5px 4.5px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--muted) 11%, transparent) 0 1.5px, transparent 1.5px 4.5px),
    radial-gradient(ellipse 90% 60% at 30% 0%, rgba(212,175,55,.08), transparent 65%),
    var(--bg);
}

/* Account-synced light/dark theme (public/shared/settings.js), separate from
   base.css's display-skin system (default/paper — left untouched). Kept
   self-contained here rather than in display/base.css so display.js/about.js
   aren't affected. Values mirror phone/base.css's dark palette so signed-in
   dark-mode users see a consistent look across phone and this hub. */
html[data-theme="dark"] {
  --bg: #171512;
  --bg-gradient:
    repeating-linear-gradient(45deg, rgba(200,180,140,.12) 0 1.5px, transparent 1.5px 4.5px),
    repeating-linear-gradient(-45deg, rgba(200,180,140,.12) 0 1.5px, transparent 1.5px 4.5px),
    radial-gradient(ellipse at top, #26221C 0%, #171512 55%, #0D0B09 100%),
    var(--bg);
  --surface: #221F1A;
  --text: #F2F0E8;
  --muted: #A8A398;
  --border: #574F3E;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --page-bg: var(--bg);
  --panel-bg: var(--surface);
}

body {
  background: var(--bg-gradient);
  background-attachment: fixed;
}

/* Readable secondary text: same hub-scoped --muted as daily.css (shared
   --muted is 3.65:1 light / 3.89:1 dark at the crosshatch's worst point;
   these are 5.1:1 / 5.3:1 there and 7.6:1 / 9.0:1 on --surface). */
.levels-hub { --muted: #55504A; }
html[data-theme="dark"] .levels-hub { --muted: #C4BFB3; }

::selection { background: color-mix(in srgb, var(--indigo) 45%, transparent); color: var(--text); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.levels-hub {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 64px;
  font-variant-numeric: tabular-nums;
}

.levels-hub-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-gradient);
  background-attachment: fixed;
  padding-top: 8px;
}
.levels-hub-toprow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-bottom: 8px;
}
.levels-back {
  justify-self: start;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--fs-md);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  transition: border-color .15s;
}
.levels-back:hover { border-color: var(--indigo); }
/* Same 34px tile, 1px border and radius as the Daily hub's calendar icon;
   it doubles as a home link, with a 44px hit area round the tile. */
.levels-hub-icon {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  position: relative;
  transition: transform .15s, border-color .15s;
}
.levels-hub-icon::after { content: ''; position: absolute; inset: -6px; }
.levels-hub-icon:hover { transform: translateY(-1px); border-color: var(--indigo); }
.levels-hub-mark { width: 24px; height: 24px; display: block; }
.levels-hub-toprow-end { justify-self: end; width: 34px; height: 34px; }

/* Title and subtitle on a solid card, off the crosshatch. */
.levels-intro {
  text-align: center;
  margin: 4px 0 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.levels-hub-title {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
}
.levels-hub-subtitle {
  color: var(--muted);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.45;
  margin: 6px auto 0;
  max-width: 46ch;
  text-wrap: balance;
}

.levels-download-btn {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 11px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.levels-download-btn:hover:not(:disabled) { border-color: var(--indigo); }
.levels-download-btn:disabled { color: var(--muted); cursor: default; }

.levels-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 12px;
}

.levels-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.levels-card-top { display: flex; align-items: flex-start; gap: 12px; flex: 1; }
.levels-card-art { width: 72px; height: 72px; flex: none; }
.levels-card-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.levels-card-name { font-size: var(--fs-xl); font-weight: 800; line-height: 1.2; }
.levels-card-summary {
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.levels-card-meta { font-size: var(--fs-sm); color: var(--muted); font-weight: 700; }
.levels-card-meta:empty { display: none; }
.levels-card-meta b { color: var(--text); font-weight: 800; }
.levels-progress {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  overflow: hidden;
  margin-top: 2px;
}
.levels-progress span { display: block; height: 100%; background: var(--tile-accent, var(--indigo)); border-radius: inherit; min-width: 6px; }

.levels-card-btn {
  display: block;
  text-align: center;
  padding: 11px 10px;
  border-radius: var(--radius);
  font-size: var(--fs-lg);
  font-weight: 800;
  text-decoration: none;
  background: var(--indigo);
  border: 2px solid var(--indigo);
  color: #221F1B;
  transition: opacity .15s, transform .15s;
}
.levels-card-btn:hover { opacity: .9; transform: translateY(-1px); }
.levels-card-btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.levels-card-btn.ghost:hover { border-color: var(--indigo); opacity: 1; }
button.levels-card-btn { width: 100%; font-family: inherit; cursor: pointer; }
/* Lock on gated "Sign in to play", right arrow on Start/Continue. */
.levels-card-btn.has-icon { display: flex; align-items: center; justify-content: center; gap: 7px; }
.levels-btn-icon { width: 16px; height: 16px; flex: none; }
.levels-card-btn.ghost .levels-btn-icon { color: var(--indigo); }
.levels-btn-arrow { transition: transform .15s; }
.levels-card-btn:hover .levels-btn-arrow { transform: translateX(2px); }
/* No sign-in on this server: a status line under a hairline, deliberately
   not button-shaped (no fill, no centered bar, nothing to tap). */
.levels-card-locked {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.levels-card-locked .levels-btn-icon { width: 14px; height: 14px; }

.levels-empty, .levels-loading {
  grid-column: 1 / -1;
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 600;
  padding: 28px 16px;
  margin-top: 4px;
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
/* Outside .levels-hub (the pre-auth "Loading…"): keep it in the column. */
#app > .levels-loading { max-width: 728px; margin: 24px auto 0; }

.levels-signin-gate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  scroll-margin-top: 80px;
}
.levels-signin-gate-text { flex: 1 1 260px; min-width: 0; }
.levels-signin-gate-title { font-size: var(--fs-xl); font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.levels-signin-gate-msg { color: var(--muted); font-size: var(--fs-md); font-weight: 600; line-height: 1.45; max-width: 60ch; }
.levels-signin-btn {
  flex: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 22px;
  border-radius: var(--radius);
  border: 2px solid var(--indigo);
  background: var(--indigo);
  color: #221F1B;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.levels-signin-btn:hover { opacity: .9; transform: translateY(-1px); }
.levels-link {
  position: relative;
  color: var(--text);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--indigo);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Touch: grow small links to a 44px hit area without changing line layout. */
@media (pointer: coarse) {
  .levels-link::after { content: ''; position: absolute; inset: -13px -4px; }
}

@media (prefers-reduced-motion: reduce) {
  .levels-card-btn, .levels-btn-arrow, .levels-signin-btn, .levels-back, .levels-hub-icon { transition: none; }
  .levels-card-btn:hover, .levels-card-btn:hover .levels-btn-arrow, .levels-signin-btn:hover, .levels-hub-icon:hover { transform: none; }
}
html.reduce-motion .levels-card-btn, html.reduce-motion .levels-btn-arrow, html.reduce-motion .levels-signin-btn, html.reduce-motion .levels-hub-icon { transition: none; }
html.reduce-motion .levels-card-btn:hover, html.reduce-motion .levels-card-btn:hover .levels-btn-arrow, html.reduce-motion .levels-signin-btn:hover, html.reduce-motion .levels-hub-icon:hover { transform: none; }
