/* Shared structural styles for both editions. Colors come entirely from the
   active theme file's token contract; this file never hard-codes brand colors. */

html { scroll-behavior: smooth; background: var(--bg); }

/* Themed scrollbars (desktop / precise pointers). Colors come from the token
   contract, so each edition + light/dark theme gets its own automatically:
   a muted thumb derived from --ink, brightening to the brand --accent on hover. */
@media (pointer: fine) {
  html { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 26%, transparent) transparent; }
  ::-webkit-scrollbar { width: 11px; height: 11px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 22%, transparent); border-radius: 7px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent); }
  ::-webkit-scrollbar-corner { background: transparent; }
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  transition: background .3s ease, color .3s ease;
  min-height: 100vh;
}

.page { display: flex; flex-direction: column; min-height: 100vh; position: relative; }
.container { max-width: 1180px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }
main { flex: 1; }

/* Opt-in vertical centering: a page wraps its content in `.page-center` to have
   it centered in the space between nav and footer. main already fills that space
   (flex:1 in the full-height .page); making it a column flex context lets the
   wrapper's auto block margins center it vertically. The wrapper itself stays a
   plain block, so its sections keep their normal full-width left-aligned flow. */
main:has(> .page-center) { display: flex; flex-direction: column; }
.page-center { margin-block: auto; }


h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.1; }
.eyebrow {
  font-family: var(--font-mono); font-size: 13.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--eyebrow);
}
.muted { color: var(--muted); }
.accent { color: var(--accent); }
code { color: var(--accent); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-weight: 600; font-size: 16px; padding: 13px 24px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: filter .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-gradient { background: linear-gradient(100deg, var(--accent), var(--accent2)); background-origin: border-box; color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--ink); background: none; }
/* Hover: subtle in-place feedback — no translate, so buttons don't jump.
   Each variant re-asserts its own text color; the global `a:hover` (reset.css)
   would otherwise recolor the label to --accent and tank contrast. */
.btn-primary:hover { color: var(--on-accent); filter: brightness(1.06); }
.btn-gradient:hover { color: #fff; filter: brightness(1.08); }
.btn-ghost:hover { color: var(--ink); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn-sm { padding: 9px 16px; font-size: 14.5px; border-radius: 8px; }

/* ---- cross-ref ribbon ---- */
.ribbon {
  position: relative; z-index: 61;
  background: var(--surface2); border-bottom: 1px solid var(--line);
}
.ribbon .container { padding-top: 9px; padding-bottom: 9px; text-align: center; font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.ribbon a { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ---- nav ---- */
.nav {
  position: sticky; top: -1px; z-index: 60;
  background: var(--navbg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 20px; height: 74px; }
/* Brand lockup: square glyph left of a name(+optional slogan) text block.
   Common pattern across logo variants — the glyph is sized to the text block's
   height: name-only for the plain variant, name+slogan for the stacked variant.
   --mark holds that height per variant. */
.brand { --mark: 15px; display: inline-flex; align-items: center; gap: 16px; margin-right: auto; color: var(--accent); }
.brand--stacked { --mark: 35px; }
.brand--lg { --mark: 17px; }
.brand--lg.brand--stacked { --mark: 37px; }
.brand__mark { display: flex; align-items: center; flex: none; }
/* glyph viewBox is 42x28 (tight to the artwork) -> width = height * 1.5 */
.brand__mark svg { height: var(--mark); width: calc(var(--mark) * 1.5); display: block; }
.brand__text { display: flex; flex-direction: column; justify-content: center; }
/* Brand name always uses the Flux (.com) display face so the logo is identical
   across editions, regardless of each theme's --font-display. */
.brand__name { font-family: 'Space Grotesk', system-ui, sans-serif; font-weight: 700; font-size: 19px; line-height: 1.05; letter-spacing: -.02em; color: var(--ink); }
.brand__slogan { font-family: var(--font-mono); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); line-height: 1.1; margin-top: 9px; white-space: nowrap; }
.brand--lg .brand__name { font-size: 21.5px; }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-link {
  font-family: var(--font-mono); font-size: 16.5px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px; color: var(--ink); white-space: nowrap;
}
.nav-link:hover { color: var(--accent); }
.nav-link.active { color: var(--accent); font-weight: 600; }
.nav-outline { border: 1px solid var(--line); padding: 8px 13px; border-radius: 8px; font-family: var(--font-mono); font-size: 16px; white-space: nowrap; }

.burger {
  display: none; width: 40px; height: 40px; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
}

/* mobile nav drawer */
.mobile-nav { display: none; border-top: 1px solid var(--line); background: var(--navbg); backdrop-filter: blur(14px); }
.mobile-nav.open { display: block; }
.mobile-nav .container { display: flex; flex-direction: column; padding-top: 8px; padding-bottom: 16px; }
.mobile-nav a { padding: 13px 6px; color: var(--ink); font-size: 17px; border-bottom: 1px solid var(--line); }
.mobile-nav a:last-child { border-bottom: none; }

/* ---- theme toggle (segmented) ---- */
.theme-toggle { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.theme-toggle button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; color: var(--muted);
}
.theme-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 24px; }
/* Card titles sit directly under the page H1, so they are <h2>; h3 kept for any
   card markup still using it. */
.card h2, .card h3 { font-size: 20.5px; margin-bottom: 8px; font-weight: 700; }
.card p { font-size: 16px; color: var(--muted); line-height: 1.6; }
/* Clickable cards get the same accent-border hover as .post-card (blog) and
   .api-ref-card (/api/) — same transition, same token, so all three match.
   Scoped to `a.card`: the plain <div class="card"> feature blocks on / and the
   principle blocks on /intro/ are not links, and hover feedback on something
   that cannot be clicked is misleading. */
a.card { transition: border-color .15s ease; }
a.card:hover { border-color: var(--accent); text-decoration: none; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.section { padding-top: 44px; padding-bottom: 44px; }
/* container-query context (kept for any component that opts into @container) */
.section-label { font-family: var(--font-mono); font-size: 13.5px; letter-spacing: .16em; color: var(--muted); margin-bottom: 20px; }

/* ---- footer ---- */
.footer { border-top: 1px solid var(--line); background: var(--surface2); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; padding-top: 48px; padding-bottom: 30px; }
.footer h4 { font-family: var(--font-mono); color: var(--muted); letter-spacing: .1em; font-size: 13.5px; margin-bottom: 12px; font-weight: 600; text-transform: uppercase; }
.footer-links { display: flex; flex-direction: column; gap: 9px; font-size: 15px; }
.footer-links a:hover { color: var(--accent); }
.footer-brand-desc { font-size: 15px; color: var(--muted); line-height: 1.6; max-width: 260px; margin-top: 4px; }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-top: 18px; padding-bottom: 40px; border-top: 1px solid var(--line); font-size: 16.5px; color: var(--muted); }

/* ---- tutorial layout (chapter sidebar + content) ---- */
.tut-layout { display: grid; grid-template-columns: 240px 1fr; gap: 44px; align-items: start; }
.tut-side { position: sticky; top: 90px; font-family: var(--font-mono); font-size: 14.5px; }
.tut-side .lbl { color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-size: 13.5px; margin-bottom: 14px; }
.tut-ch { display: block; padding: 10px 12px; border-radius: 8px; color: var(--muted); margin-bottom: 2px; }
.tut-ch:hover { color: var(--accent); }
.tut-ch.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.tut-nav { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); margin-top: 36px; padding-top: 22px; }
.tut-nav a { font-family: var(--font-mono); font-size: 14.5px; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; color: var(--ink); }
.tut-nav a:hover { border-color: var(--accent); color: var(--accent); }
.tut-nav .next { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.tut-nav .next:hover { color: var(--on-accent); }
@media (max-width: 860px) {
  .tut-layout { grid-template-columns: minmax(0, 1fr); }
  .tut-side { position: static; margin-bottom: 24px; }
}

/* ---- responsive (media queries) ---- */
/* Nav collapses to the burger *before* its items would run out of room and wrap.
   The com (Flux) nav carries more items than org (Terminal), so each edition
   switches at its own measured width. */
@media (max-width: 1000px) {
  [data-skin="flux"] .nav-links, [data-skin="flux"] .nav-actions { display: none; }
  [data-skin="flux"] .burger { display: inline-flex; }
}
@media (max-width: 1000px) {
  [data-skin="terminal"] .nav-links, [data-skin="terminal"] .nav-actions { display: none; }
  [data-skin="terminal"] .burger { display: inline-flex; }
}
/* ≤760px = content mobile layout */
@media (max-width: 760px) {
  .nav-links, .nav-actions { display: none; }
  .burger { display: inline-flex; }
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  /* Shrink headings whose size a template sets INLINE — post.html, docs.html,
     cli.html, mcp.html, tutorial.html, /intro/, the blog and topic hubs, the com
     heroes, 404 — at 34-46px they are far too big on a phone. `!important` is
     the only thing that beats a style attribute, which is why it is here.

     Everything in :not() owns its own size and must keep it. Three of them own an
     explicit MOBILE size that this rule was silently overriding — .prose h1/h2
     (prose.css:195-196), .hero h1 (org/index.html) and .fx-h2/.fx-thanks h2
     (flux.css:142,118) — so those media queries had no effect at all. The
     component ones were the visible damage: .aside-box h2 and .blog-archive h2
     are 13.5px uppercase mono labels and were rendering at 29.5px, so every blog
     post showed "Written by" and the sidebar headings at section-heading size,
     and .card/.post-card titles were as large as the sections containing them.

     .fx-h1 is deliberately NOT excluded: the com heroes carry an inline 44-46px
     that beats flux.css's own 38px mobile rule, so this is what shrinks them. */
  h1:not(.prose h1, .hero h1) { font-size: 38.5px !important; }
  h2:not(.prose h2, .card h2, .post-card h2, .aside-box h2, .blog-archive h2, .fx-h2, .fx-thanks h2) { font-size: 29.5px !important; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---- image lightbox (click a screenshot to view it full size) ---- */
html.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 4vmin;
  background: color-mix(in srgb, var(--bg) 82%, #000); backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }
.lightbox__fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; max-height: 100%; }
.lightbox__img {
  max-width: min(92vw, 1100px); max-height: 86vh; width: auto; height: auto;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5); cursor: default;
}
.lightbox__cap { font-family: var(--font-mono); font-size: 14.5px; color: var(--muted); text-align: center; }
.lightbox__cap[hidden] { display: none; }
.lightbox__close {
  position: fixed; top: 16px; right: 18px; width: 42px; height: 42px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 25px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox__close:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Blog ------------------------------------------------------------- */
.blog-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 40px; align-items: start; }
/* minmax(0,…), not a bare 1fr: `1fr` floors at the content's min-content width,
   so a wide child (code block, table) stretches the track past the viewport. */
@media (max-width: 900px) { .blog-layout { grid-template-columns: minmax(0, 1fr); } }

.post-list { display: flex; flex-direction: column; gap: 18px; }
.post-card { display: flex; flex-direction: column; gap: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; text-decoration: none; color: inherit; transition: border-color .15s ease; }
.post-card:hover { border-color: var(--accent); }
.post-card-meta { font-family: var(--font-mono); font-size: 13.5px; color: var(--muted); margin: 0; }
.post-card-meta a { color: var(--accent); text-decoration: none; }
/* Card titles are <h2>: they are the page's top-level content under the H1, and
   as <h3> they made /blog/ and the author pages skip H1->H3. h3 kept in the
   selector for any card markup still using it. */
.post-card h2, .post-card h3 { font-size: 25px; margin: 0; line-height: 1.25; letter-spacing: -.01em; font-weight: 700; }
.post-card-art { border-radius: 8px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); padding: 24px 0; display: flex; justify-content: center; }
.post-card-art .post-illu { width: 100%; max-width: 480px; height: auto; display: block; }
.post-hero { border-radius: 12px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); margin-bottom: 24px; padding: 28px 0; display: flex; justify-content: center; }
.post-hero .post-illu { width: 100%; max-width: 560px; height: auto; display: block; }
.post-card p { font-size: 17px; color: var(--muted); line-height: 1.6; margin: 0; }
.post-card-more { font-family: var(--font-mono); font-size: 14.5px; color: var(--accent); }

.blog-aside { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 88px; }
.aside-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
/* Sidebar box headings are <h2>: they are page-level sections, and as <h4> they
   made every post's outline skip H2->H4. h4 kept in the selector so any
   not-yet-migrated markup keeps the same look. */
.aside-box h2, .aside-box h4 { font-family: var(--font-mono); font-size: 13.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.aside-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.aside-links a { color: var(--ink); text-decoration: none; font-size: 16px; line-height: 1.4; }
.aside-links a:hover { color: var(--accent); }
.aside-links .meta { display: block; font-family: var(--font-mono); font-size: 12.5px; color: color-mix(in srgb, var(--muted) 68%, var(--bg)); margin-top: 3px; }

.blog-search input { width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); font-family: var(--font-mono); font-size: 16px; }
.blog-search input:focus { outline: none; border-color: var(--accent); }
.search-results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.search-results:empty { display: none; }
.search-results a { display: block; color: var(--ink); text-decoration: none; font-size: 16px; line-height: 1.4; }
.search-results a:hover { color: var(--accent); }
.search-results .meta { display: block; font-family: var(--font-mono); font-size: 12.5px; color: color-mix(in srgb, var(--muted) 68%, var(--bg)); margin-top: 3px; }
.search-note { font-size: 14.5px; color: var(--muted); margin: 10px 0 0; }
.search-note[hidden] { display: none; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 34px; font-family: var(--font-mono); font-size: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; min-width: 38px; height: 38px; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.pagination .disabled { opacity: .4; pointer-events: none; }

.post-layout { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 44px; align-items: start; }
/* See .blog-layout above: a bare `1fr` let long `pre` lines widen the whole page. */
@media (max-width: 900px) { .post-layout { grid-template-columns: minmax(0, 1fr); } }
.post-byline { display: flex; align-items: center; gap: 12px; margin: 4px 0 0; }
.post-byline .avatar-svg { width: 42px; height: 42px; display: block; flex: 0 0 auto; }
.post-byline .who a { color: var(--accent); text-decoration: none; font-weight: 600; }
.post-byline .role { font-family: var(--font-mono); font-size: 13.5px; color: var(--muted); }
.post-aside { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 20px; }
.post-aside .post-illu { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); }

.author-hero { display: grid; grid-template-columns: 120px 1fr; gap: 26px; align-items: center; margin-top: 22px; }
@media (max-width: 560px) { .author-hero { grid-template-columns: 1fr; } }
.author-hero-avatar svg, .author-hero-avatar img { width: 120px; height: 120px; display: block; }
.author-chip { display: inline-flex; align-items: center; gap: 8px; }
.author-chip svg, .author-chip img { width: 26px; height: 26px; }
.avatar-img { border-radius: 50%; object-fit: cover; display: block; }
.post-byline .avatar-img { width: 42px; height: 42px; flex: 0 0 auto; }
.aside-authors a { display: flex; align-items: center; gap: 11px; }
.aside-authors .avatar-img { width: 36px; height: 36px; flex: 0 0 auto; }
.aside-authors .who { min-width: 0; }

/* ---- breadcrumbs -------------------------------------------------------- */
/* Rendered trail matching the BreadcrumbList JSON-LD (see breadcrumbs.html). */
.crumbs { font-family: var(--font-mono); font-size: 13px; margin: 0 0 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; line-height: 1.4; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { color: var(--muted); }
.crumbs span[aria-current] { color: var(--muted); }

/* ---- blog topic taxonomy ----------------------------------------------- */
.topic-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.topic-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12.5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; white-space: nowrap; }
a.topic-chip:hover { border-color: var(--accent); color: var(--accent); }
.topic-chip > span { color: var(--muted); font-size: 11.5px; }
.topic-chip--flat { color: var(--muted); }

/* ---- blog archive ------------------------------------------------------ */
.blog-archive { margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--line); }
.blog-archive h2 { font-family: var(--font-mono); font-size: 13.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 18px; font-weight: 600; }
.blog-archive h3 { font-family: var(--font-mono); font-size: 15px; color: var(--muted); margin: 22px 0 8px; font-weight: 500; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { display: flex; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px dashed color-mix(in srgb, var(--line) 60%, transparent); }
.archive-list a { color: var(--ink); text-decoration: none; font-size: 15.5px; }
.archive-list a:hover { color: var(--accent); }
.archive-list .meta { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); margin-left: auto; white-space: nowrap; }
