/* =========================================================
   Wonders: the hub (/wonders.html) and every topic page.
   Each topic sets four colors in its .11tydata.json:
     hero        dark background of the header band (white text sits on it)
     glow        bright highlight used on the dark band only
     accent      accent on light pages; must pass 4.5:1 on white
     accentDark  accent in dark mode; must pass 4.5:1 on #1f2431
   Everything else comes from the site's own tokens, so menus,
   Dark mode, Hide images and focus styles match the rest of the site.
   ========================================================= */

/* ---------- Wider page for topic pages (card grids need the room) ---------- */
.page-wonder .layout { width: min(100% - 1rem, 72rem); }
.page-wonder .content .container,
.page-wonder main .container { width: min(100% - 1.5rem, 64rem); max-width: none; }
.page-wonder .content { padding-top: 1rem; }
@media (min-width: 56rem) {
  .page-wonder .layout { width: min(100% - 2rem, 72rem); }
  .page-wonder .content .container { width: min(100% - 4rem, 64rem); }
}

.wonder { --w: var(--w-accent); }
:root[data-theme="dark"] .wonder,
:root[data-theme="dark"] .wonder-card { --w: var(--w-accent-dark); }
.wonder-card { --w: var(--w-accent); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Header band: the topic's personality ---------- */
.wonder-head {
  display: grid;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border-radius: 0.75rem;
  color: #ffffff;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--w-glow) 28%, transparent) 0%, transparent 55%),
    var(--w-hero);
}
.wonder-head h1 {
  margin: 0.25rem 0 0;
  color: #ffffff;
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);
  line-height: 1.15;
}
.wonder-head-hero { padding-block: 1.75rem; }
.wonder-head-hero h1 { font-size: clamp(2.1rem, 1.5rem + 3vw, 3.2rem); }
@media (min-width: 46rem) {
  .wonder-head-hero { grid-template-columns: 1fr minmax(10rem, 15rem); }
}
.glow-text { color: var(--w-glow); }
.wonder-eyebrow {
  margin: 0.5rem 0 0;
  color: var(--w-glow);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wonder-crumbs ol {
  display: flex; flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin: 0; padding: 0;
  list-style: none;
  font-size: 0.95rem;
}
.wonder-crumbs li + li { margin-top: 0; }
.wonder-crumbs li + li::before { content: "›"; margin-right: 0.5rem; color: #c9d1e3; }
.wonder-crumbs a { color: #ffffff; text-decoration-color: currentColor; }
.wonder-crumbs a[aria-current="page"] { text-decoration: none; font-weight: 600; }
.wonder-head a:focus-visible { outline: 3px solid #ffd600; outline-offset: 2px; }

.wonder-art { justify-self: center; width: 100%; max-width: 15rem; }
.wonder-art svg { display: block; width: 100%; height: auto; }

@media (prefers-reduced-motion: no-preference) {
  .wonder-art .glow-pulse { animation: w-glow 6s ease-in-out infinite; transform-origin: center; }
  .wonder-art .drift { animation: w-drift 9s ease-in-out infinite; }
}
@keyframes w-glow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes w-drift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- Topic menu ---------- */
.wonder-nav { margin: 0 0 1.75rem; }
.wonder-nav-list {
  display: flex; flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0; padding: 0;
  list-style: none;
}
.wonder-nav-list li { flex: 0 1 auto; }
.wonder-nav-list li + li { margin-top: 0; }
.wonder-nav-list a {
  display: block;
  min-height: 44px;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
}
.wonder-nav-list a:hover { background: var(--surface-alt); text-decoration: underline; }
.wonder-nav-list a[aria-current="page"] {
  border: 2px solid var(--w);
  background: var(--surface-alt);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--w);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.3em;
}
.wonder-nav-list a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Body building blocks (the class list Grok writes to) ---------- */
.wonder-body h2 { margin-top: 2rem; }
.wonder-body h3 { margin: 0 0 0.5rem; font-size: 1.3rem; }
.wonder-body .prose { max-width: 46rem; }
.wonder-body p.prose { max-width: 46rem; }
.wonder-body .section { margin-top: 2.5rem; }
.lead { font-size: 1.2em; line-height: 1.55; }
.muted { color: var(--text-muted); }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.25rem 0 0; }
.button {
  display: inline-flex; align-items: center;
  min-height: 48px;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--w);
  border-radius: 0.5rem;
  background: var(--w);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
}
:root[data-theme="dark"] .button { color: var(--w-hero); }
.button-secondary { background: transparent; color: var(--text); }
:root[data-theme="dark"] .button-secondary { color: var(--text); }
.button:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.card-grid li + li { margin-top: 0; }
.card {
  height: 100%;
  padding: 1.1rem 1.25rem 1.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-top: 4px solid var(--w);
  border-radius: 0.6rem;
  font-size: 1.05rem;
}
.card > :last-child { margin-bottom: 0; }
.card p { margin: 0.5rem 0 0; }
.card-icon {
  display: block;
  width: 3.5rem; height: 3.5rem;
  margin-bottom: 0.6rem;
  padding: 0.35rem;
  border-radius: 0.6rem;
  background: var(--w-hero);
}

.facts-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.85rem;
  margin: 0.5rem 0;
  font-size: 0.95em;
}
.facts-list dt { font-weight: 600; }
.facts-list dd { margin: 0; }
@media (max-width: 30rem) {
  .facts-list { grid-template-columns: 1fr; }
  .facts-list dd { margin-bottom: 0.4rem; }
}

.toc {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  max-width: 46rem;
}
.toc h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.toc ul { margin: 0; }

.wonder-body .callout {
  /* The site's own callout (dark field, white text), in this topic's colors */
  margin: 2.5rem 0 0;
  padding: 1.25rem 1.5rem;
  max-width: 46rem;
  background: var(--w-hero);
  color: #ffffff;
  border: 0;
  border-left: 6px solid var(--w-glow);
  border-radius: 0 0.6rem 0.6rem 0;
}
.wonder-body .callout h2 { margin-top: 0; font-size: 1.3rem; color: #ffffff; }
.wonder-body .callout a { color: #ffffff; text-decoration-color: currentColor; }
.wonder-body .callout a:focus-visible { outline: 3px solid #ffd600; outline-offset: 2px; }

/* Glow facts */
.fact-number {
  margin: 0 0 0.25rem !important;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.fact h2 { margin: 0 0 0.25rem; font-size: 1.25rem; }
.fact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-top: 0.85rem; }
.share-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--w);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer;
}
.share-btn[hidden] { display: none; }
.share-btn:hover { background: var(--surface-hover); }
.share-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.share-status {
  position: sticky; bottom: 1rem;
  margin: 1rem 0 0;
  padding: 0.6rem 1rem;
  background: var(--w-hero);
  color: #ffffff;
  border-radius: 0.5rem;
  font-weight: 600;
}
.share-status:empty { display: none; }

.wonder-foot {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1rem;
}

/* ---------- Hub cards ---------- */
.wonder-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
  list-style: none;
}
.wonder-list li + li { margin-top: 0; }
.wonder-card {
  position: relative;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-top: 5px solid var(--w);
  border-radius: 0.6rem;
}
.wonder-card img {
  display: block;
  width: 100%; height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--w-hero);
}
.wonder-card-body { padding: 1rem 1.25rem 1.25rem; }
.wonder-card-topic {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.wonder-card h2 { margin: 0.2rem 0 0.4rem; font-size: 1.6rem; }
.wonder-card h2 a { text-decoration: none; }
.wonder-card h2 a::after { content: ""; position: absolute; inset: 0; }
.wonder-card p { margin: 0; font-size: 1.05rem; line-height: 1.5; }
.wonder-card:hover { background: var(--surface-hover); }
.wonder-card:hover h2 a,
.wonder-card h2 a:focus-visible { text-decoration: underline; text-decoration-thickness: 2px; }
.wonder-card:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.wonder-card h2 a:focus-visible { outline: none; }

/* ---------- Hide images (site toggle): decorative art goes too ---------- */
.hide-images .wonder-art,
.hide-images .card-icon { display: none; }

/* ---------- Windows Contrast Themes ---------- */
@media (forced-colors: active) {
  .wonder-head, .card, .toc, .callout, .wonder-card, .share-status { border: 1px solid CanvasText; }
  .wonder-nav-list a, .button, .share-btn { border: 2px solid ButtonText; }
  .wonder-nav-list a[aria-current="page"] { border: 3px solid Highlight; }
  .wonder-card:focus-within { outline: 3px solid Highlight; }
}

@media print {
  .wonder-nav, .wonder-art, .share-btn, .button-row { display: none; }
  .wonder-head { color: #000; background: none; border: 1px solid #000; }
  .wonder-head h1, .wonder-crumbs a { color: #000; }
}
