/*!
Theme Name: thesharingkh
Theme URI: https://www.thesharingkh.com/
Author: TheSharing.KH
Description: Knowledge, Motivation, News & Technology platform for Cambodia
Version: 1.0.0
Requires at least: 5.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: thesharingkh
Tags: custom-menu, featured-images, threaded-comments, translation-ready
*/

/* ============================================
   TheSharing.KH — Main Stylesheet
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a56db;
  --primary-dark: #1a3c8f;
  --accent: #f59e0b;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
  --font: 'Inter', system-ui, sans-serif;
  --header-h: 68px;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.7; font-size: 16px; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 4.5rem 0; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.75rem; border-radius: 8px; font-weight: 600;
  font-size: .95rem; cursor: pointer; border: 2px solid transparent; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,86,219,.35); }
.btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.btn-outline:hover { background: rgba(255,255,255,.15); }

/* ===== HEADER ===== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.header-inner { display: flex; align-items: center; gap: 2rem; height: var(--header-h); }

.logo {
  font-size: 1.35rem; font-weight: 800; color: var(--primary);
  display: flex; align-items: center; gap: .35rem; flex-shrink: 0;
}
.logo--white { color: #fff; }
.logo-icon { color: var(--accent); font-size: 1.1rem; }
.logo-kh { color: var(--accent); }

/* WordPress nav menu output */
.nav-menu { display: flex; gap: .25rem; margin-left: auto; list-style: none; }
.nav-menu a,
.nav-link {
  padding: .5rem .85rem; border-radius: 6px; font-size: .9rem;
  font-weight: 500; color: var(--text-light); transition: all .2s; display: block;
}
.nav-menu a:hover, .nav-menu .current-menu-item > a,
.nav-link:hover, .nav-link.active { color: var(--primary); background: #eff6ff; }

.header-actions { display: flex; align-items: center; gap: .5rem; }
.search-btn {
  background: none; border: none; cursor: pointer; padding: .5rem;
  border-radius: 8px; color: var(--text-light); transition: all .2s;
}
.search-btn:hover { background: var(--bg-alt); color: var(--primary); }
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: .5rem; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: all .3s; }

.search-bar { display: none; border-top: 1px solid var(--border); padding: 1rem 0; background: var(--bg-alt); }
.search-bar.open { display: block; }
.search-bar .container { display: flex; gap: .75rem; }
.search-input {
  flex: 1; padding: .65rem 1rem; border: 2px solid var(--border);
  border-radius: 8px; font-size: .95rem; outline: none; transition: border .2s;
}
.search-input:focus { border-color: var(--primary); }
.search-submit {
  padding: .65rem 1.25rem; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-weight: 600;
}

/* ===== HERO ===== */
.hero {
  position: relative; min-height: 560px; display: flex; align-items: center;
  overflow: hidden; background: linear-gradient(135deg,#0f172a 0%,#1e3a8a 60%,#1a56db 100%); color: #fff;
}
.hero-bg {
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-content { position: relative; z-index: 1; padding: 5rem 1.25rem; width: 100%; }
.hero-badge {
  display: inline-block; background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25); border-radius: 50px;
  padding: .35rem 1rem; font-size: .85rem; font-weight: 500; margin-bottom: 1.25rem;
}
.hero-title { font-size: clamp(2rem,5vw,3.5rem); font-weight: 800; line-height: 1.15; margin-bottom: 1.25rem; }
.hero-sub { font-size: 1.1rem; color: rgba(255,255,255,.8); max-width: 560px; margin-bottom: 2rem; }
.hero-btns { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2.5rem; }
.hero-stats { display: flex; align-items: center; gap: 1.5rem; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 1.5rem; font-weight: 800; }
.stat span { font-size: .8rem; opacity: .7; }
.stat-divider { width: 1px; height: 36px; background: rgba(255,255,255,.25); }

/* ===== AD ZONES ===== */
.ad-zone { text-align: center; padding: 1rem 0; }
.ad-zone--horizontal { margin: 1rem auto; }
.ad-zone--rectangle { margin: 2rem auto; }
.ad-zone--sidebar { margin-bottom: 1.5rem; }
.ad-label { display: block; font-size: .7rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; margin-bottom: .5rem; }
.ad-placeholder {
  background: var(--bg-alt); border: 2px dashed var(--border);
  border-radius: 8px; padding: 1.5rem; color: var(--text-light);
  font-size: .85rem; display: flex; align-items: center; justify-content: center; min-height: 90px;
}
.ad-zone--rectangle .ad-placeholder { min-height: 280px; max-width: 336px; margin: 0 auto; }
.ad-zone--sidebar .ad-placeholder { min-height: 250px; }

/* ===== SECTION HEADERS ===== */
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.section-title { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.section-sub { color: var(--text-light); margin-top: .35rem; }
.view-all { color: var(--primary); font-weight: 600; font-size: .9rem; }
.view-all:hover { text-decoration: underline; }

/* ===== CATEGORIES ===== */
.categories-section { background: var(--bg-alt); }
.categories-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 1.25rem; }
.category-card {
  background: #fff; border-radius: var(--radius); padding: 2rem 1.75rem;
  border: 1px solid var(--border); transition: all .25s; display: block; position: relative; overflow: hidden;
}
.category-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: var(--radius) var(--radius) 0 0; }
.cat-knowledge::before { background: linear-gradient(90deg,#667eea,#764ba2); }
.cat-motivation::before { background: linear-gradient(90deg,#f093fb,#f5576c); }
.cat-news::before { background: linear-gradient(90deg,#43e97b,#38f9d7); }
.cat-technology::before, .cat-tech::before { background: linear-gradient(90deg,#4facfe,#00f2fe); }
.category-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.cat-icon { font-size: 2.25rem; margin-bottom: .75rem; }
.category-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; }
.category-card p { color: var(--text-light); font-size: .9rem; margin-bottom: 1rem; }
.cat-count { font-size: .8rem; color: var(--primary); font-weight: 600; }

/* ===== ARTICLE CARDS ===== */
.articles-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap: 1.5rem; }
.article-card--featured { grid-column: span 2; }
.article-card { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); transition: all .25s; display: flex; flex-direction: column; }
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.article-img { height: 180px; position: relative; display: flex; align-items: flex-end; padding: 1rem; }
.article-card--featured .article-img { height: 240px; }
.article-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .6; }

.article-category-tag {
  font-size: .72rem; font-weight: 700; padding: .3rem .75rem;
  border-radius: 50px; text-transform: uppercase; letter-spacing: .5px; position: relative; z-index: 1;
}
.tag-knowledge { background: #ede9fe; color: #6d28d9; }
.tag-motivation { background: #fce7f3; color: #be185d; }
.tag-news { background: #d1fae5; color: #065f46; }
.tag-tech { background: #dbeafe; color: #1d4ed8; }

.article-body { padding: 1.5rem; flex: 1; display: flex; flex-direction: column; }
.article-meta { font-size: .8rem; color: var(--text-light); margin-bottom: .75rem; }
.article-title { font-size: 1rem; font-weight: 700; line-height: 1.45; margin-bottom: .75rem; }
.article-card--featured .article-title { font-size: 1.25rem; }
.article-title a:hover { color: var(--primary); }
.article-excerpt { color: var(--text-light); font-size: .9rem; flex: 1; margin-bottom: 1rem; }
.article-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.author { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--text-light); }
.author-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  object-fit: cover;
}
.read-more { font-size: .85rem; font-weight: 600; color: var(--primary); }
.read-more:hover { text-decoration: underline; }

/* ===== TWO COLUMN LAYOUT ===== */
.two-col-layout { display: grid; grid-template-columns: 1fr 340px; gap: 3rem; align-items: start; }
.col-sidebar { position: sticky; top: calc(var(--header-h) + 1rem); }

/* ===== TRENDING ===== */
.trending-list { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 1.5rem; }
.trending-item { display: flex; gap: 1.25rem; align-items: flex-start; padding: 1.25rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); transition: box-shadow .2s; }
.trending-item:hover { box-shadow: var(--shadow); }
.trending-num { font-size: 2rem; font-weight: 800; color: var(--border); line-height: 1; flex-shrink: 0; width: 44px; }
.trending-body { flex: 1; }
.trending-body h4 { font-size: .95rem; font-weight: 600; line-height: 1.45; margin: .4rem 0 .35rem; }
.trending-body h4 a:hover { color: var(--primary); }
.trending-meta { font-size: .78rem; color: var(--text-light); }

/* ===== SIDEBAR ===== */
.sidebar-widget { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.widget-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }
.tags-cloud { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag {
  padding: .35rem .85rem; background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 50px; font-size: .8rem; font-weight: 500; color: var(--text-light); transition: all .2s;
}
.tag:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.social-links { display: flex; flex-direction: column; gap: .6rem; }
.social-link {
  display: block; padding: .6rem 1rem; border-radius: 8px;
  font-weight: 600; font-size: .9rem; text-align: center; transition: filter .2s;
}
.social-link:hover { filter: brightness(1.1); }
.social-fb { background: #1877f2; color: #fff; }
.social-tg { background: #0088cc; color: #fff; }
.social-yt { background: #ff0000; color: #fff; }
.social-tt { background: #000; color: #fff; }

/* ===== NEWSLETTER ===== */
.newsletter-section {
  background: linear-gradient(135deg,#1e3a8a 0%,#1a56db 100%);
  color: #fff; padding: 5rem 0; text-align: center;
}
.newsletter-inner { max-width: 600px; margin: 0 auto; }
.newsletter-icon { font-size: 3rem; margin-bottom: 1rem; }
.newsletter-section h2 { font-size: 2.25rem; font-weight: 800; margin-bottom: .75rem; }
.newsletter-section p { opacity: .85; margin-bottom: 2rem; font-size: 1.05rem; }
.newsletter-form { display: flex; gap: .75rem; max-width: 480px; margin: 0 auto 1rem; }
.newsletter-input { flex: 1; padding: .8rem 1.25rem; border-radius: 8px; border: 2px solid transparent; font-size: 1rem; outline: none; }
.newsletter-input:focus { border-color: var(--accent); }
.newsletter-note { font-size: .8rem; opacity: .65; }
.subscribe-success { margin-top: 1rem; background: rgba(255,255,255,.2); border-radius: 8px; padding: .75rem 1.5rem; font-weight: 600; }

/* ===== ABOUT ===== */
.about-section { background: var(--bg-alt); }
.about-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: start; }
.about-text h2 { margin-bottom: 1rem; }
.about-text p { color: var(--text-light); margin-bottom: .75rem; }
.about-values { display: flex; flex-direction: column; gap: 1rem; }
.value-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; gap: 1rem; align-items: flex-start; }
.value-icon { font-size: 1.75rem; flex-shrink: 0; }
.value-card h4 { font-size: .95rem; font-weight: 700; margin-bottom: .3rem; }
.value-card p { font-size: .875rem; color: var(--text-light); }

/* ===== SINGLE POST CONTENT ===== */
.entry-content h1, .entry-content h2, .entry-content h3 { margin: 1.75rem 0 .75rem; font-weight: 700; }
.entry-content p { margin-bottom: 1.25rem; }
.entry-content ul, .entry-content ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
.entry-content li { margin-bottom: .4rem; }
.entry-content img { border-radius: var(--radius); margin: 1.5rem auto; }
.entry-content blockquote { border-left: 4px solid var(--primary); padding: 1rem 1.5rem; background: var(--bg-alt); border-radius: 0 var(--radius) var(--radius) 0; margin: 1.5rem 0; font-style: italic; }
.entry-content a { color: var(--primary); text-decoration: underline; }
.entry-content code { background: var(--bg-alt); padding: .15rem .4rem; border-radius: 4px; font-size: .9em; }
.entry-content pre { background: #1f2937; color: #f9fafb; padding: 1.5rem; border-radius: var(--radius); overflow-x: auto; margin: 1.5rem 0; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 2.5rem; flex-wrap: wrap; }
.pagination .page-numbers {
  padding: .5rem .9rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .875rem; color: var(--text-light);
  transition: all .2s; background: #fff;
}
.pagination .page-numbers.current,
.pagination .page-numbers:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== FOOTER ===== */
.site-footer { background: #0f172a; color: rgba(255,255,255,.75); padding: 4rem 0 0; }
.footer-inner { display: grid; grid-template-columns: 2fr 3fr; gap: 3rem; padding-bottom: 3rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.footer-brand p { margin-top: .75rem; font-size: .875rem; }
.footer-links { display: grid; grid-template-columns: repeat(3,1fr); gap: 2rem; }
.footer-col h4 { font-size: .875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #fff; margin-bottom: 1rem; }
.footer-col a { display: block; font-size: .875rem; margin-bottom: .5rem; opacity: .75; transition: opacity .2s; }
.footer-col a:hover { opacity: 1; }
.footer-bottom { padding: 1.25rem 0; text-align: center; font-size: .8rem; opacity: .5; }

/* ===== BACK TO TOP ===== */
.back-to-top {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 99;
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary);
  color: #fff; border: none; cursor: pointer; font-size: 1.4rem;
  box-shadow: var(--shadow-lg); display: none; align-items: center; justify-content: center; transition: all .2s;
}
.back-to-top.visible { display: flex; }
.back-to-top:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* ===== SCROLL ANIMATION ===== */
.tsk-animate { opacity: 0; transform: translateY(20px); transition: opacity .5s ease, transform .5s ease; }
.tsk-visible  { opacity: 1; transform: translateY(0); }

/* ===== ARTICLE ROW (index & archive) ===== */
.article-row,.archive-article{display:flex;flex-direction:row;background:#fff;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;}
.article-row-thumb,.archive-thumb{width:200px;min-width:200px;height:150px;flex-shrink:0;overflow:hidden;}
.article-row-thumb img,.archive-thumb img{width:100%;height:150px;object-fit:cover;display:block;}
.article-row-thumb-bg,.archive-thumb-bg{width:100%;height:150px;display:block;}
.article-row-body,.archive-body{padding:1rem;flex:1;display:flex;flex-direction:column;justify-content:center;}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .two-col-layout { grid-template-columns: 1fr; }
  .col-sidebar { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
  .col-sidebar .ad-zone { grid-column: span 2; }
  .about-inner { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .article-row,.archive-article{flex-direction:column !important;}
  .article-row-thumb,.archive-thumb{width:100% !important;min-width:100% !important;height:180px !important;}
  .article-row-thumb img,.archive-thumb img{width:100% !important;height:180px !important;object-fit:cover !important;}
  .article-row-thumb-bg,.archive-thumb-bg{height:180px !important;}
  .article-row-body,.archive-body{padding:1rem !important;}
  .nav-menu { display: none; flex-direction: column; position: absolute; top: var(--header-h); left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border); padding: 1rem; gap: .25rem; }
  .nav-menu.open { display: flex; }
  .hamburger { display: flex; }
  .article-card--featured { grid-column: span 1; }
  .articles-grid { grid-template-columns: 1fr; }
  .newsletter-form { flex-direction: column; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-links { grid-template-columns: repeat(2,1fr); }
  .col-sidebar { grid-template-columns: 1fr; }
  .col-sidebar .ad-zone { grid-column: span 1; }

  /* Hero mobile */
  .hero { min-height: unset; align-items: flex-start; }
  .hero-content { padding: 3rem 1.5rem; width: 100%; max-width: 100%; }
  .hero-title { font-size: 1.75rem; }
  .hero-sub { font-size: .95rem; max-width: 100%; margin-bottom: 1.5rem; }
  .hero-badge { font-size: .8rem; margin-bottom: 1rem; }
  .hero-btns { margin-bottom: 2rem; }
  .hero-stats { gap: 1.25rem; flex-wrap: wrap; }
  .stat strong { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .categories-grid { grid-template-columns: 1fr; }
  .footer-links { grid-template-columns: 1fr; }

  /* Hero small phones */
  .hero-content { padding: 2.5rem 1.25rem; }
  .hero-title { font-size: 1.5rem; }
  .hero-btns { flex-direction: column; }
  .hero-btns .btn { width: 100%; justify-content: center; }
  .hero-stats { gap: 1rem; }
  .stat-divider { display: none; }
  .stat { flex-direction: row; align-items: center; gap: .4rem; }
  .stat strong { font-size: 1.1rem; }
  .stat span { font-size: .8rem; opacity: .7; }
}

/* ===== ARTICLE ROW BODY MOBILE ===== */
@media (max-width: 768px) {
  .article-row-body, .archive-body {
    padding: .875rem !important;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .article-row-body h3, .archive-body h3 {
    font-size: .9rem !important;
    line-height: 1.4 !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .article-row-body p, .archive-body p {
    font-size: .8rem !important;
    margin-bottom: .5rem !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .article-row-body .article-footer,
  .archive-body .article-footer {
    flex-wrap: wrap;
    gap: .4rem;
    font-size: .75rem !important;
  }
  .article-row-body .article-meta,
  .archive-body .article-meta {
    font-size: .72rem !important;
    white-space: normal !important;
  }
  .article-row-body .read-more,
  .archive-body .read-more {
    font-size: .8rem !important;
  }
}

/* ===== RESPONSIVE ADS ===== */
.ad-desktop { display: block; }
.ad-mobile  { display: none; }

@media (max-width: 768px) {
  /* Show mobile ad, hide desktop ad */
  .ad-desktop { display: none !important; }
  .ad-mobile  { display: block !important; text-align: center; overflow: hidden; }

  /* Sidebar ads — hide on mobile */
  .col-sidebar .ad-zone { display: none !important; }

  /* Wrap ALL page content so nothing overflows viewport */
  body { overflow-x: hidden !important; }

  /* Scale down any iframe that is wider than viewport */
  iframe {
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* Ad wrapper divs — clip overflow */
  .ad-mobile,
  #container-c709415a98dbe6dbb3c48e58b4b2efe4,
  div[id^="container-"] {
    max-width: 100% !important;
    overflow: hidden !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* 320x50 mobile banner centering */
  .ad-mobile iframe {
    display: block !important;
    margin: 0 auto !important;
    max-width: 320px !important;
  }
}
