/* style.css — MSU branded Hail Stats! */

:root {
  --maroon: #5D1725;
  --white: #ffffff;
  --light-gray: #f5f5f5;
  --mid-gray: #ddd;
  --hint-gray: #555;
  --muted-gray: #777;
  --dark-text: #1a1a1a;
  --green-flash: #2e7d32;
  --green-bg: #e8f5e9;
  --reveal-bg: #fff3e0;
  --reveal-text: #e65100;
  --border-gray: #e0e0e0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--light-gray);
  color: var(--dark-text);
  line-height: 1.5;
}

/* Focus-visible for all buttons */
button:focus-visible {
  outline: 2px solid var(--maroon);
  outline-offset: 2px;
}

/* Header */
.site-header {
  background: var(--maroon);
  color: var(--white);
  text-align: center;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header h1 {
  font-size: 1.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 900;
}

.site-header h1 a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.15s;
}

.site-logo {
  height: 72px;
  width: auto;
}

.site-header h1 a:hover {
  opacity: 0.85;
}

/* Container */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px;
}

/* Category header */
#category-header h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
  color: var(--maroon);
}

#category-header .prompt {
  font-size: 0.9rem;
  color: var(--hint-gray);
  margin-bottom: 12px;
}

/* Quiz navigation arrows */
.quiz-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.quiz-title-block {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.quiz-title-block h2 {
  margin-bottom: 0;
}

.pub-date {
  font-size: 0.85rem;
  color: var(--muted-gray);
}

.nav-arrow {
  background: none;
  border: 1px solid var(--mid-gray);
  border-radius: 4px;
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--maroon);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.nav-arrow:hover:not(.disabled) {
  background: var(--maroon);
  color: var(--white);
}

.nav-arrow.disabled {
  color: var(--mid-gray);
  cursor: default;
  border-color: var(--border-gray);
}

/* Archive button */

/* Archive overlay/modal */
.archive-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.archive-modal {
  background: var(--white);
  border-radius: 10px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.archive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-gray);
  position: sticky;
  top: 0;
  background: var(--white);
  border-radius: 10px 10px 0 0;
}

.archive-header h2 {
  font-size: 1.1rem;
  color: var(--maroon);
  margin: 0;
}

.archive-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted-gray);
  padding: 0 4px;
  line-height: 1;
}

.archive-close:hover {
  color: var(--dark-text);
}

.archive-list {
  list-style: none;
  padding: 8px 0;
}

.archive-list li {
  border-bottom: 1px solid var(--border-gray);
}

.archive-list li:last-child {
  border-bottom: none;
}

.archive-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  text-decoration: none;
  color: var(--dark-text);
  transition: background 0.1s;
}

.archive-link:hover {
  background: var(--light-gray);
}

.archive-date {
  font-size: 0.8rem;
  color: var(--muted-gray);
  white-space: nowrap;
  min-width: 90px;
}

.archive-title {
  font-weight: 600;
  color: var(--maroon);
  font-size: 0.95rem;
}

/* Progress */
.progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.progress-track {
  flex: 1;
  height: 12px;
  background: var(--mid-gray);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--maroon);
  transition: width 0.3s ease;
  border-radius: 6px;
}

#progress-label {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Guess input */
#guess-area {
  margin-bottom: 14px;
}

#guess-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.1rem;
  border: 2px solid var(--maroon);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

#guess-input::-webkit-search-cancel-button,
#guess-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

#guess-input:focus {
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(93, 23, 37, 0.2);
}

#guess-input.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Answer board */
#answer-board {
  overflow-x: auto;
  transition: opacity 0.3s ease;
}

#answer-board.dimmed {
  opacity: 0.45;
}

#answer-board table {
  width: 100%;
  border-collapse: collapse;
}

#answer-board td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-gray);
  font-size: 0.95rem;
}

.col-rank {
  width: 36px;
  text-align: center;
  font-weight: 700;
  color: var(--maroon);
}

.col-year {
  width: 70px;
  font-weight: 700;
  color: var(--maroon);
  white-space: nowrap;
}

.col-hint {
  color: var(--hint-gray);
  font-size: 0.9rem;
  white-space: nowrap;
}

.col-answer {
  font-weight: 600;
}

.group-header td {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--maroon);
  padding: 14px 8px 6px;
  border-bottom: 2px solid var(--maroon);
}

.answer-blank {
  color: var(--muted-gray);
  font-style: italic;
}

.answer-found {
  color: var(--green-flash);
  background: var(--green-bg);
}

.answer-revealed {
  color: var(--reveal-text);
  background: var(--reveal-bg);
}

/* Flash animation */
.answer-row.flash {
  animation: flash-green 0.6s ease forwards;
}

@keyframes flash-green {
  0% { background: #a5d6a7; }
  100% { background: var(--green-bg); }
}

.guess-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.guess-row #guess-input {
  flex: 1;
}

#reveal-btn {
  background: none;
  border: none;
  color: var(--muted-gray);
  padding: 10px 12px;
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
  min-width: 14ch;
  text-align: left;
}

#reveal-btn:hover {
  color: var(--hint-gray);
  text-decoration: underline;
}

#reveal-btn:active {
  color: var(--dark-text);
}

/* Actions */
.actions {
  text-align: center;
  margin: 16px 0;
  font-size: 0.85rem;
  color: var(--muted-gray);
}

.actions > * + * {
  margin-left: 12px;
}

#random-btn,
#archive-btn {
  color: var(--muted-gray);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#random-btn:hover,
#archive-btn:hover {
  color: var(--maroon);
}

/* Completion */
.completion-msg {
  text-align: center;
  font-size: 1rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.completion-msg:not(:empty) {
  padding: 16px 20px;
  margin-top: 12px;
  margin-bottom: 14px;
}

.flavor-line {
  font-size: 1.15rem;
  font-style: italic;
}

.score-line {
  font-size: 1.15rem;
}

.score-line strong {
  font-size: 1.3rem;
}

.completion-msg.success {
  background: var(--green-bg);
  border: 2px solid var(--green-flash);
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.15);
}

.completion-msg.revealed {
  background: var(--white);
  border: 2px solid var(--maroon);
  box-shadow: 0 2px 8px rgba(93, 23, 37, 0.1);
}

.completion-msg .share-btn,
.completion-msg .try-another-btn {
  display: inline-block;
  margin: 0;
  background: none;
  color: var(--maroon);
  border: none;
  padding: 8px 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}

.completion-msg .share-btn:hover,
.completion-msg .try-another-btn:hover {
  opacity: 0.7;
}

.completion-msg .share-btn:active,
.completion-msg .try-another-btn:active {
  opacity: 0.5;
}

.btn-sep {
  color: var(--muted-gray);
  margin: 0 8px;
}

/* Loading state */
.container.loading .progress-container,
.container.loading #guess-area,
.container.loading #answer-board,
.container.loading .actions {
  display: none;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 24px 12px;
  font-size: 0.8rem;
  color: var(--muted-gray);
}

/* Error message */
.error-msg {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .site-header h1 { font-size: 1.5rem; }
  #guess-input { font-size: 1rem; padding: 10px 12px; }
  #answer-board td { padding: 8px 6px; font-size: 0.88rem; }
  .col-hint { font-size: 0.82rem; white-space: normal; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
