/*
Theme Name: TechPulse AdSense
Theme URI: https://example.com/techpulse-adsense
Author: TechPulse Studio
Author URI: https://example.com
Description: Lightweight, fast, Core Web Vitals and Google AdSense-ready WordPress theme built for Tech, AI Tools, and How-To Guide publications. Includes built-in E-E-A-T author boxes, auto Table of Contents, Schema.org JSON-LD, Customizer AdSense slots, automatic ads.txt, working contact form shortcode, and one-click AdSense legal pages generator.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: techpulse-adsense
Tags: blog, news, two-columns, right-sidebar, custom-menu, featured-images, theme-options, translation-ready
*/

:root {
  --tp-bg: #ffffff;
  --tp-surface: #f8fafc;
  --tp-surface-alt: #f1f5f9;
  --tp-border: #e2e8f0;
  --tp-text: #0f172a;
  --tp-text-muted: #475569;
  --tp-text-subtle: #64748b;
  --tp-accent: #2563eb;
  --tp-accent-hover: #1d4ed8;
  --tp-accent-soft: #eff6ff;
  --tp-success: #059669;
  --tp-warning: #d97706;
  --tp-danger: #dc2626;
  --tp-radius: 12px;
  --tp-radius-sm: 8px;
  --tp-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --tp-max-width: 1180px;
  --tp-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --tp-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --tp-bg: #0b1120;
  --tp-surface: #111827;
  --tp-surface-alt: #1e293b;
  --tp-border: #1f2937;
  --tp-text: #f1f5f9;
  --tp-text-muted: #cbd5e1;
  --tp-text-subtle: #94a3b8;
  --tp-accent: #3b82f6;
  --tp-accent-hover: #60a5fa;
  --tp-accent-soft: rgba(59, 130, 246, 0.14);
  --tp-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.25);
}

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

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

body {
  margin: 0;
  font-family: var(--tp-font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--tp-text);
  background-color: var(--tp-bg);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--tp-accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--tp-accent-hover);
  text-decoration: underline;
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  width: auto;
  height: auto;
  clip: auto;
  padding: 10px 16px;
  background: var(--tp-accent);
  color: #fff;
  border-radius: var(--tp-radius-sm);
}

.tp-container {
  width: 100%;
  max-width: var(--tp-max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header & Navigation */
.tp-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--tp-bg);
  border-bottom: 1px solid var(--tp-border);
  backdrop-filter: blur(8px);
}

.tp-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.tp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--tp-text);
  text-decoration: none;
}

.tp-brand:hover {
  text-decoration: none;
  color: var(--tp-accent);
}

.tp-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--tp-accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}

.tp-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tp-nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
}

.tp-nav-menu > li {
  position: relative;
}

.tp-nav-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--tp-radius-sm);
  color: var(--tp-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}

.tp-nav-menu a:hover,
.tp-nav-menu .current-menu-item > a {
  color: var(--tp-accent);
  background: var(--tp-accent-soft);
}

.tp-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--tp-radius-sm);
  border: 1px solid var(--tp-border);
  background: var(--tp-surface);
  color: var(--tp-text);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tp-icon-btn:hover {
  background: var(--tp-surface-alt);
  border-color: var(--tp-accent);
}

.tp-menu-toggle {
  display: none;
}

.tp-search-bar {
  display: none;
  border-top: 1px solid var(--tp-border);
  background: var(--tp-surface);
  padding: 12px 0;
}

.tp-search-bar.is-open {
  display: block;
}

.tp-search-form {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}

.tp-search-form input[type="search"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  background: var(--tp-bg);
  color: var(--tp-text);
  font-size: 0.95rem;
}

.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--tp-radius-sm);
  border: none;
  background: var(--tp-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.tp-btn:hover {
  background: var(--tp-accent-hover);
  color: #fff;
  text-decoration: none;
}

/* Layout Grid */
.tp-main {
  padding: 28px 0 56px;
}

.tp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 36px;
  align-items: start;
}

.tp-layout--full {
  grid-template-columns: minmax(0, 1fr);
  max-width: 860px;
  margin: 0 auto;
}

/* Hero / Intro Banner on Home */
.tp-hero {
  background: linear-gradient(135deg, var(--tp-accent-soft) 0%, var(--tp-surface) 100%);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  padding: 28px 32px;
  margin-bottom: 28px;
}

.tp-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.tp-hero p {
  margin: 0;
  color: var(--tp-text-muted);
  max-width: 68ch;
}

.tp-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tp-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  color: var(--tp-text-muted);
}

.tp-pill:hover {
  border-color: var(--tp-accent);
  color: var(--tp-accent);
  text-decoration: none;
}

/* Post Grid Cards */
.tp-post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.tp-card {
  display: flex;
  flex-direction: column;
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  overflow: hidden;
  box-shadow: var(--tp-shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.tp-card:hover {
  transform: translateY(-2px);
  border-color: var(--tp-accent);
}

.tp-card-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tp-surface-alt);
}

.tp-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tp-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px;
}

.tp-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--tp-text-subtle);
  margin-bottom: 8px;
}

.tp-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--tp-accent-soft);
  color: var(--tp-accent);
  font-weight: 600;
  font-size: 0.78rem;
}

.tp-card-title {
  margin: 0 0 10px;
  font-size: 1.18rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.tp-card-title a {
  color: var(--tp-text);
  text-decoration: none;
}

.tp-card-title a:hover {
  color: var(--tp-accent);
}

.tp-card-excerpt {
  margin: 0 0 16px;
  color: var(--tp-text-muted);
  font-size: 0.94rem;
  flex: 1;
}

.tp-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--tp-text-subtle);
  padding-top: 12px;
  border-top: 1px solid var(--tp-border);
}

/* Single Article & Pages */
.tp-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--tp-text-subtle);
  margin-bottom: 16px;
}

.tp-article {
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  padding: 32px;
}

.tp-article-header h1 {
  margin: 10px 0 14px;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.22;
  letter-spacing: -0.025em;
}

.tp-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--tp-border);
  font-size: 0.9rem;
  color: var(--tp-text-subtle);
}

.tp-article-thumb {
  margin: 0 0 24px;
  border-radius: var(--tp-radius-sm);
  overflow: hidden;
  border: 1px solid var(--tp-border);
}

.tp-toc {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-left: 4px solid var(--tp-accent);
  border-radius: var(--tp-radius-sm);
  padding: 16px 20px;
  margin: 0 0 26px;
}

.tp-toc-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tp-text);
}

.tp-toc ul {
  margin: 0;
  padding-left: 18px;
}

.tp-toc li {
  margin: 4px 0;
  font-size: 0.92rem;
}

.tp-toc li.tp-toc-h3 {
  margin-left: 16px;
}

.tp-entry-content {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--tp-text);
}

.tp-entry-content h2 {
  margin: 34px 0 12px;
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  scroll-margin-top: 84px;
}

.tp-entry-content h3 {
  margin: 26px 0 10px;
  font-size: 1.22rem;
  line-height: 1.35;
  scroll-margin-top: 84px;
}

.tp-entry-content p {
  margin: 0 0 18px;
}

.tp-entry-content ul,
.tp-entry-content ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.tp-entry-content li {
  margin-bottom: 6px;
}

.tp-entry-content blockquote {
  margin: 22px 0;
  padding: 14px 20px;
  background: var(--tp-surface);
  border-left: 4px solid var(--tp-accent);
  border-radius: 0 var(--tp-radius-sm) var(--tp-radius-sm) 0;
  color: var(--tp-text-muted);
}

.tp-entry-content pre,
.tp-entry-content code {
  font-family: var(--tp-font-mono);
  font-size: 0.9em;
}

.tp-entry-content code {
  background: var(--tp-surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
}

.tp-entry-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 20px;
  border-radius: var(--tp-radius-sm);
  overflow-x: auto;
  margin: 20px 0;
}

.tp-entry-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.tp-entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 0.94rem;
}

.tp-entry-content th,
.tp-entry-content td {
  border: 1px solid var(--tp-border);
  padding: 10px 12px;
  text-align: left;
}

.tp-entry-content th {
  background: var(--tp-surface);
  font-weight: 700;
}

/* Tags & Author Box (E-E-A-T) */
.tp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--tp-border);
}

.tp-author-box {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 28px;
  padding: 22px;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
}

.tp-author-avatar img {
  border-radius: 50%;
  min-width: 68px;
}

.tp-author-info h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.tp-author-role {
  font-size: 0.82rem;
  color: var(--tp-accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.tp-author-info p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--tp-text-muted);
}

/* Related Posts */
.tp-related {
  margin-top: 32px;
}

.tp-section-heading {
  font-size: 1.25rem;
  margin: 0 0 16px;
}

.tp-related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

/* Sidebar */
.tp-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tp-widget {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  padding: 20px;
}

.tp-widget-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--tp-border);
}

.tp-widget ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tp-widget li {
  padding: 7px 0;
  border-bottom: 1px dashed var(--tp-border);
  font-size: 0.92rem;
}

.tp-widget li:last-child {
  border-bottom: none;
}

/* AdSense Containers (CLS-safe) */
.tp-ad-slot {
  margin: 22px 0;
  padding: 10px;
  background: var(--tp-surface);
  border: 1px dashed var(--tp-border);
  border-radius: var(--tp-radius-sm);
  text-align: center;
  min-height: 100px;
  overflow: hidden;
}

.tp-ad-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tp-text-subtle);
  margin-bottom: 6px;
}

/* Pagination */
.tp-pagination {
  margin-top: 32px;
  display: flex;
  justify-content: center;
}

.tp-pagination .nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tp-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--tp-radius-sm);
  border: 1px solid var(--tp-border);
  background: var(--tp-bg);
  color: var(--tp-text);
  font-weight: 600;
  font-size: 0.9rem;
}

.tp-pagination .page-numbers.current {
  background: var(--tp-accent);
  border-color: var(--tp-accent);
  color: #fff;
}

/* Contact Form */
.tp-contact-form {
  display: grid;
  gap: 16px;
  max-width: 620px;
  margin: 20px 0;
}

.tp-form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.tp-form-group input,
.tp-form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  background: var(--tp-bg);
  color: var(--tp-text);
  font-family: inherit;
  font-size: 0.95rem;
}

.tp-alert {
  padding: 14px 16px;
  border-radius: var(--tp-radius-sm);
  margin-bottom: 16px;
  font-size: 0.94rem;
}

.tp-alert--success {
  background: rgba(5, 150, 105, 0.12);
  border: 1px solid var(--tp-success);
  color: var(--tp-success);
}

.tp-alert--error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid var(--tp-danger);
  color: var(--tp-danger);
}

/* Comments */
.tp-comments {
  margin-top: 32px;
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  padding: 28px;
}

.comment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
}

.comment-list .comment {
  padding: 14px 0;
  border-bottom: 1px solid var(--tp-border);
}

.comment-form textarea,
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  background: var(--tp-bg);
  color: var(--tp-text);
}

.comment-form .submit {
  padding: 10px 20px;
  border-radius: var(--tp-radius-sm);
  border: none;
  background: var(--tp-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* Footer */
.tp-footer {
  background: var(--tp-surface);
  border-top: 1px solid var(--tp-border);
  padding: 40px 0 24px;
  color: var(--tp-text-muted);
  font-size: 0.92rem;
}

.tp-footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--tp-border);
}

.tp-footer h4 {
  margin: 0 0 12px;
  color: var(--tp-text);
  font-size: 1rem;
}

.tp-footer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tp-footer-menu li {
  margin-bottom: 6px;
}

.tp-footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
  font-size: 0.85rem;
  color: var(--tp-text-subtle);
}

/* Responsive */
@media (max-width: 960px) {
  .tp-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .tp-related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tp-footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .tp-menu-toggle {
    display: inline-flex;
  }
  .tp-nav {
    display: none;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--tp-bg);
    border-bottom: 1px solid var(--tp-border);
    padding: 12px 20px 18px;
  }
  .tp-nav.is-open {
    display: block;
  }
  .tp-nav-menu {
    flex-direction: column;
  }
  .tp-post-grid,
  .tp-related-grid,
  .tp-footer-grid {
    grid-template-columns: 1fr;
  }
  .tp-article {
    padding: 20px;
  }
  .tp-author-box {
    flex-direction: column;
  }
}
