/*
Theme Name: HIB Newspaper
Theme URI: https://homeimprovementbox.com
Author: Home Improvement Box
Description: Custom news/magazine theme for Home Improvement Box. Serif/sans editorial typography, sticky nav, trending sidebar, AJAX infinite scroll, dark mode, and hardened output escaping throughout.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: hib-newspaper
*/

/* ==========================================================================
   1. DESIGN TOKENS
   ========================================================================== */
:root{
  --font-headline: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Merriweather', Georgia, 'Times New Roman', serif;

  --color-bg: #ffffff;
  --color-surface: #f7f5f2;
  --color-text: #1a1a1a;
  --color-text-muted: #5b5b5b;
  --color-border: #e3e0da;
  --color-accent: #b3311f;      /* masthead red */
  --color-accent-dark: #8a2418;
  --color-link: #1a1a1a;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;

  --max-width: 1240px;
  --radius: 4px;
  --nav-height: 64px;
}

[data-theme="dark"]{
  --color-bg: #121212;
  --color-surface: #1b1b1b;
  --color-text: #ececec;
  --color-text-muted: #a8a8a8;
  --color-border: #2e2e2e;
  --color-accent: #e2604d;
  --color-accent-dark: #ff7a63;
  --color-link: #f2f2f2;
}

img{ max-width: 100%; height: auto; display: block; }
a{ color: var(--color-link); text-decoration: none; }
a:hover{ text-decoration: underline; }
*, *::before, *::after{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body{
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.75;
  transition: background .2s ease, color .2s ease;
}
h1,h2,h3,h4,h5,h6{
  font-family: var(--font-headline);
  line-height: 1.2;
  font-weight: 800;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
p{ margin: 0 0 var(--space-3); }
.container{
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-2);
}
.screen-reader-text{
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px,1px,1px,1px); white-space: nowrap;
}
.site-header{
  position: sticky; top: 0; z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.site-header__top{
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-height);
  gap: var(--space-3);
}
.site-branding a{
  font-family: var(--font-headline);
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.primary-nav{ display: flex; }
.primary-nav ul{
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: var(--space-3); flex-wrap: wrap;
}
.primary-nav a{
  font-family: var(--font-headline);
  font-weight: 700; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--color-text);
  padding: var(--space-1) 0;
}
.primary-nav a:hover{ color: var(--color-accent); text-decoration: none; }
.header-actions{ display: flex; align-items: center; gap: var(--space-2); }
.search-form{ display: flex; align-items: center; }
.search-form__input{
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: .45rem .75rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9rem;
  width: 180px;
}
.theme-toggle{
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 999px;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem;
}
.theme-toggle:hover{ border-color: var(--color-accent); }
.mobile-nav-toggle{
  display: none;
  border: 0; background: transparent; font-size: 1.5rem; cursor: pointer;
  color: var(--color-text);
}
@media (max-width: 860px){
  .primary-nav{
    display: none;
    position: absolute; left: 0; right: 0; top: var(--nav-height);
    background: var(--color-bg); border-bottom: 1px solid var(--color-border);
    padding: var(--space-2);
  }
  .primary-nav.is-open{ display: block; }
  .primary-nav ul{ flex-direction: column; gap: var(--space-2); }
  .mobile-nav-toggle{ display: inline-flex; min-width: 44px; min-height: 44px; align-items:center; justify-content:center; }
  .search-form__input{ width: 120px; }
}
.hero{
  display: grid; gap: var(--space-3);
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.hero__figure{ margin: 0; border-radius: var(--radius); overflow: hidden; max-height: 420px; }
.hero__figure img{ width: 100%; height: 420px; object-fit: cover; display: block; }
.hero__kicker{
  font-family: var(--font-headline); text-transform: uppercase;
  letter-spacing: .08em; font-size: .8rem; font-weight: 800;
  color: var(--color-accent); margin-bottom: var(--space-1);
}
.hero__title{ font-size: clamp(1.9rem, 4vw, 3.2rem); margin-bottom: var(--space-2); }
.hero__excerpt{ color: var(--color-text-muted); font-size: 1.15rem; max-width: 62ch; }
.hero__meta{ font-size: .85rem; color: var(--color-text-muted); }
.content-layout{
  display: grid; gap: var(--space-4);
  grid-template-columns: minmax(0,1fr);
  padding-block: var(--space-4);
}
@media (min-width: 960px){
  .content-layout{ grid-template-columns: minmax(0,2.1fr) minmax(280px, 1fr); }
}
.story-grid{
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.story-card{ border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-3); }
.story-card__figure{ margin: 0 0 var(--space-2); border-radius: var(--radius); overflow: hidden; max-height: 220px; }
.story-card__figure img{ width: 100%; height: 220px; object-fit: cover; display: block; }
.story-card__category{
  font-family: var(--font-headline); font-size: .75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; color: var(--color-accent);
}
.story-card__title{ font-size: 1.25rem; margin: var(--space-1) 0; }
.story-card__excerpt{ color: var(--color-text-muted); font-size: .95rem; }
.story-card__meta{ font-size: .8rem; color: var(--color-text-muted); }
.widget-area{ display: flex; flex-direction: column; gap: var(--space-4); }
.widget{
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.widget__title{
  font-size: .95rem; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 2px solid var(--color-accent); padding-bottom: var(--space-1);
  margin-bottom: var(--space-2);
}
.trending-list{ list-style: none; margin: 0; padding: 0; counter-reset: trend; }
.trending-list li{
  counter-increment: trend;
  display: flex; gap: var(--space-2); align-items: baseline;
  padding-block: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.trending-list li:last-child{ border-bottom: 0; }
.trending-list li::before{
  content: counter(trend);
  font-family: var(--font-headline); font-weight: 900; font-size: 1.3rem;
  color: var(--color-accent); min-width: 1.4rem;
}
.trending-list a{ font-weight: 700; }
.hib-breadcrumbs{
  font-size: .8rem; color: var(--color-text-muted);
  padding-top: var(--space-2);
}
.hib-breadcrumbs a{ color: var(--color-text-muted); }
.hib-breadcrumbs a:hover{ color: var(--color-accent); }
.single-article__header{ padding-block: var(--space-4) var(--space-2); border-bottom: 1px solid var(--color-border); }
.single-article__title{ font-size: clamp(1.8rem, 3.5vw, 2.6rem); }
.single-article__byline{ color: var(--color-text-muted); font-size: .9rem; }
.single-article__figure{ margin: var(--space-3) 0; max-height: 480px; overflow: hidden; border-radius: var(--radius); }
.single-article__figure img{ width: 100%; height: 480px; object-fit: cover; display: block; }
.single-article__body{ max-width: 70ch; font-size: 1.15rem; }
.single-article__body p{ margin-bottom: var(--space-3); }
.single-article__footer{
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-4); padding-top: var(--space-3);
  display: flex; flex-wrap: wrap; gap: var(--space-2);
}
.tag-pill{
  border: 1px solid var(--color-border); border-radius: 999px;
  padding: .25rem .75rem; font-size: .8rem; font-family: var(--font-headline);
}
.next-up{
  border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: var(--space-3); margin-top: var(--space-4);
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-2);
}
.next-up__label{ font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); }
.next-up__title{ font-size: 1.15rem; margin: 0; }
.newsletter-box{
  background: var(--color-accent); color: #fff;
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-block: var(--space-4);
}
.newsletter-box *{ color: #fff; }
.newsletter-box__title{ margin-bottom: var(--space-1); }
.newsletter-box form{
  display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap;
}
.newsletter-box input[type="email"]{
  flex: 1 1 220px; min-height: 44px;
  padding: .6rem .8rem; border-radius: var(--radius); border: 0; font-size: 1rem;
}
.newsletter-box button{
  min-height: 44px; padding: .6rem 1.4rem; border-radius: var(--radius);
  border: 2px solid #fff; background: transparent; color: #fff; font-weight: 800;
  cursor: pointer; font-family: var(--font-headline); text-transform: uppercase; letter-spacing: .04em;
}
.newsletter-box button:hover{ background: #fff; color: var(--color-accent-dark); }
.newsletter-box__status{ margin-top: var(--space-1); font-size: .9rem; }
.newsletter-box--footer{ background: var(--color-surface); color: var(--color-text); }
.newsletter-box--footer *{ color: var(--color-text); }
.newsletter-box--footer button{ border-color: var(--color-accent); color: var(--color-accent); }
.newsletter-box--footer button:hover{ background: var(--color-accent); color: #fff; }
.site-footer{
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-5);
  margin-top: var(--space-5);
}
.footer-grid{
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.footer-grid h3{ font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; }
.footer-grid ul{ list-style: none; margin: 0; padding: 0; }
.footer-grid li{ margin-bottom: var(--space-1); }
.site-footer__bottom{
  text-align: center; color: var(--color-text-muted); font-size: .85rem;
  margin-top: var(--space-4); padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.infinite-scroll-sentinel{ height: 1px; }
.infinite-scroll-loader{
  text-align: center; padding: var(--space-3); color: var(--color-text-muted);
  font-family: var(--font-headline); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em;
  display: none;
}
.infinite-scroll-loader.is-active{ display: block; }
a, button, input, .tag-pill{ min-height: 24px; }
.primary-nav a, .theme-toggle, .newsletter-box button, .mobile-nav-toggle{
  min-height: 44px; display: inline-flex; align-items: center;
}
@media (max-width: 600px){
  body{ font-size: 1rem; }
  .single-article__body{ font-size: 1.05rem; }
}
