/*
Theme Name: AutoPulse
Theme URI: https://example.com/autopulse
Author: Ahoy Creative
Description: Clean, modern, Apple-style news theme for automotive and motorcycle news. RTL-ready, WCAG 2.1 AA accessible, SEO-optimized with schema.org NewsArticle markup and smooth slow-motion scroll animations.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.8
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: autopulse
Tags: news, blog, rtl-language-support, accessibility-ready, custom-menu, featured-images
*/

/* ==========================================================================
   1. Design tokens
   ========================================================================== */
:root {
  --ap-bg: #fbfbfd;
  --ap-surface: #ffffff;
  --ap-text: #1d1d1f;
  --ap-text-secondary: #6e6e73;
  --ap-accent: #0071e3;
  --ap-accent-hover: #0077ed;
  --ap-border: rgba(0, 0, 0, 0.08);
  --ap-radius: 18px;
  --ap-radius-sm: 12px;
  --ap-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --ap-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.12);
  --ap-max-width: 1120px;
  --ap-content-width: 720px;
  --ap-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ap-duration: 0.9s;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ap-bg: #000000;
    --ap-surface: #1d1d1f;
    --ap-text: #f5f5f7;
    --ap-text-secondary: #a1a1a6;
    --ap-border: rgba(255, 255, 255, 0.12);
    --ap-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --ap-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.6);
  }
}

/* ==========================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ap-bg);
  color: var(--ap-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: var(--ap-accent); text-decoration: none; transition: color 0.3s var(--ap-ease); }
a:hover { color: var(--ap-accent-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--ap-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.15;
  color: var(--ap-text);
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
h3 { font-size: 1.35rem; }

.ap-container { max-width: var(--ap-max-width); margin: 0 auto; padding: 0 24px; }

/* Screen-reader / accessibility helpers */
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  overflow: hidden;
  word-wrap: normal !important;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ap-accent);
  color: #fff;
  padding: 12px 20px;
  z-index: 1000;
  border-radius: 0 0 var(--ap-radius-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ==========================================================================
   3. Header — translucent, Apple-style
   ========================================================================== */
.ap-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--ap-bg) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--ap-border);
}
.ap-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 24px;
}
.ap-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ap-text);
}
.ap-logo:hover { text-decoration: none; color: var(--ap-text); }

.ap-nav ul { display: flex; gap: 28px; list-style: none; margin: 0; padding: 0; }
.ap-nav a {
  color: var(--ap-text);
  font-size: 0.92rem;
  opacity: 0.85;
  transition: opacity 0.3s var(--ap-ease);
}
.ap-nav a:hover { opacity: 1; text-decoration: none; }

.ap-menu-toggle {
  display: none;
  background: none;
  border: 0;
  font-size: 1.5rem;
  color: var(--ap-text);
  cursor: pointer;
  padding: 8px;
}

@media (max-width: 768px) {
  .ap-menu-toggle { display: block; }
  .ap-nav { display: none; width: 100%; }
  .ap-nav.is-open { display: block; }
  .ap-nav ul { flex-direction: column; gap: 4px; padding: 12px 0 20px; }
  .ap-nav a { display: block; padding: 12px 0; font-size: 1.15rem; }
  .ap-header-inner { flex-wrap: wrap; }
}

/* ==========================================================================
   4. Hero
   ========================================================================== */
.ap-hero { padding: 96px 0 64px; text-align: center; }
.ap-hero .ap-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ap-accent);
}
.ap-hero p.ap-sub {
  font-size: 1.3rem;
  color: var(--ap-text-secondary);
  max-width: 640px;
  margin: 0 auto;
}

/* ==========================================================================
   5. Article cards
   ========================================================================== */
.ap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  padding: 32px 0 80px;
}
.ap-card {
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  overflow: hidden;
  box-shadow: var(--ap-shadow);
  border: 1px solid var(--ap-border);
  transition: transform 0.7s var(--ap-ease), box-shadow 0.7s var(--ap-ease);
  display: flex;
  flex-direction: column;
}
.ap-card:hover { transform: translateY(-6px) scale(1.01); box-shadow: var(--ap-shadow-hover); }
.ap-card-media { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #e8e8ed, #d2d2d7); overflow: hidden; }
@media (prefers-color-scheme: dark) {
  .ap-card-media { background: linear-gradient(135deg, #2c2c2e, #1c1c1e); }
}
.ap-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ap-ease); }
.ap-card:hover .ap-card-media img { transform: scale(1.05); }
.ap-card-body { padding: 22px 24px 26px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ap-card-cat {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ap-accent);
}
.ap-card h3 a { color: var(--ap-text); }
.ap-card h3 a:hover { color: var(--ap-accent); text-decoration: none; }
.ap-card p { color: var(--ap-text-secondary); font-size: 0.95rem; margin: 0; flex: 1; }
.ap-card time { color: var(--ap-text-secondary); font-size: 0.8rem; }

/* ==========================================================================
   6. Single article
   ========================================================================== */
.ap-article { max-width: var(--ap-content-width); margin: 0 auto; padding: 64px 24px 80px; }
.ap-article-header { text-align: center; margin-bottom: 40px; }
.ap-article-meta { color: var(--ap-text-secondary); font-size: 0.9rem; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.ap-article .ap-featured {
  border-radius: var(--ap-radius);
  overflow: hidden;
  margin: 0 0 40px;
  box-shadow: var(--ap-shadow);
}
.ap-article-content { font-size: 1.12rem; line-height: 1.75; }
.ap-article-content h2 { margin-top: 1.8em; }
.ap-article-content figure { margin: 2em 0; }
.ap-video-embed { position: relative; aspect-ratio: 16 / 9; border-radius: var(--ap-radius); overflow: hidden; margin: 2em 0; }
.ap-video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ap-source-attribution {
  margin-top: 48px;
  padding: 20px 24px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  font-size: 0.9rem;
  color: var(--ap-text-secondary);
}

/* Tags */
.ap-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
.ap-tags a {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.82rem;
  color: var(--ap-text-secondary);
}
.ap-tags a:hover { color: var(--ap-accent); text-decoration: none; border-color: var(--ap-accent); }

/* ==========================================================================
   7. Pagination, archive header
   ========================================================================== */
.ap-archive-header { padding: 72px 0 8px; }
.ap-archive-header p { color: var(--ap-text-secondary); }
.ap-pagination { display: flex; justify-content: center; gap: 8px; padding-bottom: 80px; }
.ap-pagination .page-numbers {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--ap-border);
  color: var(--ap-text);
  font-size: 0.9rem;
}
.ap-pagination .page-numbers.current { background: var(--ap-accent); color: #fff; border-color: var(--ap-accent); }
.ap-pagination a:hover { text-decoration: none; border-color: var(--ap-accent); }

/* ==========================================================================
   8. Footer
   ========================================================================== */
.ap-footer {
  border-top: 1px solid var(--ap-border);
  padding: 48px 0 64px;
  font-size: 0.85rem;
  color: var(--ap-text-secondary);
}
.ap-footer-nav ul { display: flex; flex-wrap: wrap; gap: 10px 24px; list-style: none; margin: 0 0 20px; padding: 0; }
.ap-footer-nav a { color: var(--ap-text-secondary); }
.ap-footer-nav a:hover { color: var(--ap-accent); }

/* ==========================================================================
   9. Slow reveal animations (JS adds .ap-visible)
   Respects prefers-reduced-motion for accessibility.
   ========================================================================== */
.ap-reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity var(--ap-duration) var(--ap-ease), transform var(--ap-duration) var(--ap-ease);
}
.ap-reveal.ap-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ap-reveal { opacity: 1; transform: none; transition: none; }
  .ap-card, .ap-card-media img { transition: none; }
}

/* ==========================================================================
   10. Forms / search
   ========================================================================== */
.ap-search-form { display: flex; gap: 8px; max-width: 480px; }
.ap-search-form input[type="search"] {
  flex: 1;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--ap-border);
  background: var(--ap-surface);
  color: var(--ap-text);
  font-size: 1rem;
}
.ap-btn, .ap-search-form button {
  background: var(--ap-accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s var(--ap-ease);
}
.ap-btn:hover, .ap-search-form button:hover { background: var(--ap-accent-hover); }
