/* ============================================================
   CyberBLOG Grav Plugin — Styles
   Layout matches cyberchaperone-redesign/articles.php
   Theme-neutral: uses CSS var() with safe fallbacks so it
   looks native on any Grav theme that defines common vars,
   and looks great standalone on themes that don't.
   ============================================================ */

:root {
  /* Accent: uses theme's primary if defined, falls back to Cyber Chaperone blue */
  --cb-accent:      var(--color-primary,  #0066cc);
  --cb-accent-dark: var(--color-primary-dark, #0052a3);
  /* Text */
  --cb-text:        var(--color-dark,     #1a1a1a);
  --cb-muted:       var(--color-text-light, #4a5568);
  /* Surfaces */
  --cb-bg:          var(--color-light,    #f8f9fa);
  --cb-white:       #ffffff;
  --cb-border:      #e5e7eb;
  /* Shadows */
  --cb-shadow:      0 2px 12px rgba(0,0,0,0.08);
  --cb-shadow-hover: 0 8px 24px rgba(0,102,255,0.15);
  /* Shape */
  --cb-radius:      12px;
  --cb-max-width:   1200px;
  --cb-narrow:      800px;
}

/* ── Reset ── */
.cyberblog-page *,
.cb-article-page * {
  box-sizing: border-box;
}

/* ── Container ── */
.cb-container {
  max-width: var(--cb-max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.cb-container--narrow {
  max-width: var(--cb-narrow);
  margin: 0 auto;
  padding: 0 2rem;
}

/* ============================================================
   PAGE HEADER
   White → light-gray gradient, left-aligned — matches articles.php hero
   ============================================================ */
.cb-page-header {
  background: linear-gradient(to bottom, var(--cb-white) 0%, var(--cb-bg) 100%);
  padding: 5rem 0 1.5rem;
  border-bottom: 1px solid var(--cb-border);
}

.cb-page-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--cb-text);
  margin: 0 0 0.6rem;
  line-height: 1.2;
}

.cb-page-header__sub {
  font-size: 1rem;
  color: var(--cb-muted);
  margin: 0;
  font-weight: 400;
  line-height: 1.6;
}

/* ============================================================
   GENERATOR SECTION
   ============================================================ */
.cb-generator {
  background: var(--cb-bg);
  padding: 2rem 0;
  border-bottom: 1px solid var(--cb-border);
}

.cb-generator__card {
  background: var(--cb-white);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  padding: 2rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  border-left: 4px solid var(--cb-accent);
}

.cb-generator__info h2 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--cb-text);
}

.cb-generator__info p {
  margin: 0;
  color: var(--cb-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.cb-generator__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.cb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  border: 2px solid transparent;
  white-space: nowrap;
}

.cb-btn:active { transform: translateY(1px); }

.cb-btn--primary {
  background: var(--cb-accent);
  color: var(--cb-white);
  border-color: var(--cb-accent);
}

.cb-btn--primary:hover {
  background: var(--cb-accent-dark);
  border-color: var(--cb-accent-dark);
  box-shadow: 0 4px 16px rgba(0,102,204,0.3);
}

.cb-btn--outline {
  background: transparent;
  color: var(--cb-accent);
  border-color: var(--cb-accent);
}

.cb-btn--outline:hover {
  background: var(--cb-accent);
  color: var(--cb-white);
}

.cb-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ── Status ── */
.cb-status {
  font-size: 0.875rem;
  min-height: 1.25rem;
  text-align: right;
  color: var(--cb-muted);
}

.cb-status.loading { color: var(--cb-accent); font-weight: 600; }
.cb-status.success { color: #10b981; font-weight: 600; }
.cb-status.error   { color: #ef4444; font-weight: 600; }

/* ============================================================
   ARTICLES SECTION
   ============================================================ */
.cb-articles {
  background: var(--cb-white);
  padding: 3rem 0 4rem;
}

/* ── Filter Bar ── */
.cb-filter-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.cb-search {
  flex: 1;
  min-width: 220px;
  max-width: 400px;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--cb-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--cb-white);
  color: var(--cb-text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cb-search:focus {
  border-color: var(--cb-accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

.cb-results-count {
  font-size: 0.875rem;
  color: var(--cb-muted);
}

/* ============================================================
   ARTICLE GRID
   ============================================================ */
.cb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
}

/* ── Card ── */
.cb-card {
  background: var(--cb-white);
  border-radius: var(--cb-radius);
  border: 1px solid var(--cb-border);
  box-shadow: var(--cb-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cb-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--cb-shadow-hover);
}

.cb-card[hidden] { display: none; }

/* Image with zoom on hover */
.cb-card__image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: var(--cb-bg);
  flex-shrink: 0;
}

.cb-card__image a {
  display: block;
  width: 100%;
  height: 100%;
}

.cb-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.cb-card:hover .cb-card__image img {
  transform: scale(1.05);
}

/* Card header: meta + title, with bottom border */
.cb-card__header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--cb-border);
}

.cb-card__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.875rem;
  font-size: 0.825rem;
  color: var(--cb-muted);
  flex-wrap: wrap;
}

.cb-card__date {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cb-card__date svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.cb-card__author::before {
  content: '·';
  margin-right: 0.5rem;
  opacity: 0.5;
}

.cb-card__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--cb-text);
}

.cb-card__title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.cb-card__title a:hover { color: var(--cb-accent); }

/* Card body: excerpt */
.cb-card__body {
  padding: 1.5rem;
  flex: 1;
}

.cb-card__excerpt {
  margin: 0;
  color: var(--cb-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Card footer: tags + read more link */
.cb-card__footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--cb-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Keyword Pill Tags ── */
.cb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cb-tag {
  background: var(--cb-bg);
  color: var(--cb-accent);
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

/* ── Read More Link ── */
.cb-read-more {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--cb-accent);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: gap 0.2s ease;
}

.cb-read-more:hover { gap: 0.65rem; }

.cb-read-more svg { flex-shrink: 0; }

/* ── Empty State ── */
.cb-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--cb-muted);
}

.cb-empty svg {
  margin: 0 auto 1.5rem;
  display: block;
  opacity: 0.3;
  color: var(--cb-text);
}

.cb-empty h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--cb-text);
  margin: 0 0 0.5rem;
}

.cb-empty p {
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

/* ============================================================
   ARTICLE DETAIL PAGE
   ============================================================ */
.cb-article-header {
  background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
  color: #fff;
  padding: 5rem 0 3rem;
  text-align: center;
}

.cb-breadcrumb {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: 1.5rem;
}

.cb-breadcrumb a {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
}

.cb-breadcrumb a:hover { text-decoration: underline; }
.cb-breadcrumb span { margin: 0 0.4rem; opacity: 0.7; }

.cb-article-title {
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
  margin: 0 auto 1.5rem;
  max-width: 900px;
}

.cb-article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.9);
  flex-wrap: wrap;
}

.cb-tags--article {
  justify-content: center;
  margin-top: 1.25rem;
}

.cb-tags--article .cb-tag {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}

/* ── Featured Image ── */
.cb-article-hero-image {
  padding: 2rem 0;
  background: var(--cb-white);
}

.cb-article-hero-img {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: var(--cb-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  display: block;
}

/* ── Article Body ── */
.cb-article-body {
  background: var(--cb-white);
  padding: 3rem 0 4rem;
}

.cb-article-content {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--cb-text);
}

.cb-article-content p  { margin: 0 0 1.5rem; }

.cb-article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  color: var(--cb-text);
  border-left: 4px solid var(--cb-accent);
  padding-left: 0.875rem;
}

.cb-article-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  color: var(--cb-text);
}

.cb-article-content ul,
.cb-article-content ol {
  padding-left: 1.75rem;
  margin: 1rem 0 1.5rem;
}

.cb-article-content li { margin-bottom: 0.5rem; line-height: 1.7; }

.cb-article-content strong { font-weight: 700; color: var(--cb-text); }

.cb-article-content blockquote {
  border-left: 4px solid var(--cb-accent);
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--cb-muted);
}

.cb-article-content a {
  color: var(--cb-accent);
  text-decoration: underline;
}

.cb-article-content a:hover { color: var(--cb-accent-dark); }

/* ── Author Box ── */
.cb-author-box {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  padding: 1.5rem;
  margin: 3rem 0 2rem;
  border: 1px solid var(--cb-border);
}

.cb-author-box__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--cb-accent);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cb-author-box__info strong { font-size: 1rem; color: var(--cb-text); }

.cb-author-box__info p {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--cb-muted);
  line-height: 1.6;
}

.cb-article-back {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--cb-border);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .cb-page-header { padding: 4rem 0 1.25rem; }

  .cb-grid { grid-template-columns: 1fr; gap: 1.5rem; }

  .cb-generator__card {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem;
  }

  .cb-generator__controls {
    align-items: flex-start;
    width: 100%;
  }

  .cb-article-header { padding: 4rem 0 2rem; }

  .cb-article-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .cb-author-box {
    flex-direction: column;
    gap: 0.75rem;
  }

  .cb-card__footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================================
   AUTHOR PAGE
   ============================================================ */
.cb-author-hero {
  background: linear-gradient(to bottom, var(--cb-white) 0%, var(--cb-bg) 100%);
  padding: 5rem 0 3rem;
  border-bottom: 1px solid var(--cb-border);
}

.cb-author-hero__inner {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.cb-author-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--cb-accent);
  color: #fff;
  font-size: 3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.cb-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cb-author-hero__info { flex: 1; min-width: 0; }

.cb-author-name {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--cb-text);
  margin: 0 0 0.35rem;
  line-height: 1.15;
}

.cb-author-title-line {
  font-size: 1rem;
  font-weight: 600;
  color: var(--cb-accent);
  margin: 0 0 0.25rem;
}

.cb-author-org {
  font-size: 0.9rem;
  color: var(--cb-muted);
  margin: 0 0 1rem;
}

.cb-author-org a {
  color: var(--cb-muted);
  text-decoration: none;
}

.cb-author-org a:hover { text-decoration: underline; }

.cb-author-bio {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--cb-muted);
  margin: 0 0 1.5rem;
  max-width: 640px;
}

.cb-author-hero__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cb-btn--sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Articles section on author page */
.cb-author-articles { background: var(--cb-white); }

.cb-author-articles__heading {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 800;
  color: var(--cb-text);
  margin: 0 0 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--cb-border);
}

/* Author link in article header */
.cb-author-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.cb-author-link:hover { color: var(--cb-accent); }

/* "View all articles" in author box */
.cb-author-all-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--cb-accent);
  text-decoration: none;
}

.cb-author-all-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .cb-author-hero__inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .cb-author-bio { max-width: 100%; }

  .cb-author-hero__actions { justify-content: center; }
}

/* ── Loading Spinner ── */
.cb-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cb-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes cb-spin {
  to { transform: rotate(360deg); }
}
