/**
 * Asteroidle - Modals & Dialogs Stylesheet
 * Styling for Calendar Archive, Wordle Stats, Results, and Help Modals
 */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #0b1329;
  border: 1px solid var(--border-glow);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   Archive Modal (Calendar & List View)
   ========================================================================== */
.archive-modal-dialog {
  max-width: 580px;
  width: 95%;
}

.archive-view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.archive-tab-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.archive-tab-btn:hover {
  color: #ffffff;
  border-color: var(--accent-cyan);
}

.archive-tab-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* Calendar Navigation Bar */
.calendar-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  gap: 6px;
  flex-wrap: wrap;
}

.calendar-selectors-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.calendar-select {
  background: #0b1329;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #38bdf8;
  font-family: var(--font-display);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.calendar-select:focus,
.calendar-select:hover {
  border-color: #38bdf8;
}

.calendar-nav-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: #bae6fd;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.calendar-nav-btn:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #ffffff;
}

.calendar-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Weekday column headers */
.calendar-weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-weight: 800;
  font-size: 0.72rem;
  font-family: var(--font-display);
  color: #38bdf8;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* Calendar Month Grid - Fixed 6 Rows (42 Cells) */
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  min-height: 340px;
  box-sizing: border-box;
}

.calendar-day-cell {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 4px 2px;
  box-sizing: border-box;
  cursor: pointer;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  user-select: none;
  min-height: 52px;
}

.calendar-day-cell:hover:not(.is-empty):not(.is-future) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  z-index: 2;
}

.calendar-day-cell.is-empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}

.calendar-day-cell.is-future {
  background: rgba(15, 23, 42, 0.25);
  color: #475569;
  border-color: rgba(255, 255, 255, 0.03);
  cursor: not-allowed;
  opacity: 0.35;
}

.calendar-day-cell.is-today {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.calendar-day-cell.status-completed {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
}

.calendar-day-cell.status-completed:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  border-color: #10b981;
}

.cal-day-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  align-self: flex-start;
  padding-left: 3px;
  line-height: 1;
}

.calendar-day-cell.is-today .cal-day-num {
  color: #38bdf8;
}

.cal-puzzle-num {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: #e2e8f0;
  font-weight: 700;
}

.cal-status-tag {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  color: #94a3b8;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day-cell.status-completed .cal-status-tag {
  color: #34d399;
}

.calendar-day-cell.is-today .cal-status-tag {
  color: #38bdf8;
}

/* List View Controls */
.archive-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.archive-search-input {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.archive-search-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.archive-filter-group {
  display: flex;
  gap: 6px;
}

.archive-filter-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.archive-filter-btn:hover {
  color: #ffffff;
  border-color: #38bdf8;
}

.archive-filter-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: #38bdf8;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.archive-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.15s, background 0.15s;
}

.archive-card:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--accent-cyan);
}

.archive-card.status-completed {
  border-left: 4px solid var(--accent-green);
}

.archive-card.status-today {
  border-left: 4px solid var(--accent-cyan);
}

.archive-card.status-pending {
  border-left: 4px solid var(--text-secondary);
}

.archive-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archive-number {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.archive-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.archive-action {
  display: flex;
  align-items: center;
  gap: 10px;
}

.archive-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
}

.archive-card.status-completed .archive-badge {
  color: #34d399;
}

.archive-play-btn {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--accent-cyan);
  color: #bae6fd;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.archive-play-btn:hover {
  background: var(--accent-cyan);
  color: #030712;
}

/* ==========================================================================
   Statistics Modal (Pilot Targeting Record)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.stat-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stat-num {
  font-family: var(--font-display, 'Orbitron', sans-serif);
  font-size: 1.45rem;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1.1;
  margin-bottom: 4px;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.section-title {
  font-family: var(--font-display, 'Orbitron', sans-serif);
  font-size: 0.88rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Score Distribution Bar Graph (Wordle-Style Horizontal Bars)
   ========================================================================== */
.distribution-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.dist-label {
  width: 80px;
  font-family: var(--font-display, 'Orbitron', monospace);
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: right;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.dist-bar-track {
  flex: 1;
  height: 24px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.dist-bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Filled Bar (> 0 count) */
.dist-bar-fill.has-data {
  background: linear-gradient(90deg, #15803d, #22c55e);
  justify-content: flex-end;
  padding-right: 8px;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

/* Highlight Current Puzzle Bracket */
.dist-bar-fill.has-data.highlight {
  background: linear-gradient(90deg, #16a34a, #22c55e);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.6), 0 0 8px rgba(56, 189, 248, 0.8);
  border: 1px solid #38bdf8;
}

/* Zero Bar (count = 0) */
.dist-bar-fill.is-zero {
  width: 24px;
  background: #475569;
  justify-content: center;
  padding-right: 0;
}

.dist-bar-num {
  font-family: var(--font-display, 'Orbitron', monospace);
  font-size: 0.8rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
}

/* ==========================================================================
   Current Mission Performance Breakdown (5-Round Grid)
   ========================================================================== */
.current-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.round-blocks-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.round-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 54px;
  transition: transform 0.15s, border-color 0.15s;
}

.round-block:hover {
  transform: translateY(-2px);
}

.block-label {
  font-family: var(--font-display, 'Orbitron', monospace);
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.block-val {
  font-family: var(--font-display, 'Orbitron', monospace);
  font-size: 1.18rem;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.1;
}

/* Status variants */
.round-block.block-hit {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.25);
}
.round-block.block-hit .block-val {
  color: #4ade80;
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.round-block.block-high {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #eab308;
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.2);
}
.round-block.block-high .block-val {
  color: #facc15;
}

.round-block.block-mid {
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid #f97316;
}
.round-block.block-mid .block-val {
  color: #fb923c;
}

.round-block.block-miss {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.45);
}
.round-block.block-miss .block-val {
  color: #f87171;
}

.round-block.block-pending {
  background: rgba(30, 41, 59, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.15);
}
.round-block.block-pending .block-val {
  color: #64748b;
}

.total-score-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.12);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: var(--font-display, 'Orbitron', monospace);
  font-size: 0.9rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.05em;
}

.total-score-box .score-highlight {
  font-size: 1.25rem;
  font-weight: 900;
  color: #38bdf8;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.share-actions-row {
  margin-top: 4px;
}

.share-toast {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  border-radius: 6px;
  padding: 8px;
  animation: fadeIn 0.2s ease;
}

.share-toast.hidden {
  display: none;
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .round-blocks-row {
    gap: 6px;
  }
  .block-val {
    font-size: 1.05rem;
  }
  .dist-label {
    width: 58px;
    font-size: 0.75rem;
  }
}

.modal-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.share-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-green) 0%, #16a34a 100%);
  color: #ffffff;
  border: 1px solid #86efac;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.share-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(34, 197, 94, 0.7);
}

.next-countdown-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.countdown-timer {
  font-family: var(--font-display);
  color: var(--accent-cyan);
  font-weight: 700;
}

/* ==========================================================================
   Help Modal Content
   ========================================================================== */
.help-step {
  display: flex;
  gap: 12px;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  font-family: var(--font-display);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.step-content h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: #ffffff;
  margin-bottom: 3px;
}

.step-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
