/* Guides: the list at /guides/, topic and author pages, and each article. Loaded only on those pages
   (build.py, GUIDE_ASSETS). Spacing uses one scale: --g-s1 (small) to --g-s4 (before a section heading). */
.guide-page {
  --g-col: 720px;            /* the article column: text, callouts, tables, code, figures, FAQ, author box */
  --g-side: 280px;           /* the sidebar */
  --g-page: 1100px;          /* article head and body share this width, centred */
  --g-header: 108px;         /* clears the floating site header for sticky and anchored things */
  --g-s1: .5rem; --g-s2: 1.1rem; --g-s3: 1.6rem; --g-s4: 2.6rem;
  --g-ok: #13804B; --g-ok-soft: #E9F7EF; --g-warn: #8A5300; --g-warn-soft: #FEF5E3; --g-note-soft: #EEF5FF;
}
@media (prefers-color-scheme: dark) {
  .guide-page { --g-ok: #5BD69A; --g-ok-soft: #0D2A22; --g-warn: #F5C46B; --g-warn-soft: #2A2110; --g-note-soft: #0F1E40; }
  .guide-page .lead { color: var(--muted); }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.guide-page) { scroll-behavior: auto; }
  .guide-page *, .guide-page *::before, .guide-page *::after { transition: none !important; }
}

/* ───────── Article head ───────── */
.guide-head { background: var(--hero-bg); padding: clamp(32px, 4.5vw, 56px) 0; border-bottom: 1px solid var(--rule); }
.guide-head .wrap, .guide-layout.wrap, .guide-related .wrap { width: min(var(--g-page), calc(100% - 48px)); }
.guide-head-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(28px, 4.5vw, 56px); align-items: center; }
.guide-head-grid.no-cover { grid-template-columns: minmax(0, 1fr); }
.guide-head-grid.no-cover > div { max-width: var(--g-col); }
.guide-head h1 { font-size: clamp(2rem, 3.5vw, 3rem); font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; color: var(--head); margin-bottom: .4em; overflow-wrap: break-word; }
.guide-head .lead { max-width: 54ch; margin-bottom: var(--g-s3); }
.guide-cover img { width: 100%; border-radius: 16px; box-shadow: var(--shadow-lift); }

.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 var(--g-s2); padding: 0; font-size: .88rem; }
.crumbs li { color: var(--muted); }
.crumbs li + li::before { content: "/"; margin: 0 9px; color: color-mix(in srgb, var(--muted) 55%, transparent); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--link); text-decoration: underline; }
.crumbs [aria-current] { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.guide-head .crumbs [aria-current] { display: none; }   /* the article's own title is the h1 right below */

/* Each item carries its dot on the left; the list is pulled left and clipped, so a wrapped line never starts with a dot */
.guide-meta { list-style: none; display: flex; flex-wrap: wrap; align-items: center; row-gap: 8px; margin: 0 0 0 -25px; padding: 0; font-size: .92rem; color: var(--muted); clip-path: inset(-4px -4px -4px 25px); }
.guide-meta li { position: relative; padding-left: 25px; }
.guide-meta li::before { content: ""; position: absolute; left: 10px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: currentColor; opacity: .45; }
.guide-meta a:not(.guide-cat) { color: var(--text); font-weight: 600; text-decoration: none; }
.guide-meta a:not(.guide-cat):hover { color: var(--link); text-decoration: underline; }
.guide-cat { display: inline-block; padding: 4px 12px; border-radius: 100px; background: color-mix(in srgb, var(--blue) 11%, transparent); color: var(--link); font-weight: 600; font-size: .84rem; text-decoration: none; }
.guide-cat:hover { background: color-mix(in srgb, var(--blue) 18%, transparent); }

/* ───────── Article layout: one column of text and a sidebar ───────── */
.guide-layout { display: grid; grid-template-columns: minmax(0, var(--g-col)) var(--g-side); justify-content: space-between;
  column-gap: 48px; padding: clamp(28px, 4vw, 44px) 0 clamp(56px, 6vw, 80px); align-items: start; }
.guide-article { min-width: 0; max-width: var(--g-col); }
.guide-side { position: sticky; top: var(--g-header); display: flex; flex-direction: column; gap: var(--g-s3); }

.toc-title { font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc { max-height: max(220px, calc(100vh - var(--g-header) - 330px)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.toc-list, .toc-list ol { list-style: none; margin: 0; padding: 0; }
.toc-list { border-left: 2px solid var(--rule); }
.toc-list a { display: block; margin-left: -2px; padding: 5px 0 5px 16px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; font-size: .9rem; line-height: 1.4; }
.toc-list ol a { padding-left: 30px; font-size: .86rem; }
.toc-list a:hover { color: var(--text); }
.toc-list a[aria-current="true"] { color: var(--link); border-left-color: var(--blue); font-weight: 600; }

.side-cta { padding: 20px; border-radius: 16px; background: linear-gradient(160deg, #0F2350, #0A3D99); color: #EEF2FD; box-shadow: var(--shadow); }
.side-cta-title { font-weight: 650; font-size: 1.02rem; margin: 0 0 6px; color: #fff; }
.side-cta p { font-size: .9rem; line-height: 1.5; color: #C3D0EE; margin-bottom: 14px; }
.side-cta .btn { width: 100%; justify-content: center; padding: 12px 18px; }
.side-cta-link { display: block; text-align: center; margin-top: 12px; font-size: .9rem; font-weight: 600; color: #7CCBFF; text-decoration: none; }
.side-cta-link:hover { text-decoration: underline; }

.toc-mobile { display: none; margin: 0 0 var(--g-s3); padding: 0; border: 1px solid var(--rule); border-radius: 14px; background: var(--card-soft); }
.toc-mobile summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::after { content: ""; font-size: 0; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: -4px; transition: transform .15s; }
.toc-mobile[open] summary { margin-bottom: 0; }
.toc-mobile[open] summary::after { content: ""; transform: rotate(-135deg); margin-top: 4px; }
.toc-mobile .toc-list { margin: 0 18px 16px; }

/* ───────── Article text: one vertical rhythm ───────── */
.prose { font-size: 1.06rem; line-height: 1.7; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose > * { max-width: none; }
.prose p { margin: 0 0 var(--g-s2); }
.prose h2 { font-size: clamp(1.5rem, 2.3vw, 1.85rem); font-weight: 550; letter-spacing: -0.022em; line-height: 1.2; color: var(--head);
  margin: var(--g-s4) 0 var(--g-s1); scroll-margin-top: var(--g-header); }
.prose > p:first-child + h2, .prose > p:first-child + p + h2 { margin-top: calc(var(--g-s4) * .75); }   /* right after the opening answer */
.prose h3 { font-size: 1.2rem; font-weight: 620; line-height: 1.3; margin: var(--g-s3) 0 var(--g-s1); scroll-margin-top: var(--g-header); }
.prose h2 + h3 { margin-top: var(--g-s2); }
.prose h4 { font-size: 1.03rem; font-weight: 650; margin: var(--g-s3) 0 .3rem; }
.prose a { font-weight: 500; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 var(--g-s2); }
.prose li { margin-bottom: .4em; }
.prose li > ul, .prose li > ol { margin: .4em 0 .2em; }
.prose li::marker { color: color-mix(in srgb, var(--blue) 70%, var(--muted)); }
.prose hr { border: 0; height: 1px; background: var(--rule); margin: var(--g-s4) 0; }
.prose strong { font-weight: 650; }
.prose blockquote { margin: var(--g-s3) 0; padding: 14px 20px; border-left: 3px solid var(--amber); background: var(--bg-soft); border-radius: 0 12px 12px 0; font-size: 1rem; color: var(--text); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { font: .86em var(--mono); background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--rule); overflow-wrap: anywhere; }
.prose kbd { display: inline-block; min-width: 1.7em; padding: 0 7px; font: 600 .8em/1.7 var(--font); text-align: center; color: var(--text); background: var(--card); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 6px; white-space: nowrap; }

/* Blocks share one top and bottom margin */
.prose .callout, .prose .code, .prose .table-wrap, .prose figure, .prose ol.gsteps, .prose .faq { margin: var(--g-s3) 0; }
.prose h2 + .callout, .prose h2 + .code, .prose h2 + .table-wrap, .prose h2 + figure, .prose h2 + ol.gsteps,
.prose h3 + .callout, .prose h3 + .code, .prose h3 + .table-wrap, .prose h3 + figure, .prose h3 + ol.gsteps { margin-top: var(--g-s2); }
.prose p + .code { margin-top: calc(var(--g-s1) * -1 + var(--g-s2)); }   /* a command sits close to the sentence introducing it */

/* Numbered steps */
.prose ol.gsteps { list-style: none; counter-reset: step; padding: 0; }
.prose ol.gsteps > li { counter-increment: step; position: relative; padding: 3px 0 0 48px; margin: 0 0 14px; min-height: 32px; }
.prose ol.gsteps > li:last-child { margin-bottom: 0; }
.prose ol.gsteps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 650; font-size: .9rem; display: grid; place-items: center; line-height: 1; }

/* Callouts */
.callout { padding: 14px 18px; border-radius: 12px; border: 1px solid; border-left-width: 4px; font-size: 1rem; line-height: 1.6; }
.callout > :last-child { margin-bottom: 0; }
.callout p { margin-bottom: var(--g-s1); }
.callout ol, .callout ul { margin-bottom: var(--g-s1); }
.callout .code { margin: var(--g-s1) 0; }
.callout-label { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 2px !important; }
.callout-note { background: var(--g-note-soft); border-color: color-mix(in srgb, var(--blue) 30%, transparent); border-left-color: var(--blue); }
.callout-note .callout-label { color: var(--link); }
.callout-tip { background: var(--g-ok-soft); border-color: color-mix(in srgb, var(--g-ok) 28%, transparent); border-left-color: var(--g-ok); }
.callout-tip .callout-label { color: var(--g-ok); }
.callout-warning { background: var(--g-warn-soft); border-color: color-mix(in srgb, var(--amber) 45%, transparent); border-left-color: var(--amber); }
.callout-warning .callout-label { color: var(--g-warn); }

/* Code and Terminal commands */
.code { border-radius: 12px; overflow: hidden; background: var(--night); border: 1px solid var(--panel-rule); }
.code-bar { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px 7px 16px; border-bottom: 1px solid #1E2A52; font-size: .76rem; font-weight: 600; letter-spacing: .04em; color: #9FB3DA; }
.code-copy { font: 600 .76rem var(--font); color: #DCE7FF; background: #15234A; border: 1px solid #2A3B6E; border-radius: 7px; padding: 4px 11px; cursor: pointer; }
.code-copy:hover { background: #1D2E5E; }
.code-copy:focus-visible { outline: 2px solid #7CCBFF; outline-offset: 2px; }
.code pre { margin: 0; padding: 14px 18px; overflow-x: auto; color: #DCE7FF; font: .88rem/1.65 var(--mono); tab-size: 4; }
.code pre code { background: none; border: 0; padding: 0; font: inherit; color: inherit; overflow-wrap: normal; }

/* Tables scroll inside their box when they don't fit */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 12px; }
.table-wrap:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: .93rem; line-height: 1.5; }
.table-wrap th, .table-wrap td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); min-width: 6.5em; }
.table-wrap th { background: var(--bg-soft); font-weight: 650; font-size: .88rem; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.table-wrap code { overflow-wrap: normal; white-space: normal; }

/* Images and screenshots: wide ones fill the column, tall ones are capped and centred */
.prose figure img { display: block; width: auto; max-width: 100%; max-height: 640px; margin: 0 auto; border-radius: 12px; border: 1px solid var(--rule); box-shadow: var(--shadow); }
.prose figcaption { margin-top: 10px; font-size: .88rem; line-height: 1.5; color: var(--muted); text-align: center; }
.gshot-todo div { aspect-ratio: 16 / 10; display: grid; place-items: center; border: 2px dashed color-mix(in srgb, var(--blue) 35%, var(--rule)); border-radius: 12px; background: var(--card-soft); }
.gshot-todo span { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* FAQ: expandable answers, the same width as the text */
.faq { border-top: 1px solid var(--rule); }
.faq details { background: none; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; padding: 0; margin: 0; }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 18px; padding: 16px 2px; font-weight: 620; font-size: 1.04rem; line-height: 1.4; }
.faq details[open] summary { margin-bottom: 0; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; font-size: 1.35rem; line-height: 1; color: var(--link); font-weight: 400; }
.faq details[open] summary::after { content: "\2212"; }
.faq summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.faq details > :not(summary) { margin-left: 2px; margin-right: 2px; }
.faq details > :last-child { margin-bottom: 18px; }

/* End of the article */
.tested-note { margin: var(--g-s4) 0 0; padding: 14px 18px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--rule); font-size: .92rem; line-height: 1.6; color: var(--muted); max-width: none; }
.tested-note strong { color: var(--text); }
.author-box { display: flex; gap: 16px; align-items: flex-start; margin: var(--g-s3) 0 0; padding: var(--g-s3) 0 0; border-top: 1px solid var(--rule); }
.author-box p { margin: 0; font-size: .93rem; line-height: 1.55; color: var(--muted); max-width: none; }
.author-box .author-box-name { font-size: 1rem; color: var(--text); font-weight: 650; }
.author-box-name span { font-weight: 400; color: var(--muted); }
.author-box-name a { color: var(--text); text-decoration: none; }
.author-box-name a:hover { color: var(--link); text-decoration: underline; }
.author-box .author-box-role { margin-bottom: 6px; font-size: .86rem; }
.avatar { flex: none; width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.avatar-mark { border-radius: 14px; }
.avatar-initials { display: grid; place-items: center; background: linear-gradient(160deg, #1A6CF0, #0B43B8); color: #fff; font-weight: 650; font-size: 1.1rem; letter-spacing: .02em; }

/* ───────── Related guides ───────── */
.guide-related { padding: clamp(44px, 5.5vw, 72px) 0; background: var(--bg-soft); border-top: 1px solid var(--rule); }
.guide-related h2 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); margin-bottom: 24px; }
.guide-related .center-link { margin: 28px 0 0; text-align: center; max-width: none; }

/* ───────── Guide cards ───────── */
.gcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 24px; }
.gcard { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--rule); border-radius: 16px; overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.gcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--blue) 40%, var(--rule)); }
.gcard:focus-visible, .gfeature:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.gcard-cover { aspect-ratio: 16 / 9; background: #0F2350; }
.gcard-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-none { display: grid; place-items: center; width: 100%; height: 100%; padding: 16px; background: linear-gradient(135deg, #0F2350, #0A47B0); color: #7CCBFF; font-weight: 700; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; text-align: center; }
.gcard-body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 20px; }
.gcard-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 0 0 8px; font-size: .82rem; color: var(--muted); max-width: none; }
.gcard-meta > span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; margin: 0 9px; vertical-align: middle; }
.gcard-cat { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--link); font-size: .74rem; }
.gcard-desc { margin: 0 0 14px; color: var(--muted); font-size: .95rem; line-height: 1.55; }
.gcard-more { margin-top: auto; font-weight: 600; font-size: .92rem; color: var(--link); }
.gcard-more::after { content: " \2192"; transition: margin .15s; }
.gcard:hover .gcard-more::after, .gfeature:hover .gcard-more::after { margin-left: 4px; }

/* ───────── List, topic and author pages ───────── */
.guides-head { padding-bottom: clamp(28px, 4vw, 44px); }
.guides-head .crumbs { margin-bottom: var(--g-s2); }
.gcount { margin: var(--g-s2) 0 0; font-size: .92rem; font-weight: 600; color: var(--muted); }
.guides-list { padding: clamp(32px, 4vw, 48px) 0 clamp(56px, 7vw, 96px); }
.gfeature { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); background: var(--card); border: 1px solid var(--rule); border-radius: 20px; overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s; }
.gfeature:hover { box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--blue) 40%, var(--rule)); }
.gfeature-cover { background: #0F2350; }
.gfeature-cover img { width: 100%; height: 100%; object-fit: cover; }
.gfeature-body { display: flex; flex-direction: column; justify-content: center; padding: clamp(24px, 3.4vw, 44px); }
.gfeature-body h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 550; line-height: 1.15; color: var(--head); margin-bottom: .5em; }
.gfeature-body p:not(.gcard-meta) { color: var(--muted); }
.gfeature .gcard-more { margin-top: 6px; }

.glist-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px 24px; margin: clamp(44px, 5vw, 64px) 0 24px; }
.glist-head h2, .gsection-title { font-size: clamp(1.5rem, 2.6vw, 2rem); margin: 0; }
.gsection-title { margin-bottom: 24px; }
.gtopics { display: flex; flex-wrap: wrap; gap: 8px; }
.gtopics a { font-weight: 600; font-size: .9rem; padding: 8px 15px; border-radius: 100px; border: 1px solid var(--rule); background: var(--card); color: var(--text); text-decoration: none; }
.gtopics a:hover { border-color: color-mix(in srgb, var(--blue) 45%, var(--rule)); color: var(--link); }
.gtopics a[aria-current="page"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.gother { margin-top: clamp(44px, 5vw, 64px); padding-top: clamp(28px, 3vw, 40px); border-top: 1px solid var(--rule); }
.gother h2 { font-size: 1.3rem; margin-bottom: 16px; }

.author-hero { display: flex; align-items: center; gap: 20px; margin-bottom: var(--g-s2); }
.author-hero .avatar { width: 96px; height: 96px; }
.author-hero .avatar-mark { border-radius: 22px; }
.author-hero .avatar-initials { font-size: 1.8rem; }
.author-hero h1 { margin: 0 0 4px; font-size: clamp(2rem, 4vw, 3rem); }
.author-role { margin: 0; color: var(--muted); font-weight: 600; }
.author-links { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; margin: var(--g-s2) 0 0; padding: 0; font-size: .92rem; }

/* ───────── Narrow screens ───────── */
@media (max-width: 980px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-article { max-width: var(--g-col); margin: 0 auto; width: 100%; }
  .guide-side { display: none; }
  .toc-mobile { display: block; }
}
@media (max-width: 860px) {
  .guide-head-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-head-grid > div:first-child { max-width: var(--g-col); }
  .guide-cover { max-width: 560px; }
  .gfeature { grid-template-columns: minmax(0, 1fr); }
  .gfeature-cover img { aspect-ratio: 16 / 9; }
}
@media (max-width: 560px) {
  .guide-page { --g-s3: 1.4rem; --g-s4: 2.2rem; }
  .prose { font-size: 1.02rem; }
  .prose ol.gsteps > li { padding-left: 44px; }
  .table-wrap th, .table-wrap td { min-width: 10em; }   /* scroll sideways rather than squeeze rows tall */
  .code pre { font-size: .82rem; padding: 12px 14px; }
  .author-hero { flex-direction: column; align-items: flex-start; }
}

/* ───────── Print: the article only, with link addresses ───────── */
@media print {
  .site-header, .site-footer, footer, .guide-side, .toc-mobile, .guide-related, .closing, .skip, .code-copy, .guide-cover { display: none !important; }
  .guide-page { background: #fff; color: #000; }
  .guide-head { background: none; border: 0; padding: 0 0 12pt; }
  .guide-head .wrap, .guide-layout.wrap { width: 100%; }
  .guide-layout { display: block; padding: 0; }
  .guide-article { max-width: none; }
  .prose { font-size: 11pt; line-height: 1.5; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #444; overflow-wrap: anywhere; }
  .code { background: #f4f4f4; border-color: #ccc; }
  .code pre { color: #000; white-space: pre-wrap; }
  .code-bar { color: #444; border-color: #ccc; }
  .callout, .code, .table-wrap, figure, .faq details, .author-box, .tested-note { break-inside: avoid; }
  .prose h2, .prose h3 { break-after: avoid; }
  .table-wrap { overflow: visible; }
  .prose figure img { box-shadow: none; max-height: 9cm; }
}
