/* PuzzleLore Puzzle Styles - Matches landing page design tokens */

/* ========== Puzzle Container ========== */
#puzzle-container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

/* ========== Puzzle Header ========== */
.puzzle-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.puzzle-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.puzzle-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1.5px solid var(--gold);
  padding: 0.3rem 0.8rem;
  border-radius: 2px;
}

.puzzle-difficulty {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--crimson);
  background: rgba(139, 34, 82, 0.08);
  padding: 0.3rem 0.8rem;
  border-radius: 2px;
}

.puzzle-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.puzzle-desc {
  font-size: 1rem;
  color: rgba(26, 26, 46, 0.6);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ========== Puzzle Area Layout ========== */
.puzzle-area {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .puzzle-area {
    grid-template-columns: 1fr;
  }
}

/* ========== Logic Grid ========== */
.logic-grid-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Murdle-style staircase layout */
.grid-staircase {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
}

.staircase-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.sub-grid {
  flex-shrink: 0;
}

.sub-grid.no-row-labels {
  border-left: 2px solid var(--ink);
}

.logic-grid {
  border-collapse: collapse;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  width: auto;
  transition: transform 0.3s;
}

.logic-grid.shake {
  animation: shake 0.4s ease-in-out;
}

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

.logic-grid.grid-solved {
  box-shadow: 0 0 30px rgba(201, 162, 39, 0.3);
}

/* Corner cell */
.grid-corner {
  background: transparent;
  border: none;
}

/* Category headers */
.grid-cat-header {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: center;
  padding: 0.6rem 0.3rem 0.2rem;
  border-bottom: 2px solid var(--ink);
}

/* Item headers (rotated) */
.grid-item-header {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  padding: 0.5rem 0.2rem;
  border-bottom: 1px solid rgba(26, 26, 46, 0.15);
  border-right: 1px solid rgba(26, 26, 46, 0.08);
  color: rgba(26, 26, 46, 0.7);
  min-width: 60px;
  max-width: 90px;
}

.grid-item-header span {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  max-height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 auto;
}

/* Staircase row separators — second+ rows get a top border */
.staircase-row + .staircase-row .sub-grid {
  border-top: 2px solid var(--ink);
}

/* Row labels */
.grid-row-label {
  font-weight: 500;
  font-size: 0.8rem;
  padding: 0.5rem 0.8rem;
  white-space: nowrap;
  border-right: 2px solid var(--ink);
  background: rgba(26, 26, 46, 0.02);
  color: var(--ink);
  height: 48px;
  box-sizing: border-box;
}

/* Interactive cells */
.grid-cell-interactive {
  width: 48px;
  height: 48px;
  min-width: 48px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid rgba(26, 26, 46, 0.12);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.grid-cell-interactive:hover {
  background: rgba(201, 162, 39, 0.06);
}

.grid-cell-interactive.empty {
  background: white;
}

.grid-cell-interactive.x {
  background: rgba(139, 34, 82, 0.04);
}

.grid-cell-interactive.check {
  background: rgba(45, 80, 22, 0.08);
}

.cell-x {
  color: var(--crimson);
  font-size: 1.4rem;
  font-weight: 300;
  line-height: 1;
  opacity: 0.6;
}

.cell-check {
  color: var(--forest);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

/* Sub-grid outer border for visual separation */
.sub-grid .logic-grid {
  border: 1px solid rgba(26, 26, 46, 0.12);
}

/* ── Unified single-table grid (L-shape: C×C quadrant omitted) ── */
.unified-grid {
  border: none;
}

/* Thick border between the two column groups (B|C split) */
.unified-grid .col-section-start,
.unified-grid .grid-cat-header + .grid-cat-header {
  border-left: 2px solid var(--ink) !important;
}

/* Section separator: thick top border on first C-section row */
.grid-section-start td,
.grid-section-start th {
  border-top: 2px solid var(--ink) !important;
}

.grid-row-label.section-start {
  border-top: 2px solid var(--ink);
}

/* L-shape edge borders — right edge of C×B quadrant */
.quadrant-edge-right {
  border-right: 1px solid rgba(26, 26, 46, 0.18) !important;
}

/* Bottom edge of last A row in the A×C section */
.unified-grid .grid-row:last-of-type .grid-cell-interactive {
  border-bottom: 1px solid rgba(26, 26, 46, 0.18);
}

/* Top edge of the grid — subtle line above headers */
.unified-grid .grid-header-cats .grid-cat-header {
  border-top: 1px solid rgba(26, 26, 46, 0.18);
}
.unified-grid .grid-header-cats .grid-corner {
  border-top: 1px solid rgba(26, 26, 46, 0.18);
  border-left: 1px solid rgba(26, 26, 46, 0.18);
}

/* Left edge of the grid — row labels */
.unified-grid .grid-row-label {
  border-left: 1px solid rgba(26, 26, 46, 0.18);
}

/* ========== Clues Panel ========== */
.clues-panel {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid rgba(26, 26, 46, 0.08);
  box-shadow: 0 2px 12px rgba(26, 26, 46, 0.04);
}

.clues-panel h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(26, 26, 46, 0.08);
}

.clue-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.clue-item {
  padding: 0.6rem 0.4rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ink);
  border-bottom: 1px solid rgba(26, 26, 46, 0.05);
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  border-radius: 4px;
}

.clue-item:hover {
  background: rgba(26, 26, 46, 0.02);
}

.clue-item.clue-crossed {
  opacity: 0.35;
  text-decoration: line-through;
}

.clue-item.hint-revealed {
  background: rgba(201, 162, 39, 0.12);
  border-left: 3px solid var(--gold);
  padding-left: 0.6rem;
}

.clue-tier {
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  background: var(--ink);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.tier-1 .clue-tier { background: var(--forest); }
.tier-2 .clue-tier { background: var(--gold); color: var(--ink); }
.tier-3 .clue-tier { background: var(--crimson); }

/* ========== Controls ========== */
.puzzle-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid rgba(26, 26, 46, 0.08);
}

@media (max-width: 600px) {
  .puzzle-controls {
    flex-direction: column;
    gap: 1rem;
  }
}

.timer {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.control-buttons {
  display: flex;
  gap: 0.6rem;
}

.btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.6rem 1.2rem;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  background: transparent;
  color: var(--ink);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-check {
  background: var(--ink);
  color: var(--parchment);
}

.btn-check:hover {
  background: var(--royal);
  border-color: var(--royal);
}

.btn-hint {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-hint:hover {
  background: rgba(201, 162, 39, 0.1);
}

.btn-reset {
  border-color: rgba(26, 26, 46, 0.3);
  color: rgba(26, 26, 46, 0.5);
}

.btn-reset:hover {
  border-color: var(--crimson);
  color: var(--crimson);
}

/* ========== Result Area ========== */
.result-area {
  text-align: center;
  padding: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  min-height: 2rem;
  margin-top: 1rem;
  border-radius: 6px;
  transition: all 0.3s;
}

.result-area.success {
  background: rgba(45, 80, 22, 0.1);
  color: var(--forest);
  padding: 1rem;
  font-size: 1.1rem;
}

.result-area.error {
  background: rgba(139, 34, 82, 0.08);
  color: var(--crimson);
  padding: 1rem;
}

.result-area.warning {
  background: rgba(201, 162, 39, 0.1);
  color: #8a6d00;
  padding: 1rem;
}

.result-area.hint {
  background: rgba(201, 162, 39, 0.08);
  color: var(--gold);
  padding: 0.8rem;
}

/* ========== No Puzzle ========== */
.no-puzzle {
  text-align: center;
  padding: 4rem 2rem;
}

.no-puzzle h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.no-puzzle p {
  color: rgba(26, 26, 46, 0.5);
}

/* ========== Confetti ========== */
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  top: 0;
  animation: confettiFall 2.5s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(400px) rotate(720deg);
  }
}

/* ========== CTA Section ========== */
.play-cta {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 2rem 1rem;
}

.cta-btn {
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1rem 2.5rem;
  background: var(--ink);
  color: var(--parchment);
  border: 2px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.cta-btn:hover {
  background: var(--royal);
  border-color: var(--royal);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(46, 16, 101, 0.2);
}

/* ========== Arc Browser ========== */
.arc-section {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.arc-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 0.5rem;
}

.arc-section .subtitle {
  text-align: center;
  color: rgba(26, 26, 46, 0.5);
  margin-bottom: 2.5rem;
}

.arc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.arc-card {
  background: white;
  border: 1px solid rgba(26, 26, 46, 0.08);
  border-radius: 8px;
  padding: 1.8rem;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.arc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(26, 26, 46, 0.08);
}

.arc-card h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.arc-card p {
  font-size: 0.9rem;
  color: rgba(26, 26, 46, 0.6);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.arc-card .arc-meta {
  display: flex;
  gap: 0.8rem;
}

.arc-card .arc-tag {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  background: rgba(26, 26, 46, 0.05);
  color: rgba(26, 26, 46, 0.6);
}

.arc-card .arc-tag.free {
  background: rgba(45, 80, 22, 0.1);
  color: var(--forest);
}
