/* ==========================================================================
   PUZZLE COLLECTION PAGE STYLES
   ========================================================================== */

.puzzles-collection {
  /* Uses Ghost's default layout handling */
}

.puzzles-header {
  text-align: center;
  margin-bottom: 3rem;
}

.puzzles-header h1 {
  font-size: 2.4rem !important;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  color: #2d3748;
  text-align: center;
  margin: 0;
}

.puzzles-header p {
  margin-top: 12px;
  font-size: 1.7rem;
  color: var(--color-secondary-text);
  text-align: center;
}

/* Puzzle Grid Layout - Following Ghost's gh-topic-grid pattern */
.puzzles-collection .gh-topic-grid .gh-topic-content {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 32px 40px !important;
  justify-items: center !important;
}

/* Individual Puzzle Cards - Following Ghost's gh-card pattern */
.puzzles-collection .gh-topic-grid .gh-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
  max-width: 400px !important;
  width: 100% !important;
}

.puzzles-collection .gh-topic-grid .gh-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
  border-color: var(--brand-primary) !important;
}

.puzzles-collection .gh-topic-grid .gh-card:focus-within {
  outline: 2px solid var(--brand-primary) !important;
  outline-offset: 2px !important;
  border-color: var(--brand-primary) !important;
}

.puzzles-collection .gh-topic-grid .gh-card .gh-card-link {
  display: flex !important;
  align-items: flex-start !important;
  gap: 1.5rem !important;
}

.puzzles-collection .gh-topic-grid .gh-card .gh-card-image {
  flex: 0 0 120px;
  max-width: 120px;
}

.puzzles-collection .gh-topic-grid .gh-card .gh-card-image img {
  width: 100% !important;
  height: auto !important;
  object-fit: cover !important;
  border-radius: 8px !important;
}

.puzzles-collection .gh-topic-grid .gh-card .gh-card-wrapper {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.puzzles-collection .gh-topic-grid .gh-card .gh-card-title {
  font-size: 1.4rem !important;
  font-weight: 600 !important;
  color: #2d3748 !important;
  margin: 1.5rem 1.5rem 1rem !important;
  line-height: 1.3 !important;
}

.puzzles-collection .gh-topic-grid .gh-card .gh-card-excerpt {
  color: #718096 !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  margin: 0 1.5rem 1.5rem !important;
  flex-grow: 1 !important;
}

.puzzles-collection .gh-topic-grid .gh-card .puzzle-cta {
  display: inline-block !important;
  background: var(--brand-primary) !important;
  color: white !important;
  padding: 0.75rem 1.5rem !important;
  margin: 0 1.5rem 1.5rem !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  font-size: 0.9rem !important;
  transition: all 0.3s ease !important;
  border: 2px solid var(--brand-primary) !important;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  text-decoration: none !important;
}

.puzzles-collection .gh-topic-grid .gh-card:hover .puzzle-cta {
  background: var(--brand-primary-hover) !important;
  border-color: var(--brand-primary-hover) !important;
  transform: translateX(4px) !important;
  box-shadow: 0 4px 8px rgba(155, 37, 37, 0.3) !important;
}

.puzzles-collection .gh-topic-grid .gh-card .puzzle-cta:focus {
  outline: 2px solid var(--brand-primary) !important;
  outline-offset: 2px !important;
}

.puzzles-collection .gh-topic-grid .gh-card .puzzle-cta:active {
  background: var(--brand-primary-active) !important;
  border-color: var(--brand-primary-active) !important;
  transform: translateY(1px) !important;
}

/* ==========================================================================
   INDIVIDUAL PUZZLE PAGE STYLES
   ========================================================================== */

.puzzle-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.puzzle-page header {
  margin-bottom: 2rem;
  text-align: center;
}

.puzzle-page h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 1rem;
}

/* Navigation */
.puzzle-nav {
  margin-bottom: 2rem;
}

.puzzle-nav a {
  display: inline-flex;
  align-items: center;
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: 1px solid var(--brand-primary);
  border-radius: 6px;
  transition: all 0.3s ease;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.puzzle-nav a:hover {
  background: var(--brand-primary);
  color: white;
  transform: translateX(-4px);
  box-shadow: 0 4px 8px rgba(155, 37, 37, 0.3);
}

.puzzle-nav a:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.puzzle-nav a:active {
  background: var(--brand-primary-active);
  border-color: var(--brand-primary-active);
  transform: translateY(1px);
}

/* Puzzle Content Area */
.puzzle-content {
  background: #ffffff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  margin-bottom: 3rem;
}

.puzzle-content h2,
.puzzle-content h3 {
  color: #2d3748;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.puzzle-content p {
  color: #4a5568;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.puzzle-content ul,
.puzzle-content ol {
  color: #4a5568;
  line-height: 1.6;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.puzzle-content li {
  margin-bottom: 0.5rem;
}

/* Puzzle Embed Container */
.puzzle-embed {
  margin: 2rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background: #f7fafc;
  padding: 1rem;
}

.puzzle-embed iframe {
  width: 100%;
  min-height: 600px;
  border: none;
  border-radius: 6px;
  background: white;
}

/* Related Puzzles Sidebar */
.other-puzzles {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 2rem;
  border: 1px solid #e9ecef;
}

.other-puzzles h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 1.5rem;
  text-align: center;
}

.related-puzzle {
  display: block;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  color: #4a5568;
  font-weight: 500;
  transition: all 0.3s ease;
}

.related-puzzle:hover {
  background: var(--brand-primary);
  color: white;
  transform: translateX(4px);
  border-color: var(--brand-primary);
  box-shadow: 0 4px 8px rgba(155, 37, 37, 0.3);
}

.related-puzzle:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  background: var(--brand-primary);
  color: white;
}

.related-puzzle:active {
  background: var(--brand-primary-active);
  border-color: var(--brand-primary-active);
  transform: translateY(1px);
}

.related-puzzle:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet Styles */
@media (max-width: 768px) {

  .puzzles-header h1 {
    font-size: 2rem;
  }

  .puzzle-page h1 {
    font-size: 1.8rem;
  }

  .puzzle-content {
    padding: 1.5rem;
  }

  .puzzle-embed {
    padding: 0.5rem;
  }

  .puzzle-embed iframe {
    min-height: 500px;
  }

  .puzzles-collection .gh-topic-grid .gh-card .gh-card-link {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .puzzles-collection .gh-topic-grid .gh-card .gh-card-image,
  .puzzles-collection .gh-topic-grid .gh-card .gh-card-image img {
    max-width: 100% !important;
    width: 100% !important;
    height: 160px !important;
  }
}

/* Mobile Styles */
@media (max-width: 480px) {

  .puzzles-header h1 {
    font-size: 1.8rem;
  }

  .puzzles-header p {
    font-size: 1rem;
  }

  .puzzles-collection .gh-topic-grid .gh-card .gh-card-title {
    font-size: 1.2rem !important;
    margin: 1rem 1rem 0.75rem !important;
  }

  .puzzles-collection .gh-topic-grid .gh-card .gh-card-excerpt {
    font-size: 0.9rem !important;
    margin: 0 1rem 1rem !important;
  }

  .puzzles-collection .gh-topic-grid .gh-card .puzzle-cta {
    margin: 0 1rem 1rem !important;
    padding: 0.6rem 1.2rem !important;
    font-size: 0.85rem !important;
  }

  .puzzle-page h1 {
    font-size: 1.6rem;
  }

  .puzzle-content {
    padding: 1rem;
  }

  .other-puzzles {
    padding: 1.5rem;
  }

  .puzzle-embed iframe {
    min-height: 400px;
  }
}

/* Ensure grid goes to single column on smaller screens */
@media (max-width: 991px) {
  .puzzles-collection .gh-topic-grid .gh-topic-content {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   LOADING STATES AND ENHANCEMENTS
   ========================================================================== */

/* Loading state for iframes */
.puzzle-embed::before {
  content: "Loading puzzle...";
  display: block;
  text-align: center;
  padding: 2rem;
  color: #718096;
  font-style: italic;
}

.puzzle-embed iframe[src] + ::before {
  display: none;
}

/* Focus states for accessibility */
.puzzle-card:focus-within {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Print styles */
@media print {

  .puzzle-nav,
  .other-puzzles {
    display: none;
  }

  .puzzle-embed iframe {
    border: 1px solid #ccc;
  }

  .puzzle-content {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}