/*
 * Reusable components, named after their VvmTheme counterparts so a change in
 * the app has an obvious home here (see docs/design-system.md).
 * Depends on tokens.css and base.css.
 */

/* --- Panel / Card (VvmPanel, VvmCard) --- */

.panel {
  background: var(--vvm-surface);
  border: var(--vvm-border-thin) solid var(--vvm-border);
  border-radius: var(--vvm-radius-lg);
  padding: var(--vvm-space-lg);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--vvm-space-sm);
  background: var(--vvm-surface);
  border: var(--vvm-border-thin) solid var(--vvm-border-muted);
  border-radius: var(--vvm-radius-lg);
  padding: var(--vvm-space-lg);
  box-shadow: var(--vvm-elev-raised);
  transition: border-color var(--vvm-motion-standard) var(--vvm-ease),
    transform var(--vvm-motion-standard) var(--vvm-ease);
}

.card > :last-child {
  margin-bottom: 0;
}

.card--link:hover,
.card--link:focus-within {
  border-color: var(--vvm-border);
  transform: translateY(-2px);
}

.card__icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.card__title {
  font-family: var(--vvm-font-display);
  font-size: var(--vvm-text-title-md);
  font-weight: 700;
}

.card__body {
  color: var(--vvm-text-secondary);
  margin-bottom: 0;
}

/* --- Button (VvmButton) --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--vvm-space-sm);
  min-height: var(--vvm-touch-target);
  padding: var(--vvm-space-sm) var(--vvm-space-xl);
  border: var(--vvm-border-thin) solid transparent;
  border-radius: var(--vvm-radius-md);
  font-size: var(--vvm-text-label);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--vvm-motion-quick) var(--vvm-ease),
    color var(--vvm-motion-quick) var(--vvm-ease);
}

.btn--primary {
  background: var(--vvm-action);
  color: var(--vvm-action-content);
}

.btn--primary:hover {
  background: var(--vvm-action-hover);
  color: var(--vvm-action-content);
}

.btn--secondary {
  background: transparent;
  border-color: var(--vvm-border);
  color: var(--vvm-text);
}

.btn--secondary:hover {
  background: var(--vvm-surface-raised);
  color: var(--vvm-text);
}

.btn[aria-disabled='true'],
.btn:disabled {
  background: var(--vvm-disabled);
  border-color: transparent;
  color: var(--vvm-text-muted);
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Store badge --- */

.store-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vvm-space-md);
}

.store-badge {
  display: flex;
  align-items: center;
  gap: var(--vvm-space-md);
  min-width: 200px;
  min-height: 60px;
  padding: var(--vvm-space-sm) var(--vvm-space-lg);
  border: var(--vvm-border-thin) solid var(--vvm-border);
  border-radius: var(--vvm-radius-md);
  background: var(--vvm-surface-inset);
  color: var(--vvm-text);
  text-decoration: none;
  transition: background-color var(--vvm-motion-quick) var(--vvm-ease);
}

.store-badge:hover {
  background: var(--vvm-surface-raised);
  color: var(--vvm-text);
}

.store-badge[aria-disabled='true'] {
  cursor: not-allowed;
  pointer-events: none;
  border-color: var(--vvm-border-muted);
  color: var(--vvm-text-muted);
}

.store-badge svg {
  flex: none;
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.store-badge__lines {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.store-badge__small {
  font-size: var(--vvm-text-meta);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--vvm-text-muted);
}

.store-badge__large {
  font-size: 1.0625rem;
  font-weight: 700;
}

/* --- Badge / chip (VvmBadge) --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--vvm-space-xs);
  padding: var(--vvm-space-xxs) var(--vvm-space-sm);
  border: var(--vvm-border-thin) solid var(--vvm-border-muted);
  border-radius: var(--vvm-radius-sm);
  background: var(--vvm-surface-inset);
  font-size: var(--vvm-text-meta);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--vvm-text-secondary);
  white-space: nowrap;
}

.badge--warning {
  border-color: var(--vvm-warning);
  color: var(--vvm-warning);
}

.badge--success {
  border-color: var(--vvm-success);
  color: var(--vvm-success);
}

.badge--secret-fire {
  border-color: var(--vvm-secret-fire-border);
  background: var(--vvm-secret-fire-violet);
  color: var(--vvm-secret-fire);
}

/* --- Portrait frame (VvmPortraitFrame) --- */

.portrait {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--portrait-size, 56px);
  height: var(--portrait-size, 56px);
  overflow: hidden;
  border: var(--vvm-border-thick) solid var(--vvm-border);
  border-radius: 50%;
  background: var(--vvm-tile-plate);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait--lg {
  --portrait-size: 128px;
}

/* --- Art tile (VvmEquipmentTile): game art sits on its authored light plate --- */

.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: var(--vvm-space-xs);
  border: var(--vvm-border-thin) solid var(--vvm-border);
  border-radius: var(--vvm-radius-md);
  background: var(--vvm-tile-plate);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile--dark {
  background: var(--vvm-surface-inset);
}

.tile-figure {
  display: flex;
  flex-direction: column;
  gap: var(--vvm-space-xs);
  align-items: center;
  margin: 0;
  text-align: center;
}

.tile-figure figcaption {
  font-size: var(--vvm-text-meta);
  color: var(--vvm-text-muted);
}

.tile-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: var(--vvm-space-md);
}

/* --- Table (leaderboards) --- */

.table {
  width: 100%;
  /* Below this the name and equipment columns crush together, so the wrapping
     .scroll-x takes over rather than the text shredding. */
  min-width: 34rem;
  font-variant-numeric: tabular-nums;
  border-collapse: collapse;
  font-size: var(--vvm-text-label);
}

.table caption {
  text-align: left;
  padding-bottom: var(--vvm-space-sm);
  color: var(--vvm-text-muted);
  font-size: var(--vvm-text-meta);
}

.table th,
.table td {
  padding: var(--vvm-space-sm) var(--vvm-space-md);
  text-align: left;
  border-bottom: var(--vvm-border-thin) solid var(--vvm-border-muted);
  vertical-align: middle;
}

/* The teaser boards drop their secondary columns, so they always fit. */
.table--compact {
  min-width: 0;
}

.table th {
  font-size: var(--vvm-text-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vvm-text-muted);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: var(--vvm-surface-inset);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank {
  display: inline-grid;
  place-items: center;
  min-width: 2.25em;
  padding: 0.1em 0.4em;
  border-radius: var(--vvm-radius-sm);
  background: var(--vvm-surface-inset);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rank--1 { background: var(--vvm-action); color: var(--vvm-action-content); }
.rank--2 { background: var(--vvm-text-muted); color: var(--vvm-action-content); }
.rank--3 { background: var(--vvm-action-secondary); color: var(--vvm-text); }

.name-cell {
  display: flex;
  align-items: center;
  gap: var(--vvm-space-md);
}

.name-cell__text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.name-cell__text > a,
.name-cell__text > strong {
  white-space: nowrap;
}

.name-cell__sub {
  font-size: var(--vvm-text-meta);
  color: var(--vvm-text-muted);
  white-space: nowrap;
}

/* --- Tabs (VvmTabRow) --- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vvm-space-xs);
  margin-bottom: var(--vvm-space-lg);
  border-bottom: var(--vvm-border-thin) solid var(--vvm-border-muted);
}

.tab {
  min-height: var(--vvm-touch-target);
  padding: var(--vvm-space-sm) var(--vvm-space-lg);
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--vvm-text-muted);
  font-size: var(--vvm-text-label);
  font-weight: 700;
  cursor: pointer;
  transition: color var(--vvm-motion-quick) var(--vvm-ease),
    border-color var(--vvm-motion-quick) var(--vvm-ease);
}

.tab:hover {
  color: var(--vvm-text-secondary);
}

.tab[aria-selected='true'] {
  color: var(--vvm-action);
  border-bottom-color: var(--vvm-action);
}

/* --- Stat tile --- */

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--vvm-space-xxs);
  padding: var(--vvm-space-lg);
  border: var(--vvm-border-thin) solid var(--vvm-border-muted);
  border-radius: var(--vvm-radius-lg);
  background: var(--vvm-surface);
}

.stat__value {
  font-family: var(--vvm-font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--vvm-action);
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-size: var(--vvm-text-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vvm-text-muted);
}

/* --- Notices --- */

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vvm-space-sm);
  padding: var(--vvm-space-md) var(--vvm-space-lg);
  border: var(--vvm-border-thin) solid var(--vvm-border-muted);
  border-left-width: 4px;
  border-radius: var(--vvm-radius-md);
  background: var(--vvm-surface-inset);
  color: var(--vvm-text-secondary);
  font-size: var(--vvm-text-label);
}

.notice--warning {
  border-left-color: var(--vvm-warning);
}

.notice--info {
  border-left-color: var(--vvm-action);
}

.notice p {
  margin: 0;
}

/* --- Site chrome --- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--vvm-bg-base) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: var(--vvm-border-thin) solid var(--vvm-border-muted);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vvm-space-md);
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--vvm-space-sm);
  color: var(--vvm-text);
  font-family: var(--vvm-font-display);
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--vvm-touch-target);
  height: var(--vvm-touch-target);
  padding: 0;
  border: var(--vvm-border-thin) solid var(--vvm-border-muted);
  border-radius: var(--vvm-radius-md);
  background: transparent;
  color: var(--vvm-text);
  cursor: pointer;
}

.nav-toggle svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--vvm-space-xs);
}

.site-nav a {
  padding: var(--vvm-space-sm) var(--vvm-space-md);
  border-radius: var(--vvm-radius-md);
  color: var(--vvm-text-secondary);
  font-size: var(--vvm-text-label);
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--vvm-surface-inset);
  color: var(--vvm-text);
}

.site-nav a[aria-current='page'] {
  color: var(--vvm-action);
}

@media (max-width: 820px) {
  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--vvm-space-sm) var(--vvm-page-gutter) var(--vvm-space-lg);
    background: var(--vvm-bg-layer);
    border-bottom: var(--vvm-border-thin) solid var(--vvm-border-muted);
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a {
    min-height: var(--vvm-touch-target);
    display: flex;
    align-items: center;
  }
}

.site-footer {
  padding-block: var(--vvm-space-xxl);
  border-top: var(--vvm-border-thin) solid var(--vvm-border-muted);
  background: var(--vvm-bg-layer);
  color: var(--vvm-text-muted);
  font-size: var(--vvm-text-label);
}

.site-footer__grid {
  display: grid;
  gap: var(--vvm-space-xl);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  margin-bottom: var(--vvm-space-xl);
}

.site-footer h2 {
  font-size: var(--vvm-text-meta);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--vvm-text-secondary);
  margin-bottom: var(--vvm-space-sm);
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer li + li {
  margin-top: var(--vvm-space-xs);
}

.site-footer a {
  color: var(--vvm-text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--vvm-action);
}

.site-footer__legal {
  padding-top: var(--vvm-space-lg);
  border-top: var(--vvm-border-thin) solid var(--vvm-border-muted);
  font-size: var(--vvm-text-meta);
}

.site-footer__legal p {
  margin: 0 0 var(--vvm-space-xs);
}

.divider {
  width: 100%;
  max-width: 520px;
  margin: var(--vvm-space-xl) auto;
  opacity: 0.8;
}
