/* Launch pages for the in-browser Shiny apps (apps/<name>/index.html, built from
   apps/_shared/launch_template/ by .github/pages/build_site.R). The page carries the site's head,
   top bar and footer and links site.css, so its colors, type and controls are the site's, in light
   and dark, with the theme toggle; this file only lays out the intro and the app area, from the
   site's tokens. No color is written here: build_pages.py --check fails on a color literal.
   Replaces Shinylive's own page styles: only the few viewer rules it needs are repeated at the end. */

/* intro: shown before any R loads */
.launch .crumbs { margin: 22px 0 0; }
.launch-intro { padding-top: 16px; }
.launch-intro .chips { gap: 6px; margin: 0 0 14px; }
.launch-intro .chips .st { margin: 0; }
.launch-intro .lede { margin: 0 0 18px; }
.launch-go { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 22px; }
.launch-go ul.go { margin: 0; padding: 0; }
.launch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.launch-grid .panel { margin: 0; }
.launch-grid h2 { margin: 0 0 12px; font: 600 var(--fs-label)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.launch-try ol { margin: 0; padding-left: 1.3em; }
.launch-try li, .launch-facts li { margin: 0 0 8px; font-size: 15px; line-height: 1.55; }
.launch-try li::marker { color: var(--accent); font: 600 13px var(--mono); }
.launch-facts ul { list-style: none; margin: 0; padding: 0; }
.launch-shot { padding: 10px; }
.launch-shot picture { display: block; }
.launch-shot img { display: block; width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--line); }
.launch-shot figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }

/* status, used in the intro pill and the app bar */
.dot { display: inline-block; flex: 0 0 auto; width: .7rem; height: .7rem; border-radius: 50%; background: var(--accent); }
[data-tone="progress"] .dot { background: transparent; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: launch-spin .8s linear infinite; }
[data-tone="ok"] .dot { background: var(--green); }
[data-tone="warn"] .dot { background: var(--amber); }
[data-tone="error"] .dot { background: var(--red); }
@keyframes launch-spin { to { transform: rotate(360deg); } }
.status-pill { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink); text-decoration: none; font: 600 14px/1.2 var(--sans); box-shadow: var(--shadow-1); }
.status-pill:hover { color: var(--ink); border-color: var(--accent); }
.status-pill[data-tone="ok"] { border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.status-pill[data-tone="error"] { border-color: color-mix(in srgb, var(--red) 45%, transparent); background: var(--red-soft); color: var(--red); }

/* the app area */
.launch-app { max-width: 1680px; margin: 32px auto 0; padding: 0 16px; scroll-margin-top: calc(var(--bar-h) + 8px); }
.launch-app:focus { outline: none; }
.app-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px 8px 14px; background: var(--surface-2);
  border: 1px solid var(--line-2); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.app-status { display: flex; align-items: center; gap: 10px; flex: 1 1 320px; min-width: 0; font-size: 14px; line-height: 1.4; }
.status-text { min-width: 0; }
.status-stage { font-weight: 700; color: var(--ink); }
.status-detail { color: var(--muted); }
.app-status[data-tone="error"] .status-stage { color: var(--red); }
.app-status[data-tone="warn"] .status-stage { color: var(--amber); }
.app-status[data-tone="ok"] .status-stage { color: var(--green); }
.status-clock { margin-left: auto; color: var(--faint); font: 500 12px/1.3 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.app-tools { display: flex; gap: 8px; }
.app-tools .btn { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn[hidden] { display: none; }

.app-stage { position: relative; height: clamp(560px, calc(100vh - var(--bar-h) - 70px), 1200px); height: clamp(560px, calc(100svh - var(--bar-h) - 70px), 1200px);
  border: 1px solid var(--line-2); border-radius: 0 0 var(--r-lg) var(--r-lg); background: var(--bg); overflow: hidden; box-shadow: var(--shadow-1); }
.app-root { position: absolute; inset: 0; }
.app-cover { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px; overflow: auto; background: var(--bg); }
.launch-app[data-state="compute"] .app-cover,
.launch-app[data-state="ready"] .app-cover { display: none; }
.launch-app.has-problem .app-cover { display: flex; background: color-mix(in srgb, var(--bg) 92%, transparent); }
.cover-card { width: 100%; max-width: 40rem; padding: 20px 22px; border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 40%); box-shadow: var(--shadow-1); }
.cover-title { margin: 0 0 14px; font: 600 var(--fs-label)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { position: relative; padding: 5px 0 5px 30px; color: var(--muted); }
.steps li::before { content: ""; position: absolute; left: 4px; top: .6em; width: .85rem; height: .85rem; border-radius: 50%; border: 2px solid var(--line-2); box-sizing: border-box; }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { border-top-color: var(--accent); animation: launch-spin .8s linear infinite; }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "\2713"; border: 0; color: var(--green); font-weight: 700; top: .25em; left: 5px; width: auto; height: auto; }
.steps li.failed { color: var(--red); font-weight: 600; }
.steps li.failed::before { content: "\2715"; border: 0; color: var(--red); font-weight: 700; top: .25em; left: 5px; width: auto; height: auto; }
.steps .step-time { color: var(--faint); font: 400 12px/1.3 var(--mono); margin-left: 8px; }
.cover-problem { margin-top: 14px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--red) 45%, transparent); background: var(--red-soft); border-radius: var(--r-md); }
.cover-problem .problem-text { font-weight: 600; color: var(--red); margin: 0 0 8px; }
.cover-problem.tone-warn { border-color: var(--gap-line); background: var(--gap-bg); }
.cover-problem.tone-warn .problem-text { color: var(--gap-fg); }
.problem-said { font-family: var(--mono); font-size: .85rem; overflow-wrap: anywhere; margin: 0 0 8px; }
.problem-reasons-head { margin: 0 0 2px; font-weight: 600; }
.problem-reasons { margin: 0 0 8px; padding-left: 1.2em; }
.problem-try { margin: 0 0 10px; }
.problem-said[hidden], .problem-reasons[hidden], .problem-reasons-head[hidden] { display: none; }
.problem-reasons li { margin: 0 0 4px; }
.problem-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0; }
.problem-details { margin-top: 10px; font-size: .88rem; }
.problem-details pre { max-height: 14rem; overflow: auto; margin: 6px 0 0; font-size: .78rem; }
.launch-note { max-width: 80ch; margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* full screen: the app area covers the window, the site's top bar included */
.launch-app.is-full { position: fixed; inset: 0; z-index: 100; max-width: none; margin: 0; padding: 0; background: var(--bg); }
.launch-app.is-full .app-bar { border-radius: 0; border-left: 0; border-right: 0; }
.launch-app.is-full .app-stage { height: calc(100vh - 54px); height: calc(100dvh - 54px); border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; box-shadow: none; }
.launch-app.is-full .launch-note { display: none; }
/* the top bar is covered in full screen: launch.js puts a copy of its theme toggle in the app's bar */
.app-tools .theme-toggle { display: none; }
.launch-app.is-full .app-tools .theme-toggle { display: inline-flex; }
body.launch-full { overflow: hidden; }

/* the Shinylive viewer (from shinylive.css, which this page does not load) */
.app-root .shinylive-container { width: 100%; height: 100%; }
.shinylive-viewer { position: relative; width: 100%; height: 100%; }
.shinylive-viewer iframe, .app-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.shinylive-viewer .loading-wrapper { position: absolute; inset: 0; display: none; }
/* Shinylive's own spinner and error panel stay hidden: the cover above reports both */

@media (max-width: 720px) {
  .launch-intro { padding-top: 8px; }
  .launch-app { margin-top: 24px; padding: 0 8px; }
  .app-bar { padding: 8px 10px; }
  .status-clock { margin-left: 0; }
  .app-stage { height: calc(100vh - var(--bar-h) - 110px); height: calc(100svh - var(--bar-h) - 110px); min-height: 520px; }
  .app-cover { padding-top: 16px; }
  .launch-note { padding: 0 4px; }
}
@media (prefers-reduced-motion: reduce) {
  [data-tone="progress"] .dot, .steps li.active::before { animation: none; }
}
@media print {
  .launch-app { display: none; }
}
