/* ==========================================================================
   Ken Pond Design™ – code-snippets.css
   Styles for the Code Snippets archive page
   ========================================================================== */

/* Code Snippets Archive Page */
.code-snippet-archive {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.snippet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #000;
}

.snippet-header h1 {
  margin: 0;
  font-family: 'Public Sans', sans-serif;
  font-size: 2.5rem;
  font-weight: 100;
  text-transform: uppercase;
}

.snippet-header h1 .title-separator {
  color: #59130E;
  margin: 0 0.5rem;
}

.snippet-header h1 .current-category {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-weight: 400;
  color: #6B6B6B;
}

.new-snippet-btn {
  display: inline-block;
  background: #000;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  border: none;
  text-decoration: none;
  font-family: 'Public Sans', sans-serif;
  font-weight: 100;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease;
}

.new-snippet-btn:hover {
  background: #333;
  color: #fff;
}

/* Last Updated */
.snippet-last-updated {
  font-family: 'Public Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 300;
  color: #666;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Snippet Search */
.snippet-search-wrapper {
  margin-bottom: 1.5rem;
}

.snippet-search {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #000;
  border-radius: 4px;
  font-family: 'Public Sans', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.snippet-search:focus {
  outline: none;
  border-color: #59130e;
  box-shadow: 0 0 0 2px rgba(89, 19, 14, 0.1);
}

.snippet-search::placeholder {
  color: #999;
  font-weight: 300;
}

/* Hidden state for search filtering */
.snippet-card.hidden {
  display: none;
}

/* Snippet Category Filter */
.snippet-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
}

.category-card {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid #000;
  border-radius: 4px;
  background: #fff;
  color: #000;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.category-card:hover {
  background: #f5f5f5;
  color: #000;
}

.category-card.active {
  background: #000;
  color: #fff;
}

.category-card.active:hover {
  background: #333;
  color: #fff;
}

.category-count {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
}

.category-card.active .category-count {
  background: rgba(255, 255, 255, 0.2);
}

/* Hierarchical Category Styling */
.category-group {
  display: contents;
}

.category-card--parent {
  font-weight: 600;
}

.category-card--parent.active {
  background: #000;
  color: #fff;
}

.category-card--child {
  background: #fff;
  border: 1px solid #000;
  font-weight: 400;
}

.category-card--child.active {
  background: #59130e;
  border-color: #59130e;
  color: #fff;
}

.category-card--child:hover {
  background: #f0f0f0;
}

.category-card--child.active:hover {
  background: #6b1810;
}

.category-children {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-left: 0.5rem;
}

.category-children.visible {
  display: contents;
}

/* Snippet Grid - Masonry-style columns */
.snippet-grid {
  column-count: 2;
  column-gap: 1.5rem;
}

/* Individual Snippet Card */
.snippet-card {
  border: 1px solid #000;
  border-radius: 8px;
  padding: 1.25rem;
  background: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  break-inside: avoid;
  margin-bottom: 1.5rem;
}

.snippet-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.snippet-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.snippet-card h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 300;
  flex: 1;
}

/* Snippet badges container */
.snippet-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-left: 1rem;
}

.snippet-language {
  background: #59130e;
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.snippet-category-badge {
  background: #fff;
  color: #000;
  border: 1px solid #000;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.snippet-description {
  margin-bottom: 1rem;
  color: #333;
  line-height: 1.5;
}

.snippet-code-wrapper {
  position: relative;
}

.snippet-code-wrapper pre {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1rem;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 400px;
}

.snippet-code-wrapper code {
  font-family: 'JetBrains Mono', 'Courier New', Courier, monospace !important;
  font-size: 0.85em !important;
  line-height: 1.5 !important;
  display: block;
  white-space: pre-wrap !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Prism.js overrides - force our styles over the theme */
.snippet-code-wrapper pre,
.snippet-code-wrapper pre[class*="language-"],
.snippet-code-wrapper code,
.snippet-code-wrapper code[class*="language-"],
pre[class*="language-"],
code[class*="language-"] {
  font-family: 'JetBrains Mono', 'Courier New', Courier, monospace !important;
  font-size: 0.85em !important;
  line-height: 1.5 !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* Copy Button Wrapper with Tooltip */
.copy-btn-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 0.75rem;
}

.copy-btn-wrapper::before {
  content: 'COPY TO CLIPBOARD';
  position: absolute;
  bottom: calc(100% + 12px);
  font-family: 'Manrope', sans-serif;
  font-weight: 400;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #ffffff;
  background-color: #222222;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.copy-btn-wrapper::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  border: 6px solid transparent;
  border-top-color: #222222;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.copy-btn-wrapper:hover::before,
.copy-btn-wrapper:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.copy-btn-wrapper.copied::before,
.copy-btn-wrapper.copied::after {
  opacity: 0;
}

.copy-btn {
  appearance: none;
  background-color: #000000;
  border-radius: 5px;
  border: none;
  box-sizing: border-box;
  color: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.5;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  width: 100%;
  letter-spacing: 0.25px;
  position: relative;
  text-align: center;
  text-transform: uppercase;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  transition:
    background-color 220ms ease-out,
    color 220ms ease-out,
    transform 160ms ease-out,
    letter-spacing 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.copy-btn svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Shine sweep effect */
.copy-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.08),
    transparent
  );
  transition: left 0.6s ease-out;
  pointer-events: none;
}

.copy-btn:hover::before {
  left: 120%;
}

.copy-btn:hover {
  background-color: #ffffff;
  color: #000000;
  letter-spacing: 2.5px;
}

.copy-btn:active {
  transform: translateY(1px);
  transition: transform 60ms ease-out;
}

.copy-btn:focus {
  outline: none;
}

/* Subtle inner glow on hover */
.copy-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0);
  transition: box-shadow 0.3s ease;
  pointer-events: none;
}

.copy-btn:hover::after {
  box-shadow: inset 0 0 8px 1px rgba(0, 0, 0, 0.08);
}

/* Copied state */
.copy-btn.copied {
  background-color: #ffffff;
  color: #59130e;
  border: 1px solid rgba(0, 0, 0, 0.4);
  cursor: default;
  letter-spacing: 2.5px;
}

.copy-btn.copied::before {
  display: none;
}

/* Snippet Card Last Updated */
.snippet-card-updated {
  font-family: 'Public Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 300;
  color: #888;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e0e0e0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Snippet Actions (Edit/Delete) */
.snippet-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Remove double border when both updated and actions are present */
.snippet-card-updated + .snippet-actions {
  border-top: none;
  padding-top: 0.5rem;
}

.edit-snippet,
.delete-snippet {
  background: none;
  border: 1px solid #666;
  color: #666;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-family: 'Public Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 300;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.edit-snippet:hover {
  background: #000;
  border-color: #000;
  color: #fff;
}

.delete-snippet:hover {
  background: #d32f2f;
  border-color: #d32f2f;
  color: #fff;
}

/* No snippets state */
.no-snippets {
  text-align: center;
  padding: 4rem 2rem;
}

.no-snippets p {
  font-size: 1.1rem;
  color: #666;
  margin: 0 0 1.5rem 0;
}

/* Front page actions */
.front-page-actions {
  text-align: center;
  margin: 2rem auto 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 800px) {
  .code-snippet-archive {
    padding: 0 1rem;
  }

  .snippet-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .snippet-header h1 {
    font-size: 2rem;
  }

  .snippet-categories {
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .category-card {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .snippet-grid {
    column-count: 1;
  }

  .snippet-card {
    padding: 1.25rem;
  }

  .snippet-card-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .snippet-badges {
    margin-left: 0;
  }

  .snippet-code-wrapper pre {
    max-height: 300px;
    font-size: 0.85rem;
  }
}

@media (max-width: 360px) {
  .code-snippet-archive {
    padding: 0 0.5rem;
    margin: 1rem auto;
  }

  .snippet-header h1 {
    font-size: 1.75rem;
  }

  .snippet-categories {
    gap: 0.4rem;
  }

  .category-card {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
  }

  .new-snippet-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  .snippet-card {
    padding: 1rem;
  }

  .snippet-card h2 {
    font-size: 1.2rem;
  }

  .snippet-code-wrapper pre {
    padding: 0.75rem;
    max-height: 250px;
  }

  .copy-btn {
    width: 100%;
    padding: 0.7rem;
  }
}
