/* ==========================================================================
   Vidzy Blog Styles
   Extends design-system.css tokens and components.css base classes.
   Load order: reset → design-system → keycap-buttons → components →
               responsive → blog.css
   ========================================================================== */

/* ==========================================================================
   Section 1: Post Cards
   Extends .card, .card-body, .card-meta from components.css.
   ========================================================================== */

.post-card {
  display: flex;
  flex-direction: column;
}

.post-card .card-image {
  position: relative;
}

.post-card-category {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: 1;
}

.post-card .card-body h3 {
  display: block;
  overflow: visible;
}

.post-card .card-body h3 a {
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-card .card-body h3 a:hover {
  color: var(--color-accent);
}

.post-card .card-body p {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: var(--space-xs);
}

.post-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  color: var(--color-text-tertiary);
}

.post-card-meta .meta-separator {
  display: inline-block;
  width: var(--space-xxs);
  height: var(--space-xxs);
  border-radius: 50%;
  background-color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.post-card-meta .meta-author {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

/* Featured post card — larger, spans full width */
.post-card--featured {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .post-card--featured {
    flex-direction: row;
  }

  .post-card--featured .card-image {
    flex: 0 0 50%;
    aspect-ratio: 16 / 9;
  }

  .post-card--featured .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .post-card--featured .card-body h3 {
    font-size: var(--text-heading-large);
    line-height: var(--text-heading-large-lh);
    overflow: visible;
  }
}

/* ==========================================================================
   Section 2: Content Typography
   Scoped to .post-content — overrides reset.css defaults for article body.
   ========================================================================== */

.post-content {
  font-size: var(--text-body-large);
  line-height: var(--text-body-large-lh);
  color: var(--color-text-secondary);
}

/* Links — explicitly override reset.css a { color: inherit; text-decoration: none; } */
.post-content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: var(--space-xxs);
  transition: color 0.2s ease;
}

.post-content a:hover {
  color: var(--color-purple);
}

/* Headings */
.post-content h2 {
  font-size: var(--text-heading-large);
  line-height: var(--text-heading-large-lh);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-top: var(--space-xxl);
  margin-bottom: var(--space-md);
}

.post-content h3 {
  font-size: var(--text-heading-medium);
  line-height: var(--text-heading-medium-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
}

.post-content h4 {
  font-size: var(--text-body-large);
  line-height: var(--text-body-large-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}

.post-content h5 {
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}

.post-content h6 {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}

/* Paragraphs */
.post-content p {
  margin-bottom: var(--space-md);
}

/* Lists */
.post-content ul,
.post-content ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

.post-content ul {
  list-style-type: disc;
}

.post-content ol {
  list-style-type: decimal;
}

.post-content li {
  margin-bottom: var(--space-xs);
  line-height: var(--text-body-large-lh);
}

.post-content li::marker {
  color: var(--color-accent);
}

/* Sidebar Table of Contents */
.sidebar-toc .toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-toc .toc-list li {
  padding: var(--space-xxs) 0;
}

.sidebar-toc .toc-list a {
  display: block;
  padding: var(--space-xxs) var(--space-sm);
  color: var(--color-text-tertiary);
  text-decoration: none;
  font-size: var(--text-body-small);
  line-height: var(--text-body-medium-lh);
  border-left: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.sidebar-toc .toc-list a:hover {
  color: var(--color-text-primary);
  border-left-color: var(--color-border);
}

.sidebar-toc .toc-list a.toc-active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: var(--font-weight-medium);
}

.sidebar-toc.toc-sticky {
  position: sticky;
  top: 100px;
}

@media (max-width: 1023px) {
  .sidebar-toc {
    display: none;
  }
}

/* Blockquote */
.post-content blockquote {
  border-left: var(--space-xxs) solid var(--color-purple);
  padding-left: var(--space-lg);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-lg);
  font-style: italic;
  color: var(--color-text-secondary);
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Prompt Block — Click-to-Copy
   Replaces blockquote prompts with interactive copy blocks.
   ========================================================================== */

.prompt-block {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--corner-radius);
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.prompt-block:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent), 0 4px 12px rgba(89, 217, 117, 0.08);
}

.prompt-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.prompt-block-label {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-style: normal;
}

.prompt-block-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--corner-radius-sm);
  color: var(--color-text-tertiary);
  font-family: var(--font-family);
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.prompt-block-copy:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.prompt-block-copy.copied {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(89, 217, 117, 0.08);
}

.prompt-block-copy svg {
  flex-shrink: 0;
}

.prompt-block-text {
  padding: var(--space-md);
  font-size: var(--text-body-medium);
  line-height: var(--text-body-large-lh);
  color: var(--color-text-primary);
  font-style: normal;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Code blocks */
.post-content pre {
  background: var(--color-surface-elevated);
  border-radius: var(--corner-radius-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.post-content pre code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: var(--text-body-small);
  line-height: var(--text-body-medium-lh);
  color: var(--color-text-primary);
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Inline code */
.post-content code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.9em;
  background: var(--color-surface-elevated);
  color: var(--color-purple);
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--corner-radius-sm);
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
}

.post-content th {
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--color-border);
}

.post-content td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.post-content tr:nth-child(even) td {
  background: var(--color-surface);
}

/* Images & figures */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--corner-radius);
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

.post-content figure {
  margin: var(--space-lg) 0;
}

.post-content figure img {
  margin-bottom: var(--space-xs);
}

.post-content figcaption {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  color: var(--color-text-tertiary);
  text-align: center;
}

/* Horizontal rule */
.post-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-xl) 0;
}

/* ==========================================================================
   Section 3: Blog Layout (2-column grid)
   ========================================================================== */

.blog-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

.blog-main {
  min-width: 0; /* Prevent grid blowout from code blocks / images */
}

@media (min-width: 1024px) {
  .blog-layout {
    grid-template-columns: 1fr 240px;
  }
}

/* Blog page header — title + optional description */
.blog-page-header {
  margin-bottom: var(--space-xl);
}

.blog-page-header h1 {
  font-size: var(--text-display-medium);
  line-height: var(--text-display-medium-lh);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.blog-page-header p {
  font-size: var(--text-body-large);
  line-height: var(--text-body-large-lh);
  color: var(--color-text-secondary);
}

/* Post header — single post page */
.post-header {
  margin-bottom: var(--space-xl);
}

.post-header h1 {
  font-size: var(--text-display-medium);
  line-height: var(--text-display-medium-lh);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .post-header h1 {
    font-size: var(--text-display-large);
    line-height: var(--text-display-large-lh);
  }
}

.post-header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  color: var(--color-text-tertiary);
}

.post-header-meta .meta-author {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

/* Post featured image */
.post-featured-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--corner-radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-xl);
  background: linear-gradient(
    135deg,
    var(--color-surface) 0%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 100%
  );
}

.post-featured-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Post tags at bottom of article */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

/* Post navigation (prev/next article) */
.post-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

@media (min-width: 768px) {
  .post-nav {
    grid-template-columns: 1fr 1fr;
  }
}

.post-nav-link {
  display: block;
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--corner-radius);
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.post-nav-link:hover {
  border-color: var(--color-accent);
}

.post-nav-label {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-xxs);
}

.post-nav-title {
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.post-nav-next {
  text-align: right;
}

/* ==========================================================================
   Section 4: Sidebar Widgets
   ========================================================================== */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.sidebar-widget {
  background: transparent;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--color-border);
  padding: 0 0 var(--space-lg);
}

.sidebar-widget h3 {
  font-size: var(--text-heading-medium);
  line-height: var(--text-heading-medium-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

/* Search widget */
.widget-search {
  display: flex;
  gap: var(--space-xs);
}

.widget-search input {
  flex: 1;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--corner-radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-primary);
  font-family: var(--font-family);
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  outline: none;
  transition: border-color 0.2s ease;
}

.widget-search input::placeholder {
  color: var(--color-text-tertiary);
}

.widget-search input:focus {
  border-color: var(--color-accent);
}

/* Categories widget */
.widget-categories {
  list-style: none;
  padding: 0;
  margin: 0;
}

.widget-categories li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.widget-categories li:last-child {
  border-bottom: none;
}

.widget-categories a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  transition: color 0.2s ease;
}

.widget-categories a:hover {
  color: var(--color-accent);
}

.widget-categories .category-count {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  color: var(--color-text-tertiary);
  background: var(--color-surface-elevated);
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--corner-radius-sm);
}

/* Popular posts widget */
.widget-popular-posts {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.widget-popular-post {
  display: flex;
  gap: var(--space-sm);
  text-decoration: none;
}

.widget-popular-post:hover .widget-popular-post-title {
  color: var(--color-accent);
}

.widget-popular-post-thumb {
  flex-shrink: 0;
  width: var(--space-xxxl);
  height: var(--space-xxxl);
  border-radius: var(--corner-radius-sm);
  background: linear-gradient(
    135deg,
    var(--color-surface) 0%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 100%
  );
  overflow: hidden;
}

.widget-popular-post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.widget-popular-post-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.widget-popular-post-title {
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  transition: color 0.2s ease;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.widget-popular-post-date {
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
  color: var(--color-text-tertiary);
  margin-top: var(--space-xxs);
}

/* Tags widget — chip cloud */
.widget-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* CTA widget — App Store download card */
.widget-cta {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.widget-cta h3 {
  color: var(--color-bg);
}

.widget-cta p {
  font-size: var(--text-body-medium);
  line-height: var(--text-body-medium-lh);
  color: var(--color-bg);
  margin-bottom: var(--space-md);
  opacity: 0.9;
}

.widget-cta .cta-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-bg);
  color: var(--color-accent);
  font-family: var(--font-family);
  font-size: var(--text-body-medium);
  font-weight: var(--font-weight-semibold);
  border: none;
  border-radius: var(--corner-radius);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.widget-cta .cta-button:hover {
  opacity: 0.9;
}

/* ==========================================================================
   Section 5: Pagination
   ========================================================================== */

/* WordPress pagination — .nav-links with .page-numbers */
.pagination,
.navigation.pagination {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
}

.pagination .nav-links,
.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 var(--space-md);
  font-family: var(--font-family);
  font-size: var(--text-body-medium);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--corner-radius);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.page-numbers:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.page-numbers.current {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
  font-weight: var(--font-weight-semibold);
  pointer-events: none;
}

.page-numbers.prev,
.page-numbers.next {
  font-weight: var(--font-weight-semibold);
  padding: 0 var(--space-lg);
  background: var(--color-surface-elevated);
}

.page-numbers.dots {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-tertiary);
  cursor: default;
  min-width: 32px;
  padding: 0;
}

.page-numbers.dots:hover {
  border-color: transparent;
  color: var(--color-text-tertiary);
}

/* Hide screen reader text */
.navigation .screen-reader-text {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  width: 1px;
  overflow: hidden;
}

/* ==========================================================================
   Section 6: Breadcrumbs
   ========================================================================== */

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  font-size: var(--text-body-small);
  line-height: var(--text-body-small-lh);
  margin-bottom: var(--space-lg);
}

.breadcrumbs a {
  color: var(--color-text-tertiary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.breadcrumbs a:hover {
  color: var(--color-accent);
}

.breadcrumbs .breadcrumb-separator {
  color: var(--color-text-tertiary);
}

.breadcrumbs .breadcrumb-separator::after {
  content: '›';
}

.breadcrumbs .breadcrumb-current {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
}

/* ==========================================================================
   Blog Empty State — search results with no matches
   ========================================================================== */

.blog-empty-state {
  text-align: center;
  padding: var(--space-xxxl) var(--space-lg);
}

.blog-empty-state-icon {
  font-size: var(--space-xxxl);
  margin-bottom: var(--space-md);
}

.blog-empty-state h2 {
  font-size: var(--text-heading-large);
  line-height: var(--text-heading-large-lh);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.blog-empty-state p {
  font-size: var(--text-body-large);
  line-height: var(--text-body-large-lh);
  color: var(--color-text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

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

@media (min-width: 768px) {
  .blog-page-header h1 {
    font-size: var(--text-display-large);
    line-height: var(--text-display-large-lh);
  }
}

/* On mobile, sidebar stacks below main */
@media (max-width: 1023px) {
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-widget {
    flex: 1 1 calc(50% - var(--space-md));
    min-width: 280px;
  }
}
