/* C8 System — ชำนาญการพิเศษ */
/* Base styles สำหรับทุกหน้า */

:root {
  --c8-black: #000000;
  --c8-red: #dc2626;
  --c8-gray: #6b7280;
  --c8-bg: #f9fafb;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans Thai', sans-serif;
  background-color: var(--c8-bg);
  color: var(--c8-black);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar slim */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* Focus ring */
:focus-visible { outline: 2px solid var(--c8-black); outline-offset: 2px; }

/* Prose for post content */
.prose h1, .prose h2, .prose h3 { font-weight: 700; line-height: 1.3; margin: 1rem 0 .5rem; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose p  { margin-bottom: .875rem; line-height: 1.7; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: .875rem; }
.prose li { margin-bottom: .25rem; }
.prose blockquote { border-left: 3px solid #e5e7eb; padding-left: 1rem; color: #6b7280; font-style: italic; }
.prose code { background: #f3f4f6; padding: 0 4px; border-radius: 3px; font-size: .875rem; }
.prose pre  { background: #1f2937; color: #f9fafb; padding: 1rem; border-radius: .5rem; overflow-x: auto; }

/* Table responsive */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Loading spinner */
.c8-spinner {
  width: 20px; height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #000;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton loading */
.skeleton { background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: .25rem; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Print styles */
@media print {
  nav, footer, .no-print { display: none !important; }
  body { background: white; }
}

/* ============================================================
   Infographic Blocks — โทนสี: ดำ / แดงเข้ม / เทา / ขาว
   ============================================================ */

.ib-block {
  margin: 1.5rem 0;
}

.ib-block-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid #9B1C1C;
  display: inline-block;
}

/* ── Comparison Table ──────────────────────────────────────── */
.ib-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: .5rem;
  border: 1px solid #e5e7eb;
}

.ib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 480px;
}

.ib-table thead tr {
  background: #111827;
  color: #fff;
}

.ib-table th {
  padding: .65rem 1rem;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}

.ib-table td {
  padding: .6rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: top;
  line-height: 1.5;
}

.ib-table tbody tr:last-child td { border-bottom: none; }
.ib-table tbody tr:nth-child(even) td { background: #f9fafb; }
.ib-table tbody tr:hover td { background: #fef2f2; }

.ib-col-hl { color: #9B1C1C !important; font-weight: 600; }
.ib-table thead .ib-col-hl { background: #9B1C1C; color: #fff !important; }

/* Mobile: table → card stack */
@media (max-width: 639px) {
  .ib-table-wrap { border: none; }
  .ib-table,
  .ib-table thead,
  .ib-table tbody,
  .ib-table th,
  .ib-table td,
  .ib-table tr { display: block; min-width: 0; }
  .ib-table thead { display: none; }
  .ib-table tbody tr {
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    margin-bottom: .75rem;
    overflow: hidden;
    background: #fff;
  }
  .ib-table tbody tr:nth-child(even) td { background: #fff; }
  .ib-table td {
    display: flex;
    gap: .5rem;
    border-bottom: 1px solid #f3f4f6;
    padding: .5rem .75rem;
  }
  .ib-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #6b7280;
    min-width: 6rem;
    flex-shrink: 0;
    font-size: .75rem;
    padding-top: .1rem;
  }
  .ib-table td:last-child { border-bottom: none; }
}

/* ── Step Flow ─────────────────────────────────────────────── */
.ib-step-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ib-step-item {
  display: flex;
  gap: 1rem;
  position: relative;
  padding-bottom: 1.5rem;
}

.ib-step-item::before {
  content: '';
  position: absolute;
  left: 1.1rem;
  top: 2.4rem;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}

.ib-step-last { padding-bottom: 0; }
.ib-step-last::before { display: none; }

.ib-step-dot {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .875rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.ib-step-red    { background: #9B1C1C; color: #fff; }
.ib-step-black  { background: #111827; color: #fff; }
.ib-step-gray   { background: #6b7280; color: #fff; }
.ib-step-blue   { background: #1e40af; color: #fff; }
.ib-step-green  { background: #166534; color: #fff; }
.ib-step-yellow { background: #92400e; color: #fff; }

.ib-step-body { padding-top: .35rem; }

.ib-step-title {
  font-weight: 700;
  font-size: .9375rem;
  color: #111827;
  line-height: 1.4;
}

.ib-step-desc {
  font-size: .8125rem;
  color: #6b7280;
  margin-top: .2rem;
  line-height: 1.5;
}

/* ── Highlight Box ─────────────────────────────────────────── */
.ib-highlight {
  border-left: 4px solid;
  border-radius: 0 .5rem .5rem 0;
  padding: .875rem 1.125rem;
}

.ib-hl-title {
  font-weight: 700;
  font-size: .9375rem;
  margin-bottom: .4rem;
}

.ib-hl-body {
  font-size: .875rem;
  line-height: 1.65;
}

.ib-hl-warning { background: #fffbeb; border-color: #d97706; }
.ib-hl-warning .ib-hl-title { color: #92400e; }
.ib-hl-warning .ib-hl-body  { color: #78350f; }

.ib-hl-info    { background: #f0f9ff; border-color: #0369a1; }
.ib-hl-info .ib-hl-title    { color: #0c4a6e; }
.ib-hl-info .ib-hl-body     { color: #0c4a6e; }

.ib-hl-danger  { background: #fef2f2; border-color: #9B1C1C; }
.ib-hl-danger .ib-hl-title  { color: #9B1C1C; }
.ib-hl-danger .ib-hl-body   { color: #7f1d1d; }

.ib-hl-tip     { background: #f9fafb; border-color: #374151; }
.ib-hl-tip .ib-hl-title     { color: #111827; }
.ib-hl-tip .ib-hl-body      { color: #374151; }

/* ── Card Grid ─────────────────────────────────────────────── */
.ib-card-grid {
  display: grid;
  gap: 1rem;
}

.ib-card-cols-1 { grid-template-columns: 1fr; }
.ib-card-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ib-card-cols-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 639px) {
  .ib-card-cols-2,
  .ib-card-cols-3 { grid-template-columns: 1fr; }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .ib-card-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

.ib-card {
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: 1rem 1.125rem;
  background: #fff;
}

.ib-card-icon  { font-size: 1.5rem; margin-bottom: .4rem; }

.ib-card-title {
  font-weight: 700;
  font-size: .9375rem;
  color: #111827;
  margin-bottom: .35rem;
}

.ib-card-body {
  font-size: .8125rem;
  color: #6b7280;
  line-height: 1.6;
}

/* ── Rich Text + Image ─────────────────────────────────────── */
.ib-richtext { }

.ib-rt-img {
  width: 100%;
  height: auto;
  border-radius: .375rem;
  display: block;
  transition: opacity .2s;
}
.ib-rt-img:hover { opacity: .85; }

.ib-rt-img-wrap { margin-bottom: .875rem; }

.ib-rt-right,
.ib-rt-left {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

.ib-rt-right { grid-template-columns: 1fr 220px; }
.ib-rt-left  { grid-template-columns: 220px 1fr; }

.ib-rt-right .ib-rt-img-wrap { order: 2; }
.ib-rt-right .ib-rt-content  { order: 1; }
.ib-rt-left  .ib-rt-img-wrap { order: 1; }
.ib-rt-left  .ib-rt-content  { order: 2; }

@media (max-width: 639px) {
  .ib-rt-right,
  .ib-rt-left { grid-template-columns: 1fr; }
  .ib-rt-right .ib-rt-img-wrap,
  .ib-rt-left  .ib-rt-img-wrap { order: 1; }
  .ib-rt-right .ib-rt-content,
  .ib-rt-left  .ib-rt-content  { order: 2; }
}

/* ── Print overrides ───────────────────────────────────────── */
@media print {
  .ib-block         { page-break-inside: avoid; margin: 1rem 0; }
  .ib-table-wrap    { overflow: visible; border: 1px solid #000; }
  .ib-table         { min-width: 0; }
  .ib-table thead tr { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ib-table tbody tr:nth-child(even) td { background: #f3f4f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ib-table tbody tr:hover td { background: transparent !important; }
  .ib-highlight     { border-left: 3px solid #000 !important; background: #fff !important; }
  .ib-hl-title,
  .ib-hl-body       { color: #000 !important; }
  .ib-step-dot      { background: #000 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ib-step-item::before { background: #ccc !important; }
  .ib-card          { border: 1px solid #000 !important; break-inside: avoid; }

  /* Mobile card mode ไม่ใช้ตอน print */
  .ib-table thead   { display: table-header-group !important; }
  .ib-table tbody tr { display: table-row !important; }
  .ib-table td      { display: table-cell !important; }
  .ib-table td::before { display: none !important; }
}
