/*
Theme Name: AV Sub Thai
Theme URI: https://avsubthai.com
Author: AV Sub Thai Team
Description: Custom WordPress theme สำหรับเว็บข่าวและเทรนด์ AV Sub Thai — Mobile-first, SEO-optimized
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: avsubthai
Tags: news, blog, custom-header, custom-logo, responsive-layout, translation-ready
*/

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
  --color-primary:    #e63946;
  --color-secondary:  #1d3557;
  --color-accent:     #f4a261;
  --color-bg:         #0d0d0d;
  --color-surface:    #1a1a1a;
  --color-surface2:   #242424;
  --color-border:     #2e2e2e;
  --color-text:       #f0f0f0;
  --color-muted:      #888;
  --color-badge:      #e63946;

  --font-sans:        'Noto Sans Thai', 'Sarabun', sans-serif;
  --font-size-base:   16px;
  --line-height:      1.7;

  --radius:           8px;
  --radius-sm:        4px;
  --gap:              1.5rem;
  --container:        1200px;

  --transition:       0.2s ease;
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent); }

img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* =====================================================
   LAYOUT
   ===================================================== */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1rem;
}

.site-wrap { display: flex; flex-direction: column; min-height: 100vh; }
.site-main  { flex: 1; padding: 2rem 0; }

/* =====================================================
   HEADER
   ===================================================== */
.site-header {
  background: var(--color-secondary);
  border-bottom: 3px solid var(--color-primary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  max-width: var(--container);
  margin: 0 auto;
}

.site-logo a {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.site-logo span { color: var(--color-primary); }

/* NAV */
.main-nav ul { display: flex; gap: 1.5rem; }
.main-nav a {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.main-nav a:hover,
.main-nav .current-menu-item a { color: #fff; border-color: var(--color-primary); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
}
.nav-toggle span {
  display: block; width: 24px; height: 2px;
  background: #fff; margin: 5px 0; transition: var(--transition);
}

/* =====================================================
   BREADCRUMB
   ===================================================== */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--color-muted);
  padding: 0.6rem 0 1.2rem;
}
.breadcrumb a { color: var(--color-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb span { margin: 0 0.35rem; }

/* =====================================================
   HERO / INTRO
   ===================================================== */
.hero-section {
  background: linear-gradient(135deg, var(--color-secondary) 0%, #0d1b2a 100%);
  padding: 3rem 1rem;
  text-align: center;
  border-bottom: 3px solid var(--color-primary);
}

.hero-section h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  color: #fff;
  margin-bottom: 1rem;
  line-height: 1.2;
}
.hero-section h1 em { color: var(--color-primary); font-style: normal; }

.hero-section .hero-desc {
  max-width: 680px;
  margin: 0 auto 1.5rem;
  color: rgba(255,255,255,0.75);
  font-size: 1.05rem;
}

.hero-badge {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.8rem;
  border-radius: 50px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* =====================================================
   SECTION HEADER
   ===================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-border);
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-header h2::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.2em;
  background: var(--color-primary);
  border-radius: 2px;
}

.see-all {
  font-size: 0.85rem;
  color: var(--color-primary);
  font-weight: 600;
  white-space: nowrap;
}
.see-all:hover { color: var(--color-accent); }

/* =====================================================
   HOME SECTION
   ===================================================== */
.home-section { padding: 2.5rem 0; }
.home-section + .home-section { border-top: 1px solid var(--color-border); }

/* =====================================================
   POST CARD GRID
   ===================================================== */
.post-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

.post-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.card-thumb {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--color-surface2);
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.post-card:hover .card-thumb img { transform: scale(1.05); }

.card-thumb .no-thumb {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-muted);
  font-size: 2rem;
}

.card-badge {
  position: absolute;
  top: 0.5rem; left: 0.5rem;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.card-cat {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
  letter-spacing: 0.05em;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.4;
  flex: 1;
}
.card-title a { color: inherit; }
.card-title a:hover { color: var(--color-primary); }

.card-excerpt {
  font-size: 0.85rem;
  color: var(--color-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.card-meta .update-date { color: var(--color-accent); font-weight: 600; }

/* =====================================================
   CATEGORY PAGE
   ===================================================== */
.category-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 2rem;
}
.category-header h1 {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
}
.category-header .cat-desc {
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}
.category-header .cat-desc p { margin-bottom: 1rem; }
.category-header .cat-desc h2,
.category-header .cat-desc h3 {
  color: var(--color-text);
  font-weight: 800;
  margin: 1.25rem 0 0.5rem;
}
.category-header .cat-desc h2 { font-size: 1.3rem; }
.category-header .cat-desc h3 { font-size: 1.1rem; }
.category-header .cat-desc strong { color: var(--color-text); }
.category-header .cat-desc a {
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-primary);
}
.category-header .cat-desc a:hover { color: var(--color-accent); border-color: var(--color-accent); }

.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
  margin-bottom: 3rem;
}

/* =====================================================
   SINGLE POST
   ===================================================== */
.single-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

.post-article { min-width: 0; }

.post-header { margin-bottom: 1.5rem; }

.post-cat-label {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.post-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.post-meta .modified { color: var(--color-accent); font-weight: 600; }

.post-featured-img {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  aspect-ratio: 16/9;
}
.post-featured-img img { width: 100%; height: 100%; object-fit: cover; }

/* POST CONTENT */
.post-content {
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(240,240,240,0.9);
}
.post-content h2 { font-size: 1.4rem; font-weight: 800; margin: 2rem 0 0.75rem; color: #fff; }
.post-content h3 { font-size: 1.15rem; font-weight: 700; margin: 1.5rem 0 0.5rem; color: #fff; }
.post-content p { margin-bottom: 1.2rem; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin-bottom: 1.2rem; }
.post-content li { margin-bottom: 0.4rem; }
.post-content a { border-bottom: 1px solid var(--color-primary); }
.post-content blockquote {
  border-left: 4px solid var(--color-primary);
  padding: 0.75rem 1.25rem;
  background: var(--color-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--color-muted);
}

/* EDITORIAL LINK BOX */
.editorial-link-box {
  background: var(--color-surface2);
  border: 1px solid var(--color-primary);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 2rem 0;
}
.editorial-link-box .elb-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.editorial-link-box ul { padding-left: 1rem; }
.editorial-link-box ul li { margin-bottom: 0.35rem; }
.editorial-link-box a { color: var(--color-text); border-bottom: 1px dashed var(--color-primary); }
.editorial-link-box a:hover { color: var(--color-primary); }

/* RELATED POSTS */
.related-posts { margin-top: 3rem; padding-top: 2rem; border-top: 2px solid var(--color-border); }
.related-posts h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 1.25rem; }

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

/* SIDEBAR */
.post-sidebar { position: sticky; top: 80px; }

.sidebar-widget {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.sidebar-widget h4 {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-primary);
}

.sidebar-posts li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}
.sidebar-posts li:last-child { border-bottom: none; }
.sidebar-posts a { color: var(--color-text); line-height: 1.4; }
.sidebar-posts a:hover { color: var(--color-primary); }
.sidebar-posts .s-date { display: block; font-size: 0.7rem; color: var(--color-muted); margin-top: 0.2rem; }

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}
.pagination a:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
  background: var(--color-secondary);
  border-top: 3px solid var(--color-primary);
  padding: 2.5rem 0 1rem;
  margin-top: 4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-col h5 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.footer-col ul li { margin-bottom: 0.4rem; }
.footer-col a { color: rgba(255,255,255,0.7); font-size: 0.875rem; }
.footer-col a:hover { color: #fff; }

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

/* =====================================================
   NO POSTS MESSAGE
   ===================================================== */
.no-posts {
  text-align: center;
  padding: 3rem;
  color: var(--color-muted);
  font-size: 1rem;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .single-layout { grid-template-columns: 1fr; }
  .post-sidebar { position: static; }
}

@media (max-width: 700px) {
  .main-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--color-secondary); padding: 1rem; }
  .main-nav.is-open { display: block; }
  .main-nav ul { flex-direction: column; gap: 0.75rem; }
  .nav-toggle { display: block; }
  .post-cards { grid-template-columns: 1fr 1fr; }
  .hero-section { padding: 2rem 1rem; }
}

@media (max-width: 480px) {
  .post-cards { grid-template-columns: 1fr; }
  .archive-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
}
