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

:root {
  /* Sandy, chalky parchment palette */
  --sand:        #e8dfc8;
  --sand-light:  #f2ead6;
  --sand-dark:   #d4c9b0;
  --parchment:   #f7f2e6;

  /* Maroon / dark red replacing all greens */
  --maroon:      #6b1a1a;
  --maroon-mid:  #8b2424;
  --maroon-light:#a83030;
  --maroon-pale: #f5eaea;

  /* Ink & text */
  --ink:         #2a1f1f;
  --ink-mid:     #5a4040;
  --ink-muted:   #8a7070;

  /* Accents */
  --gold:        #9a7d3a;
  --cream:       #fdf8ef;

  --radius: 8px;
  --shadow: 0 2px 10px rgba(60,20,20,0.10);
}

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--sand);
  /* Subtle noise texture via repeating gradient */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--maroon);
  /* Faint diagonal line texture for a worn feel */
  background-image: repeating-linear-gradient(
    135deg,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 8px
  );
  color: var(--sand-light);
  padding: 2rem 2.5rem 1.75rem;
  border-bottom: 4px solid var(--gold);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--gold);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

h1 {
  font-family: 'Caveat', cursive;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sand-light);
  letter-spacing: 0.01em;
  /* Slight text-shadow for chalky feel */
  text-shadow: 1px 2px 0px rgba(0,0,0,0.25), 0 0 20px rgba(232,223,200,0.15);
}

.header-sub {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.85rem;
  color: rgba(232,223,200,0.6);
  font-style: italic;
  margin-top: 4px;
  letter-spacing: 0.03em;
}

.header-stats {
  display: flex;
  gap: 2.5rem;
  padding-bottom: 4px;
}

.stat { text-align: center; }

.stat-num {
  display: block;
  font-family: 'Caveat', cursive;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sand-light);
}

.stat-label {
  display: block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(232,223,200,0.5);
  margin-top: 2px;
}

/* ── Main ── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 3rem;
  flex: 1;
  width: 100%;
}

/* ── Controls ── */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--sand-light);
  border: 1px solid var(--sand-dark);
  border-radius: var(--radius);
}

.controls input,
.controls select {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  border: 1.5px solid var(--sand-dark);
  border-radius: 6px;
  background: var(--parchment);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.controls input { flex: 1; min-width: 220px; }
.controls select { min-width: 140px; }

.controls input:focus,
.controls select:focus {
  border-color: var(--maroon);
}

.results-label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 1rem;
  padding-left: 2px;
  font-style: italic;
}

/* ── Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
  overflow: visible;
  isolation: isolate;
}

.loading, .no-results {
  font-family: 'Source Sans 3', sans-serif;
  color: var(--ink-muted);
  font-style: italic;
  grid-column: 1/-1;
  padding: 2rem 0;
  text-align: center;
}

/* ── Individual card ── */
.card {
  background: var(--parchment);
  border: 1px solid var(--sand-dark);
  border-radius: var(--radius);
  overflow: visible;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  transform-origin: center center;
  will-change: transform;
}

/* clip inner content without clipping the scaled card */
.card-top,
.card-body {
  overflow: hidden;
}

.card-top {
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: visible;
}

.card-body {
  border-radius: 0 0 var(--radius) var(--radius);
}

.card:hover {
  transform: scale(1.33);
  box-shadow: 0 16px 48px rgba(60,20,20,0.30);
  z-index: 50;
}

.card-top {
  background: var(--maroon);
  background-image: repeating-linear-gradient(
    135deg,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 8px
  );
  padding: 0.6rem 1rem 0.6rem;
  position: relative;
  border-bottom: 2px solid var(--gold);
}

.card-player-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-right: 110px;
}

.card-logo {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--gold);
  flex-shrink: 0;
  display: block;
}

.card-year-brand {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(232,223,200,0.6);
  margin-bottom: 3px;
}

.card-player {
  font-family: 'Caveat', cursive;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--sand-light);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.card-team {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.78rem;
  color: rgba(232,223,200,0.6);
  font-style: italic;
}

.card-badges {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0.75rem;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.badge {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 6px;
  border-radius: 3px;
}

.badge-rc   { background: var(--gold);         color: #fff; }
.badge-auto { background: rgba(255,255,255,0.15); color: var(--sand-light); border: 1px solid rgba(232,223,200,0.4); }

/* Stack RC and AUTO vertically before the diamond */
.card-badges {
  flex-wrap: nowrap;
}

.card-badges .badge {
  align-self: center;
}

/* When both badges present, wrap them in a mini column */
.card-badges.dual-badge {
  gap: 3px;
}

.card-badges.dual-badge .badge {
  display: block;
}

.card-body {
  padding: 0.85rem 1rem;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--sand);
  font-size: 0.83rem;
}

.card-row:last-child { border-bottom: none; }

.row-label {
  font-family: 'Source Sans 3', sans-serif;
  color: var(--ink-muted);
  font-size: 0.75rem;
}

.row-value {
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  font-family: 'Source Sans 3', sans-serif;
}

.value-money { color: var(--maroon-mid); }

.card-notes {
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--sand-dark);
  font-size: 0.77rem;
  font-style: italic;
  color: var(--ink-muted);
  font-family: 'Lora', Georgia, serif;
  line-height: 1.5;
}

/* ── Footer ── */
footer {
  background: var(--maroon);
  border-top: 3px solid var(--gold);
  text-align: center;
  padding: 1rem;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.78rem;
  color: rgba(232,223,200,0.5);
  letter-spacing: 0.03em;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  header  { padding: 1.5rem 1rem 1.25rem; }
  main    { padding: 1.25rem 1rem 2rem; }
  h1      { font-size: 2.25rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .header-stats { gap: 1.5rem; }
}

/* ── Position diamond icon ── */
.position-diamond {
  width: 38px;
  height: 38px;
  display: block;
  border-radius: 3px;
  border: 1px solid var(--gold);
  background: var(--maroon-mid);
  flex-shrink: 0;
}

/* Dual-badge: same row layout as single badge */
.card-badges.dual-badge {
  justify-content: flex-end;
}

/* ── Emoji rain ── */
.emoji-rain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: 0;
}

.emoji-drop {
  position: absolute;
  top: -1.5em;
  font-size: 14px;
  animation: fall linear forwards;
  opacity: 0.85;
  user-select: none;
}

@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg);   opacity: 0.85; }
  100% { transform: translateY(120px) rotate(360deg); opacity: 0; }
}

/* Vertical stack of RC/AUTO badges sitting left of the diamond */
.badge-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}
