/* ==========================================================================
   Card Type System - Built-in Card Styles for Different Content Types

   Card types: article, note, photo, video, link, quote, guide, inline, default

   Design principles:
   - Feed container constrained (max-width: 750px), cards fill container
   - Differentiate by padding, background, borders - NOT width
   - All cards same width for visual consistency
   ========================================================================== */

@layer components {

/* ==========================================================================
   Feed Container - Constrain the feed, not individual cards
   ========================================================================== */

.feed .posts,
.feed .posts-list {
  max-width: 750px;
  margin: 0 auto;
}

/* ==========================================================================
   Feed Layouts: Grid & Masonry
   ========================================================================== */

/* Grid layout with subgrid support */
.feed-layout-grid,
.feed-layout-masonry {
  max-width: var(--grid-max-width, 1400px) !important;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.feed-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: var(--space-6);
  align-items: start;
}

/* Progressive Enhancement: Native Masonry */
@supports (grid-template-rows: masonry) {
  .feed-layout-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
    grid-template-rows: masonry;
    gap: var(--space-6);
    align-items: start;
  }
}

/* CSS Subgrid for Card Alignment across rows */
@supports (grid-template-rows: subgrid) {
  /* Only apply subgrid in the grid layout (not masonry as it packs items) */
  .feed-layout-grid .card {
    grid-row: span 3;
    display: grid;
    grid-template-rows: subgrid;
    gap: 0; /* Align perfectly across rows */
  }

  /* Card components participate in the subgrid */
  .card .card-header { grid-row: 1; }
  .card .card-body,
  .card .card-content,
  .card .card-excerpt { grid-row: 2; }
  .card .card-meta,
  .card footer { grid-row: 3; }
}

/* ==========================================================================
   Base Card Styles (shared by all card types)
   Extends the .card class from main.css
   ========================================================================== */

.card {
  width: 100%;
  background: var(--color-surface);
}

/* Ensure card sections don't paint their own bands */
.card .card-header,
.card .card-body,
.card .card-content,
.card .card-excerpt,
.card .card-meta,
.card footer {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}


/* Card title links */
.card .card-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
}

.card .card-title a {
  color: var(--color-text);
  text-decoration: none;
}

.card .card-title a:hover {
  color: var(--color-primary);
}

.card .card-description,
.card .card-excerpt,
.card .card-link-snippet,
.card-note .card-text {
  color: var(--color-text-muted);
}

/* Card meta (date, reading time, etc.) */
.card .card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline; /* Align on text baseline */
  gap: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}

.card .card-meta time {
  display: inline;
}

/* Card tags - inline with meta, baseline aligned */
.card .card-tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0; /* Remove top margin when inline with meta */
}

.card .card-tags .tag {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  line-height: 1;
  vertical-align: baseline;
}

/* ==========================================================================
   Article Card - High prominence for blog posts, tutorials, essays
   Large title, excerpt, tags, reading time, generous padding
   ========================================================================== */

.card-article {
  padding: var(--space-6);
}

/* Embed-style: cover image on left, content on right */
.card-article.has-cover {
  display: flex;
  padding: 0;
  overflow: hidden;
}

.card-article .card-cover {
  flex-shrink: 0;
  width: 220px;
  min-height: 160px;
  overflow: hidden;
  background: var(--color-surface);
}

.card-article .card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.card-article.has-cover:hover .card-cover-img {
  transform: scale(1.03);
}

.card-article.has-cover .card-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
}

/* Push footer to bottom in embed layout */
.card-article.has-cover .card-body {
  flex: 1;
}

.card-article .card-header {
  margin-bottom: var(--space-3);
}

.card-article .card-title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-3);
}

/* Slightly smaller title in embed layout to balance with image */
.card-article.has-cover .card-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.card-article .card-excerpt {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}

/* Clamp only when space is tight (embed with cover image) */
.card-article.has-cover .card-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-article .reading-time::before {
  content: "\2022";
  margin-right: var(--space-2);
}

/* ==========================================================================
   Note Card - Low prominence for pings, thoughts, status updates
   Centered, right border accent, subtle shadow, no left border
   ========================================================================== */

.card-note {
  padding: var(--space-4);
  border: none;
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  max-width: 550px;
  margin-left: auto;
  margin-right: auto;
}

.card-note:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.card-note .card-content {
  margin-bottom: var(--space-3);
}

.card-note .card-title {
  font-size: var(--text-lg);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.card-note .card-title a {
  color: var(--color-text);
}

.card-note .card-text {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.card-note .card-meta {
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
}

.card-note .card-link {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-decoration: none;
}

.card-note .card-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ==========================================================================
   Photo Card - Image/video prominent for shots, photos, gallery posts
   Large media with aspect-ratio, caption/description below
   Auto-detects video files (.mp4, .webm, .mov) and displays as looping video
   ========================================================================== */

.card-photo {
  padding: 0;
  overflow: hidden;
}

.card-photo .card-image-link {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-surface);
}

.card-photo .card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

/* Video element styling - ensure it fills container */
.card-photo video.card-image {
  display: block;
}

.card-photo:hover .card-image {
  transform: scale(1.02);
}

.card-photo .card-body {
  padding: var(--space-4);
}

.card-photo .card-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.card-photo .card-caption {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-2);

  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Standalone photo figures rendered directly in feed lists should center
   their media and caption within the feed column, not hug the left edge. */
.feed .posts-list > .photo-figure {
  width: 100%;
  max-width: 100%;
  display: grid;
  justify-items: center;
  text-align: center;
}

.feed .posts-list > .photo-figure > a {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 100%;
}

.feed .posts-list > .photo-figure img,
.feed .posts-list > .photo-figure video {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================================
   Video Card - Video/thumbnail prominent for video, clip, stream posts
   Video thumbnail with play indicator, title below
   ========================================================================== */

.card-video {
  padding: 0;
  overflow: hidden;
}

.card-video .card-video-link {
  display: block;
}

.card-video .card-video-container {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-surface);
}

.card-video .card-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card-video:hover .card-thumbnail {
  transform: scale(1.02);
}

.card-video .card-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background 0.2s, transform 0.2s;
}

.card-video:hover .card-play-icon {
  background: var(--color-primary);
  transform: translate(-50%, -50%) scale(1.1);
}

.card-video .card-play-icon svg {
  margin-left: 4px; /* Visual centering for play icon */
}

.card-video .card-body {
  padding: var(--space-4);
}

.card-video .card-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.card-video .card-description {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.card-video .duration {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* ==========================================================================
   Link Card - URL preview style for links, bookmarks, TIL posts
   Shows domain, title, description in preview card style
   ========================================================================== */

.card-link {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Wide layout: title and excerpt share one row on desktop */
@media (min-width: 769px) {
  .card-link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  .card-link .card-header {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
  }

  .card-link .card-body {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .card-link .card-meta {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  /* Revert to stacked layout inside narrow sidebar contexts */
  aside .card-link {
    display: flex;
    flex-direction: column;
  }
}

.card-link .card-link-wrapper {
  display: flex;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
}

.card-link .card-link-body {
  padding: 0 var(--space-4) var(--space-4);
}

/* card-body inside link cards needs its own padding since card-link has padding:0 */
.card-link .card-body {
  padding: var(--space-3) var(--space-4);
}

.card-link .card-link-snippet {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.card-link .card-link-image {
  flex-shrink: 0;
  width: 120px;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-link .card-link-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-link .card-link-content {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  min-width: 0;
}

/* Reset <p> wrappers injected by the markdown processor around domain/data elements */
.card-link .card-link-content p,
.card-link .card-meta p {
  margin: 0;
  display: inline;
}

.card-link .card-domain {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  text-decoration: none;
  text-transform: lowercase;

  /* Truncate long URLs */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-link .card-domain:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.card-link .card-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 0;

  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-link .card-description,
.card-link .card-excerpt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);

  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Flatten paragraph margins inside excerpt so line-clamp works across <p> children */
.card-link .card-excerpt p {
  display: inline;
}

/* Add a space between consecutive paragraphs rendered inline */
.card-link .card-excerpt p + p::before {
  content: " ";
}

.card-link .card-meta {
  margin-top: auto;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* Sidebar link cards: de-emphasize title, show more content */
aside .card-link .card-title {
  font-size: var(--text-sm);
  font-weight: 500;
  -webkit-line-clamp: 1;
}

aside .card-link .card-excerpt {
  -webkit-line-clamp: 6;
  font-size: var(--text-sm);
}

/* ==========================================================================
   Quote Card - Blockquote styling for quotes, quotations
   Large quote with source attribution
   ========================================================================== */

.card-quote {
  padding: var(--space-6);
  background: var(--color-surface);
  border-left: 4px solid var(--color-primary);
}

.card-quote .card-blockquote {
  margin: 0 0 var(--space-4);
  padding: 0;
  border: none;
  background: none;
  font-style: italic;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text);
}

.card-quote .card-blockquote p {
  margin: 0;
}

.card-quote .card-attribution {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.card-quote .card-attribution cite {
  font-style: normal;
}

.card-quote .quote-author {
  font-weight: 600;
  color: var(--color-text);
}

.card-quote .quote-author::after {
  content: ",";
  margin-right: var(--space-1);
}

.card-quote .quote-source {
  font-style: italic;
}

.card-quote .card-title-link {
  color: var(--color-primary);
  text-decoration: none;
}

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

/* ==========================================================================
   Guide Card - Step/chapter indicator for guides, series, tutorials
   Shows step number, title, description
   ========================================================================== */

.card-guide {
  padding: var(--space-4);
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.card-guide .card-step-indicator {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-guide .step-number {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
}

.card-guide .card-body {
  flex: 1;
  min-width: 0;
}

.card-guide .card-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.card-guide .card-description {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-2);

  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Inline Card - Full rendered content for gratitude, micro posts
   Minimal wrapper, displays full article_html content
   ========================================================================== */

.card-inline {
  padding: var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
}

.card-inline:hover {
  border-color: var(--color-border);
  box-shadow: none;
}

.card-inline .card-content {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text);
}

/* Style inline content (rendered markdown) */
.card-inline .card-content h1,
.card-inline .card-content h2,
.card-inline .card-content h3,
.card-inline .card-content h4,
.card-inline .card-content h5,
.card-inline .card-content h6 {
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.card-inline .card-content h1:first-child,
.card-inline .card-content h2:first-child,
.card-inline .card-content h3:first-child,
.card-inline .card-content h4:first-child {
  margin-top: 0;
}

.card-inline .card-content p {
  margin-bottom: var(--space-3);
}

.card-inline .card-content p:last-child {
  margin-bottom: 0;
}

.card-inline .card-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: var(--space-3) 0;
}

.card-inline .card-content blockquote {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  padding-left: var(--space-4);
  border-left: 3px solid var(--color-primary);
  background: var(--color-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.card-inline .card-meta {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  justify-content: space-between;
}

.card-inline .card-permalink {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.card-inline .card-permalink:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ==========================================================================
   Contact Card - Person/character profile for contacts, characters, people
   Shows avatar, name, handle, and short bio
   ========================================================================== */

.card-contact {
  padding: var(--space-4);
}

.card-contact-layout {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.card-contact-avatar-link {
  text-decoration: none;
  flex-shrink: 0;
}

.card-contact-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-contact-initials {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.card-contact-body {
  flex: 1;
  min-width: 0;
}

.card-contact .card-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
}

.card-contact-handle {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.card-contact-bio {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: var(--leading-relaxed);

  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-contact-site {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-link);
  margin-top: var(--space-1);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.card-contact-site:hover {
  text-decoration: underline;
}

.card-contact .card-meta {
  margin-top: var(--space-3);
}

/* ==========================================================================
   Default Card - Fallback for unmapped templateKey values
   Basic card layout, similar to original card.html
   ========================================================================== */

.card-default {
  padding: var(--space-5);
}

.card-default .card-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.card-default .card-description {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}

/* ==========================================================================
   Simple Feed - Dense, compact list view for scanning many posts quickly
   Each post renders as a single line: Title (link) · Date · Reading Time
   ========================================================================== */

.feed-simple {
  max-width: 750px;
  margin: 0 auto;
}

.feed-simple-header {
  margin-bottom: var(--space-4);
}

.feed-simple-header h1 {
  margin-bottom: var(--space-2);
}

.feed-simple-header .p-summary {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

/* Feed view switcher */
.feed-simple-nav {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.feed-simple-nav a {
  color: var(--color-primary);
  text-decoration: none;
}

.feed-simple-nav a:hover {
  text-decoration: underline;
}

.feed-simple-nav-current {
  font-weight: 600;
  color: var(--color-text);
}

/* Simple list (ordered) */
.simple-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Individual simple item - single line on desktop */
.simple-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.simple-item:last-child {
  border-bottom: none;
}

/* Title link - takes remaining space, truncates if needed */
.simple-item-title {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.simple-item-title:hover {
  color: var(--color-primary);
}

/* Date - fixed width for alignment */
.simple-item-date {
  flex-shrink: 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: nowrap;
}

/* Reading time */
.simple-item-reading-time {
  flex-shrink: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.simple-item-reading-time::before {
  content: "\00B7";
  margin-right: var(--space-2);
}

/* ==========================================================================
   Simple Feed Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .feed-simple {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .simple-item {
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
  }

  .simple-item-title {
    flex-basis: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .simple-item-reading-time::before {
    content: "\00B7";
  }
}

/* ==========================================================================
   Simple Feed Print
   ========================================================================== */

@media print {
  .simple-item {
    border-bottom-color: #ccc;
  }

  .feed-simple-nav {
    display: none;
  }
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
  /* Reduce feed max-width constraint on mobile */
  .feed .posts,
  .feed .posts-list {
    max-width: 100%;
  }

  /* Article card */
  .card-article {
    padding: var(--space-4);
  }

  /* Stack embed layout vertically on tablet */
  .card-article.has-cover {
    flex-direction: column;
  }

  .card-article .card-cover {
    width: 100%;
    min-height: 0;
    height: 180px;
  }

  .card-article.has-cover .card-content {
    padding: var(--space-4);
  }

  .card-article .card-title {
    font-size: var(--text-xl);
  }

  .card-article.has-cover .card-title {
    font-size: var(--text-lg);
  }

  /* Note card */
  .card-note {
    padding: var(--space-3);
    max-width: 100%;
  }

  /* Photo card */
  .card-photo .card-body {
    padding: var(--space-3);
  }

  /* Video card */
  .card-video .card-play-icon {
    width: 48px;
    height: 48px;
  }

  .card-video .card-play-icon svg {
    width: 32px;
    height: 32px;
  }

  .card-video .card-body {
    padding: var(--space-3);
  }

  /* Link card - stack vertically on mobile */
  .card-link .card-link-wrapper {
    flex-direction: column;
  }

  .card-link .card-link-image {
    width: 100%;
    height: 120px;
  }

  /* Quote card */
  .card-quote {
    padding: var(--space-4);
  }

  .card-quote .card-blockquote {
    font-size: var(--text-base);
  }

  /* Guide card - stack on mobile */
  .card-guide {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .card-guide .card-step-indicator {
    width: 40px;
    height: 40px;
  }

  .card-guide .step-number {
    font-size: var(--text-lg);
  }

  /* Inline card */
  .card-inline {
    padding: var(--space-3);
  }

  /* Contact card */
  .card-contact {
    padding: var(--space-3);
  }

  .card-contact-avatar {
    width: 48px;
    height: 48px;
  }

  /* Default card */
  .card-default {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .card-article .card-title {
    font-size: var(--text-lg);
  }

  .card-article.has-cover .card-title {
    font-size: var(--text-base);
  }

  .card-article .card-cover {
    height: 140px;
  }

  .card-note .card-text {
    -webkit-line-clamp: 2;
  }

  .card-photo .card-image-link {
    aspect-ratio: 4 / 3;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ccc;
    box-shadow: none;
  }

  .card-photo .card-image,
  .card-video .card-thumbnail {
    max-height: 200px;
  }

  .card-inline .card-content img {
    max-height: 150px;
  }
}

/* ==========================================================================
   Card Classes - Grid span utilities from frontmatter card_classes
   Applied via wrapper div in card-router.html when post has card_classes set
   ========================================================================== */

.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.row-span-1 { grid-row: span 1; }
.row-span-2 { grid-row: span 2; }
.row-span-3 { grid-row: span 3; }

/* Cards inside span wrappers must fill the wrapper */
[class*="col-span-"] > .card,
[class*="col-span-"] > .photo-figure,
[class*="row-span-"] > .card,
[class*="row-span-"] > .photo-figure {
  height: 100%;
}

/* Photo figures spanning rows: image fills available space */
[class*="row-span-"] > .photo-figure {
  display: flex;
  flex-direction: column;
}

[class*="row-span-"] > .photo-figure > a {
  flex: 1;
  display: block;
  min-height: 0;
}

[class*="row-span-"] > .photo-figure img,
[class*="row-span-"] > .photo-figure video {
  height: 100%;
  width: 100%;
  object-fit: cover;
}

/* aspect-auto: let the natural aspect ratio show instead of forced 16:9 */
.aspect-auto img,
.aspect-auto video {
  aspect-ratio: auto !important;
}

/* Responsive: collapse spans on small screens */
@media (max-width: 600px) {
  .col-span-2,
  .col-span-3,
  .col-span-4 { grid-column: span 1; }
  .row-span-2,
  .row-span-3 { grid-row: span 1; }
}

/* ==========================================================================
   Reduced Motion - Respect prefers-reduced-motion for card hover effects
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .card-photo .card-image,
  .card-video .card-thumbnail,
  .card-video .card-play-icon {
    transition: none;
  }

  .card-photo:hover .card-image,
  .card-video:hover .card-thumbnail {
    transform: none;
  }

  .card-video:hover .card-play-icon {
    transform: translate(-50%, -50%);
  }
}

}
