@import url('../hcc-tokens.css');
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--hcc-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(var(--hcc-grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--hcc-grid-color) 1px, transparent 1px),
    var(--hcc-bg);
  background-size: 44px 44px, 44px 44px, auto;
  color: var(--hcc-text);
  font-family: var(--hcc-ff-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
img { max-width: 100%; height: auto; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

::selection {
  background: color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 34%, transparent);
  color: var(--hcc-text);
}

.hcc-shell {
  width: min(var(--hcc-page-max), calc(100vw - 36px));
  margin: 0 auto;
}

.hcc-display {
  font-family: var(--hcc-ff-display);
  font-weight: 700;
  font-style: italic;
  line-height: 1.05;
  letter-spacing: 0;
}

.hcc-mono,
.hcc-label {
  font-family: var(--hcc-ff-mono);
}

.hcc-label {
  color: var(--hcc-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hcc-logo-plate,
.nav-hcc-link,
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hcc-logo-plate {
  width: fit-content;
  padding: 8px 10px;
  border: 1px solid var(--hcc-logo-plate-border);
  border-radius: var(--hcc-radius);
  background: var(--hcc-logo-plate);
}

.hcc-logo-plate img {
  display: block;
}

/* ═══════════════════════════════════════════════════════════
   NAV SYSTEM — unified across all HCC pages
   ═══════════════════════════════════════════════════════════
   Structure (used on every page type):
     <header class="hcc-nav" | #header>
       <div class="nav-brand-group">   ← logo + separator + label
       <div class="nav-end">           ← theme toggle (always) + links + burger
         <button class="hcc-theme-toggle">
         <nav class="nav" id="…">      ← collapsible on mobile
           <a class="nav-link">…
         </nav>
         <button class="burger" id="…">
   ═══════════════════════════════════════════════════════════ */

/* ── Container ─────────────────────────────────────────── */
.hcc-nav,
#header,
.hcc-site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 22px;
  border-bottom: 1px solid var(--hcc-border);
  background: var(--hcc-nav-bg);
  color: var(--hcc-nav-text);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  /* overflow:visible is required so mobile dropdown can escape the container */
  overflow: visible;
  transition:
    padding var(--hcc-duration) var(--hcc-ease),
    box-shadow var(--hcc-duration) var(--hcc-ease),
    border-color var(--hcc-duration) var(--hcc-ease);
}

.hcc-nav.scrolled,
#header.scrolled {
  padding-top: 8px;
  padding-bottom: 8px;
  border-color: var(--hcc-border-strong);
  box-shadow: var(--hcc-shadow-sm);
}

/* ── Brand (left side) ─────────────────────────────────── */
.hcc-nav-brand,
.nav-brand-group,
.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.hcc-nav-brand {
  color: var(--hcc-nav-text);
  text-decoration: none;
}

.hcc-nav-brand img,
.nav-hcc-logo,
.logo-img,
.nav-property-logo {
  display: block;
  width: auto;
}

.nav-hcc-logo      { height: 24px; }
.logo-img          { max-height: 26px; }
.nav-property-logo { height: 22px; }

/* Logo plate (dark pill behind logo) */
.nav-hcc-link,
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 4px 7px;
  border: 1px solid var(--hcc-logo-plate-border);
  border-radius: var(--hcc-radius-sm);
  background: var(--hcc-logo-plate);
  text-decoration: none;
}

.nav-brand-sep {
  color: rgba(255, 255, 255, 0.28);
  font-family: var(--hcc-ff-mono);
  font-size: 16px;
  font-weight: 300;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.hcc-page-nav-label {
  font-family: var(--hcc-ff-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--hcc-accent);
}

/* ── Right end: theme toggle + links + burger ──────────── */
.nav-end,
.hcc-nav-actions,
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Nav links (visible on desktop, dropdown on mobile) ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.hcc-nav-link,
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--hcc-radius-sm);
  color: rgba(244, 242, 236, 0.68);
  font-family: var(--hcc-ff-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  transition:
    color var(--hcc-transition),
    border-color var(--hcc-transition),
    background var(--hcc-transition),
    transform var(--hcc-transition);
}

.hcc-nav-link:hover,
.nav-link:hover {
  color: var(--hcc-nav-text);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

.hcc-nav-link:active,
.nav-link:active {
  transform: translateY(1px);
}

.nav-link--active {
  color: var(--hcc-accent) !important;
  border-color: rgba(232, 213, 163, 0.28) !important;
  background: rgba(232, 213, 163, 0.08) !important;
}

.nav-muted,
.hcc-nav-link-muted {
  color: rgba(244, 242, 236, 0.38);
}

/* Badges / chips */
.nav-alpha-badge,
.hcc-chip,
.hcc-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  width: fit-content;
  padding: 2px 7px;
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius-sm);
  background: var(--hcc-panel-tint);
  color: var(--hcc-text-muted);
  font-family: var(--hcc-ff-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* ── Avatars ────────────────────────────────────────────── */
.avatar,
.hcc-avatar,
.hub-avatar {
  width: 30px;
  height: 30px;
  border: 1.5px solid color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 55%, rgba(255,255,255,0.18));
  border-radius: 50%;
  background: var(--hcc-surface-2);
  object-fit: cover;
  display: block;
}

.hcc-avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--hcc-border);
  border-radius: 50%;
  background: var(--hcc-surface-2);
  color: var(--hcc-text);
  font-family: var(--hcc-ff-mono);
  font-size: 12px;
  font-weight: 700;
}

/* ── Burger button (hidden on desktop) ─────────────────── */
.burger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--hcc-radius-sm);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  flex-shrink: 0;
  gap: 0;
}

.burger span {
  display: block;
  width: 16px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--hcc-nav-text);
  transition:
    transform 200ms var(--hcc-ease),
    opacity 150ms var(--hcc-ease),
    width 200ms var(--hcc-ease);
  margin: 2.5px 0;
}

.burger.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; width: 0; }
.burger.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.hcc-btn,
.btn,
.play-btn,
.tl-primary-link,
.tl-mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--hcc-control-height);
  padding: 0 15px;
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius);
  background: var(--hcc-surface-2);
  color: var(--hcc-text);
  font-family: var(--hcc-ff-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--hcc-transition),
    background var(--hcc-transition),
    border-color var(--hcc-transition),
    color var(--hcc-transition),
    box-shadow var(--hcc-transition);
}

.hcc-btn:hover,
.btn:hover,
.play-btn:hover,
.tl-primary-link:hover,
.tl-mini-button:hover {
  border-color: color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 48%, var(--hcc-border));
  transform: translateY(-1px);
}

.hcc-btn:active,
.btn:active,
.play-btn:active,
.tl-primary-link:active,
.tl-mini-button:active {
  transform: translateY(1px);
}

.hcc-btn-primary,
.btn.primary,
.play-btn,
.tl-primary-link {
  border-color: var(--game-primary, var(--hcc-accent));
  background: var(--game-primary, var(--hcc-accent));
  color: var(--hcc-on-accent);
}

.hcc-btn-ghost,
.btn.ghost {
  background: transparent;
}

.hcc-btn-danger,
.btn.danger {
  color: var(--hcc-red);
  border-color: color-mix(in srgb, var(--hcc-red) 36%, var(--hcc-border));
  background: color-mix(in srgb, var(--hcc-red) 9%, transparent);
}

.hcc-card,
.card,
.game-card,
.login-card {
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius);
  background: var(--hcc-surface);
  color: var(--hcc-text);
  box-shadow: none;
}

.hcc-panel {
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius);
  background: linear-gradient(180deg, var(--hcc-panel-tint), transparent), var(--hcc-surface);
}

.hcc-divider {
  height: 1px;
  margin: 20px 0;
  background: var(--hcc-border);
}

input,
textarea,
select,
.hcc-input {
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius);
  background: var(--hcc-input-bg);
  color: var(--hcc-text);
}

input:focus,
textarea:focus,
select:focus,
.hcc-input:focus {
  border-color: color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 62%, var(--hcc-border));
  outline: 2px solid color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 22%, transparent);
  outline-offset: 0;
}

input::placeholder,
textarea::placeholder {
  color: var(--hcc-text-dim);
}

.tabs,
.hcc-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab,
.hcc-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius-full);
  background: var(--hcc-surface);
  color: var(--hcc-text-muted);
  font-family: var(--hcc-ff-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.tab:hover,
.hcc-tab:hover {
  color: var(--hcc-text);
  border-color: var(--hcc-border-strong);
}

.tab.active,
.hcc-tab.active {
  border-color: var(--game-primary, var(--hcc-accent));
  background: var(--game-primary, var(--hcc-accent));
  color: var(--hcc-on-accent);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--hcc-border);
}

th {
  color: var(--hcc-text-muted);
  font-family: var(--hcc-ff-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hcc-alert,
.msg,
.error-msg,
.error-bar {
  border: 1px solid var(--hcc-border);
  border-radius: var(--hcc-radius);
  background: var(--hcc-surface);
  color: var(--hcc-text);
}

.hcc-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-width: 76px;
  min-height: 32px;
  padding: 3px 7px 3px 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--hcc-radius-full);
  background: #08090b;
  color: #f4f2ec;
  font-family: var(--hcc-ff-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
}

.hcc-theme-toggle__knob {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--game-primary, var(--hcc-accent));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}

.hcc-theme-toggle__label {
  min-width: 34px;
  text-align: center;
}

.hcc-theme-toggle--dock {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 200;
  box-shadow: var(--hcc-shadow);
}

@media (max-width: 760px) {
  .hcc-nav,
  #header,
  .hcc-site-nav {
    min-height: 58px;
    padding: 10px 14px;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    background: var(--hcc-nav-bg);
  }

  .nav.open { display: flex; }

  .nav .nav-link,
  .nav .hcc-theme-toggle {
    width: 100%;
  }

  .burger { display: inline-flex; flex-direction: column; }
  .nav-alpha-badge { display: none; }
}

@media (max-width: 420px) {
  .nav-hcc-logo { height: 22px; }
  .logo-img { max-height: 22px; }
  .nav-brand-group { gap: 6px; }
  .hcc-theme-toggle--dock { right: 10px; bottom: 10px; }
}

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

/* ── Shared page nav (hub, leaderboard, profile, admin) ── */
.hcc-page-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 24px;
  background: var(--hcc-nav-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--hcc-border);
  /* overflow:visible lets the mobile dropdown escape the container */
  overflow: visible;
  transition: padding var(--hcc-duration) var(--hcc-ease),
              background var(--hcc-duration) var(--hcc-ease),
              box-shadow var(--hcc-duration) var(--hcc-ease);
}
.hcc-page-nav.scrolled {
  padding-top: 8px; padding-bottom: 8px;
  background: color-mix(in srgb, var(--hcc-nav-bg) 98%, transparent);
  box-shadow: var(--hcc-shadow-sm);
}
.hcc-page-nav-left {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.hcc-page-nav-logo-link { display: inline-flex; align-items: center; }
.hcc-page-nav-logo { height: 24px; width: auto; display: block; opacity: .9; }
.hcc-page-nav-sep {
  color: rgba(255,255,255,0.22); font-size: 18px; line-height: 1;
  font-weight: 300; user-select: none;
}
.hcc-page-nav-label {
  font-family: var(--hcc-ff-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--hcc-accent);
}
.hcc-page-nav-right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

@media (max-width: 760px) {
  .hcc-page-nav { min-height: 58px; padding: 10px 14px; }
  .hcc-page-nav-label { display: none; }
  .hcc-page-nav-sep { display: none; }
  /* hub-nav brand: always visible on mobile (override scroll-reveal) */
  .hub-nav .hub-nav-brand {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
}

/* ── site-nav: reveal-brand mode (hub fades brand in on scroll) ── */
.hcc-page-nav[data-reveal-brand="true"] .hcc-page-nav-left {
  opacity: 0; transform: translateY(-4px);
  transition: opacity .3s var(--hcc-ease), transform .3s var(--hcc-ease);
  pointer-events: none;
}
.hcc-page-nav[data-reveal-brand="true"].scrolled .hcc-page-nav-left {
  opacity: 1; transform: none; pointer-events: auto;
}
@media (max-width: 760px) {
  .hcc-page-nav[data-reveal-brand="true"] .hcc-page-nav-left {
    opacity: 1 !important; transform: none !important; pointer-events: auto !important;
  }
}

/* ── site-nav: game-context (HCC logo · game wordmark) ── */
.hcc-page-nav-game-logo-link { display: inline-flex; align-items: center; }
.hcc-page-nav-game-logo {
  height: 24px; width: auto; max-width: 180px;
  object-fit: contain; object-position: left center; opacity: .92;
}
@media (max-width: 540px) {
  .hcc-page-nav-game-logo { height: 22px; max-width: 140px; }
}

/* ── site-nav: avatar popover button (hub) ── */
.hcc-page-nav-avatar-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--hcc-surface-2);
  border: 2px solid var(--hcc-accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic; font-weight: 700; font-size: 13px;
  color: var(--hcc-text); cursor: pointer; padding: 0; overflow: hidden;
  transition: transform .2s var(--hcc-ease), box-shadow .2s var(--hcc-ease);
  flex-shrink: 0;
}
.hcc-page-nav-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.hcc-page-nav-avatar-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px color-mix(in srgb, var(--hcc-accent) 35%, transparent);
}

/* ── site-nav: initials fallback (no avatar image) ── */
.hcc-page-nav-initials {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--hcc-surface-2); color: var(--hcc-text);
  border: 1.5px solid color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 55%, rgba(255,255,255,0.18));
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic; font-weight: 700; font-size: 12px;
}

/* ── site-nav: active link gets accent underline (desktop) ── */
@media (min-width: 761px) {
  .hcc-page-nav .nav-link--active {
    position: relative;
  }
  .hcc-page-nav .nav-link--active::after {
    content: ''; position: absolute;
    left: 10px; right: 10px; bottom: 2px; height: 2px;
    background: var(--game-primary, var(--hcc-accent));
    border-radius: 1px;
  }
}

/* ── Avatar link (avatar in nav without text) ── */
.avatar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  transition: transform var(--hcc-transition), box-shadow var(--hcc-transition);
}
.avatar-link:hover {
  transform: scale(1.08);
  box-shadow: 0 0 10px color-mix(in srgb, var(--game-primary, var(--hcc-accent)) 50%, transparent);
}

/* ── Light-mode logo inversion ──────────────────────────────
   The nav background is always dark so in-nav logos need no
   change. Page-level logos (hero, hypercard on open bg) need
   to be inverted when the theme switches to light.
   We expose .hcc-logo-on-bg for any logo rendered on the
   page background (outside the nav stripe).
   ────────────────────────────────────────────────────────── */
.hcc-logo-on-bg {
  transition: filter var(--hcc-duration) var(--hcc-ease);
}
[data-theme="light"] .hcc-logo-on-bg {
  filter: invert(1);
}

/* Hub hero wordmark — always on page background */
.hub-wordmark {
  filter: none;
  transition: filter var(--hcc-duration) var(--hcc-ease);
}
[data-theme="light"] .hub-wordmark {
  filter: invert(1);
}

/* Game card logos — rendered on --hcc-surface (white in light) */
.game-logo {
  transition: filter var(--hcc-duration) var(--hcc-ease);
}
[data-theme="light"] .game-logo {
  filter: invert(1) brightness(0.82);
}

/* Profile card watermark — on --hcc-surface */
.pf-card-mark img {
  transition: filter var(--hcc-duration) var(--hcc-ease);
}
[data-theme="light"] .pf-card-mark img {
  filter: invert(1) brightness(0.7);
}

/* Hypercard logo inside the card (always on dark gradient — no change) */
.hcc-hypercard-logo { filter: none; }

