/* ═══════════════════════════════════════════════════════════════
   SiamCafe Blog — Dark Luxury Tech Theme (FIXED CONTRAST)
   Version: 2.0 | 2026-03-04
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --text-primary: #e8e6e3;
  --text-secondary: #8892a0;
  --text-muted: #555d6e;
  --accent-gold: #d4a853;
  --accent-cyan: #00d4ff;
  --accent-green: #00c48f;
  --border: rgba(255, 255, 255, 0.06);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 780px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: 'Sarabun', 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif !important;
  font-weight: 400;
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  line-height: 1.8 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── OVERRIDE INLINE STYLES (CRITICAL) ──────────────────────── */
body, body p, body li, body td, body th, body span, body div,
body details, body summary, body blockquote, body figcaption,
body dt, body dd, body label {
  color: #e8e6e3 !important;
}

body[style], p[style], div[style], span[style],
td[style], th[style], li[style], section[style],
article[style], main[style], header[style] {
  color: #e8e6e3 !important;
}

/* ── Reading Progress Bar ───────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-cyan));
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ── Top Navigation ─────────────────────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 10, 15, 0.95) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  max-width: 100%;
}

.top-nav a {
  color: var(--text-secondary) !important;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

.top-nav a:first-child {
  color: var(--accent-gold) !important;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.top-nav a:hover {
  color: var(--accent-cyan) !important;
}

/* ── Main Container ─────────────────────────────────────────── */
.container,
.article-container,
article {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: #ffffff !important;
  font-family: 'Inter', 'Sarabun', system-ui, sans-serif;
  font-weight: 700;
  margin: 2rem 0 1rem;
  line-height: 1.3;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #d4a853 0%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.6rem;
  border-left: 3px solid var(--accent-cyan);
  padding-left: 1rem;
  margin-top: 3rem;
}

h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent-gold) !important;
}

h4 { font-size: 1.1rem; }

p {
  color: #e8e6e3 !important;
  margin-bottom: 1.5em;
  font-size: 1.05rem;
  line-height: 1.8;
}

strong, b {
  color: #ffffff !important;
  font-weight: 600;
}

em, i {
  color: #e8e6e3 !important;
}

/* ── Links ──────────────────────────────────────────────────── */
a {
  color: #00d4ff !important;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

a:hover {
  color: #d4a853 !important;
  text-decoration: underline;
}

a:visited {
  color: #00b8d9 !important;
}

/* ── Cover Hero ─────────────────────────────────────────────── */
.cover-hero {
  width: 100%;
  max-width: var(--max-width);
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  margin: 1.5rem auto;
  display: block;
}

/* ── Post Meta ──────────────────────────────────────────────── */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  color: var(--text-secondary) !important;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-meta span {
  color: var(--text-secondary) !important;
}

.category-badge {
  background: rgba(0, 212, 255, 0.15);
  color: #00d4ff !important;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.category-badge:hover {
  background: rgba(0, 212, 255, 0.25);
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb, nav.breadcrumb {
  color: #555d6e !important;
  font-size: 0.85rem;
  margin: 1rem auto;
  max-width: var(--max-width);
  padding: 0 24px;
}

.breadcrumb a {
  color: #8892a0 !important;
  font-weight: 400;
}

.breadcrumb a:hover {
  color: #00d4ff !important;
}

/* ── TOC (สารบัญ) ───────────────────────────────────────────── */
.toc {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
}

.toc h3, .toc strong {
  color: var(--accent-gold) !important;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  display: block;
}

.toc ol, .toc ul {
  padding-left: 1.5rem;
  margin: 0;
}

.toc li {
  margin: 0.5rem 0;
  color: #e8e6e3 !important;
}

.toc a {
  color: var(--accent-cyan) !important;
  font-weight: 400;
  font-size: 0.95rem;
}

.toc a:hover {
  color: var(--accent-gold) !important;
}

/* ── Code Blocks ────────────────────────────────────────────── */
pre {
  background: #0d1117 !important;
  border: 1px solid rgba(0, 212, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 1.5rem !important;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
  transition: border-color 0.2s;
}

pre:hover {
  border-color: rgba(0, 212, 255, 0.3);
}

pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
  font-size: 0.9rem !important;
  line-height: 1.6 !important;
  color: #e8e6e3 !important;
  background: transparent !important;
  padding: 0;
  border-radius: 0;
  text-shadow: none;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
  background: rgba(0, 212, 255, 0.08) !important;
  color: #00d4ff !important;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Copy button */
.copy-btn, pre .copy-button, button.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  color: #8892a0 !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover, pre .copy-button:hover, button.copy-btn:hover {
  background: rgba(0, 212, 255, 0.2);
  color: #00d4ff !important;
}

/* ── Tables ─────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

th {
  background: var(--bg-tertiary) !important;
  color: #d4a853 !important;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid rgba(212, 168, 83, 0.3);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: #e8e6e3 !important;
}

tr:nth-child(even) {
  background: rgba(18, 18, 26, 0.5) !important;
}

tr:hover {
  background: rgba(26, 26, 46, 0.5) !important;
}

/* ── FAQ Section (CRITICAL — ต้องอ่านออก!) ───────────────────── */
details, .faq-item, .faq-section details {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  padding: 0;
  overflow: hidden;
}

summary {
  color: #00d4ff !important;
  font-weight: 600;
  font-size: 1.1rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  list-style: none;
  transition: background 0.2s;
}

summary:hover {
  background: rgba(0, 212, 255, 0.05) !important;
}

summary::marker,
summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '+';
  float: right;
  color: var(--accent-gold);
  font-weight: 300;
  transition: transform var(--transition);
}

details[open] summary::after {
  content: '−';
}

details p, details div, details span,
.faq-item p, .faq-section p,
details > *:not(summary) {
  color: #e8e6e3 !important;
  padding: 0 1.5rem 1rem;
  font-size: 1rem;
  line-height: 1.8;
}

.faq-section details > div,
.faq-section details > p {
  padding: 0 1.25rem 1rem;
  color: #e8e6e3 !important;
  line-height: 1.7;
}

/* ── Article Illustration ───────────────────────────────────── */
.article-illustration {
  width: 100%;
  border-radius: var(--radius-md);
  margin: 2rem 0;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}

.article-illustration:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

/* ── Blockquote ─────────────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--accent-gold);
  background: rgba(212, 168, 83, 0.05) !important;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #e8e6e3 !important;
  font-style: italic;
}

blockquote p, blockquote span {
  color: #e8e6e3 !important;
}

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

/* ── Lists ──────────────────────────────────────────────────── */
ul, ol {
  padding-left: 2rem;
  margin: 1rem 0;
}

li {
  margin: 0.5rem 0;
  color: #e8e6e3 !important;
  line-height: 1.8;
}

li::marker {
  color: var(--accent-gold);
}

/* ── Related Links ──────────────────────────────────────────── */
.related-links {
  background: var(--bg-secondary) !important;
  border-radius: var(--radius-md);
  padding: 1.5rem 2rem;
  margin: 2.5rem 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
}

.related-links h3,
.related-links strong {
  color: var(--accent-gold) !important;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.related-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-links li {
  margin-bottom: 0.5rem;
}

.related-links a {
  color: var(--accent-cyan) !important;
  font-size: 0.9rem;
}

/* ── Back to Top ────────────────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(212, 168, 83, 0.9) !important;
  border: none !important;
  color: #0a0a0f !important;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  z-index: 90;
  box-shadow: 0 6px 20px rgba(212, 168, 83, 0.3);
  aspect-ratio: 1;
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

#back-to-top:hover {
  background: var(--accent-cyan);
  color: #0a0a0f !important;
  transform: translateY(-2px);
}

/* ── Footer ─────────────────────────────────────────────────── */
footer,
.site-footer,
footer[style],
.site-footer[style] {
  background: #12121a !important;
  background-color: #12121a !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding: 2rem 1.5rem !important;
  text-align: center !important;
  color: #8892a0 !important;
  font-size: 0.85rem !important;
  margin-top: 3rem !important;
  max-width: 100% !important;
}

footer *,
.site-footer * {
  background-color: transparent !important;
}

footer a,
.site-footer a,
footer a[style],
.site-footer a[style] {
  color: #00d4ff !important;
  margin: 0 0.5rem;
}

footer a:hover,
.site-footer a:hover {
  color: #d4a853 !important;
}

footer p,
.site-footer p,
footer small,
.site-footer small,
footer .copyright,
.site-footer .copyright {
  color: #555d6e !important;
  font-size: 0.85rem !important;
}

footer span,
.site-footer span {
  color: #8892a0 !important;
}

/* ── Images ─────────────────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

img:hover {
  box-shadow: 0 8px 32px rgba(0, 212, 255, 0.1);
}

figure {
  margin: 2rem 0;
  text-align: center;
}

figcaption {
  color: var(--text-muted) !important;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ── Horizontal Rule ────────────────────────────────────────── */
hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2.5rem 0;
}

/* ── Selection ──────────────────────────────────────────────── */
::selection {
  background: rgba(0, 212, 255, 0.3);
  color: #ffffff;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  .container,
  .article-container,
  article {
    padding: 1.25rem 1rem;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  .top-nav {
    padding: 0.6rem 1rem;
  }

  .post-meta {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  pre {
    padding: 1rem !important;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
  }

  .toc {
    padding: 1rem 1.25rem;
  }

  .cover-hero {
    border-radius: var(--radius-md);
  }

  #back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }

  table { font-size: 0.85rem; }
  th, td { padding: 8px 10px; }
}

@media (min-width: 1200px) {
  body.has-sidebar {
    display: grid;
    grid-template-columns: 1fr var(--max-width) 260px 1fr;
  }

  body.has-sidebar .top-nav {
    grid-column: 1 / -1;
  }

  body.has-sidebar article {
    grid-column: 2;
  }

  body.has-sidebar .toc-sidebar {
    grid-column: 3;
    position: sticky;
    top: 80px;
    height: fit-content;
    padding: 1.5rem;
    margin-top: 2rem;
  }
}

/* ── Prism.js Override ──────────────────────────────────────── */
pre[class*="language-"] {
  background: #0d1117 !important;
  border: 1px solid rgba(0, 212, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 1.5rem !important;
  margin: 1.5rem 0;
}

code[class*="language-"] {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
  font-size: 0.9rem;
  text-shadow: none;
  color: #e8e6e3 !important;
}

/* ── Utility Classes ────────────────────────────────────────── */
.text-gold { color: var(--accent-gold) !important; }
.text-cyan { color: var(--accent-cyan) !important; }
.text-green { color: var(--accent-green) !important; }
.text-muted { color: var(--text-muted) !important; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.text-center { text-align: center; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeInUp 0.6s ease-out both;
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  body { background: white !important; color: black !important; }
  a { color: black !important; }
  nav, footer, #back-to-top, #reading-progress, .back-to-top { display: none !important; }
}
