/*
Theme Name: The Bookshelf
Theme URI: https://thebookshelf.com
Author: The Bookshelf LLC
Author URI: https://thebookshelf.com
Description: A clean, modern WordPress theme for The Bookshelf — a self-publishing education platform and writers' guild. Features a nature-inspired green palette, editorial typography, and blog-focused layout.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: bookshelf
Tags: blog, education, one-column, custom-header, custom-menu, featured-images, theme-options
*/

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Primary Greens */
  --color-primary-950: #21331C;
  --color-primary-900: #26331F;
  --color-primary-800: #2F4027;
  --color-primary-700: #44533D;
  --color-primary-600: #5A6B52;

  /* Neutral */
  --color-white: #FFFFFF;
  --color-white-200: #E6E6E6;
  --color-white-400: #A5A5A5;
  --color-white-500: #767676;
  --color-neutral-bg: #D5D9D4;
  --color-neutral-border: #D6D6D6;

  /* Shadows */
  --shadow-nav: 0px 4px 8px rgba(47, 64, 39, 0.16);
  --shadow-card: 0px 4px 8px rgba(47, 64, 39, 0.16);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-full: 20px;

  /* Typography Scale */
  --font-display: 'Bricolage Grotesque', serif;
  --font-body: 'DM Sans', sans-serif;

  /* Max width */
  --container-max: 1224px;
  --container-pad: 108px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-700);
  background: var(--color-white);
}

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

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s ease;
}

ul, ol {
  list-style: none;
}

button, input {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 3rem;       /* 48px */
  line-height: 1.25;     /* 60px */
  color: var(--color-primary-800);
}

.h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.25rem;    /* 36px */
  line-height: 1.278;    /* 46px */
  color: var(--color-primary-800);
}

.h2-bold {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1.278;
  color: var(--color-primary-800);
}

.body-1 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.125rem;   /* 18px */
  line-height: 1.556;    /* 28px */
  color: var(--color-primary-700);
}

.body-1-semibold {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.556;
  color: var(--color-primary-800);
}

.body-2 {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;       /* 16px */
  line-height: 1.5;      /* 24px */
}

.body-2-semibold {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
}

.body-3 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;   /* 14px */
  line-height: 1.429;    /* 20px */
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1440px) {
  .container {
    padding: 0;
  }
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: 80px;
  background: var(--color-white);
  box-shadow: var(--shadow-nav);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.site-logo img {
  height: 40px;
  width: auto;
}

.site-logo .logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-primary-950);
  white-space: nowrap;
}

/* Primary Nav */
.primary-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.primary-nav .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease;
}

.primary-nav .nav-item:hover {
  background: var(--color-neutral-bg);
}

.primary-nav .nav-item a,
.primary-nav .nav-item span {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-800);
  text-align: center;
}

.primary-nav .nav-item .arrow-down {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.primary-nav .nav-item:hover .arrow-down {
  transform: rotate(180deg);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}

.header-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  cursor: pointer;
  color: var(--color-primary-800);
}

.header-search-btn svg {
  width: 16px;
  height: 16px;
}

.header-divider {
  width: 0;
  height: 24px;
  border-left: 1px solid var(--color-neutral-border);
}

.btn-ghost {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-800);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: opacity 0.2s ease;
}

.btn-ghost:hover {
  opacity: 0.7;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px;
  gap: 10px;
  background: var(--color-primary-800);
  color: var(--color-white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-primary:hover {
  background: var(--color-primary-950);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Mobile toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-primary-800);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
  position: relative;
  width: 100%;
  min-height: 820px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #D5D9D4 32.31%, rgba(255, 255, 255, 0) 50.89%);
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 704px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero-text-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Offer badge */
.offer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 16px;
  background: var(--color-primary-800);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.offer-badge svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.offer-badge span {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.429;
  color: var(--color-white);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 3rem;
  line-height: 1.25;
  color: var(--color-primary-800);
  max-width: 626px;
}

.hero-subtitle {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.556;
  color: var(--color-primary-700);
  max-width: 498px;
}

/* Hero Search Bar */
.hero-search {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 48px;
}

.hero-search input {
  width: 100%;
  height: 100%;
  padding: 8px 170px 8px 16px;
  background: var(--color-white);
  border: 1px solid var(--color-white-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-800);
}

.hero-search input::placeholder {
  color: var(--color-white-500);
}

.hero-search .btn-primary {
  position: absolute;
  right: 4px;
  top: 4px;
  height: 40px;
  background: var(--color-primary-900);
}

/* ============================================================
   STATS SECTION
   ============================================================ */
.stats-section {
  padding: 120px 0 80px;
}

.stats-section .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 56px;
}

.stats-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1.278;
  text-align: center;
  color: var(--color-primary-800);
  max-width: 808px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  width: 100%;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 16px;
  background: var(--color-neutral-bg);
  border-radius: var(--radius-md);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(47, 64, 39, 0.12);
}

.stat-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary-800);
}

.stat-icon svg {
  width: 60px;
  height: 60px;
}

.stat-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.stat-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1.278;
  text-align: center;
  color: var(--color-primary-800);
}

.stat-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.stat-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.556;
  color: var(--color-primary-700);
  flex: 1;
}

.stat-arrow {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-white);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.stat-arrow:hover {
  background: var(--color-primary-800);
  transform: scale(1.05);
}

.stat-arrow:hover svg {
  stroke: var(--color-white);
}

.stat-arrow svg {
  width: 24px;
  height: 24px;
  stroke: var(--color-primary-800);
  transition: stroke 0.2s ease;
}

/* ============================================================
   BLOG SECTION
   ============================================================ */
.blog-section {
  padding: 80px 0 120px;
}

.blog-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 56px;
}

.blog-header-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1.278;
  text-align: center;
  color: var(--color-primary-800);
}

.blog-header-sub {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.556;
  text-align: center;
  color: var(--color-primary-700);
  max-width: 808px;
}

/* Category Filter Tabs */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
}

.cat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px;
  border: 1px solid var(--color-primary-800);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-800);
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
}

.cat-btn:hover {
  background: rgba(47, 64, 39, 0.08);
}

.cat-btn.active,
.cat-btn[aria-pressed="true"] {
  background: var(--color-primary-800);
  color: var(--color-white);
  border-color: var(--color-primary-800);
}

/* Blog Toolbar */
.blog-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.blog-count {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.556;
  color: var(--color-primary-700);
}

.blog-search {
  position: relative;
  width: 400px;
}

.blog-search input {
  width: 100%;
  height: 40px;
  padding: 8px 40px 8px 16px;
  background: var(--color-white);
  border: 1px solid var(--color-primary-800);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-800);
}

.blog-search input::placeholder {
  color: var(--color-white-500);
}

.blog-search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-white-500);
  pointer-events: none;
}

/* Blog Grid */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* Blog Card */
.blog-card {
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 32px rgba(47, 64, 39, 0.18);
}

.blog-card-image {
  width: 100%;
  aspect-ratio: 392 / 240;
  overflow: hidden;
}

.blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.blog-card:hover .blog-card-image img {
  transform: scale(1.05);
}

.blog-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
}

.blog-card-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.556;
  color: var(--color-primary-800);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-title a:hover {
  color: var(--color-primary-700);
}

.blog-card-date {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-white-400);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 56px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-primary-800);
  border: 1px solid var(--color-primary-800);
  transition: all 0.2s ease;
}

.pagination a:hover {
  background: rgba(47, 64, 39, 0.08);
}

.pagination .current {
  background: var(--color-primary-800);
  color: var(--color-white);
  border-color: var(--color-primary-800);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  padding: 40px 0;
  border-top: 1px solid var(--color-white-200);
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-copyright {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-700);
}

.footer-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-primary-800);
  flex-shrink: 0;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-links a {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-primary-700);
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--color-primary-800);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .hero-title {
    font-size: 2.5rem;
    line-height: 1.2;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .primary-nav {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .primary-nav.is-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 80px;
    left: 0;
    width: 100%;
    background: var(--color-white);
    box-shadow: var(--shadow-nav);
    padding: 24px;
    gap: 8px;
    z-index: 99;
  }
}

@media (max-width: 768px) {
  .hero {
    min-height: 600px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .hero-search {
    max-width: 100%;
  }

  .stats-heading,
  .blog-header-title {
    font-size: 1.75rem;
  }

  .stat-number {
    font-size: 1.75rem;
  }

  .blog-toolbar {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .blog-search {
    width: 100%;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }

  .site-footer .container {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .header-actions {
    gap: 16px;
  }

  .header-divider,
  .header-search-btn {
    display: none;
  }
}

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

  .hero {
    min-height: 500px;
  }

  .hero-content {
    gap: 24px;
  }

  .category-filters {
    gap: 8px;
  }

  .cat-btn {
    padding: 6px 16px;
    font-size: 0.875rem;
  }
}

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