/* MakeJokesBadAgain — minimal stylesheet */

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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface-hover: #22222e;
  --border: #2e2e3e;
  --text: #e8e8f0;
  --text-muted: #8888a8;
  --accent: #7c6af7;
  --accent-hover: #9580ff;
  --danger: #e05555;
  --success: #50c878;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #c47fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

header .tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.4rem;
}

main {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Mode navigation (feature 009) — switch between Random Joke and AI Joke Battle */
.mode-nav {
  display: flex;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem;
  background: var(--surface);
}

.mode-tab {
  flex: 1;
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.mode-tab-active {
  background: var(--accent);
  color: #fff;
}

.mode-tab-active:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Cards */
.joke-card, .explanation-card, .error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.joke-setup {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.joke-delivery {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-hover);
}

.joke-text {
  font-size: 1.1rem;
}

.joke-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.joke-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  margin: 0;
}

/* Explanation */
.explanation-card h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.explanation-card p {
  font-size: 1rem;
  line-height: 1.7;
}

.explanation-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* Error */
.error-card {
  border-color: var(--danger);
}

.error-card p {
  color: var(--danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Loading spinner */
.htmx-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: 7.25rem;
  visibility: hidden;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.12s ease, visibility 0s linear 0s;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-icon {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* Subtle fade on HTMX swaps (FR-013). Gated on prefers-reduced-motion so opted-out
   users get no animation on joke/explanation updates (SC-007). Paired with
   hx-swap="innerHTML swap:180ms" so the fade-out completes before content is replaced. */
@media (prefers-reduced-motion: no-preference) {
  #joke-section,
  #explanation-section {
    transition: opacity 180ms ease;
  }
  #joke-section.htmx-swapping,
  #explanation-section.htmx-swapping {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner-icon { animation: none; }
}
