/* ============================================================
   GIGAnalyser Blog — page-specific styles
   ============================================================ */
@layer base, components;

@layer base {
  html { color-scheme: dark; }
  html:not(.dark) { color-scheme: light; }

  /* Blog prose inherits from theme.css tokens */
  body { background: rgb(var(--surface-rgb)); color: rgb(var(--text-primary-rgb)); }

  a.blog-link {
    color: rgb(var(--accent-rgb));
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
  }
  a.blog-link:hover { text-decoration-thickness: 2px; }

  /* Ensure heading colors follow theme */
  html.dark h1, html.dark h2, html.dark h3, html.dark h4,
  html.dark h5, html.dark h6 { color: #FFFFFF; }
  html.dark p, html.dark li { color: rgb(var(--text-primary-rgb)); }
}

@layer components {

  /* ---- Blog container ---- */
  .blog-wrap { max-width: 740px; margin: 0 auto; padding: 0 20px; }
  .blog-wrap-wide { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

  /* ---- Breadcrumb ---- */
  .breadcrumb {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: rgb(var(--text-muted-rgb));
    margin-bottom: 16px; flex-wrap: wrap;
  }
  .breadcrumb a { color: rgb(var(--accent-rgb)); text-decoration: none; }
  .breadcrumb a:hover { text-decoration: underline; }
  .breadcrumb .sep { opacity: .5; }

  /* ---- Article hero ---- */
  .article-hero { padding: 56px 0 40px; }
  .article-hero .category-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(74,141,247,.12); border: 1px solid rgba(74,141,247,.25);
    color: rgb(var(--accent-rgb)); padding: 5px 12px;
    border-radius: 999px; font-size: 12px; font-weight: 600;
    letter-spacing: .03em; margin-bottom: 16px;
  }
  .article-hero h1 {
    font-size: clamp(28px, 5vw, 42px); font-weight: 800;
    line-height: 1.12; letter-spacing: -.025em;
    margin: 0 0 16px; max-width: 720px;
  }
  .article-hero .meta {
    font-size: 14px; color: rgb(var(--text-muted-rgb));
    display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  }
  .article-hero .meta span { display: inline-flex; align-items: center; gap: 5px; }

  /* ---- Quick answer box ---- */
  .quick-answer {
    background: rgba(74,141,247,.07);
    border-left: 3px solid rgb(var(--accent-rgb));
    border-radius: 0 12px 12px 0;
    padding: 18px 22px; margin-bottom: 40px;
    font-size: 16px; line-height: 1.65;
    color: rgb(var(--text-primary-rgb));
  }
  .quick-answer strong { color: rgb(var(--accent-rgb)); }

  /* ---- Article prose ---- */
  .prose h2 {
    font-size: clamp(22px, 3vw, 28px); font-weight: 800;
    letter-spacing: -.02em; margin: 48px 0 14px;
    padding-top: 24px;
  }
  .prose h2:first-of-type { margin-top: 32px; padding-top: 0; }
  .prose h3 {
    font-size: 18px; font-weight: 700; letter-spacing: -.01em;
    margin: 28px 0 10px;
  }
  .prose p, .prose li {
    font-size: 16px; line-height: 1.7;
    color: rgb(var(--text-primary-rgb));
    margin: 0 0 14px;
  }
  .prose ul, .prose ol { padding-left: 22px; margin: 0 0 16px; }
  .prose li { margin-bottom: 6px; }
  .prose strong { font-weight: 700; color: rgb(var(--text-primary-rgb)); }
  .prose em { font-style: italic; }
  .prose blockquote {
    border-left: 3px solid rgb(var(--accent-rgb));
    margin: 24px 0; padding: 14px 18px;
    background: rgba(74,141,247,.05);
    border-radius: 0 10px 10px 0;
    color: rgb(var(--text-secondary-rgb));
    font-style: italic;
  }

  /* Tables */
  .prose table {
    width: 100%; border-collapse: collapse;
    margin: 24px 0; font-size: 15px;
  }
  .prose thead th {
    background: rgba(74,141,247,.10);
    text-align: left; padding: 10px 14px;
    font-weight: 700; font-size: 13px;
    text-transform: uppercase; letter-spacing: .04em;
    color: rgb(var(--accent-rgb));
    border-bottom: 2px solid rgba(74,141,247,.25);
  }
  .prose tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid rgb(var(--surface-border-rgb));
    color: rgb(var(--text-primary-rgb));
  }
  .prose tbody tr:hover { background: rgba(74,141,247,.04); }

  /* ---- Tool CTA box ---- */
  .cta-box {
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
    border-radius: 16px; padding: 32px 28px;
    margin: 40px 0; text-align: center;
    color: #fff; position: relative; overflow: hidden;
  }
  html.light .cta-box { background: linear-gradient(135deg, #1a1a2e 0%, #0a0a0f 100%); }
  .cta-box::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse 60% 80% at 50% 50%, rgba(74,141,247,.15), transparent 70%);
    pointer-events: none;
  }
  .cta-box h3 {
    font-size: 22px; font-weight: 800; margin: 0 0 8px;
    position: relative; color: #fff;
  }
  .cta-box p {
    color: rgba(255,255,255,.75); font-size: 15px;
    margin: 0 0 20px; position: relative; line-height: 1.6;
  }
  .cta-box .btn-row {
    display: flex; gap: 12px; justify-content: center; align-items: center;
    flex-wrap: wrap; position: relative;
  }

  /* ---- Buttons (blog pages) ----
     Base `.btn` carries generous padding (12px 24px) so even unsized
     buttons (e.g. inside CTAs) look right. Sizes: .btn-sm / .btn-lg.
     Uses theme tokens (accent) so it matches the rest of the site. */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 12px 24px;
    border-radius: 12px; border: 1.5px solid transparent;
    font-weight: 600; font-size: 15px; line-height: 1;
    color: rgb(var(--text-primary-rgb));
    text-decoration: none !important; cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease,
                background-color .2s ease, border-color .2s ease, color .2s ease;
    will-change: transform;
  }
  .btn:active { transform: translateY(0) scale(0.98); }
  .btn:focus-visible { outline: 2px solid rgb(var(--accent-rgb)); outline-offset: 2px; }

  /* Primary — solid blue */
  .btn-primary {
    background: rgb(var(--accent-rgb));
    color: #fff; border-color: rgb(var(--accent-rgb));
    box-shadow: 0 4px 14px rgba(74,141,247,.25);
  }
  .btn-primary:hover {
    background: rgb(var(--accent-hover-rgb));
    border-color: rgb(var(--accent-hover-rgb));
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(74,141,247,.35);
  }

  /* Secondary — ghost / outline (blue border + blue text) */
  .btn-outline {
    background: transparent;
    color: rgb(var(--accent-rgb));
    border-color: rgb(var(--accent-rgb));
  }
  .btn-outline:hover {
    background: rgba(74,141,247,.08);
    color: rgb(var(--accent-hover-rgb));
    border-color: rgb(var(--accent-hover-rgb));
    transform: translateY(-2px);
  }

  /* Nav-button variants reused from the site chrome */
  .btn-wa { background: #25d366; color: #fff; box-shadow: 0 4px 14px rgba(37,211,102,.25); }
  .btn-wa:hover { background: #1fb859; color: #fff; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(37,211,102,.35); }
  .btn-ghost { background: transparent; color: rgb(var(--text-primary-rgb)); border-color: rgb(var(--surface-border-rgb)); }
  .btn-ghost:hover { border-color: rgb(var(--accent-rgb)); color: rgb(var(--accent-rgb)); transform: translateY(-2px); }

  /* Size variants */
  .btn-lg { padding: 16px 32px; font-size: 17px; }
  .btn-sm { padding: 8px 14px; font-size: 14px; }

  /* On the dark gradient CTA box, brighten the outline so labels stay readable */
  .cta-box .btn-outline {
    color: #aecbff;
    border-color: rgba(74,141,247,.75);
  }
  .cta-box .btn-outline:hover {
    color: #fff;
    border-color: #fff;
    background: rgba(74,141,247,.12);
  }

  @media (max-width: 480px) {
    .cta-box .btn-row .btn { width: 100%; }
    .cta-box { padding: 28px 18px; }
  }

  /* ---- FAQ accordion ---- */
  .prose-faq details {
    background: rgb(var(--surface-raised-rgb));
    border: 1px solid rgb(var(--surface-border-rgb));
    border-radius: 10px; margin-bottom: 8px; padding: 0;
  }
  .prose-faq summary {
    cursor: pointer; padding: 14px 18px;
    font-weight: 600; font-size: 16px; line-height: 1.4;
    list-style: none; display: flex; justify-content: space-between;
    align-items: center; gap: 12px;
    color: rgb(var(--text-primary-rgb));
  }
  .prose-faq summary::-webkit-details-marker { display: none; }
  .prose-faq summary::after {
    content: '▾'; font-size: 14px; color: rgb(var(--text-muted-rgb));
    transition: transform .15s ease; flex-shrink: 0;
  }
  .prose-faq details[open] summary::after { transform: rotate(180deg); color: rgb(var(--accent-rgb)); }
  .prose-faq summary:hover { color: rgb(var(--accent-rgb)); }
  .prose-faq details .faq-answer {
    padding: 0 18px 14px; font-size: 15px; line-height: 1.65;
    color: rgb(var(--text-secondary-rgb));
  }

  /* ---- Related articles grid ---- */
  .related-articles {
    display: grid; grid-template-columns: 1fr; gap: 16px;
    margin-top: 16px;
  }
  @media (min-width: 640px) { .related-articles { grid-template-columns: 1fr 1fr; } }
  .related-card {
    background: rgb(var(--surface-raised-rgb));
    border: 1px solid rgb(var(--surface-border-rgb));
    border-radius: 14px; padding: 22px 20px;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    text-decoration: none !important;
  }
  .related-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(74,141,247,.10);
    border-color: rgba(74,141,247,.35);
  }
  .related-card .pill {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: rgb(var(--accent-rgb));
    margin-bottom: 8px;
  }
  .related-card h4 {
    font-size: 17px; font-weight: 700; line-height: 1.25;
    margin: 0 0 8px; color: rgb(var(--text-primary-rgb));
    letter-spacing: -.01em;
  }
  .related-card p {
    font-size: 14px; color: rgb(var(--text-secondary-rgb));
    line-height: 1.55; margin: 0;
  }

  /* ---- Blog index hero ---- */
  .blog-index-hero {
    text-align: center; padding: 56px 0 40px;
  }
  .blog-index-hero h1 {
    font-size: clamp(28px, 5vw, 44px); font-weight: 800;
    line-height: 1.1; letter-spacing: -.025em; margin: 12px 0;
  }
  .blog-index-hero p {
    font-size: 17px; color: rgb(var(--text-secondary-rgb));
    max-width: 540px; margin: 0 auto; line-height: 1.6;
  }

  /* Blog index card grid */
  .blog-grid {
    display: grid; grid-template-columns: 1fr; gap: 20px;
    max-width: 1080px; margin: 0 auto;
  }
  @media (min-width: 640px) { .blog-grid { grid-template-columns: 1fr 1fr; } }
  .blog-card {
    background: rgb(var(--surface-raised-rgb));
    border: 1px solid rgb(var(--surface-border-rgb));
    border-radius: 16px; overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
  }
  .blog-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(74,141,247,.08); }
  .blog-card-body { padding: 22px 20px; }
  .blog-card .pill-sm {
    display: inline-block; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    color: rgb(var(--accent-rgb)); margin-bottom: 10px;
  }
  .blog-card h3 {
    font-size: 18px; font-weight: 800; line-height: 1.2;
    margin: 0 0 10px; letter-spacing: -.01em;
  }
  .blog-card h3 a { color: rgb(var(--text-primary-rgb)); text-decoration: none; }
  .blog-card h3 a:hover { color: rgb(var(--accent-rgb)); }
  .blog-card .desc {
    font-size: 14px; color: rgb(var(--text-secondary-rgb));
    line-height: 1.6; margin: 0 0 14px;
  }
  .blog-card .meta-row {
    font-size: 13px; color: rgb(var(--text-muted-rgb));
    display: flex; align-items: center; gap: 12px;
  }

  /* Pillar card stands out */
  .blog-card.pillar {
    grid-column: 1 / -1;
    border-color: rgba(74,141,247,.3);
    background: linear-gradient(180deg, rgba(74,141,247,.06) 0%, rgb(var(--surface-raised-rgb)) 100%);
  }
  .blog-card.pillar h3 { font-size: clamp(20px, 3vw, 26px); }

  /* ---- WA floating ---- */
  .wa-float {
    position: fixed; bottom: 24px; right: 24px; z-index: 60;
    width: 56px; height: 56px; border-radius: 999px;
    background: #25d366; color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 26px rgba(37,211,102,.40);
    transition: transform .15s ease;
    text-decoration: none !important;
  }
  .wa-float:hover { transform: scale(1.06); }

  /* Responsive padding */
  @media (max-width: 768px) {
    .article-hero { padding: 40px 0 28px; }
    .prose h2 { margin-top: 36px; }
    .cta-box { padding: 26px 18px; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
  }
}