/* ============================================
   Renn Driver CSS - Shared base styles
   Loaded on every page (header, footer, typography, nav)
   Page-specific styles are in src/styles/ and imported per-page
   ============================================ */

:root {
  --ast-global-color-0: #C0392B; /* Primary red */
  --ast-global-color-1: #A93226; /* Link red */
  --ast-global-color-2: #0F172A; /* Dark navy - headings */
  --ast-global-color-3: #454F5E; /* Body text */
  --ast-global-color-4: #F5F0EF; /* Warm light bg */
  --ast-global-color-5: #FFFFFF; /* White */
  --ast-global-color-6: #E0D5D3; /* Muted warm */
  --ast-global-color-7: #181823; /* Near black */
  --ast-global-color-8: #222222; /* Dark text alt */
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
  font-family: 'Poppins', 'Poppins Fallback', sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.65em;
  color: var(--ast-global-color-3);
  background: var(--ast-global-color-5);
  -webkit-font-smoothing: antialiased;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  color: var(--ast-global-color-2);
  margin-bottom: 20px;
}

h1 { font-family: 'Poppins', 'Poppins Fallback', sans-serif; font-size: 2.222rem; font-weight: 500; line-height: 1.4em; }
h2 { font-family: 'Be Vietnam Pro', 'Be Vietnam Pro Fallback', sans-serif; font-size: 1.778rem; font-weight: 500; line-height: 1.3em; }
h3 { font-family: 'Be Vietnam Pro', 'Be Vietnam Pro Fallback', sans-serif; font-size: 1.389rem; font-weight: 500; line-height: 1.3em; }
h4 { font-family: 'Be Vietnam Pro', 'Be Vietnam Pro Fallback', sans-serif; font-size: 1.333rem; font-weight: 500; line-height: 1.2em; }
h5 { font-family: 'Be Vietnam Pro', 'Be Vietnam Pro Fallback', sans-serif; font-size: 1.111rem; font-weight: 500; line-height: 1.2em; }
h6 { font-family: 'Be Vietnam Pro', 'Be Vietnam Pro Fallback', sans-serif; font-size: 0.778rem; font-weight: 500; line-height: 1.25em; }

p { margin-bottom: 1em; }
a { color: var(--ast-global-color-1); text-decoration: none; transition: color 0.2s; }
a:hover, a:focus { color: var(--ast-global-color-2); }
img { max-width: 100%; height: auto; }
ul, ol { margin: 0 0 1em 1.5em; }
li { margin-bottom: 0.4em; }
strong { font-weight: 600; }

blockquote {
  border-left: 4px solid var(--ast-global-color-0);
  padding: 1em 1.5em;
  margin: 1.5em 0;
  background: var(--ast-global-color-4);
  font-style: italic;
}

table { width: 100%; border-collapse: collapse; margin: 0 auto 1.5em; }
th, td { padding: 0.75em 1em; border: 1px solid #e6e6e6; text-align: left; }
th { background: var(--ast-global-color-2); color: white; font-weight: 500; }

/* ---- Header ---- */
.site-header {
  position: sticky; top: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  z-index: 100; transition: box-shadow 0.3s;
}
.ast-primary-header-bar { max-width: 1200px; margin: 0 auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; min-height: 0; }
.site-branding .custom-logo { max-width: 200px; height: auto; display: block; }
.site-navigation { display: none; }
@media (min-width: 922px) {
  .site-navigation { display: block; }
  .mobile-menu-trigger { display: none; }
}
.main-header-menu { list-style: none; display: flex; gap: 0; margin: 0; padding: 0; }
.main-header-menu li { margin-bottom: 0; }
.main-header-menu .menu-link { display: block; padding: 10px 20px; font-size: 0.889rem; font-weight: 500; color: var(--ast-global-color-2); transition: color 0.2s; }
.main-header-menu .menu-link:hover { color: var(--ast-global-color-0); }
.main-header-menu .menu-link.active { color: var(--ast-global-color-0); }

/* Dropdown submenu */
.main-header-menu .has-submenu { position: relative; }
.main-header-menu .submenu { display: none; position: absolute; top: 100%; left: 0; list-style: none; margin: 0; padding: 0.25rem 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 0.5rem; box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 140px; z-index: 100; }
.main-header-menu .has-submenu:hover .submenu { display: block; }
.main-header-menu .submenu li { margin: 0; }
.main-header-menu .submenu a { display: block; padding: 0.5rem 1.25rem; font-size: 0.85rem; font-weight: 500; color: var(--ast-global-color-2); white-space: nowrap; transition: background 0.15s, color 0.15s; }
.main-header-menu .submenu a:hover { background: #f3f4f6; color: var(--ast-global-color-0); }

.mobile-menu-trigger { background: none; border: none; cursor: pointer; padding: 8px; color: var(--ast-global-color-2); }
.mobile-menu { background: var(--ast-global-color-5); border-top: 1px solid #e6e6e6; padding: 16px 20px; }
.mobile-menu.hidden { display: none; }
.mobile-menu ul { list-style: none; margin: 0; padding: 0; }
.mobile-menu li { margin-bottom: 0; }
.mobile-menu a { display: block; padding: 10px 0; font-size: 0.889rem; font-weight: 500; color: var(--ast-global-color-2); border-bottom: 1px solid #f0f0f0; }

/* ---- Main Content ---- */
.site-main { min-height: 60vh; }
.post-article { padding: 40px 0 60px; }
.ast-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.content-area { max-width: 750px; margin: 0 auto; }
.entry-title { font-size: 2.222rem; margin-bottom: 10px; }
.post-meta { display: flex; align-items: center; justify-content: space-between; color: #999; font-size: 0.833rem; margin-bottom: 2em; }
.post-meta-right { display: flex; align-items: center; gap: 4px; }

/* Entry content (article body) */
.entry-content { line-height: 1.65em; overflow-wrap: break-word; word-wrap: break-word; }
.entry-content iframe { max-width: 100%; }
.entry-content pre, .entry-content code { overflow-x: auto; max-width: 100%; }
.entry-content h2 { margin-top: 1em; }
.entry-content h3 { margin-top: 0.75em; }
.entry-content h4 { margin-top: 0.75em; }
.entry-content img { display: block; max-width: 100%; height: auto; margin: 1.5em auto; }
.entry-content img.alignnone { display: block; margin: 1em 0; }
.entry-content img.aligncenter { display: block; margin: 1.5em auto; }
.entry-content img.alignleft { float: left; margin: 0 1.5em 1em 0; }
.entry-content img.alignright { float: right; margin: 0 0 1em 1.5em; }
.entry-content hr { border: none; border-top: 1px solid #e6e6e6; margin: 2em 0; }
.entry-content ul { padding-left: 4em; margin-left: 0; list-style-position: outside; }
.entry-content li { margin-bottom: 0.5em; }

/* Table of Contents */
#toc_container { background: #fff; border: 1px solid #edf0f3; border-radius: 14px; padding: 22px 26px; margin: 1.5em 0 1.25em; display: block; width: 100%; box-sizing: border-box; box-shadow: 0 2px 14px rgba(15,23,42,.07); }
#toc_container .toc_title { font-family: 'Be Vietnam Pro', 'Be Vietnam Pro Fallback', sans-serif; font-weight: 600; font-size: 1.1rem; color: var(--ast-global-color-2); margin-bottom: 0; }
#toc_container .toc_title .toc_toggle { font-weight: 400; font-size: 0.85rem; color: var(--ast-global-color-1); cursor: pointer; margin-left: 4px; }
#toc_container .toc_title .toc_toggle:hover { text-decoration: underline; }
#toc_container.collapsed .toc_list { display: none; }
#toc_container:not(.collapsed) .toc_title { margin-bottom: 14px; }
/* 2 columns on desktop fills the width; tight line-height beats the inherited 1.65em that bloated the gaps. Columns scoped to the TOP list only (sub-list is also .toc_list). */
#toc_container .toc_list { margin: 0; padding: 0; list-style: none; }
#toc_container > .toc_list { columns: 2; column-gap: 34px; }
#toc_container > .toc_list > li { margin: 0 0 9px; line-height: 1.35; break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid; }
#toc_container .toc_list a { font-size: 0.875rem; line-height: 1.35; }
#toc_container .toc_number { color: var(--ast-global-color-0); font-weight: 600; margin-right: 6px; }
/* nested sub-list renders as <ol class="toc_list"> — indent it under its parent */
#toc_container .toc_list .toc_list { margin: 5px 0 6px; padding-left: 22px; }
#toc_container .toc_list .toc_list > li { margin: 0 0 5px; line-height: 1.3; break-inside: avoid; }

/* WP blocks compatibility */
.wp-block-heading { margin-top: 1.5em; }
.wp-block-list { margin-bottom: 1.5em; }
.wp-block-image { margin: 1.5em 0; }
.wp-block-image img { border-radius: 4px; }
.wp-block-image figcaption { text-align: center; font-size: 0.833rem; color: #999; margin-top: 8px; }

/* Historical / archival images — smaller display, centered, italic caption */
.entry-content figure.historical-img { display: block; max-width: 420px; margin: 1.5em auto; text-align: center; }
.entry-content figure.historical-img img { display: block; border-radius: 4px; max-width: 100%; height: auto; margin: 0 auto; }
.entry-content figure.historical-img figcaption { font-size: 0.833rem; color: #777; margin-top: 8px; font-style: italic; line-height: 1.4; }
@media (max-width: 767px) { .entry-content figure.historical-img { max-width: 300px; } }
.wp-block-table { margin: 1.5em 0; }
.wp-block-table table { width: 100%; }
.wp-block-separator { border: none; border-top: 1px solid #e6e6e6; margin: 2em 0; }
.wp-block-quote { border-left: 4px solid var(--ast-global-color-0); padding: 1em 1.5em; margin: 1.5em 0; background: var(--ast-global-color-4); }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid #e6e6e6; margin-top: 60px; }
.site-primary-footer-wrap { background: #f9f9f9; padding: 45px 0; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; }
.footer-inner--centered { flex-direction: column; align-items: center; gap: 20px; }
.footer-menu { list-style: none; display: flex; gap: 24px; margin: 0; padding: 0; }
.footer-menu .menu-link { font-size: 0.833rem; font-weight: 500; color: var(--ast-global-color-2); }
.footer-social-wrap { display: flex; gap: 20px; align-items: center; }
.social-link { display: inline-flex; align-items: center; justify-content: center; transition: opacity 0.2s, transform 0.2s; }
.social-link svg { width: 32px; height: 32px; }
.social-link:hover { transform: scale(1.1); opacity: 0.8; }
.social-link--facebook { color: #1877F2; }
.social-link--youtube { color: #FF0000; }
.social-link--instagram { color: #E4405F; }
.site-below-footer-wrap { padding: 20px 0; border-top: 1px solid #e6e6e6; }
.ast-footer-copyright p { font-size: 0.778rem; color: #999; margin: 0; text-align: center; }

/* ---- Responsive ---- */
@media (max-width: 767px) {
  html { font-size: 16px; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }
  .footer-inner { flex-direction: column; gap: 20px; text-align: center; }
  .content-area { padding: 0 16px; }
  /* Tighten the top of the article on mobile: less dead space above the title, tighter title line-height + byline gap */
  .post-article { padding: 18px 0 40px; }
  .entry-title { font-size: 1.8rem; line-height: 1.18; margin-bottom: 8px; }
  .post-meta { margin-bottom: 1.1em; }

  /* Tables scroll sideways on mobile via a .table-scroll wrapper (added by wrap-tables.js on every page).
     The WRAPPER owns the horizontal scroll; the table keeps normal layout with a min-width floor so the
     columns never squeeze. Never clamp thead/tbody/tr to width:100% and never word-break cells — that is
     the bug that kept recurring (Codex-reviewed 2026-07-01). */
  .entry-content .table-scroll { display: block; width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1.5em 0; }
  .entry-content .table-scroll > table { width: 100%; min-width: 42rem; max-width: none; margin: 0; }
  /* Fallback before the JS wraps (or if JS is off): a bare content table still scrolls as a block. */
  .entry-content > table, .entry-content .wp-block-table > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .entry-content th, .entry-content td { padding: 0.5em 0.6em !important; font-size: 0.85rem; white-space: normal; overflow-wrap: normal; word-break: normal; }

  /* Break long URLs and technical strings — but NOT inside table cells (that splits "402 hp" onto two lines) */
  .entry-content p, .entry-content li { overflow-wrap: break-word; word-break: break-word; }

  /* Headings: prevent overflow */
  h1, h2, h3 { overflow-wrap: break-word; }

  /* TOC: single column on phones (2-col would crowd), tight padding, no overflow */
  #toc_container { overflow-wrap: break-word; padding: 16px 18px; }
  #toc_container > .toc_list { columns: 1; }
  #toc_container .toc_list a { word-break: break-word; }

  /* Quick answer box: tighter padding + line-height on mobile */
  .quick-answer { padding: 13px 15px; line-height: 1.5; }

  /* Override inline fixed-width styles */
  .entry-content img { max-width: 100% !important; height: auto !important; }
  .entry-content [style*="width"] { max-width: 100% !important; }
}
@media (max-width: 921px) {
  .site-navigation { display: none; }
  .mobile-menu-trigger { display: block; }
}

/* Responsive embed (YouTube etc) */
.ast-oembed-container, .wp-block-embed__wrapper { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; }
.ast-oembed-container iframe, .wp-block-embed__wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* WordPress artifact cleanup */
.ql-block { margin-bottom: 1em; }
.ql-heading { margin-top: 1.5em; }
[data-color] { color: inherit !important; }
.wp-block-uagb-image, .wp-block-uagb-container { display: contents; }
.uagb-google-map__wrap { display: none; }

/* Quick answer box */
.quick-answer { background: #f0f7ff; border-left: 4px solid #2563eb; padding: 16px 20px; margin: 20px 0; border-radius: 6px; }
/* collapse the first/last child margins so the box isn't padded twice (was the wasted top/bottom space) */
.quick-answer > :first-child { margin-top: 0; }
.quick-answer > :last-child { margin-bottom: 0; }

/* FAQ questions are H4: heading then answer right below. More space above (separates from the prior answer), tight below. */
.entry-content h4 { font-size: 1.15rem; line-height: 1.3; margin: 1.5em 0 0.35em; }
.entry-content h4 + p { margin-top: 0; }
