/* ============================================================
   Events CSS — HypeCity Tycoon · Phase C
   Ticker, banners, decision modals, events modal
   ============================================================ */

/* ── Market Pulse Ticker ─────────────────────────────────── */
.market-ticker {
  position: relative;
  width: 100%;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  overflow: hidden;
  height: 36px;
  display: flex;
  align-items: center;
  z-index: 50;
}

.market-ticker__track {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
  /* Day 15 P1: padding here broke the seamless -50% loop — at the
     wrap-around the duplicated content didn't align with the visible
     window, so the leftmost item appeared clipped at the viewport
     edge. Padding moved onto the parent .market-ticker so the track
     itself stays exactly 2× the visible content. */
}

.market-ticker {
  padding-left: var(--space-4);
}

.market-ticker:hover .market-ticker__track,
.market-ticker:focus-within .market-ticker__track {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.market-ticker__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  cursor: default;
  flex-shrink: 0;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-hover);
}

.market-ticker__item:hover {
  background: var(--color-surface-elevated);
}

.market-ticker__item--extreme-boom {
  color: #00D9A0;
  font-weight: var(--weight-semibold);
}

.market-ticker__item--extreme-crash {
  color: var(--color-warning);
  font-weight: var(--weight-semibold);
}

.market-ticker__item--moderate {
  color: var(--color-text-primary);
}

.market-ticker__separator {
  color: var(--color-border-default);
  font-size: 10px;
  flex-shrink: 0;
}

.market-ticker__more {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: linear-gradient(90deg, transparent, var(--color-surface) 40%);
  font-size: var(--text-xs);
  color: var(--color-primary);
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
  z-index: 2;
}

.market-ticker__more:hover {
  color: var(--color-primary-hover);
}

/* Extreme event progress badge */
.market-ticker__progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--color-text-tertiary);
  margin-left: var(--space-1);
}

.market-ticker__progress-bar {
  width: 40px;
  height: 3px;
  background: var(--color-border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.market-ticker__progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Event Banner (passive personal events) ──────────────── */
.event-banner {
  position: fixed;
  top: calc(var(--nav-height) + 36px + var(--space-2));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  z-index: 100;
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.event-banner--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.event-banner--warning {
  border-color: rgba(255, 184, 0, 0.4);
  background: linear-gradient(135deg, var(--color-surface-elevated), rgba(255, 184, 0, 0.05));
}

.event-banner--celebration {
  border-color: rgba(0, 217, 126, 0.4);
  background: linear-gradient(135deg, var(--color-surface-elevated), rgba(0, 217, 126, 0.05));
}

.event-banner__icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.event-banner__content {
  flex: 1;
  min-width: 0;
}

.event-banner__headline {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  line-height: var(--leading-tight);
  margin-bottom: 2px;
}

.event-banner__detail {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
}

.event-banner__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.event-banner__close:hover {
  color: var(--color-text-primary);
}

/* ── Event Decision Modal ────────────────────────────────── */
.event-decision-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.event-decision-backdrop--visible {
  opacity: 1;
}

.event-decision-card {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.event-decision__header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.event-decision__icon {
  font-size: 32px;
  line-height: 1;
}

.event-decision__title-area {
  flex: 1;
}

.event-decision__severity {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: var(--space-1);
}

.event-decision__severity--mild {
  color: var(--color-text-tertiary);
  background: var(--color-surface);
}

.event-decision__severity--moderate {
  color: var(--color-warning);
  background: rgba(255, 184, 0, 0.1);
}

.event-decision__severity--severe {
  color: var(--color-error);
  background: rgba(255, 71, 71, 0.1);
}

.event-decision__headline {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}

.event-decision__body {
  padding: var(--space-4);
}

.event-decision__detail {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}

.event-decision__educational {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-left: 3px solid var(--color-info);
}

.event-decision__expiry {
  font-size: var(--text-xs);
  color: var(--color-warning);
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
}

.event-decision__choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.event-decision__choice {
  background: var(--color-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-hover);
  text-align: left;
  font-family: var(--font-body);
}

.event-decision__choice:hover {
  border-color: var(--color-primary);
  background: var(--color-surface-elevated);
}

.event-decision__choice-label {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.event-decision__choice-cost {
  font-size: var(--text-sm);
  color: var(--color-warning);
  font-family: var(--font-mono);
}

.event-decision__choice-outcome {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

/* ── Black Swan Dramatic Modal ───────────────────────────── */
.black-swan-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.black-swan-backdrop--visible {
  opacity: 1;
}

.black-swan-card {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border: 1px solid rgba(255, 71, 71, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 60px rgba(255, 71, 71, 0.15);
  max-width: 520px;
  width: 100%;
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.black-swan__icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
  animation: pulse-dramatic 2s ease-in-out infinite;
}

@keyframes pulse-dramatic {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.black-swan__headline {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: #fff;
  margin-bottom: var(--space-4);
}

.black-swan__detail {
  font-size: var(--text-base);
  color: rgba(255, 255, 255, 0.7);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

.black-swan__educational {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-6);
  border-left: 3px solid var(--color-info);
}

.black-swan__dismiss {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: var(--space-2) var(--space-6);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-base);
  transition: all var(--transition-hover);
}

.black-swan__dismiss:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ── Events History Modal ────────────────────────────────── */
.events-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 180;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-4);
  padding-top: calc(var(--nav-height) + var(--space-4));
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow-y: auto;
}

.events-modal-backdrop--visible {
  opacity: 1;
}

.events-modal {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.events-modal__header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.events-modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.events-modal__close {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.events-modal__filters {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.events-modal__filter-btn {
  font-size: var(--text-xs);
  padding: 4px 12px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-hover);
}

.events-modal__filter-btn--active {
  background: var(--color-primary);
  color: var(--color-bg);
  border-color: var(--color-primary);
}

.events-modal__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-4);
}

.events-modal__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.events-modal__item:last-child {
  border-bottom: none;
}

.events-modal__item-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.events-modal__item-content {
  flex: 1;
  min-width: 0;
}

.events-modal__item-headline {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

.events-modal__item-detail {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

.events-modal__item-meta {
  font-size: 10px;
  color: var(--color-text-disabled);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* ── Mobile responsive ───────────────────────────────────── */
@media (max-width: 640px) {
  .market-ticker {
    height: 32px;
  }

  .market-ticker__item {
    font-size: 10px;
  }

  .event-banner {
    top: calc(var(--nav-height) + 32px + var(--space-1));
    max-width: calc(100vw - 16px);
  }

  .event-decision-card {
    max-height: 90vh;
  }

  .black-swan-card {
    padding: var(--space-6) var(--space-4);
  }

  .black-swan__icon {
    font-size: 48px;
  }

  .black-swan__headline {
    font-size: var(--text-xl);
  }
}
