/*
Theme Name: TaleMingle
Theme URI: https://talemingle.com/
Author: TaleMingle
Author URI: https://talemingle.com/
Description: A blazing-fast, AdSense-ready Urdu storytelling theme with literary aesthetic. Built for speed, SEO, and instant AdSense approval. Supports RTL Urdu typography, lazy loading, schema.org markup, and minimal JavaScript.
Version: 1.0.0
Requires at least: 5.5
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: talemingle
Tags: blog, news, two-columns, right-sidebar, custom-menu, custom-logo, featured-images, threaded-comments, translation-ready, rtl-language-support, custom-colors
*/

/* ========================================
   1. CSS RESET & BASE
======================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul[role='list'], ol[role='list'] { list-style: none; }
img, picture, svg, video { max-width: 100%; height: auto; display: block; }
input, button, textarea, select { font: inherit; }

/* ========================================
   2. CSS VARIABLES (Design Tokens)
======================================== */
:root {
  --tm-bg: #FAF7F2;
  --tm-bg-alt: #F2EDE3;
  --tm-surface: #FFFFFF;
  --tm-text: #1A1A1A;
  --tm-text-muted: #6B6358;
  --tm-text-soft: #948B7E;
  --tm-accent: #B8401C;
  --tm-accent-dark: #8A2F13;
  --tm-secondary: #2D5A3F;
  --tm-border: #E8E2D5;
  --tm-border-soft: #F0EBE0;

  --tm-font-urdu: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Alvi Nastaleeq', serif;
  --tm-font-serif: 'Lora', Georgia, 'Times New Roman', serif;
  --tm-font-display: 'Playfair Display', Georgia, serif;

  --tm-container: 1180px;
  --tm-radius: 6px;
  --tm-radius-lg: 10px;
  --tm-shadow-sm: 0 1px 3px rgba(26,26,26,0.06);
  --tm-shadow: 0 4px 14px rgba(26,26,26,0.08);
}

/* ========================================
   3. TYPOGRAPHY (Urdu-first)
======================================== */
body {
  font-family: var(--tm-font-urdu);
  font-size: 18px;
  line-height: 2.0;
  color: var(--tm-text);
  background: var(--tm-bg);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* English content within Urdu pages */
body.ltr-mode, .ltr-content {
  font-family: var(--tm-font-serif);
  direction: ltr;
  text-align: left;
  line-height: 1.7;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--tm-font-urdu);
  font-weight: 700;
  line-height: 1.6;
  color: var(--tm-text);
  margin-bottom: 0.75em;
}
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: clamp(24px, 3vw, 32px); }
h3 { font-size: clamp(20px, 2.5vw, 26px); }
h4 { font-size: 20px; }

p { margin: 0 0 1.2em; }

a {
  color: var(--tm-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover, a:focus { color: var(--tm-accent-dark); text-decoration: underline; }

blockquote {
  border-right: 4px solid var(--tm-accent);
  padding: 1em 1.5em;
  margin: 1.5em 0;
  background: var(--tm-bg-alt);
  border-radius: var(--tm-radius);
  font-style: italic;
  color: var(--tm-text-muted);
}

code, pre {
  font-family: 'Courier New', monospace;
  background: var(--tm-bg-alt);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}
pre { padding: 1em; overflow-x: auto; direction: ltr; text-align: left; }

/* ========================================
   4. LAYOUT
======================================== */
.tm-container {
  max-width: var(--tm-container);
  margin: 0 auto;
  padding: 0 20px;
}

.tm-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  margin: 32px auto;
}

@media (max-width: 900px) {
  .tm-main { grid-template-columns: 1fr; gap: 24px; }
}

.tm-content { min-width: 0; }

/* ========================================
   5. HEADER
======================================== */
.tm-header {
  background: var(--tm-surface);
  border-bottom: 1px solid var(--tm-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--tm-shadow-sm);
}
.tm-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: var(--tm-container);
  margin: 0 auto;
  gap: 20px;
}
.tm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.tm-brand-mark {
  width: 42px;
  height: 42px;
  background: var(--tm-accent);
  color: #fff;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--tm-font-display);
  font-size: 22px;
  font-weight: 700;
  font-style: italic;
}
.tm-brand-name {
  font-family: var(--tm-font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--tm-text);
  letter-spacing: -0.5px;
}
.tm-brand-name span { color: var(--tm-accent); }

/* Navigation */
.tm-nav { display: flex; align-items: center; gap: 8px; }
.tm-nav ul {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
}
.tm-nav a {
  display: block;
  padding: 8px 14px;
  color: var(--tm-text);
  font-weight: 500;
  border-radius: var(--tm-radius);
  transition: background 0.2s, color 0.2s;
}
.tm-nav a:hover { background: var(--tm-bg-alt); color: var(--tm-accent); text-decoration: none; }
.tm-nav .current-menu-item > a { color: var(--tm-accent); }

.tm-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 8px 12px;
  cursor: pointer;
  color: var(--tm-text);
}

@media (max-width: 768px) {
  .tm-menu-toggle { display: block; }
  .tm-nav ul {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: var(--tm-surface);
    flex-direction: column;
    padding: 12px;
    border-top: 1px solid var(--tm-border);
    box-shadow: var(--tm-shadow);
  }
  .tm-nav.is-open ul { display: flex; }
  .tm-nav a { padding: 12px 16px; }
}

/* ========================================
   6. HOMEPAGE & POST LISTINGS
======================================== */
.tm-hero {
  background: linear-gradient(135deg, var(--tm-bg-alt) 0%, var(--tm-bg) 100%);
  padding: 48px 20px;
  text-align: center;
  border-bottom: 1px solid var(--tm-border);
  position: relative;
  overflow: hidden;
}
.tm-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(184, 64, 28, 0.06) 0%, transparent 50%),
                    radial-gradient(circle at 80% 70%, rgba(45, 90, 63, 0.05) 0%, transparent 50%);
  pointer-events: none;
}
.tm-hero-inner { position: relative; max-width: 720px; margin: 0 auto; }
.tm-hero h1 {
  font-size: clamp(28px, 4.5vw, 44px);
  margin-bottom: 12px;
  line-height: 1.5;
}
.tm-hero p {
  color: var(--tm-text-muted);
  font-size: 18px;
  line-height: 1.9;
}

/* Post Grid */
.tm-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.tm-card {
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-lg);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}
.tm-card:hover { transform: translateY(-2px); box-shadow: var(--tm-shadow); }
.tm-card-thumb {
  aspect-ratio: 16 / 10;
  background: var(--tm-bg-alt);
  overflow: hidden;
}
.tm-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.tm-card:hover .tm-card-thumb img { transform: scale(1.04); }
.tm-card-body { padding: 18px 20px 22px; flex: 1; display: flex; flex-direction: column; }
.tm-card-cat {
  display: inline-block;
  font-size: 12px;
  color: var(--tm-accent);
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.tm-card-title {
  font-size: 19px;
  line-height: 1.7;
  margin-bottom: 10px;
}
.tm-card-title a { color: var(--tm-text); }
.tm-card-title a:hover { color: var(--tm-accent); text-decoration: none; }
.tm-card-meta {
  font-size: 13px;
  color: var(--tm-text-soft);
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--tm-border-soft);
}

/* Section title */
.tm-section-title {
  font-size: 24px;
  margin: 32px 0 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--tm-accent);
  display: inline-block;
}

/* ========================================
   7. SINGLE POST
======================================== */
.tm-article {
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-lg);
  padding: 32px;
}
@media (max-width: 600px) { .tm-article { padding: 20px; } }

.tm-article-header { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--tm-border); }
.tm-article-cat {
  display: inline-block;
  background: var(--tm-accent);
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 100px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}
.tm-article-cat a { color: #fff; }
.tm-article-title {
  font-size: clamp(26px, 3.5vw, 36px);
  line-height: 1.6;
  margin-bottom: 14px;
}
.tm-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 14px;
  color: var(--tm-text-soft);
}
.tm-article-meta span { display: inline-flex; align-items: center; gap: 6px; }

.tm-article-thumb { margin: 0 -32px 24px; }
@media (max-width: 600px) { .tm-article-thumb { margin: 0 -20px 20px; } }
.tm-article-thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

.tm-article-content { font-size: 18px; line-height: 2.1; }
.tm-article-content h2,
.tm-article-content h3 { margin-top: 1.5em; }
.tm-article-content img { border-radius: var(--tm-radius); margin: 1.2em 0; }

/* Tags */
.tm-tags { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--tm-border); }
.tm-tags a {
  display: inline-block;
  background: var(--tm-bg-alt);
  color: var(--tm-text-muted);
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 13px;
  margin: 4px 4px 0 0;
}
.tm-tags a:hover { background: var(--tm-accent); color: #fff; text-decoration: none; }

/* Author box */
.tm-author-box {
  margin-top: 28px;
  padding: 20px;
  background: var(--tm-bg-alt);
  border-radius: var(--tm-radius-lg);
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.tm-author-box .avatar { border-radius: 50%; flex-shrink: 0; }
.tm-author-box h4 { margin-bottom: 4px; font-size: 16px; }
.tm-author-box p { font-size: 14px; color: var(--tm-text-muted); margin: 0; }

/* Post navigation */
.tm-post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 28px;
}
@media (max-width: 600px) { .tm-post-nav { grid-template-columns: 1fr; } }
.tm-post-nav a {
  display: block;
  padding: 16px 18px;
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-lg);
  color: var(--tm-text);
  transition: border-color 0.2s, background 0.2s;
}
.tm-post-nav a:hover { border-color: var(--tm-accent); background: var(--tm-bg-alt); text-decoration: none; }
.tm-post-nav .label { font-size: 12px; color: var(--tm-text-soft); display: block; margin-bottom: 4px; }

/* ========================================
   8. SIDEBAR & WIDGETS
======================================== */
.tm-sidebar { display: flex; flex-direction: column; gap: 24px; }
.tm-widget {
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-lg);
  padding: 22px;
}
.tm-widget-title {
  font-size: 18px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--tm-accent);
  display: inline-block;
}
.tm-widget ul { list-style: none; padding: 0; margin: 0; }
.tm-widget li {
  padding: 8px 0;
  border-bottom: 1px solid var(--tm-border-soft);
}
.tm-widget li:last-child { border-bottom: none; }
.tm-widget li a { color: var(--tm-text); }
.tm-widget li a:hover { color: var(--tm-accent); text-decoration: none; }

/* ========================================
   9. ADSENSE ZONES
======================================== */
.tm-ad {
  margin: 24px auto;
  text-align: center;
  min-height: 90px;
  background: var(--tm-bg-alt);
  border-radius: var(--tm-radius);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tm-ad-label {
  display: block;
  font-size: 11px;
  color: var(--tm-text-soft);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.tm-ad-empty { color: var(--tm-text-soft); font-size: 13px; opacity: 0.6; }
.tm-ad ins { display: block; }

/* ========================================
   10. PAGINATION
======================================== */
.tm-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 32px 0;
}
.tm-pagination .page-numbers {
  display: inline-block;
  padding: 8px 14px;
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  color: var(--tm-text);
  font-weight: 500;
  min-width: 40px;
  text-align: center;
}
.tm-pagination .page-numbers:hover,
.tm-pagination .page-numbers.current {
  background: var(--tm-accent);
  color: #fff;
  border-color: var(--tm-accent);
  text-decoration: none;
}

/* ========================================
   11. COMMENTS
======================================== */
.tm-comments {
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-lg);
  padding: 28px;
  margin-top: 28px;
}
.tm-comments h3 { margin-bottom: 18px; }
.comment-list { list-style: none; padding: 0; margin: 0; }
.comment-list li { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--tm-border-soft); }
.comment-list .comment-author { font-weight: 600; }
.comment-list .comment-meta { font-size: 13px; color: var(--tm-text-soft); margin-bottom: 8px; }
#commentform input[type=text],
#commentform input[type=email],
#commentform input[type=url],
#commentform textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  background: var(--tm-bg);
  font-family: inherit;
  margin-bottom: 12px;
}
#commentform textarea { min-height: 120px; }
.tm-btn, #commentform input[type=submit] {
  background: var(--tm-accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--tm-radius);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.tm-btn:hover, #commentform input[type=submit]:hover { background: var(--tm-accent-dark); }

/* ========================================
   12. FOOTER
======================================== */
.tm-footer {
  background: #1A1A1A;
  color: #C8C0B5;
  margin-top: 60px;
  padding: 40px 0 20px;
}
.tm-footer a { color: #E8E2D5; }
.tm-footer a:hover { color: var(--tm-accent); }
.tm-footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 28px;
}
@media (max-width: 700px) { .tm-footer-grid { grid-template-columns: 1fr; gap: 24px; } }
.tm-footer h4 { color: #fff; font-size: 16px; margin-bottom: 14px; }
.tm-footer ul { list-style: none; padding: 0; margin: 0; }
.tm-footer li { padding: 4px 0; }
.tm-footer-bottom {
  border-top: 1px solid #333;
  padding-top: 18px;
  text-align: center;
  font-size: 13px;
  color: #948B7E;
}

/* ========================================
   13. UTILITIES & HELPERS
======================================== */
.tm-search-form {
  display: flex;
  gap: 8px;
}
.tm-search-form input[type=search] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  background: var(--tm-bg);
  font-family: inherit;
}
.tm-search-form button {
  background: var(--tm-accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--tm-radius);
  cursor: pointer;
}

.screen-reader-text {
  border: 0;
  clip: rect(1px,1px,1px,1px);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.alignleft { float: left; margin: 0 1.5em 1em 0; }
.alignright { float: right; margin: 0 0 1em 1.5em; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.wp-caption { max-width: 100%; }
.wp-caption-text { font-size: 14px; color: var(--tm-text-soft); text-align: center; margin-top: 6px; }

/* ========================================
   14. PERFORMANCE
======================================== */
img[loading="lazy"] { content-visibility: auto; }
.tm-card-thumb img { content-visibility: auto; }
