/* ===================================================================
   GradeWise Comics — Mobile-First Design System
   Built on Bootstrap 5 dark theme
   =================================================================== */

:root {
  --gw-topbar-h: 52px;
  --gw-bottomnav-h: 60px;
  --gw-accent: #0d6efd;
  --gw-success: #198754;
  --gw-danger: #dc3545;
  --gw-warning: #ffc107;
  --gw-surface: #1a1d21;
  --gw-surface-alt: #212529;
  --gw-border: #2c3034;
  --gw-muted: #6c757d;
}

/* ---- App Shell ---- */

.gw-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--gw-topbar-h);
  background: var(--gw-surface);
  border-bottom: 1px solid var(--gw-border);
  z-index: 1030;
  padding: 0 12px;
  display: flex;
  align-items: center;
}

.gw-logo-icon {
  font-size: 1.4rem;
  color: var(--gw-accent);
}

.gw-brand {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  letter-spacing: -0.02em;
}

.gw-page-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.gw-source-offer {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gw-muted);
}

.gw-source-offer a {
  color: inherit;
}

.gw-login-overlay .gw-source-offer {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  margin: 0;
}

.gw-main {
  padding-top: calc(var(--gw-topbar-h) + 12px);
  padding-bottom: calc(var(--gw-bottomnav-h) + 16px + env(safe-area-inset-bottom, 0));
  padding-left: 12px;
  padding-right: 12px;
  min-height: 100vh;
}

.gw-bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--gw-bottomnav-h);
  background: var(--gw-surface);
  border-top: 1px solid var(--gw-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.gw-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--gw-muted);
  font-size: 0.65rem;
  gap: 2px;
  padding: 4px 12px;
  border-radius: 8px;
  transition: color 0.15s;
}

.gw-nav-item i {
  font-size: 1.25rem;
}

.gw-nav-item.active,
.gw-nav-item:hover {
  color: var(--gw-accent);
}

.gw-nav-add {
  color: var(--gw-accent) !important;
}

.gw-nav-add i {
  font-size: 1.6rem;
}

/* ---- Login Overlay ---- */

.gw-login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gw-login-card {
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
}

/* ---- Cards ---- */

.gw-card {
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

a.gw-card:hover,
button.gw-card:hover,
.gw-card[style*="cursor:pointer"]:hover {
  border-color: var(--gw-accent);
}

/* Keyboard-operable card buttons render identically to div cards */
button.gw-card {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button.gw-comic-card {
  display: flex;
}

:focus-visible {
  outline: 2px solid var(--gw-accent);
  outline-offset: 2px;
}

.gw-card a {
  text-decoration: none;
  color: inherit;
}

/* Comic Card */

.gw-comic-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.gw-comic-info {
  flex: 1;
  min-width: 0;
}

.gw-comic-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gw-comic-meta {
  font-size: 0.75rem;
  color: var(--gw-muted);
}

.gw-comic-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ---- Metric Chip ---- */

.gw-metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.gw-metric-label {
  font-size: 0.65rem;
  color: var(--gw-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gw-metric-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.gw-metric-value.positive {
  color: var(--gw-success);
}

.gw-metric-value.negative {
  color: var(--gw-danger);
}

/* ---- Stat Block ---- */

.gw-stat-block {
  background: var(--gw-surface-alt);
  border: 1px solid var(--gw-border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}

.gw-stat-block .label {
  font-size: 0.65rem;
  color: var(--gw-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.gw-stat-block .value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.gw-stat-block .value.sm {
  font-size: 1rem;
}

.gw-stat-block .helper {
  font-size: 0.7rem;
  color: var(--gw-muted);
  margin-top: 2px;
}

/* ---- KPI Row ---- */

.gw-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

/* ---- Section Header ---- */

.gw-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  margin-top: 20px;
}

.gw-section-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gw-muted);
  margin: 0;
}

/* ---- Badges / Tags ---- */

.gw-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gw-badge-key {
  background: rgba(255,193,7,0.15);
  color: var(--gw-warning);
}

.gw-badge-rare {
  background: rgba(220,53,69,0.15);
  color: var(--gw-danger);
}

.gw-badge-scarce {
  background: rgba(255,193,7,0.15);
  color: var(--gw-warning);
}

.gw-badge-uncommon {
  background: rgba(13,110,253,0.15);
  color: var(--gw-accent);
}

.gw-badge-common {
  background: rgba(108,117,125,0.15);
  color: var(--gw-muted);
}

.gw-badge-grade {
  background: rgba(25,135,84,0.15);
  color: var(--gw-success);
}

/* ---- Rarity Score Visual ---- */

.gw-rarity-display {
  text-align: center;
  padding: 20px 0;
}

.gw-rarity-score {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, var(--gw-accent), #6610f2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gw-rarity-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ---- Recommendation Banner ---- */

.gw-recommendation {
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gw-recommendation i {
  font-size: 1.3rem;
}

.gw-recommendation.grade-now {
  background: rgba(25,135,84,0.15);
  color: var(--gw-success);
  border: 1px solid rgba(25,135,84,0.3);
}

.gw-recommendation.do-not-grade {
  background: rgba(220,53,69,0.15);
  color: var(--gw-danger);
  border: 1px solid rgba(220,53,69,0.3);
}

.gw-recommendation.speculative {
  background: rgba(255,193,7,0.15);
  color: var(--gw-warning);
  border: 1px solid rgba(255,193,7,0.3);
}

.gw-recommendation.conditional {
  background: rgba(13,110,253,0.15);
  color: var(--gw-accent);
  border: 1px solid rgba(13,110,253,0.3);
}

/* ---- Bottom Sheet (filter overlay) ---- */

.gw-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--gw-surface);
  border-top: 1px solid var(--gw-border);
  border-radius: 16px 16px 0 0;
  z-index: 1050;
  padding: 16px;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.gw-bottom-sheet.open {
  transform: translateY(0);
}

.gw-bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1049;
  display: none;
}

.gw-bottom-sheet-backdrop.open {
  display: block;
}

/* ---- Empty State ---- */

.gw-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--gw-muted);
}

.gw-empty i {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

/* ---- Loading Skeleton ---- */

.gw-skeleton {
  background: linear-gradient(90deg, var(--gw-surface-alt) 25%, var(--gw-border) 50%, var(--gw-surface-alt) 75%);
  background-size: 200% 100%;
  animation: gw-shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes gw-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Form Enhancements ---- */

.gw-form .form-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gw-muted);
  font-weight: 600;
}

.gw-form .form-control,
.gw-form .form-select {
  background: var(--gw-surface-alt);
  border-color: var(--gw-border);
}

.gw-form .form-text {
  font-size: 0.7rem;
}

/* ---- Responsive tweaks ---- */

@media (min-width: 576px) {
  .gw-main {
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 768px) {
  .gw-main {
    max-width: 720px;
  }
  .gw-kpi-row {
    grid-template-columns: repeat(4, 1fr);
  }
}
