/* ==========================================================================
   RRCT Drone Blog — Shared Article Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-primary: #0052cc;
  --color-primary-dark: #003b99;
  --color-success: #10b981;
  --color-line: #06c755;
  --color-accent: #f59e0b;
  --color-dji: #e60012;
  --text-main: #0f172a;
  --text-muted: #475569;
  --bg-secondary: #f8fafc;
  --border-light: #e2e8f0;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(15,23,42,0.08);
  --font-family: 'Kanit', 'Inter', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font-family); color: var(--text-main); line-height: 1.75; background: #fff; -webkit-font-smoothing: antialiased; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ── HEADER ── */
.blog-header {
  background: rgba(255,255,255,0.97);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.blog-header .inner {
  max-width: 1100px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo-wrap { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: #0f172a; white-space: nowrap; }
.logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, #0052cc, #0072ff); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 0.9rem; }
.logo-sub { font-size: 0.68rem; color: var(--color-primary); font-weight: 500; display: block; }
.header-cta { display: flex; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; font-size: 0.88rem; font-weight: 600; border-radius: 10px; border: none; cursor: pointer; text-decoration: none; transition: all 0.2s ease; white-space: nowrap; }
.btn-line { background: var(--color-line); color: #fff; box-shadow: 0 3px 10px rgba(6,199,85,0.25); }
.btn-line:hover { background: #05b04b; transform: translateY(-2px); color: #fff; text-decoration: none; }
.btn-outline { background: #fff; border: 1.5px solid var(--color-primary); color: var(--color-primary); }
.btn-outline:hover { background: #eff6ff; text-decoration: none; }
.btn-home { background: #f1f5f9; color: #334155; border: 1px solid var(--border-light); }
.btn-home:hover { background: #e2e8f0; text-decoration: none; color: #0f172a; }

/* ── BREADCRUMB ── */
.breadcrumb {
  max-width: 800px; margin: 1.5rem auto 0; padding: 0 1.5rem;
  font-size: 0.85rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.breadcrumb a { color: var(--color-primary); }
.breadcrumb span { color: #94a3b8; }

/* ── ARTICLE LAYOUT ── */
.article-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ── ARTICLE HERO ── */
.article-hero { margin-bottom: 2rem; }
.article-category-tag {
  display: inline-block;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--color-primary);
  font-size: 0.8rem; font-weight: 700;
  padding: 4px 14px; border-radius: 50px;
  margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.article-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700; line-height: 1.3;
  color: var(--text-main);
  margin-bottom: 1rem;
}
.article-meta {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem;
}
.article-meta span { display: flex; align-items: center; gap: 4px; }
.article-hero-img {
  width: 100%; height: 380px; object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-bottom: 0.75rem;
}
.article-hero-caption { font-size: 0.82rem; color: #94a3b8; text-align: center; }

/* ── ARTICLE BODY ── */
.article-body h2 {
  font-size: 1.45rem; font-weight: 700;
  color: var(--text-main);
  margin: 2.5rem 0 1rem;
  padding-left: 14px;
  border-left: 4px solid var(--color-primary);
}
.article-body h3 {
  font-size: 1.15rem; font-weight: 600;
  color: var(--text-main);
  margin: 2rem 0 0.75rem;
}
.article-body p { margin-bottom: 1.25rem; color: #334155; font-size: 1rem; }
.article-body ul, .article-body ol { margin: 0 0 1.25rem 1.5rem; color: #334155; }
.article-body li { margin-bottom: 0.5rem; }
.article-body strong { color: var(--text-main); }

/* Inline images */
.article-body .article-img {
  width: 100%; border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  margin: 1.5rem 0 0.5rem; box-shadow: var(--shadow-sm);
}
.article-body .img-caption { font-size: 0.82rem; color: #94a3b8; text-align: center; margin-bottom: 1.5rem; }

/* Step blocks */
.step-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.step-block .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}
.step-block .step-row { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 1rem; }
.step-block .step-row:last-child { margin-bottom: 0; }
.step-block .step-content h4 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.step-block .step-content p { font-size: 0.92rem; color: var(--text-muted); margin: 0; }

/* Warning / info boxes */
.info-box {
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
  display: flex; gap: 14px; align-items: flex-start;
}
.info-box.warning { background: #fff7ed; border: 1px solid #fed7aa; }
.info-box.info    { background: #eff6ff; border: 1px solid #bfdbfe; }
.info-box.success { background: #f0fdf4; border: 1px solid #bbf7d0; }
.info-box.danger  { background: #fff1f2; border: 1px solid #fecdd3; }
.info-box .icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; }
.info-box p { margin: 0; font-size: 0.93rem; line-height: 1.6; }
.info-box strong { display: block; margin-bottom: 4px; font-size: 0.95rem; }

/* Comparison table */
.compare-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-light); font-size: 0.93rem; }
.compare-table th { background: var(--color-primary); color: #fff; padding: 12px 14px; text-align: left; }
.compare-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-light); }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:nth-child(even) td { background: var(--bg-secondary); }

/* CTA BLOCK (soft sell) */
.cta-block {
  background: linear-gradient(135deg, #eff6ff 0%, #e0edff 100%);
  border: 2px solid #bfdbfe;
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  margin: 2.5rem 0;
  text-align: center;
}
.cta-block .cta-badge {
  display: inline-block;
  background: var(--color-primary); color: #fff;
  font-size: 0.78rem; font-weight: 700; padding: 4px 14px;
  border-radius: 50px; text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.cta-block h3 { font-size: 1.25rem; margin-bottom: 0.6rem; color: var(--text-main); }
.cta-block p { font-size: 0.93rem; color: var(--text-muted); margin-bottom: 1.25rem; max-width: 500px; margin-left: auto; margin-right: auto; }
.cta-block .btn-group { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Related articles */
.related-section { border-top: 2px solid var(--border-light); padding-top: 2.5rem; margin-top: 3rem; }
.related-section h3 { font-size: 1.2rem; margin-bottom: 1.25rem; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.related-card { background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 1.25rem; transition: all 0.2s ease; }
.related-card:hover { border-color: var(--color-primary); transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration: none; }
.related-card .rc-tag { font-size: 0.75rem; font-weight: 700; color: var(--color-primary); text-transform: uppercase; margin-bottom: 6px; }
.related-card h4 { font-size: 0.95rem; color: var(--text-main); line-height: 1.4; }

/* Footer */
.blog-footer {
  background: #0f172a; color: #94a3b8;
  padding: 2rem 1.5rem; text-align: center; font-size: 0.88rem;
}
.blog-footer a { color: #cbd5e1; }
.blog-footer a:hover { color: #fff; }

/* Table Responsive Scroll Fix for Mobile */
.compare-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

/* Responsive Rules for All Mobile Screens (< 640px) */
@media (max-width: 640px) {
  .blog-header {
    padding: 10px 0;
  }
  .blog-header .inner {
    padding: 0 0.8rem;
    gap: 0.4rem;
  }
  .logo-wrap {
    font-size: 0.88rem;
    gap: 6px;
  }
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    border-radius: 6px;
  }
  .logo-sub {
    display: none; /* ซ่อนข้อความย่อยบนมือถือเพื่อเพิ่มพื้นที่ */
  }
  .header-cta {
    gap: 6px;
  }
  .header-cta .btn-home {
    display: none;
  }
  .btn-line {
    padding: 7px 10px;
    font-size: 0.78rem;
    border-radius: 8px;
  }
  .article-wrap {
    padding: 1.25rem 0.85rem 3.5rem;
  }
  .article-hero h1 {
    font-size: 1.45rem;
    line-height: 1.35;
  }
  .article-hero-img {
    height: 200px;
    border-radius: 14px;
  }
  .article-body h2 {
    font-size: 1.2rem;
    margin: 1.75rem 0 0.75rem;
    padding-left: 10px;
  }
  .article-body h3 {
    font-size: 1.05rem;
    margin: 1.5rem 0 0.5rem;
  }
  .article-body p, .article-body li {
    font-size: 0.93rem;
    line-height: 1.65;
  }
  .article-body ul, .article-body ol {
    margin-left: 1.1rem;
  }
  .step-block, .info-box, .cta-block {
    padding: 1.1rem 0.85rem;
    border-radius: 12px;
    margin: 1.25rem 0;
  }
  .info-box {
    gap: 10px;
  }
  .info-box .icon {
    font-size: 1.2rem;
  }
  .cta-block .btn-group {
    flex-direction: column;
    width: 100%;
  }
  .cta-block .btn-group .btn {
    width: 100%;
    text-align: center;
  }
  .compare-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .compare-table th, .compare-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

/* ==========================================================================
   CORE WEB VITALS OPTIMIZATIONS
   — Prevents CLS (Cumulative Layout Shift)
   — Improves LCP (Largest Contentful Paint)
   ========================================================================== */

/* ── CLS Fix: Reserve space for images BEFORE they load ── */
.article-hero-img,
.article-card-img {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  background-color: #f1f5f9; /* Skeleton placeholder */
}

/* ── CLS Fix: Reserve space for logo icon ── */
.logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  contain: strict;
}

/* ── Performance: Off-screen content rendering optimization ── */
.article-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 350px;
}

/* ── CLS Fix: Language switcher buttons prevent layout jump ── */
.lang-btn-group,
.lang-selector-wrap {
  min-height: 36px;
  min-width: 80px;
}

/* ── Performance: Smooth image loading with fade-in ── */
img {
  color: transparent; /* Hide alt text during load for visual cleanliness */
}
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
}
img[loading="lazy"].loaded,
img:not([loading]) {
  opacity: 1;
}

/* ── CLS Fix: Step blocks have consistent height ── */
.step-block {
  contain: layout style;
}

/* ── Performance: Will-change for animated elements only ── */
.btn:hover {
  will-change: transform;
}

/* ── Print styles for SEO / accessibility ── */
@media print {
  .blog-header,
  .blog-footer,
  .cta-block,
  .lang-btn-group,
  .lang-selector-wrap {
    display: none !important;
  }
  body { font-size: 12pt; color: #000; }
  a { color: #000; text-decoration: underline; }
  .article-body { max-width: 100%; padding: 0; }
}
