/* ============================================================
   CONTEXTO — panels, modal headers and the archive list
   Loaded after theme.css on the Daily, Unlimited and Battle pages.

   Shared look: a dark header bar over a bordered card.
     - inline panels : How to Play, FAQ, Battle "How it works"
     - modals        : How to Play, Stats, Leaderboard, Archive, Create Game
   ============================================================ */

/* ---------- Dark header bar (shared) ---------- */
#how-to-play .how-header,
.battle-how .how-header,
#faq-section .faq-title,
.modal .how-header,
#archiveModal .modal-header,
#createGameModal .create-game-header {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0;
  padding: 0.7rem 1rem;
  background: #170d08;
  color: #fff8e1;
  border-bottom: 3px solid var(--ink);
}
/* modals leave room on the right for the close button */
.modal .how-header,
#archiveModal .modal-header,
#createGameModal .create-game-header { padding-right: 3rem; }

#how-to-play .how-title,
.battle-how .how-title,
.modal .how-title,
#archiveModal .modal-title,
#createGameModal .create-game-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: inherit;
}
#how-to-play .help-icon,
.battle-how .help-icon,
.modal .help-icon { color: #f9c935; font-size: 1.15rem; }

/* icons for the modal headers that don't have one in their markup */
#archiveModal .modal-header::before,
#createGameModal .create-game-header::before {
  font-family: "Font Awesome 6 Free"; font-weight: 900;
  color: #f9c935; font-size: 1.05rem; line-height: 1;
}
#archiveModal .modal-header::before { content: "\f073"; }       /* calendar */
#createGameModal .create-game-header::before { content: "\f055"; } /* circle-plus */


/* ---------- Inline panels: How to Play, Battle "How it works", FAQ ---------- */
#how-to-play.info-card,
.battle-how.info-card,
#faq-section.faq-section {
  padding: 0;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 6px;
  box-shadow: 8px 8px 0 var(--ink);
}
#how-to-play.info-card,
.battle-how.info-card { margin-bottom: 1.8rem; }
#faq-section.faq-section { margin-top: 1.5rem; background: var(--card-bg); }
/* Unlimited / Battle have no Create Game + Play Archive row: same gap under the input bar */
body:not(:has(#bottom-actions-section)) #how-to-play { margin-top: 1.4rem; }
@media (max-width: 600px) {
  #how-to-play.info-card,
  .battle-how.info-card,
  #faq-section.faq-section { box-shadow: 5px 5px 0 var(--ink); }
}

/* numbered rule list (inline panels + How to Play modal) */
#how-to-play .how-list,
.battle-how .how-list,
#howToPlayModal .how-list,
#hintModal .how-list { list-style: none; padding: 0; margin: 0; counter-reset: clue; }
#how-to-play .how-list li,
.battle-how .how-list li,
#howToPlayModal .how-list li,
#hintModal .how-list li {
  counter-increment: clue;
  display: flex; gap: 0.9rem;
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-primary);
}
#how-to-play .how-list li:last-child,
.battle-how .how-list li:last-child,
#howToPlayModal .how-list li:last-child,
#hintModal .how-list li:last-child { border-bottom: 0; }
#how-to-play .how-list li::before,
.battle-how .how-list li::before,
#howToPlayModal .how-list li::before,
#hintModal .how-list li::before { content: counter(clue); flex: 0 0 1.1rem; font-weight: 900; }

/* FAQ rows */
#faq-section .faq-title { font-size: 0.95rem; letter-spacing: 0.1em; text-transform: uppercase; }
#faq-section .faq-item,
body.dark-mode #faq-section .faq-item {
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
}
#faq-section .faq-item:last-of-type { border-bottom: 0; }
#faq-section .faq-item:hover { transform: none; box-shadow: none; }
#faq-section .faq-question { background: transparent; font-weight: 700; font-size: 0.92rem; padding: 0.8rem 1rem; }
#faq-section .faq-question:hover,
#faq-section .faq-question.active,
body.dark-mode #faq-section .faq-question:hover,
body.dark-mode #faq-section .faq-question.active { background: var(--tint-gold); }
#faq-section .faq-answer { background: transparent; }


/* ---------- Modals: frame, close button and body padding ---------- */
#howToPlayModal .modal-content,
#hintModal .modal-content,
#statsModal .modal-content,
#leaderboardModal .modal-content,
#archiveModal .modal-content,
#createGameModal .modal-content {
  padding: 0;
  overflow-x: hidden;
  border: 4px solid var(--ink);
  border-radius: 6px;
}
#howToPlayModal .close-btn,
#hintModal .close-hint-btn,
#statsModal .close-btn,
#leaderboardModal .close-btn,
#archiveModal .close-btn,
#createGameModal .close-btn {
  position: absolute; top: 0.45rem; right: 0.8rem; z-index: 2;
  color: #fff8e1; font-size: 1.6rem; line-height: 1;
}
#archiveModal .modal-body,
#createGameModal .create-game-body { padding: 1.1rem 1.2rem 1.2rem; }
#leaderboard-content { padding: 1.1rem 1.2rem 1.2rem; }
/* hint rules contain bold text, so keep each row as normal flowing text (number placed absolutely) */
#hintModal .how-list li { display: block; position: relative; padding-left: 2.6rem; }
#hintModal .how-list li::before { position: absolute; left: 1rem; top: 0.75rem; }
#hintModal .hint-btn { margin: 1.1rem 1.2rem 1.2rem; }
#hintModal .hint-result { margin: -0.4rem 1.2rem 1.2rem; }

/* Stats modal: header spans the full width, everything under it is inset */
#stats-modal-content > :not(.how-header):not(.sx-loading) { margin-left: 1.2rem; margin-right: 1.2rem; }
#stats-modal-content > :last-child { margin-bottom: 1.2rem; }
#stats-modal-content > .how-header + * { margin-top: 1.1rem; }
#stats-modal-content > .sx-loading { margin: 0; padding: 1.4rem 1.2rem; text-align: center; }
#stats-modal-content:not(:has(.how-header)) { padding: 1.5rem; }   /* "sign in to view stats" has no header */


/* ---------- Daily: Create Game / Play Archive buttons ---------- */
#bottom-actions-section .horizontal-separator { display: none; }
#bottom-actions-section .bottom-action-buttons { margin: 0 0 1.6rem; gap: 0.6rem; }
#bottom-actions-section .bottom-action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink);
}
#bottom-actions-section .bottom-action-btn::after {
  content: "\f04b";                                  /* play */
  font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 0.7em; line-height: 1;
}
#bottom-actions-section .bottom-action-btn:hover { box-shadow: 0 4px 0 var(--ink); }


/* ---------- Archive: list of past games, newest first, grouped by month ---------- */
#archiveModal .calendar-container { display: none; }

.archive-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.archive-filter {
  padding: 0.3rem 0.8rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
}
.archive-filter:hover { background: var(--overlay-hover); }
.archive-filter.active { background: linear-gradient(var(--gold-top), var(--gold-bottom)); color: var(--ink); box-shadow: 0 2px 0 var(--ink); }

.archive-list { max-height: min(55vh, 430px); overflow-y: auto; padding: 0 0.35rem 0.5rem 0; }
/* sticky month heading spans the whole list width (incl. the right padding) so row shadows don't peek out beside it */
.archive-month {
  position: sticky; top: 0; z-index: 1;
  margin: 0.2rem -0.35rem 0.5rem 0;
  padding: 0.25rem 0.35rem 0.25rem 0;
  background: var(--modal-bg);
  font-size: 0.75rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-secondary);
}
.archive-row {
  display: flex; align-items: center; gap: 0.8rem;
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--card-bg);
  color: var(--text-primary);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.archive-row:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.archive-row-num { font-weight: 900; min-width: 3.4rem; }
.archive-row-date { flex: 1; font-size: 0.88rem; color: var(--text-secondary); font-weight: 700; }
.archive-row-status {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--tint-gold);
  color: var(--text-primary);
  font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em;
}
.archive-row.is-completed .archive-row-status { background: #64b6ab; color: #140c08; }
.archive-row.is-given_up .archive-row-status { background: #F59069; color: #140c08; }
.archive-row.is-in-progress .archive-row-status { background: #f9c935; color: #140c08; }
.archive-row.is-new .archive-row-status { background: var(--card-bg); }
.archive-empty { padding: 1.2rem 0; text-align: center; color: var(--text-secondary); font-weight: 700; }
