/* ==========================================================================
   Base / page chrome
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  overflow-y: scroll;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #eeeeee;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

a {
  color: #0366d6;
}

small {
  color: #666;
}

.container {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 16px;
}

nav a {
  margin-right: 12px;
  text-decoration: none;
  color: #333;
  font-weight: 500;
}

nav a:hover {
  text-decoration: underline;
}

nav a.active {
  font-weight: bold;
}

/* github-markdown-css is meant to sit inside a padded "paper" surface -
   applying that consistently here is what lets every page (posts, cheatsheets,
   sandbox, home) share one unified look instead of post.html inventing its own. */
.markdown-body {
  background: white;
  padding: 24px 32px;
  border-radius: 10px;
  border: 1px solid #eee;
}

.markdown-body ul {
  list-style: disc;
  padding-left: 2em;
}

.markdown-body li {
  margin: 0.25em 0;
}

.markdown-body li > p {
  margin: 0;
}

.post-count {
  font-size: 10px;
  color: #aaa;
  margin: 10px 0;
}

/* ==========================================================================
   Buttons (shared by pagination links and the snapshots "load more" button)
   ========================================================================== */

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #333;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: #f5f5f5;
}

/* ==========================================================================
   Filters (category filter links - see _includes/filters.html)
   ========================================================================== */

#filters {
  margin-bottom: 20px;
}

#filters .filter-link {
  display: inline-block;
  border: 1px solid #ddd;
  background: #eee;
  padding: 6px 12px;
  border-radius: 6px;
  margin-right: 6px;
  text-decoration: none;
  color: #333;
}

#filters .filter-link:hover {
  background: #ddd;
}

#filters .filter-link.active {
  background: #ccc;
  font-weight: bold;
}

/* ==========================================================================
   Cards - shared grid + card look used on home, cheatsheets, sandbox
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

/* Blog post cards vary a lot in excerpt length. A multi-column grid
   stretches every card in a row to match the tallest one, which leaves
   large empty gaps under shorter posts - so the post feed (home + category
   archives) always renders single-column, unlike the more uniform
   cheatsheets/sandbox/snapshot cards. */
.post-grid {
  grid-template-columns: minmax(0, 1fr);
}

.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;

  /* Force the flex container to shrink when needed */
  min-width: 0;
  word-wrap: break-word; /* Ensure long links or titles wrap safely */

  border: 1px solid #eee;
  border-radius: 10px;
  padding: 16px;

  background: white;
  color: inherit;
  text-decoration: none;
}

.card:hover {
  border-color: #ccc;
}

.card h3 {
  margin: 0 0 6px 0;
}

.card-thumb {
  width: 100%;
  aspect-ratio: 5 / 3;
  background: #f0f0f0;
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-description {
  font-size: 13px;
  color: #555;
  margin-bottom: 10px;
}

.card-excerpt {
  margin: 10px 0;
  color: #333;
}

.card-cta {
  display: block;
  text-align: center;
  margin: 10px 0;
  font-weight: 500;
}

/* Only the post card's "Read post" is an actual <a> (cheatsheets/sandbox
   cards are plain text inside their own single card-level <a>). */
.card-cta-link {
  color: inherit;
  text-decoration: none;
}

.card-cta-link:hover {
  text-decoration: underline;
}

.card-tags {
  font-size: 12px;
  color: #777;
}

.card-footer {
  margin-top: auto;
}

/* ==========================================================================
   Post layout
   ========================================================================== */

.post-header {
  margin-bottom: 20px;
}

.post-meta a {
  color: inherit;
}

/* The post card is NOT a single big <a> (its excerpt can contain real
   links - see _includes/post-card.html) - only the title links to the post. */
.post-card-title {
  color: inherit;
  text-decoration: none;
}

.post-card-title:hover {
  text-decoration: underline;
}

.card-excerpt a {
  color: #0366d6;
}

/* ==========================================================================
   Pagination (main blog feed - see index.html)
   ========================================================================== */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0;
}

.pagination-info {
  font-size: 13px;
  color: #777;
}

/* ==========================================================================
   Snapshots page
   ========================================================================== */

.snapshot-card {
  /* border / padding / radius / background / flex layout come from .card */
  position: relative;
}

.snapshot-images {
  width: 100%;
  aspect-ratio: 5 / 3;

  position: relative;

  background: #f0f0f0;

  border-radius: 6px;

  margin-bottom: 10px;

  overflow: hidden;
}

.snapshot-arrow {
  position: absolute;

  top: 50%;
  transform: translateY(-50%);

  width: 34px;
  height: 34px;

  border: none;
  border-radius: 999px;

  background: rgba(0,0,0,0.45);

  cursor: pointer;

  z-index: 6;

  opacity: 0;

  transition: opacity 0.15s;

  backdrop-filter: blur(4px);

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;
}

.snapshot-images:hover .snapshot-arrow {
  opacity: 1;
}

.snapshot-arrow.left {
  left: 10px;
}

.snapshot-arrow.right {
  right: 10px;
}

.arrow-svg {
  width: 18px;
  height: 18px;

  stroke: white;
  stroke-width: 2.6;

  fill: none;

  stroke-linecap: round;
  stroke-linejoin: round;

  display: block;
}

.snapshot-slide {
  position: absolute;
  inset: 0;

  opacity: 0;
  pointer-events: none;

  transition: opacity 0.2s;
}

.snapshot-slide.active {
  opacity: 1;
  pointer-events: auto;
}

.snapshot-slide img {
  width: 100%;
  height: 100%;

  object-fit: contain;

  background: #f0f0f0;

  display: block;

  cursor: pointer;
}

.snapshot-dots {
  position: absolute;

  left: 50%;
  bottom: 10px;

  transform: translateX(-50%);

  display: flex;
  align-items: center;
  gap: 8px;

  padding: 6px 10px;

  border-radius: 999px;

  background: rgba(0,0,0,0.35);

  backdrop-filter: blur(6px);

  z-index: 5;
}

.snapshot-dot {
  position: relative;

  width: 14px;
  height: 14px;

  border-radius: 999px;

  background: rgba(255,255,255,0.22);

  overflow: visible;

  cursor: pointer;

  flex-shrink: 0;
}

.snapshot-dot-fill {
  position: absolute;

  left: 50%;
  top: 50%;

  width: 15px;
  height: 15px;

  margin-left: -7.5px;
  margin-top: -7.5px;

  border-radius: 999px;

  background: white;

  transform: scale(0);

  transform-origin: center center;

  will-change: transform;
}

.snapshot-text {
  font-size: 13px;
  color: #555;

  margin-top: 4px;

  line-height: 1.5;

  min-height: 40px;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;

  overflow: hidden;
}

#loadMoreBtn {
  margin: 30px auto 0 auto;
  display: none;
}

.viewer {
  position: fixed;
  inset: 0;

  z-index: 9999;
}

.viewer.hidden {
  display: none;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(0,0,0,0.92);
}

.viewer-content {
  position: relative;
  z-index: 2;

  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  padding: 30px;
}

#viewerImage {
  max-width: 95%;
  max-height: 80vh;

  object-fit: contain;

  border-radius: 8px;
}

.viewer-text {
  margin-top: 18px;

  max-width: 700px;
  max-height: 120px;

  overflow-y: auto;

  padding: 0 12px;

  text-align: center;

  color: white;
  line-height: 1.5;
}

.viewer-close {
  position: absolute;

  top: 20px;
  right: 20px;

  background: rgba(255,255,255,0.1);

  border: none;
  color: white;

  width: 40px;
  height: 40px;

  border-radius: 999px;

  cursor: pointer;
  font-size: 18px;
}

.viewer-arrow {
  position: absolute;

  top: 50%;
  transform: translateY(-50%);

  width: 52px;
  height: 52px;

  border: none;
  border-radius: 999px;

  background: rgba(255,255,255,0.12);

  cursor: pointer;

  z-index: 5;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;
}

.viewer-arrow .arrow-svg {
  width: 24px;
  height: 24px;

  stroke-width: 2.4;
}

.viewer-arrow.left {
  left: 20px;
}

.viewer-arrow.right {
  right: 20px;
}

@media (max-width: 600px) {
  .markdown-body {
    /* Reduce the 32px horizontal desktop padding to save screen space */
    padding: 16px;
  }

  .card-grid {
    /* Override the minmax(240px, 1fr) rule to force a single column and prevent overflow on non-blog pages */
    grid-template-columns: minmax(0, 1fr);
  }
}