/* =====================================================================
   History Bypass — layout fixes + motion layer
   Loaded last on every page so it wins over page-level <style> blocks.
   ===================================================================== */

/* ---------- 1. LAYOUT FIXES ---------- */

/* Stacked section headers (label / title / description) */
.section-header:has(.section-label),
.section-header:has(.section-desc) {
  flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 8px;
}
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--accent); display: inline-flex; align-items: center; gap: 10px;
}
.section-label::before { content: ''; width: 28px; height: 1px; background: var(--accent); }
.section-desc { color: var(--text-muted); font-size: 15px; max-width: 620px; }

/* Grids that left orphan cards */
.tools-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important; }
.series-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important; }
@media (min-width: 1100px) { .series-grid { grid-template-columns: repeat(3, 1fr) !important; } }

/* Today bar stacks on phones */
@media (max-width: 640px) {
  .today-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* Blog sidebar newsletter */
.newsletter-mini { display: flex; flex-direction: column; gap: 10px; }
.newsletter-mini input {
  width: 100%; background: #0b0b0b; border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 13px; color: var(--text); font: inherit; font-size: 14px;
}
.newsletter-mini input:focus { outline: none; border-color: var(--accent); }

/* Toasts fully hidden until shown */
.toast { opacity: 0; visibility: hidden; transition: transform .35s cubic-bezier(.2,.9,.3,1.2), opacity .25s, visibility .25s !important; }
.toast.show { opacity: 1; visibility: visible; }

/* Buttons that were missing base styles on sub-pages */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px; border-radius: 8px;
  background: var(--accent); color: #0b0b0b; font-weight: 600; font-size: 14px; border: 1px solid var(--accent);
  cursor: pointer; transition: transform .2s, background .2s;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-secondary { background: transparent; color: var(--accent); }
.btn-secondary:hover { background: var(--accent-muted); }

img { max-width: 100%; }
.thumb-wrap img, .short-thumb img, .video-thumb img, .hero-featured-video img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* ---------- 2. WORLD MAP ---------- */
.world-map {
  position: relative; width: 100%; aspect-ratio: 1000 / 389;
  background: radial-gradient(ellipse at 50% 45%, rgba(255,45,32,.10), transparent 70%), var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
.world-map-full { margin-bottom: 2rem; }
.world-map .wm-dots { position: absolute; inset: 0; width: 100%; height: 100%; }
.world-map .wm-scan {
  position: absolute; top: 0; bottom: 0; width: 18%;
  background: linear-gradient(90deg, transparent, rgba(255,45,32,.14), transparent);
  animation: wmScan 7s linear infinite; pointer-events: none;
}
@keyframes wmScan { from { left: -20%; } to { left: 105%; } }
.world-map .wm-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: linear-gradient(rgba(255,45,32,.08) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,45,32,.08) 1px, transparent 1px);
  background-size: 8.33% 12.85%;
  animation: gridDrift 30s linear infinite;
}
.wm-marker {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(11,11,11,.8), 0 0 18px rgba(255,210,31,.8);
  cursor: pointer; z-index: 2; transition: transform .25s, opacity .3s; border: 0; padding: 0;
}
.wm-marker::before, .wm-marker::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent);
  animation: wmPulse 2.4s ease-out infinite; animation-delay: var(--d, 0s);
}
.wm-marker::after { animation-delay: calc(var(--d, 0s) + 1.2s); }
@keyframes wmPulse { from { transform: scale(.5); opacity: .9; } to { transform: scale(2.6); opacity: 0; } }
.wm-marker:hover, .wm-marker.hot { transform: scale(1.45); z-index: 4; }
.wm-marker.dim { opacity: .12; pointer-events: none; }
.wm-tip {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%) translateY(6px);
  background: #0b0b0b; border: 1px solid var(--accent); color: var(--text); font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; font-family: var(--font-body);
}
.wm-marker:hover .wm-tip, .wm-marker.hot .wm-tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.wm-arc { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.wm-arc path { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-opacity: .55;
  stroke-dasharray: 4 6; animation: arcFlow 1.6s linear infinite; vector-effect: non-scaling-stroke; }
@keyframes arcFlow { to { stroke-dashoffset: -20; } }
.world-map-caption {
  position: absolute; left: 20px; bottom: 16px; z-index: 3; display: flex; flex-direction: column; gap: 2px;
  background: rgba(11,11,11,.72); backdrop-filter: blur(6px); border: 1px solid var(--border);
  padding: 10px 14px; border-radius: 10px;
}
.world-map-caption strong { font-family: var(--font-head); font-size: 17px; color: var(--text); }
.world-map-caption span { font-size: 12px; color: var(--text-muted); }
.place-card.flash { animation: cardFlash 1.4s ease; }
@keyframes cardFlash { 0%,100% { box-shadow: none; } 30% { box-shadow: 0 0 0 2px var(--accent), 0 0 40px rgba(255,45,32,.45); } }
@media (max-width: 640px) { .world-map-caption { display: none; } .wm-marker { width: 10px; height: 10px; margin: -5px 0 0 -5px; } }

/* ---------- 3. MOTION LAYER ---------- */

/* Scroll progress bar */
#hb-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 1000; pointer-events: none;
  background: linear-gradient(90deg, #b3120a, var(--accent), #ffd21f, var(--accent));
  background-size: 200% 100%; animation: shimmerMove 3s linear infinite;
  transform-origin: 0 50%; transform: scaleX(0);
}
@keyframes shimmerMove { to { background-position: -200% 0; } }

/* Page entrance */
body { animation: pageIn .6s ease both; }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }

/* Announcement bar shimmer sweep */
#announcement-bar { position: relative; overflow: hidden; }
#announcement-bar::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 120px; left: -150px; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent);
  animation: barSweep 5s ease-in-out infinite;
}
@keyframes barSweep { 0%, 55% { left: -150px; } 100% { left: 110%; } }

/* Sticky nav condenses on scroll */
nav { transition: background .3s, box-shadow .3s, backdrop-filter .3s; }
nav.scrolled { background: rgba(11,11,11,.82) !important; backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.nav-links > li > a { position: relative; }
.nav-links > li > a::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 4px; height: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .3s ease; transform-origin: left;
}
.nav-links > li:hover > a::after, .nav-links > li.active > a::after { transform: scaleX(1); }
.dropdown { animation: none; }
.nav-links > li:hover .dropdown { animation: dropIn .25s ease both; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.btn-subscribe { position: relative; animation: subPulse 2.8s ease-in-out infinite; }
@keyframes subPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(204,0,0,.55); } 50% { box-shadow: 0 0 0 9px rgba(204,0,0,0); } }

/* Hero backgrounds: drifting glow + moving grid + embers */
.hero, .about-hero, .watch-hero, .explore-hero, .timeline-hero, .map-hero, .learn-hero,
.community-hero, .blog-hero, .page-hero { position: relative; overflow: hidden; isolation: isolate; }
.hb-fx { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.hb-fx .glow {
  position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(60px); opacity: .55;
  background: radial-gradient(circle, rgba(255,45,32,.28), transparent 65%);
  animation: glowDrift 18s ease-in-out infinite alternate;
}
.hb-fx .glow.g2 { right: -20vmax; bottom: -30vmax; background: radial-gradient(circle, rgba(160,60,30,.22), transparent 65%); animation-duration: 23s; animation-direction: alternate-reverse; }
.hb-fx .glow.g1 { left: -20vmax; top: -30vmax; }
@keyframes glowDrift { from { transform: translate(0,0) scale(1); } to { transform: translate(14vmax, 8vmax) scale(1.15); } }
.hb-fx .grid {
  position: absolute; inset: -60px; opacity: .5;
  background-image: linear-gradient(rgba(255,45,32,.07) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,45,32,.07) 1px, transparent 1px);
  background-size: 60px 60px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
  animation: gridDrift 14s linear infinite;
}
@keyframes gridDrift { from { transform: translate(0,0); } to { transform: translate(60px,60px); } }
.hb-fx canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Gold shimmer on accent words in headings */
.hero h1 em, .section-title span {
  background: linear-gradient(100deg, var(--accent) 20%, #ffd21f 40%, var(--accent) 60%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; animation: textShine 5s linear infinite;
}
@keyframes textShine { from { background-position: 150% 0; } to { background-position: -100% 0; } }

/* Hero headline word rise */
.hb-word { display: inline-block; opacity: 0; transform: translateY(.55em) rotate(2deg); animation: wordRise .8s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes wordRise { to { opacity: 1; transform: none; } }

/* Featured hero video float + ring */
.hero-featured-video { animation: floatY 6s ease-in-out infinite; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.play-btn { animation: playRing 2.2s ease-out infinite; }
@keyframes playRing { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.55); } 100% { box-shadow: 0 0 0 26px rgba(255,255,255,0); } }

/* Today-in-history ticker */
.today-bar { position: relative; overflow: hidden; }
.today-bar::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,45,32,.12), transparent);
  animation: wmScan 9s linear infinite; width: 30%;
}
.today-label::first-letter { display: inline-block; }
.today-event.swap { animation: eventSwap .6s ease; }
@keyframes eventSwap { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Scroll reveal (only when JS is running) */
.hb-js .reveal { opacity: 0; transform: translateY(34px); transition: opacity .8s cubic-bezier(.2,.8,.2,1), transform .8s cubic-bezier(.2,.8,.2,1); transition-delay: var(--rd, 0s); }
.hb-js .reveal.from-left { transform: translateX(-40px); }
.hb-js .reveal.from-right { transform: translateX(40px); }
.hb-js .reveal.zoom { transform: scale(.92); }
.hb-js .reveal.in { opacity: 1; transform: none; }

/* Card hover: lift, tilt, shine sweep, thumbnail zoom */
.video-card, .video-card-lg, .topic-card, .tool-card, .place-card, .article-card, .series-card,
.short-card, .suggestion-card, .tier-card, .mission-pillar, .map-place, .featured-article, .sidebar-box,
.sidebar-widget, .topic-grid > *, .era-card {
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s, border-color .35s !important;
  will-change: transform;
}
.hb-tilt { transform-style: preserve-3d; }
.video-card:hover, .video-card-lg:hover, .topic-card:hover, .tool-card:hover, .place-card:hover,
.article-card:hover, .series-card:hover, .short-card:hover, .tier-card:hover, .mission-pillar:hover {
  box-shadow: 0 22px 50px rgba(0,0,0,.55), 0 0 0 1px rgba(255,45,32,.45); border-color: rgba(255,45,32,.5) !important;
}
.hb-shine { position: relative; overflow: hidden; }
.hb-shine::after {
  content: ''; position: absolute; top: -50%; bottom: -50%; left: -60%; width: 40%; pointer-events: none; z-index: 3;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.16), transparent);
  transform: skewX(-20deg); transition: left .8s ease;
}
.hb-shine:hover::after { left: 130%; }
.thumb-wrap, .short-thumb, .video-thumb { overflow: hidden; }
.thumb-wrap img, .short-thumb img, .video-thumb img { animation: kenBurns 16s ease-in-out infinite alternate; transition: transform .6s; }
.video-card:hover img, .video-card-lg:hover img, .short-card:hover img { transform: scale(1.08); }
@keyframes kenBurns { from { object-position: 50% 45%; } to { object-position: 50% 55%; } }
.topic-icon, .tool-icon, .tier-emoji, .pillar-icon, .map-place-icon, .article-thumb span, .series-icon {
  display: inline-block; transition: transform .45s cubic-bezier(.3,1.6,.5,1);
}
.topic-card:hover .topic-icon, .tool-card:hover .tool-icon, .place-card:hover .hb-glyph,
.tier-card:hover .tier-emoji, .mission-pillar:hover .pillar-icon, .map-place:hover .map-place-icon {
  transform: scale(1.22) rotate(-8deg);
}
.topic-icon { animation: bob 4.5s ease-in-out infinite; animation-delay: var(--bd, 0s); }
@keyframes bob { 0%,100% { translate: 0 0; } 50% { translate: 0 -6px; } }

/* Buttons: shine sweep */
.btn-primary, .btn-primary-lg, .btn, .tool-btn, .contact-submit, .tier-btn, .nav-cta {
  position: relative; overflow: hidden;
}
.btn-primary::before, .btn-primary-lg::before, .btn::before, .tool-btn::before, .contact-submit::before, .tier-btn::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -80%; width: 50%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent); transform: skewX(-20deg);
  animation: btnSweep 4.5s ease-in-out infinite;
}
@keyframes btnSweep { 0%, 70% { left: -80%; } 100% { left: 140%; } }
.btn-primary-lg:hover, .btn-outline:hover { transform: translateY(-3px); }

/* Filter pills / tabs: animated active state */
.filter-btn, .cat-btn, .region-tab, .era-tab, .tab-btn, .status-tab, .support-tab, .period-tab {
  transition: background .25s, color .25s, transform .2s, border-color .25s !important;
}
.filter-btn:hover, .cat-btn:hover, .region-tab:hover, .era-tab:hover, .tab-btn:hover { transform: translateY(-2px); }
.filter-btn.active, .cat-btn.active, .region-tab.active, .era-tab.active, .tab-btn.active { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.08); } }

/* Filtered items animate back in */
.hb-filter-in { animation: filterIn .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes filterIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }

/* Timeline: line draws itself as you scroll */
.tl-line-fill {
  position: absolute; left: 50%; top: 0; width: 3px; margin-left: -1.5px; z-index: 0; pointer-events: none;
  background: linear-gradient(var(--accent), #ffd21f); box-shadow: 0 0 14px rgba(255,45,32,.7);
  transform-origin: top; transform: scaleY(0); height: 100%;
}
.timeline-item .t-dot { animation: dotGlow 2.4s ease-in-out infinite; }
@keyframes dotGlow { 50% { box-shadow: 0 0 0 6px rgba(255,45,32,.18), 0 0 16px rgba(255,45,32,.6); } }

/* Shorts row auto-scroll marquee feel */
.shorts-row { scroll-behavior: smooth; }

/* Quiz option feedback */
.quiz-option, .quiz-opt { transition: transform .2s, background .2s, border-color .2s !important; }
.quiz-option:hover, .quiz-opt:hover { transform: translateX(6px); }
.quiz-option.correct, .quiz-opt.correct { animation: pop .4s ease; }
.quiz-option.wrong, .quiz-opt.wrong { animation: shake .4s ease; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

/* Vote count bump */
.vote-count.bump { animation: pop .35s ease; }

/* Floating scroll-top */
#scroll-top { transition: transform .3s, opacity .3s !important; }
#scroll-top.visible { animation: floatY 3s ease-in-out infinite; }

/* Stat numbers glow while counting */
.hb-counting { text-shadow: 0 0 18px rgba(255,45,32,.6); }

/* Respect reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .hb-js .reveal { opacity: 1; transform: none; }
}

/* Map list ↔ marker hover link */
.map-place.hb-hover, .place-card.hb-hover { border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent), 0 14px 40px rgba(0,0,0,.5); }

/* Map card emblem: keep its centered block layout, animate the glyph only */
.hb-glyph { display: inline-block; transition: transform .45s cubic-bezier(.3,1.6,.5,1); animation: bob 4.5s ease-in-out infinite; animation-delay: var(--bd, 0s); }

/* Learn page: quiz question is a question, not a label */
#quizQ { text-transform: none !important; letter-spacing: 0 !important; color: var(--text) !important;
  font-family: var(--font-head) !important; font-size: clamp(19px, 2.2vw, 24px) !important; font-weight: 600; line-height: 1.4; }

/* ---------- Operator notice + footer credit ---------- */
.hb-indie {
  background: #0a0907; color: var(--text-muted); font-size: 12px; text-align: center;
  padding: 7px 16px; border-bottom: 1px solid var(--border); letter-spacing: .2px; line-height: 1.5;
}
.hb-indie a { color: var(--accent); text-decoration: none; font-weight: 600; }
.hb-indie a:hover { text-decoration: underline; }
.footer-grid { grid-template-columns: 1.6fr repeat(4, 1fr) !important; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr !important; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr !important; } }
.footer-disclaimer {
  font-size: 12px; color: var(--text-dim, #737373); line-height: 1.65; max-width: 820px;
  margin: 28px 0 0;
}
.footer-bottom p a { color: var(--accent); text-decoration: none; }
