/* lass-artifact-runtime.css — shared styles for every academy artifact (sim/guide).
 * Linked via <link rel="stylesheet" href="/lass-artifact-runtime.css">. Consolidates
 * the former inline a11y / font-resize / bridge / print styles into one file.
 * (Per-guide light-theme blocks remain generated per guide — not here.) */

/* ── Accessibility ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
:where(a, button, input, select, textarea, summary, [tabindex], [role="button"]):focus-visible {
  /* #1a73e8 meets WCAG 1.4.11 (≥3:1) against both light and dark backgrounds. */
  outline: 2px solid #1a73e8 !important; outline-offset: 2px !important; border-radius: 3px;
}
.lass-skip {
  position: fixed; left: -9999px; top: 0; z-index: 2147483601;
  background: #12161f; color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
  font: 600 14px/1 system-ui, -apple-system, Segoe UI, sans-serif; text-decoration: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
}
.lass-skip:focus { left: 0; }

/* ── Reading-progress bar ──────────────────────────────────────────────── */
#lass-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2147483600;
  background: #1a73e8; transition: width .12s linear; pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { #lass-progress { transition: none; } }
@media print { #lass-progress { display: none !important; } }

/* ── Smooth scroll + anchor offset (motion-safe) ───────────────────────── */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
:is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: 16px; }

/* ── Themed text selection (white on #1a73e8 ≈ 5:1) ────────────────────── */
::selection { background: #1a73e8; color: #fff; }

/* ── Subtle, themed scrollbars ─────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(128, 128, 128, .5) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, .45); border-radius: 8px;
  border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(128, 128, 128, .7); background-clip: content-box; }

/* ── Back-to-top button ────────────────────────────────────────────────── */
#lass-top-btn {
  position: fixed; z-index: 2147483600; width: 40px; height: 40px; padding: 0; font-size: 18px; line-height: 1;
  right: calc(14px + env(safe-area-inset-right)); bottom: calc(58px + env(safe-area-inset-bottom));
  border-radius: 9px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(18, 22, 32, .72); color: #fff;
  cursor: pointer; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
#lass-top-btn.lass-show { opacity: 1; transform: none; pointer-events: auto; }
#lass-top-btn:hover { background: rgba(40, 46, 60, .9); }
#lass-top-btn.lass-show:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { #lass-top-btn { transition: none; } }
@media (pointer: coarse) { #lass-top-btn { width: 44px; height: 44px; } }
@media print { #lass-top-btn { display: none !important; } }

/* ── External-link affordance ──────────────────────────────────────────── */
a[target="_blank"].lass-ext::after { content: " ↗"; font-size: .85em; opacity: .65; }
@media print { a[target="_blank"].lass-ext::after { content: ""; } }

/* ── Glossary term tooltips ────────────────────────────────────────────── */
abbr.lass-term {
  text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 2px;
  cursor: help; -webkit-text-decoration: underline dotted;
}
@media print { abbr.lass-term { text-decoration: none; } }

/* ── Shared control chrome (font / complete / report / print buttons) ───── */
.lass-fr-ctl { position: fixed; right: 14px; bottom: 14px; z-index: 2147483600; display: flex; gap: 6px;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif; }
.lass-fr-ctl button { width: 34px; height: 34px; }
#lass-complete-btn { position: fixed; left: 14px; bottom: 14px; }
#lass-report-btn { position: fixed; left: 14px; bottom: 56px; padding: 8px 12px; font-size: 12px; }
#lass-print-btn { position: fixed; right: 14px; top: 14px; padding: 9px 14px; font-size: 13px; }
.lass-fr-ctl button, #lass-complete-btn, #lass-report-btn, #lass-print-btn {
  z-index: 2147483600; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(18, 22, 32, .72); color: #fff; font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-weight: 600; line-height: 1; cursor: pointer; padding: 0;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
#lass-complete-btn, #lass-report-btn, #lass-print-btn { padding: 9px 14px; width: auto; height: auto; }
#lass-report-btn { padding: 8px 12px; }
.lass-fr-ctl button:hover, #lass-complete-btn:hover, #lass-report-btn:hover, #lass-print-btn:hover {
  background: rgba(40, 46, 60, .9);
}
.lass-fr-ctl button { font-size: 15px; }
#lass-complete-btn.is-done { background: rgba(14, 113, 64, .95); border-color: rgba(14, 113, 64, .97); cursor: default; }

/* ── Tactile + mobile control polish ───────────────────────────────────── */
/* Honour notch/safe-area insets so fixed controls never sit under device chrome. */
.lass-fr-ctl { right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); }
#lass-complete-btn { left: calc(14px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom)); }
#lass-report-btn { left: calc(14px + env(safe-area-inset-left)); bottom: calc(56px + env(safe-area-inset-bottom)); }
#lass-print-btn { right: calc(14px + env(safe-area-inset-right)); top: calc(14px + env(safe-area-inset-top)); }
/* Press feedback. */
.lass-fr-ctl button:active, #lass-complete-btn:active, #lass-report-btn:active, #lass-print-btn:active { transform: translateY(1px); }
/* Touch devices: meet the 44px min tap target (WCAG 2.5.5) without changing desktop sizing. */
@media (pointer: coarse) {
  .lass-fr-ctl button { width: 44px; height: 44px; font-size: 17px; }
  #lass-complete-btn, #lass-report-btn, #lass-print-btn { min-height: 44px; padding: 12px 16px; }
}
/* Animated completion check (motion-safe). */
@media (prefers-reduced-motion: no-preference) {
  #lass-complete-btn.is-done { animation: lass-pop .3s ease; }
  @keyframes lass-pop { 0% { transform: scale(.94); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
}

/* ── Report-issue overlay ──────────────────────────────────────────────── */
#lass-report-form { position: fixed; left: 14px; bottom: 56px; z-index: 2147483601; width: 300px; max-width: 80vw;
  background: #12161f; color: #fff; border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; padding: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45); font-family: system-ui, -apple-system, Segoe UI, sans-serif; }
#lass-report-form label { display: block; font: 600 13px/1.2 system-ui; margin-bottom: 8px; }
#lass-report-form textarea { width: 100%; box-sizing: border-box; background: #0b0e14; color: #fff;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; padding: 8px; font: 13px/1.4 system-ui; resize: vertical; }
.lass-rf-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.lass-rf-row button { padding: 7px 14px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .08); color: #fff; font: 600 12px system-ui; cursor: pointer; }
.lass-rf-row #lass-rf-send { background: #0077aa; border-color: #0077aa; }
.lass-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2147483602;
  background: rgba(14, 113, 64, .97); color: #fff; padding: 10px 18px; border-radius: 10px;
  font: 600 13px system-ui; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); }

/* ── Print / Save-as-PDF ───────────────────────────────────────────────── */
@media print {
  html, body { background: #fff !important; color: #111 !important; }
  :is(h1,h2,h3,h4,h5,h6,p,li,dd,dt,td,th,figcaption,blockquote,label,span,a,strong,em,b,small) {
    color: #111 !important; text-shadow: none !important; }
  :is(.muted,.dim,.sub,.subtitle,.caption,.hint,.secondary) { color: #444 !important; }
  :is(section,article,aside,header,footer,main,div,ul,ol,table,figure)[class] {
    background: transparent !important; box-shadow: none !important; }
  :is(canvas#bg,canvas.bg,canvas#stars,canvas.stars,canvas#starfield,canvas.starfield,
      canvas#particles,canvas.particles,canvas.bg-canvas,#bg-canvas,.bg-canvas,
      .starfield,#starfield,.stars,#stars,.particles,#particles) { display: none !important; }
  nav, [role="navigation"], [class*="sidebar"], [class*="side-bar"], [class*="side-nav"], [class*="sidenav"] {
    background: #fff !important; border-color: #ccc !important; }
  :is(nav, [role="navigation"], [class*="sidebar"], [class*="side-nav"], [class*="sidenav"]) * {
    color: #222 !important; background: transparent !important; box-shadow: none !important; }
  .lass-fr-ctl, #lass-complete-btn, .lass-skip, #lass-print-btn, #lass-report-btn, #lass-report-form, .lass-toast {
    display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  :is(h1,h2,h3,h4) { break-after: avoid-page; }
  :is(li,tr,figure,blockquote,pre,img) { break-inside: avoid; }
  a[href] { text-decoration: underline; }
  @page { margin: 1.5cm; }
}

/* ── Light-theme title-contrast safety net ─────────────────────────────── */
/* Guides render with ?theme=light in the Academy dashboard thumbnails. Some
   per-guide light blocks switch the BACKGROUND to light but leave the title
   using the dark-theme (light) ink — an unreadable light-on-light title. Force
   the top heading levels to a dark ink under html.light so every guide's title
   stays legible (WCAG AA on a light surface). Specificity (html.light body h*)
   beats the common `.hero h1` rule but stays BELOW a guide's own
   `html.light .x h1` override, so guides that already theme their title
   correctly are untouched. */
html.light body :is(h1, h2, h3) { color: #10182c; }
