/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --text: #1a1a1b;
  --text-muted: #6a6d6f;
  --bg: #ffffff;
  --bg-alt: #f6f7f8;
  --border: #e2e4e6;
  --accent: #0b5fbf;
  --accent-hover: #094a96;
  --code-bg: #f2f3f5;
  --callout-bg: #fff8e6;
  --callout-border: #e8c667;
  --max-width: 760px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 17px;
}

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

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

/* ---------- Layout shell ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-logo span { color: var(--accent); }

.site-nav { display: flex; gap: 24px; }

.site-nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.site-nav a:hover { color: var(--text); text-decoration: none; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 32px 20px 48px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer a { color: var(--text-muted); text-decoration: underline; }

/* ---------- Homepage ---------- */
.hero {
  max-width: 1000px;
  margin: 0 auto;
  padding: 56px 20px 32px;
}

.hero h1 {
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 620px;
}

.post-grid {
  max-width: 1000px;
  margin: 0 auto;
  padding: 8px 20px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.post-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

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

.post-card__eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 8px;
}

.post-card h2 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  line-height: 1.35;
}

.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--accent); text-decoration: none; }

.post-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-grow: 1;
}

.post-card__meta {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- Article page ---------- */
.article {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 20px 24px;
}

.article__eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 14px;
}

.article h1 {
  font-size: 2rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 14px;
}

.article__meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.article-body {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 40px;
}

.article-body h2 {
  font-size: 1.4rem;
  margin: 40px 0 14px;
  letter-spacing: -0.01em;
}

.article-body h3 {
  font-size: 1.15rem;
  margin: 28px 0 10px;
}

.article-body p { margin-bottom: 18px; }

.article-body ul,
.article-body ol {
  margin: 0 0 18px 1.3em;
}

.article-body li { margin-bottom: 8px; }

.article-body code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.article-body strong { font-weight: 700; }

/* Quick-reference tables used in every post.
   Wrapped in .ref-table-wrap so wide tables scroll horizontally
   on narrow screens instead of squashing/overflowing. */
.ref-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0 28px;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.92rem;
}

.ref-table th,
.ref-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.ref-table th {
  background: var(--bg-alt);
  font-weight: 700;
}

/* Callout box for warnings / "when to stop DIY" notes */
.callout {
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 24px 0;
  font-size: 0.95rem;
}

.callout strong { display: block; margin-bottom: 4px; }

/* Affiliate link marker — transparency without being spammy */
.aff {
  border-bottom: 1px dashed var(--accent);
}

.aff::after {
  content: " (affiliate)";
  font-size: 0.75em;
  color: var(--text-muted);
  border: none;
}

/* Ad slot placeholders — swap for real ad network embed later */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-muted);
  text-align: center;
  padding: 28px 16px;
  margin: 32px 0;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Disclosure banner shown at the top of every post */
.disclosure-banner {
  max-width: var(--max-width);
  margin: 0 auto 32px;
  padding: 14px 18px;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.disclosure-banner a { font-weight: 600; }

/* Related posts */
.related {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding: 24px 20px 0;
  border-top: 1px solid var(--border);
}

.related h3 { font-size: 1rem; margin-bottom: 12px; }

/* ---------- 3-column page layout (sidebars for ads + cross-promo) ---------- */
.page-layout {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 28px;
  align-items: start;
  padding: 0 20px;
}

.main-col { min-width: 0; }

.sidebar {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 32px;
}

.sidebar-ad {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-muted);
  text-align: center;
  padding: 16px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-ad--tall { min-height: 480px; }
.sidebar-ad--square { min-height: 220px; }

.sidebar-promo {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.sidebar-promo h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sidebar-promo ul { list-style: none; }

.sidebar-promo li { margin-bottom: 14px; }
.sidebar-promo li:last-child { margin-bottom: 0; }

.sidebar-promo a {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.sidebar-promo a:hover { color: var(--accent); text-decoration: none; }

.sidebar-promo p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Large desktop: give sidebars a bit more room for wider ad units (300px-class) */
@media (min-width: 1400px) {
  .page-layout { grid-template-columns: 220px minmax(0, 1fr) 220px; }
}

/* Tablet and below: collapse to a single column. Content reads before ads/promo
   (better for actual visitors, since the grid is in DOM order left-sidebar ->
   main -> right-sidebar and we don't want two ad blocks above the article). */
@media (max-width: 980px) {
  .page-layout { grid-template-columns: 1fr; }
  .main-col { order: 1; }
  .sidebar-left { order: 2; }
  .sidebar-right { order: 3; }
  .sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding-top: 0;
    justify-content: center;
  }
  .sidebar-ad, .sidebar-promo {
    flex: 1 1 240px;
    max-width: 340px;
  }
  .sidebar-ad--tall { min-height: 160px; }
  .post-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* Small tablet / large phone */
@media (max-width: 768px) {
  .hero { padding: 40px 20px 24px; }
  .article { padding: 36px 20px 20px; }
  .site-header__inner { padding: 14px 20px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .hero h1 { font-size: 1.6rem; }
  .article h1 { font-size: 1.5rem; }
  .site-nav { gap: 14px; }
  .post-grid { grid-template-columns: 1fr; }
  .sidebar-ad, .sidebar-promo { flex-basis: 100%; max-width: none; }
}

/* Very small phones (iPhone SE / older Android, ~360px and below) */
@media (max-width: 400px) {
  .site-logo { font-size: 1rem; }
  .site-nav { gap: 10px; }
  .site-nav a { font-size: 0.88rem; }
  .hero, .article, .article-body, .post-grid, .page-layout { padding-left: 14px; padding-right: 14px; }
  .ref-table th, .ref-table td { padding: 8px 9px; font-size: 0.86rem; }
}
