/* ============================================
   OPA BUNDESLIGA — Dark Stadium Scoreboard
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  /* Core palette */
  --bg-deep: #0A0A0A;
  --bg-card: #151515;
  --bg-card-hover: #1C1C1C;
  --bg-konferenz: #1A1208;

  /* Status */
  --green-live: #00E676;
  --green-glow: rgba(0, 230, 118, 0.25);
  --amber-countdown: #FFB300;
  --amber-glow: rgba(255, 179, 0, 0.15);
  --gray-muted: #555;
  --gray-upcoming: #383838;

  /* Text */
  --text-primary: #F0F0F0;
  --text-secondary: #999;
  --text-muted: #555;

  /* Accent */
  --gold: #D4AF37;
  --gold-dim: rgba(212, 175, 55, 0.15);

  /* Konferenz accent (soft blue — neutral, non-semantic) */
  --konferenz: #6C9FE8;
  --konferenz-glow: rgba(108, 159, 232, 0.12);

  /* Sizing */
  --card-radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ---- Reset & Base ---- */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  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='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

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

.app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-left) + 20px) calc(var(--safe-bottom) + 100px) calc(var(--safe-right) + 20px);
}

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

.header {
  text-align: center;
  padding: 24px 0 20px;
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), var(--gold), var(--gold-dim), transparent);
}

.header-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.3));
}

.header-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 48px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--text-primary);
  line-height: 1;
}

.header-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ---- Stale Banner ---- */

.stale-banner {
  background: var(--amber-glow);
  border: 1px solid rgba(255, 179, 0, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 15px;
  color: var(--amber-countdown);
  text-align: center;
  display: none;
}

.stale-banner.visible {
  display: block;
  animation: fadeSlideIn 0.4s ease-out;
}

/* ---- Offline Banner ---- */

.offline-banner {
  background: rgba(229, 57, 53, 0.12);
  border: 1px solid rgba(229, 57, 53, 0.3);
  border-radius: 10px;
  padding: 16px;
  margin: 16px 0;
  font-size: 17px;
  color: #EF5350;
  text-align: center;
  display: none;
}

.offline-banner.visible {
  display: block;
  animation: fadeSlideIn 0.4s ease-out;
}

/* ---- Loading State ---- */

.loading-container {
  padding: 20px 0;
}

.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  height: 110px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%);
  animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---- Date Group Headers ---- */

.date-group {
  margin-top: 28px;
}

.date-group:first-child {
  margin-top: 20px;
}

.date-header {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 28px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0 4px 10px;
  border-bottom: 2px solid #222;
  margin-bottom: 14px;
}

/* ---- Match Card ---- */

.match-card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
  border: 3px solid #222;
  min-height: 100px;
}

/* Tappable cards — rendered as native <a> tags for Safari gesture propagation */
a.match-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.match-card.tappable {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.match-card.tappable:active {
  transform: scale(0.97);
}

/* ---- Status Variants ---- */

/* Live card — full green border */
.match-card.status-live {
  border-color: rgba(0, 230, 118, 0.5);
  background: linear-gradient(135deg, #0D1F12 0%, var(--bg-card) 60%);
  box-shadow:
    0 0 20px rgba(0, 230, 118, 0.08),
    inset 0 0 30px rgba(0, 230, 118, 0.03);
}

.match-card.status-live::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--green-live), transparent);
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Available card — full green border */
.match-card.status-available {
  border-color: rgba(0, 230, 118, 0.4);
  background: linear-gradient(135deg, #0F1A10 0%, var(--bg-card) 70%);
  box-shadow: 0 0 15px rgba(0, 230, 118, 0.06);
}

/* Upcoming card — full opacity for elderly readability */
.match-card.status-upcoming {
}

.match-card.status-upcoming.soon {
  border-color: rgba(255, 179, 0, 0.3);
  background: linear-gradient(135deg, #1A1608 0%, var(--bg-card) 70%);
}

/* ---- Card Inner Layout ---- */

.match-teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.team {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.team--home {
  justify-content: flex-end;
  text-align: right;
}

.team--away {
  justify-content: flex-start;
  text-align: left;
}

.team-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.team-logo-placeholder {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #2A2A2A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  color: var(--text-secondary);
}

.team-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.match-vs {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
  padding: 0 2px;
}

/* ---- Status Badge ---- */

.match-status {
  text-align: center;
  margin-top: 4px;
}

.status-badge {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.status-badge.badge-live {
  background: var(--green-live);
  color: #0A0A0A;
  animation: liveGlow 2s ease-in-out infinite;
}

@keyframes liveGlow {
  0%, 100% { box-shadow: 0 0 8px var(--green-glow); }
  50% { box-shadow: 0 0 20px var(--green-glow), 0 0 40px rgba(0, 230, 118, 0.1); }
}

.status-badge.badge-available {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green-live);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.status-badge.badge-countdown {
  background: var(--amber-glow);
  color: var(--amber-countdown);
  border: 1px solid rgba(255, 179, 0, 0.2);
}

.status-badge.badge-future {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
}

/* Match time below badge */
.match-time {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 6px;
  text-align: center;
}

/* ---- Konferenz Card ---- */

.match-card.konferenz {
  border-color: rgba(108, 159, 232, 0.35);
  background: linear-gradient(135deg, #0D1320 0%, var(--bg-card) 60%);
}

.konferenz-inner {
  text-align: center;
}

.konferenz-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text-primary);
  line-height: 1.2;
}

.konferenz-sublabel {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 2px;
  margin-bottom: 10px;
}

/* Arrow removed — full green border signals tappability instead */
.card-arrow {
  display: none;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-text {
  font-size: 22px;
  line-height: 1.5;
}

/* ---- Footer Hint ---- */

.footer-hint {
  text-align: center;
  padding: 30px 20px 20px;
  font-size: 16px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.footer-hint span {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid #222;
  border-radius: 30px;
  background: rgba(255,255,255,0.02);
}

/* ---- Refresh Indicator ---- */

.refresh-indicator {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: #222;
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 100;
  transition: transform 0.3s ease;
  white-space: nowrap;
}

.refresh-indicator.visible {
  transform: translateX(-50%) translateY(0);
}

/* ---- Animations ---- */

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.match-card {
  animation: cardEnter 1.2s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* Stagger card animations — generous spacing for a slow, luxurious reveal */
.match-card:nth-child(1) { animation-delay: 0.08s; }
.match-card:nth-child(2) { animation-delay: 0.18s; }
.match-card:nth-child(3) { animation-delay: 0.28s; }
.match-card:nth-child(4) { animation-delay: 0.38s; }
.match-card:nth-child(5) { animation-delay: 0.48s; }
.match-card:nth-child(6) { animation-delay: 0.58s; }
.match-card:nth-child(7) { animation-delay: 0.68s; }
.match-card:nth-child(8) { animation-delay: 0.78s; }
.match-card:nth-child(9) { animation-delay: 0.88s; }
.match-card:nth-child(10) { animation-delay: 0.98s; }
.match-card:nth-child(11) { animation-delay: 1.08s; }
.match-card:nth-child(12) { animation-delay: 1.18s; }

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

@media (max-width: 400px) {
  .team-name {
    font-size: 18px;
  }
  .team-logo, .team-logo-placeholder {
    width: 34px;
    height: 34px;
  }
  .header-title {
    font-size: 40px;
    letter-spacing: 4px;
  }
  .konferenz-label {
    font-size: 20px;
  }
}

@media (min-width: 601px) {
  .team-name {
    font-size: 26px;
  }
  .match-card {
    padding: 24px 28px;
  }
}

/* ---- Standalone PWA adjustments ---- */

@media all and (display-mode: standalone) {
  .app {
    padding-top: calc(var(--safe-top) + 12px);
  }
}
