/* ============================================================
   ALTERFANS - Main Stylesheet
   Dark cosmic aesthetic · Cinzel Decorative / Crimson Pro
   ============================================================ */

/* --- Tokens --- */
:root {
  --av-void:        #0a0a0f;
  --av-void-light:  #12121c;
  --av-void-mid:    #1a1a2e;
  --av-surface:     #1e1e30;
  --av-surface-2:   #252540;
  --av-border:      #2a2a45;
  --av-border-glow: #3a3a5a;

  --av-gold:        #c9a84c;
  --av-gold-light:  #e4cc7a;
  --av-gold-dim:    #8a7433;

  --av-text:        #d4d0c8;
  --av-text-dim:    #8a8678;
  --av-text-bright: #f0ece0;
  --av-white:       #faf8f0;

  /* Faction colors */
  --av-axiom:       #3B82F6;
  --av-bravos:      #EF4444;
  --av-lyra:        #A855F7;
  --av-muna:        #22C55E;
  --av-ordis:       #F59E0B;
  --av-yzmir:       #06B6D4;

  /* Rarity */
  --av-common:      #8a8678;
  --av-rare:        #c9a84c;
  --av-unique:      #A855F7;

  /* Status */
  --av-success:     #22C55E;
  --av-warning:     #F59E0B;
  --av-danger:      #EF4444;
  --av-info:        #3B82F6;

  /* Typography */
  --av-font-display: 'Cinzel Decorative', serif;
  --av-font-body:    'Crimson Pro', Georgia, serif;
  --av-font-mono:    'JetBrains Mono', monospace;

  /* Spacing */
  --av-gap: 1.5rem;
  --av-radius: 6px;
  --av-radius-lg: 12px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--av-font-body);
  background: var(--av-void);
  color: var(--av-text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* Grain overlay */
.av-bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

a { color: var(--av-gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--av-gold-light); }

img { max-width: 100%; height: auto; }

/* --- Navigation --- */
.av-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--av-border);
}

.av-nav__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--av-gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.av-nav__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--av-gold);
  font-family: var(--av-font-display);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.av-nav__logo {
  font-size: 1.4rem;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.7; text-shadow: 0 0 4px var(--av-gold-dim); }
  50% { opacity: 1; text-shadow: 0 0 12px var(--av-gold); }
}

.av-nav__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.av-nav__link {
  color: var(--av-text-dim);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border-radius: var(--av-radius);
  transition: all 0.2s;
  white-space: nowrap;
}

.av-nav__link:hover {
  color: var(--av-text-bright);
  background: var(--av-surface);
}

.av-nav__link--cta {
  color: var(--av-gold);
  border: 1px solid var(--av-gold-dim);
}

.av-nav__link--cta:hover {
  background: rgba(201, 168, 76, 0.1);
  color: var(--av-gold-light);
}

.av-nav__link--icon { position: relative; }

.av-nav__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--av-danger);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 10px;
  font-family: var(--av-font-mono);
}

.av-nav__user {
  position: relative;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.av-nav__username {
  color: var(--av-gold);
  font-size: 0.9rem;
}

.av-nav__dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  min-width: 160px;
  padding: 0.4rem 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.av-nav__user:hover .av-nav__dropdown { display: block; }

.av-nav__dropdown a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--av-text);
  font-size: 0.85rem;
}

.av-nav__dropdown a:hover {
  background: var(--av-void-mid);
  color: var(--av-gold);
}

.av-nav__hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 4px;
}

.av-nav__hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--av-text-dim);
  transition: 0.2s;
}

/* --- Main Content --- */
.av-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--av-gap);
  position: relative;
  z-index: 1;
  min-height: 70vh;
}

/* --- Page Headers --- */
.av-page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--av-border);
}

.av-page-header h1 {
  font-family: var(--av-font-display);
  color: var(--av-gold);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.av-page-header p {
  color: var(--av-text-dim);
  margin-top: 0.4rem;
  font-size: 1.05rem;
}

/* --- Card Grid --- */
.av-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--av-gap);
}

.av-card {
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-lg);
  overflow: hidden;
  transition: all 0.3s;
  position: relative;
}

.av-card:hover {
  border-color: var(--av-gold-dim);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 20px rgba(201, 168, 76, 0.05);
}

.av-card__image {
  aspect-ratio: 5/7;
  background: var(--av-void-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.av-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.av-card:hover .av-card__image img {
  transform: scale(1.05);
}

.av-card__placeholder {
  color: var(--av-text-dim);
  font-family: var(--av-font-display);
  font-size: 0.75rem;
  text-align: center;
  padding: 1rem;
}

.av-card__rarity {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-family: var(--av-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.av-card__rarity--C { background: rgba(138,134,120,0.8); color: #fff; }
.av-card__rarity--R { background: rgba(201,168,76,0.85); color: #1a1a2e; }
.av-card__rarity--U { background: rgba(168,85,247,0.85); color: #fff; }

.av-card__faction {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--av-font-mono);
}

.av-card__info {
  padding: 0.75rem;
}

.av-card__name {
  font-family: var(--av-font-display);
  font-size: 0.8rem;
  color: var(--av-text-bright);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.av-card__meta {
  font-size: 0.75rem;
  color: var(--av-text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.av-card__stats {
  display: flex;
  gap: 0.4rem;
  font-family: var(--av-font-mono);
  font-size: 0.7rem;
}

.av-card__stats span { opacity: 0.7; }
.av-card__stats .forest { color: #22C55E; }
.av-card__stats .mountain { color: #EF4444; }
.av-card__stats .water { color: #3B82F6; }

/* Collection overlay on cards */
.av-card__owned {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(10,10,15,0.95));
  padding: 2rem 0.75rem 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.av-card:hover .av-card__owned { opacity: 1; }

.av-card__qty-control {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.av-card__qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--av-gold-dim);
  background: var(--av-void);
  color: var(--av-gold);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.av-card__qty-btn:hover {
  background: var(--av-gold);
  color: var(--av-void);
}

.av-card__qty-val {
  font-family: var(--av-font-mono);
  color: var(--av-gold-light);
  min-width: 24px;
  text-align: center;
  font-size: 0.9rem;
}

/* --- Filters Bar --- */
.av-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.av-filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.av-filter-group label {
  font-size: 0.8rem;
  color: var(--av-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--av-font-mono);
}

.av-select,
.av-input {
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  color: var(--av-text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--av-radius);
  font-family: var(--av-font-body);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.av-select:focus,
.av-input:focus {
  outline: none;
  border-color: var(--av-gold-dim);
}

.av-input--search {
  min-width: 220px;
  padding-left: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a8678' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.44.706a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.6rem center;
}

/* --- Buttons --- */
.av-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--av-radius);
  font-family: var(--av-font-body);
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.av-btn--primary {
  background: var(--av-gold);
  color: var(--av-void);
  border-color: var(--av-gold);
  font-weight: 600;
}

.av-btn--primary:hover {
  background: var(--av-gold-light);
  color: var(--av-void);
}

.av-btn--ghost {
  background: transparent;
  color: var(--av-gold);
  border-color: var(--av-gold-dim);
}

.av-btn--ghost:hover {
  background: rgba(201, 168, 76, 0.1);
  color: var(--av-gold-light);
}

.av-btn--sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.av-btn--danger {
  background: transparent;
  color: var(--av-danger);
  border-color: var(--av-danger);
}

/* --- Listings Table --- */
.av-listings {
  display: grid;
  gap: 1rem;
}

.av-listing {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 1rem;
  padding: 1rem;
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-lg);
  align-items: center;
  transition: border-color 0.2s;
}

.av-listing:hover { border-color: var(--av-border-glow); }

.av-listing__thumb {
  width: 80px;
  aspect-ratio: 5/7;
  border-radius: var(--av-radius);
  overflow: hidden;
  background: var(--av-void-mid);
}

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

.av-listing__details h3 {
  font-family: var(--av-font-display);
  font-size: 0.95rem;
  color: var(--av-text-bright);
  margin-bottom: 0.3rem;
}

.av-listing__details p {
  font-size: 0.85rem;
  color: var(--av-text-dim);
}

.av-listing__price {
  font-family: var(--av-font-display);
  font-size: 1.2rem;
  color: var(--av-gold);
  text-align: right;
}

.av-listing__type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--av-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.av-listing__type--sell { background: rgba(34,197,94,0.15); color: var(--av-success); }
.av-listing__type--trade { background: rgba(59,130,246,0.15); color: var(--av-info); }
.av-listing__type--both { background: rgba(201,168,76,0.15); color: var(--av-gold); }

/* --- Stats / Progress Bars --- */
.av-progress {
  height: 6px;
  background: var(--av-void-mid);
  border-radius: 3px;
  overflow: hidden;
}

.av-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--av-gold-dim), var(--av-gold));
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.av-stat-card {
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-lg);
  padding: 1.25rem;
}

.av-stat-card__label {
  font-size: 0.75rem;
  color: var(--av-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--av-font-mono);
}

.av-stat-card__value {
  font-family: var(--av-font-display);
  font-size: 1.8rem;
  color: var(--av-gold);
  margin: 0.3rem 0;
}

/* --- Forms --- */
.av-form {
  max-width: 480px;
}

.av-form-group {
  margin-bottom: 1.25rem;
}

.av-form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--av-text-dim);
  margin-bottom: 0.4rem;
  font-family: var(--av-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

.av-form-group .av-input,
.av-form-group .av-select,
.av-form-group textarea {
  width: 100%;
}

.av-form-group textarea {
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  color: var(--av-text);
  padding: 0.6rem 0.75rem;
  border-radius: var(--av-radius);
  font-family: var(--av-font-body);
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
}

.av-form-group textarea:focus {
  outline: none;
  border-color: var(--av-gold-dim);
}

/* --- Flash Messages --- */
.av-flashes {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem var(--av-gap) 0;
  position: relative;
  z-index: 50;
}

.av-flash {
  padding: 0.75rem 1rem;
  border-radius: var(--av-radius);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  animation: flash-in 0.3s ease-out;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.av-flash--success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: var(--av-success); }
.av-flash--error   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: var(--av-danger); }
.av-flash--info    { background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.3); color: var(--av-info); }

.av-flash__close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.6;
}

/* --- Pagination --- */
.av-pagination {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 2rem;
}

.av-pagination a,
.av-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border-radius: var(--av-radius);
  font-family: var(--av-font-mono);
  font-size: 0.85rem;
  border: 1px solid var(--av-border);
  color: var(--av-text-dim);
  transition: all 0.2s;
}

.av-pagination a:hover {
  border-color: var(--av-gold-dim);
  color: var(--av-gold);
}

.av-pagination .active {
  background: var(--av-gold);
  border-color: var(--av-gold);
  color: var(--av-void);
}

/* --- Footer --- */
.av-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--av-border);
  padding: 2rem 0;
  position: relative;
  z-index: 1;
}

.av-footer__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--av-gap);
  text-align: center;
}

.av-footer__fan-notice {
  font-size: 0.75rem;
  color: var(--av-text-dim);
  font-style: italic;
  margin-bottom: 1rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.av-footer__links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.av-footer__links a {
  font-size: 0.8rem;
  color: var(--av-text-dim);
}

.av-footer__copy {
  font-size: 0.75rem;
  color: var(--av-text-dim);
  opacity: 0.6;
}

/* --- Collection Stats Grid --- */
.av-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* --- Empty State --- */
.av-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--av-text-dim);
}

.av-empty__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.av-empty h3 {
  font-family: var(--av-font-display);
  color: var(--av-text);
  margin-bottom: 0.5rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .av-nav__links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--av-void);
    border-bottom: 1px solid var(--av-border);
    flex-direction: column;
    padding: 1rem;
  }

  .av-nav__links--open { display: flex; }
  .av-nav__hamburger { display: flex; }

  .av-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .av-listing {
    grid-template-columns: 60px 1fr;
  }

  .av-listing__price {
    grid-column: 1 / -1;
    text-align: left;
    margin-top: 0.5rem;
  }

  .av-page-header h1 { font-size: 1.3rem; }
  .av-filters { flex-direction: column; align-items: stretch; }
}
