/* EpiParam UX layer (see epiparam-ux.js). Colours follow the app's theme. */
:root { --epx-brand: #8B5A00; --epx-accent: #E07B00; --epx-ink: #2b2b2b; }

/* ---- loading screen ------------------------------------------------------ */
/* rmarkdown lays its loader out as a table (rmd_loader.css); pin ours to the
   middle of the window instead */
#rmd_loader_wrapper { background: #FBFBFB; z-index: 2000; }
#rmd_loader[data-epx] {
  display: block !important; position: fixed !important; top: 50% !important; left: 50% !important;
  transform: translate(-50%, -50%) !important; height: auto !important;
  width: min(420px, 86vw) !important; text-align: center;
  font-family: Jost, "Segoe UI", Roboto, Arial, sans-serif; color: var(--epx-ink);
}
.epx-brand { font-size: 34px; font-weight: 700; color: var(--epx-brand); letter-spacing: .5px; margin-bottom: 22px; }
.epx-spinner {
  width: 44px; height: 44px; margin: 0 auto 20px; border-radius: 50%;
  border: 4px solid rgba(139, 90, 0, .15); border-top-color: var(--epx-brand);
  animation: epx-spin .8s linear infinite;
}
.epx-loader-msg { font-size: 16px; margin: 0 0 8px; min-height: 1.4em; animation: epx-fade .4s ease; }
.epx-loader-sub { font-size: 12.5px; color: #777; margin: 0; }

/* ---- thin progress bar at the top ----------------------------------------- */
.epx-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 3000;
  overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.epx-bar.epx-on { opacity: 1; }
.epx-bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(90deg, transparent, var(--epx-accent), var(--epx-brand), transparent);
  animation: epx-slide 1.1s ease-in-out infinite;
}

/* ---- status pill ----------------------------------------------------------- */
.epx-pill {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  max-width: min(560px, 92vw); padding: 10px 18px 10px 14px; border-radius: 999px;
  background: rgba(43, 30, 5, .92); color: #fff; font-size: 14px; line-height: 1.3;
  font-family: Jost, "Segoe UI", Roboto, Arial, sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); z-index: 3000;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.epx-pill.epx-on { opacity: 1; transform: translate(-50%, 0); }
.epx-dot {
  flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3); border-top-color: #FFB347;
  animation: epx-spin .7s linear infinite;
}
.epx-pill-time { color: #FFCF8A; white-space: nowrap; }

/* ---- spinner over a recalculating output --------------------------------------
 * Shiny already dims outputs that are recalculating; add a spinner on top. */
.recalculating { opacity: .45 !important; transition: opacity .2s; }
.recalculating.html-widget-output::after,
.recalculating.shiny-plot-output::after,
.recalculating.datatables::after,
.recalculating.shiny-html-output::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 32px; height: 32px;
  margin: -16px 0 0 -16px; border-radius: 50%; z-index: 10;
  border: 3px solid rgba(139, 90, 0, .2); border-top-color: var(--epx-brand);
  animation: epx-spin .8s linear infinite;
}

/* ---- empty panel hint -------------------------------------------------------- */
.chart-stage[data-epx-hint]::before {
  content: attr(data-epx-hint);
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(460px, 80%); padding: 18px 22px 18px 56px; box-sizing: border-box;
  border: 1.5px dashed rgba(139, 90, 0, .35); border-radius: 10px;
  background: rgba(139, 90, 0, .04) no-repeat 18px 50% / 24px 24px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B5A00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E");
  color: #5c4a2a; font-size: 14px; line-height: 1.45; text-align: left;
  font-family: Jost, "Segoe UI", Roboto, Arial, sans-serif; pointer-events: none; z-index: 5;
}

.chart-stage[data-epx-kind="run"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23E07B00'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

/* ---- placeholders: no box is ever blank --------------------------------------
 * A still, faint skeleton of what the box will hold, and a caption under it.
 * It shimmers only while the app is computing (Shiny marks <html> with
 * .shiny-busy), so an idle page stays calm. */
.chart-stage[data-epx-ph]:not([data-epx-hint])::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -62%);
  pointer-events: none; z-index: 4; border-radius: 8px;
  background: var(--epx-sk1);
}
html.shiny-busy .chart-stage[data-epx-ph]:not([data-epx-hint])::before,
.chart-stage[data-epx-loading]:not([data-epx-hint])::before {
  background: linear-gradient(100deg, var(--epx-sk1) 30%, var(--epx-sk2) 50%, var(--epx-sk1) 70%);
  background-size: 300% 100%; animation: epx-shimmer 1.6s ease-in-out infinite;
}
.chart-stage[data-epx-ph="value"]:not([data-epx-hint])::before { width: 34%; max-width: 140px; height: 46px; border-radius: 12px; }
.chart-stage[data-epx-ph="table"]:not([data-epx-hint])::before {
  width: 78%; height: 66px; border-radius: 4px;
  -webkit-mask: repeating-linear-gradient(to bottom, #000 0 14px, transparent 14px 26px);
          mask: repeating-linear-gradient(to bottom, #000 0 14px, transparent 14px 26px);
}
.chart-stage[data-epx-ph="chart"]:not([data-epx-hint])::before,
.chart-stage[data-epx-ph="network"]:not([data-epx-hint])::before {
  width: min(70%, 520px); height: min(48%, 210px); border-radius: 0;
  -webkit-mask: var(--epx-mask-chart) center / contain no-repeat;
          mask: var(--epx-mask-chart) center / contain no-repeat;
}
.chart-stage[data-epx-ph="network"]:not([data-epx-hint])::before {
  -webkit-mask-image: var(--epx-mask-network); mask-image: var(--epx-mask-network);
}
.chart-stage[data-epx-ph]:not([data-epx-hint])::after {
  content: attr(data-epx-label);
  position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%);
  width: 88%; text-align: center; pointer-events: none; z-index: 4; white-space: pre-line;
  color: var(--epx-muted); font-size: 13px; line-height: 1.35;
  font-family: Jost, "Segoe UI", Roboto, Arial, sans-serif;
}
.chart-stage[data-epx-ph="value"]:not([data-epx-hint])::after { top: calc(50% + 28px); font-size: 12.5px; }
.chart-stage[data-epx-ph="chart"]:not([data-epx-hint])::after,
.chart-stage[data-epx-ph="network"]:not([data-epx-hint])::after { top: auto; bottom: 12%; }

:root {
  --epx-muted: #8a8172;
  --epx-sk1: rgba(139, 90, 0, .08); --epx-sk2: rgba(139, 90, 0, .18);
  /* silhouettes: a histogram with a fitted curve; nodes and links */
  --epx-mask-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 90'%3E%3Cg fill='%23000'%3E%3Crect x='10' y='62' width='16' height='26' rx='2'/%3E%3Crect x='30' y='40' width='16' height='48' rx='2'/%3E%3Crect x='50' y='18' width='16' height='70' rx='2'/%3E%3Crect x='70' y='8' width='16' height='80' rx='2'/%3E%3Crect x='90' y='22' width='16' height='66' rx='2'/%3E%3Crect x='110' y='40' width='16' height='48' rx='2'/%3E%3Crect x='130' y='56' width='16' height='32' rx='2'/%3E%3Crect x='150' y='68' width='16' height='20' rx='2'/%3E%3Crect x='170' y='76' width='16' height='12' rx='2'/%3E%3C/g%3E%3C/svg%3E");
  --epx-mask-network: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 90'%3E%3Cg stroke='%23000' stroke-width='2' fill='none'%3E%3Cpath d='M30 45L80 20L130 30L170 60M80 20L90 70L130 30M90 70L150 80M30 45L90 70'/%3E%3C/g%3E%3Cg fill='%23000'%3E%3Ccircle cx='30' cy='45' r='9'/%3E%3Ccircle cx='80' cy='20' r='11'/%3E%3Ccircle cx='130' cy='30' r='8'/%3E%3Ccircle cx='170' cy='60' r='7'/%3E%3Ccircle cx='90' cy='70' r='10'/%3E%3Ccircle cx='150' cy='80' r='6'/%3E%3C/g%3E%3C/svg%3E");
}

/* motion: results fade in; a page's cards rise in one after another */
.epx-fresh { animation: epx-fadein .5s ease both; }
.epx-enter .chart-wrapper { animation: epx-rise .5s cubic-bezier(.2, .7, .2, 1) both; }
.epx-enter .chart-wrapper:nth-of-type(2) { animation-delay: .05s; }
.epx-enter .chart-wrapper:nth-of-type(3) { animation-delay: .1s; }
.epx-enter .dashboard-row:nth-of-type(2) .chart-wrapper,
.epx-enter .dashboard-row:nth-of-type(2) .tabbed { animation-delay: .15s; }
@keyframes epx-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes epx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* download notice sits above the busy pill when both show */
.epx-toast { bottom: 72px; }

@keyframes epx-spin { to { transform: rotate(360deg); } }
@keyframes epx-slide { from { left: -40%; } to { left: 100%; } }
@keyframes epx-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .epx-spinner, .epx-dot, .recalculating::after { animation-duration: 2.4s; }
  .epx-bar::before { animation: none; left: 0; width: 100%; opacity: .6; }
}
