/* Rsquared Academy course ads: canonical stylesheet (spec: pm/notes/2026-11-29-course-ads-spec.md).
   Bar, navbar button, course card and footer block. Light colours only, no JavaScript. */
.rsa-course-bar {
  display: block; box-sizing: border-box; width: 100%; position: static;
  background: #1d4ed8; color: #ffffff; text-align: center; text-decoration: none;
  font-family: inherit; font-size: 15px; line-height: 1.4; font-weight: 500;
  padding: 10px 16px; margin: 0;
}
.rsa-course-bar:hover, .rsa-course-bar:focus-visible { background: #1e40af; color: #ffffff; text-decoration: none; }
.rsa-course-bar:focus-visible { outline: 2px solid #ffffff; outline-offset: -4px; }
.rsa-course-bar-cta { font-weight: 700; }
.rsa-course-bar:hover .rsa-course-bar-cta, .rsa-course-bar:focus-visible .rsa-course-bar-cta { text-decoration: underline; }
@media (max-width: 600px) { .rsa-course-bar { font-size: 14px; padding: 8px 12px; } }

/* Sites with a fixed navbar (pkgdown BS5 reserves 56px above main/aside for it): the bar sits just below
   the navbar and takes over that reserved space, so the navbar never covers it and nothing shifts twice. */
body:has(> .navbar.fixed-top) > .rsa-course-bar { margin-top: 56px; }
body:has(> .navbar.fixed-top) > .rsa-course-bar ~ .container .row > main,
body:has(> .navbar.fixed-top) > .rsa-course-bar ~ .container .row > aside { margin-top: 0; }

/* Button: footer, card, and the navbar "Courses" item (matched by its UTM medium). */
.rsa-course-btn,
.navbar a[href*="utm_campaign=own-sites"][href*="utm_medium=nav"] {
  display: inline-block; background: #1d4ed8; color: #ffffff !important; border-radius: 6px;
  padding: 6px 14px; font-size: 14px; font-weight: 600; line-height: 1.4; text-decoration: none;
}
.rsa-course-btn:hover, .rsa-course-btn:focus-visible,
.navbar a[href*="utm_campaign=own-sites"][href*="utm_medium=nav"]:hover,
.navbar a[href*="utm_campaign=own-sites"][href*="utm_medium=nav"]:focus-visible {
  background: #1e40af; color: #ffffff !important; text-decoration: none;
}
.navbar a[href*="utm_campaign=own-sites"][href*="utm_medium=nav"] { margin: 0 6px; }
.navbar li:has(> a[href*="utm_campaign=own-sites"][href*="utm_medium=nav"]) { display: flex; align-items: center; }

/* Course card: end of home and article pages, never on reference pages. */
.rsa-course-card {
  box-sizing: border-box; margin: 2rem 0 1rem; padding: 18px 20px;
  background: #eff6ff; color: #1e293b; border: 1px solid #bfdbfe; border-radius: 8px;
}
.rsa-course-card h2 { margin: 0 0 6px; padding: 0; border: 0; font-size: 1.25rem; line-height: 1.3; color: #1e293b; }
.rsa-course-card p { margin: 0 0 8px; color: #1e293b; }
.rsa-course-card ul { margin: 0 0 12px; padding-left: 1.2rem; }
.rsa-course-card li { margin: 0; color: #1e293b; }
.rsa-course-card a:not(.rsa-course-btn) { color: #1d4ed8; text-decoration: underline; }
.template-reference-topic .rsa-course-card, .template-reference-index .rsa-course-card { display: none; }

/* Footer block. */
.rsa-course-footer {
  box-sizing: border-box; margin: 1rem 0; padding: 16px 20px; text-align: center;
  background: #f1f5f9; color: #1e293b; border-radius: 8px;
}
.rsa-course-footer h2 { margin: 0 0 4px; padding: 0; border: 0; font-size: 1.1rem; line-height: 1.3; color: #1e293b; }
.rsa-course-footer p { margin: 0 0 10px; color: #1e293b; }

/* Quarto: the bar sits in a <nav class="column-screen"> at the top of <main> (full width, scrolls away). */
.rsa-course-nav { margin: 0 0 1rem; }

/* Sidebar block (2026-11-29 change): the footer block's copy and button, compact, as the LAST item of the sidebar.
   - pkgdown (>= 768 px, sidebar beside the content): the block is sticky under the navbar. If the page has a TOC, the
     whole aside is the sticky column (TOC scrolls inside it, block stays under it); on the home sidebar only the
     block is sticky, after the links. Below 768 px the sidebar stacks, nothing is sticky, and the block ends the
     stacked sidebar above the page footer.
   - Quarto (>= 992 px): the block is the margin sidebar's margin-footer, inside Quarto's own sticky TOC column.
     Below 992 px Quarto hides the margin sidebar, so the footer block (card area) stays as the one block. */
.rsa-course-side { text-align: left; margin: 1rem 0; padding: 12px 14px; }
.rsa-course-side h2 { font-size: 1rem; margin: 0 0 4px; }
.rsa-course-side p { font-size: .85rem; line-height: 1.4; margin: 0 0 8px; }
.rsa-course-side .rsa-course-btn { font-size: 13px; padding: 5px 12px; }
body:has(.rsa-course-side) .rsa-course-footer:not(.rsa-course-side) { display: none; }
body:has(.rsa-hero) .rsa-course-footer:not(.rsa-course-side) { display: none; }
@media (max-width: 991.98px) {
  body:has(.margin-sidebar .rsa-course-side) .rsa-course-footer:not(.rsa-course-side) { display: block; }
  body:has(.rsa-hero):has(.margin-sidebar .rsa-course-side) .rsa-course-footer:not(.rsa-course-side) { display: none; }
}
@media (min-width: 768px) {
  .row > aside > .rsa-course-side { position: sticky; top: 72px; z-index: 1; }
  .row > aside:has(> #toc) { position: sticky; top: 56px; align-self: flex-start; max-height: calc(100vh - 56px - 1rem); display: flex; flex-direction: column; }
  .row > aside:has(> #toc) > #toc { position: static; top: auto; max-height: none; flex: 0 1 auto; min-height: 0; overflow-y: auto; }
  .row > aside:has(> #toc) > .rsa-course-side { position: relative; flex: 0 0 auto; margin-top: .75rem; }
}

/* Code card (round 3, 2026-11-29): a dark card that shows the product. Big headline, one promise line, a mini lesson
   dark editor panel (#0f1a2e, 1px slate border; JetBrains Mono as in the lesson editor; tokens: comment #94a3b8, operator #f9a8d4,
   string #fcd34d, number #fdba74, function #93c5fd; output panel #0a1424 with #e2e8f0 text) printing the actual output (make-ad-output.R), and
   an offer strip. No JavaScript, no looping animation: the offer lifts 1 px on hover or focus only.
   Contrast (computed): headline #ffffff on #0b1220 18.9, promise #cbd5e1 on #0b1220 12.7, code #0f172a on #ffffff 17.9,
   strings #92400e 7.1, numbers #9a3412 7.3, operators #0e7490 5.4, comments #475569 7.6, console #e2e8f0 on #060b18 15.9,
   offer text #0f172a on #ffffff 17.9, CTA #ffffff on #1d4ed8 6.70. */
.rsa-codecard { position: relative; box-sizing: border-box; container-type: inline-size; overflow: hidden; text-align: left; color: #ffffff;
  background: linear-gradient(160deg, #0b1220 0%, #111a2e 100%); border: 1px solid #243457; border-radius: 16px; padding: 11px;
  box-shadow: 0 6px 20px rgba(2, 6, 23, .45), inset 0 0 0 1px rgba(255, 255, 255, .04); }
.rsa-codecard:not(.rsa-course-side):not(.rsa-hero) { max-width: 460px; margin: 1.25rem auto; }
.rsa-codecard .rsa-big { margin: 0 0 6px; padding: 0; border: 0; color: #ffffff; font-family: "Schibsted Grotesk", "Source Sans 3", system-ui, sans-serif;
  font-size: clamp(1.2rem, 9cqw, 2.2rem); line-height: 1.03; font-weight: 800; letter-spacing: -.02em; }
.rsa-codecard .rsa-promise { margin: 0 0 8px; font-size: 12.5px; line-height: 1.35; color: #cbd5e1; }
.rsa-editor { border-radius: 10px; overflow: hidden; background: #0f1a2e; border: 1px solid rgba(148, 163, 184, .25); margin: 0 0 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.rsa-etab { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 10px; background: #0b1527; border-bottom: 1px solid rgba(148, 163, 184, .2); }
.rsa-efile { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 400 11px/1.2 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #cbd5e1; }
.rsa-run { font: 600 11px/1 "Source Sans 3", "Segoe UI", system-ui, sans-serif; color: #e2e8f0; border: 1px solid #64748b; border-radius: 8px; padding: 3px 7px; background: transparent; }
.rsa-codecard .rsa-editor pre.rsa-code, .rsa-codecard .rsa-editor pre.rsa-code code { margin: 0; padding: 5px 7px; letter-spacing: -.01em; background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  color: #e2e8f0 !important; white-space: pre; overflow: hidden;
  font: 400 11.5px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.rsa-codecard .rsa-editor pre.rsa-code code { padding: 0; font-size: inherit; }
.t-dl::before { content: "$"; } .rsa-code .t-c { color: #94a3b8 !important; } .rsa-code .t-o { color: #f9a8d4 !important; } .rsa-code .t-s { color: #fcd34d !important; } .rsa-code .t-n { color: #fdba74 !important; } .rsa-code .t-f { color: #93c5fd !important; }
.rsa-codecard .rsa-out { background: #0a1424; color: #e2e8f0; border-top: 1px solid rgba(148, 163, 184, .2); padding: 4px 8px 5px; font: 400 11px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.rsa-outlabel { display: block; margin-bottom: 1px; color: #94a3b8; font-size: .9em; letter-spacing: .04em; }
.rsa-ohead { margin: 0 0 2px; color: #94a3b8; white-space: nowrap; overflow: hidden; }
.rsa-orow { display: grid; grid-template-columns: var(--lab, 7.4em) auto; justify-content: start; gap: 8px; align-items: center; }
.rsa-olab { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rsa-oval { text-align: right; }
.rsa-codecard .rsa-out pre.rsa-outpre { margin: 0; padding: 0; background: transparent !important; border: 0 !important; color: inherit !important; font: inherit; white-space: pre; overflow: hidden; }
/* table-style output: label column + right-aligned value column, header row muted */
.rsa-othead { color: #94a3b8; }
.rsa-offer { display: flex; align-items: stretch; box-sizing: border-box; background: #ffffff; border-radius: 10px; overflow: hidden; text-decoration: none; color: #0f172a; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.rsa-offer-text { flex: 1 1 auto; padding: 5px 10px; font-size: 11px; line-height: 1.25; text-transform: uppercase; letter-spacing: .05em; color: #334155; }
.rsa-offer-text b { display: block; margin-top: 1px; font-size: 13px; letter-spacing: 0; text-transform: none; color: #0f172a; }
.rsa-offer-cta { flex: 0 0 auto; display: flex; align-items: center; padding: 0 14px; background: #1d4ed8; color: #ffffff; font-size: 15px; font-weight: 800; white-space: nowrap; }
.rsa-offer:hover, .rsa-offer:focus-visible { text-decoration: none; color: #0f172a; transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0, 0, 0, .45); transition: transform .12s ease, box-shadow .12s ease; }
.rsa-offer:hover .rsa-offer-cta, .rsa-offer:focus-visible .rsa-offer-cta { background: #1e40af; }
.rsa-offer:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .rsa-offer:hover, .rsa-offer:focus-visible { transform: none; transition: none; } }

/* End-of-article topic card as a wide hero card: code left, output right on desktop, stacked on phones. */
.rsa-course-card.rsa-hero { margin: 2rem 0 1rem; padding: 22px; border-left: 1px solid #243457; color: #ffffff; }
.rsa-course-card.rsa-hero h2.rsa-big { font-size: clamp(1.5rem, 6.2cqw, 2.4rem); color: #ffffff; }
.rsa-course-card.rsa-hero p.rsa-promise { font-size: 14px; color: #cbd5e1; text-wrap: balance; text-wrap: pretty; }
.rsa-hero .rsa-otto { float: right; width: 56px; height: auto; margin: 0 0 6px 12px; filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, .95)) drop-shadow(0 3px 6px rgba(0, 0, 0, .35)); }
.rsa-hero-list { margin: 0 0 14px; padding-left: 1.1rem; font-size: 13px; color: #e2e8f0; }
.rsa-hero-list li { margin: 2px 0; color: #e2e8f0; }
.rsa-course-card.rsa-hero a:not(.rsa-offer) { color: #93c5fd; text-decoration: underline; }
@container (min-width: 720px) {
  .rsa-hero-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); column-gap: 24px; align-items: start; }
  .rsa-hero-in > .rsa-editor { grid-column: 2; grid-row: 1 / span 5; margin: 0; align-self: center; }
  .rsa-hero-in > .rsa-big, .rsa-hero-in > .rsa-promise, .rsa-hero-in > .rsa-hero-list, .rsa-hero-in > .rsa-offer { grid-column: 1; }
  /* otto perches on the code panel's top edge, left of the Run button (no own row, no empty band) */
  .rsa-hero-in > .rsa-otto { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; width: 48px; margin: 0 110px 0 0; float: none; position: relative; z-index: 1; }
}

/* Sidebar card is tall: on short viewports the TOC needs the height, so the card stops being sticky. */
@media (min-width: 768px) and (max-height: 720px) {
  .row > aside > .rsa-course-side { position: relative; top: auto; }
  .row > aside:has(> #toc) { position: static; max-height: none; display: block; }
  .row > aside:has(> #toc) > #toc { position: sticky; top: 56px; max-height: calc(100vh - 56px - 1rem); overflow-y: auto; }
}
.rsa-course-card.rsa-hero a.rsa-offer { color: #0f172a; text-decoration: none; }

/* pkgdown's footer is a flex row: the hero card takes the full row (its size containment would otherwise squeeze it). */
footer:has(> .rsa-hero) { flex-wrap: wrap; }
footer > .rsa-course-card.rsa-hero { flex: 1 1 100%; width: 100%; }


/* The sidebar card steps aside when the end-of-article hero comes into view, so only one ad shows at a time
   (scroll-linked, CSS only: not a looping animation; browsers without scroll-driven animations keep it visible). */
@supports (animation-timeline: view()) {
  body { timeline-scope: --rsa-hero; }
  .rsa-hero { view-timeline: --rsa-hero block; view-timeline-inset: 0 -300px; }
  @keyframes rsa-step-aside { to { opacity: 0; visibility: hidden; } }
  .rsa-course-side { animation: rsa-step-aside linear both; animation-timeline: --rsa-hero; animation-range: entry 0% entry 4%; }
}

/* Fallback for browsers without scroll-driven animations (older Firefox, Safari): the sidebar card is not sticky, so it scrolls
   away with the sidebar and never sits beside the end-of-article hero. pkgdown: card static after the TOC (the TOC stays
   sticky). Quarto: the margin sidebar (TOC and card) scrolls with the page. */
@supports not (animation-timeline: view()) {
  @media (min-width: 768px) {
    .row > aside > .rsa-course-side { position: relative; top: auto; }
    .row > aside:has(> #toc) { position: static; max-height: none; display: block; }
    .row > aside:has(> #toc) > #toc { position: sticky; top: 56px; max-height: calc(100vh - 56px - 1rem); overflow-y: auto; }
  }
  .sidebar.margin-sidebar { position: static !important; max-height: none; overflow: visible; }
}
