/* ==========================================================================
   RoB Assistant: visual refresh, closer to the Risk of Bias overview (/rob).
   Loaded after styles.css, sidebars.css and dark-mode.css; only restyles.
   - light canvas, white panels with a hairline border (no heavy shadows)
   - dark ink headings instead of blue, square question numbers
   - muted traffic-light colours for the rating buttons and results
   ========================================================================== */

:root {
  --rr-canvas: #f6f9fb;
  --rr-surface: #ffffff;
  --rr-line: rgba(49, 63, 69, 0.12);
  --rr-ink: #24323a;
  --rr-muted: #5f6f78;
  --rr-blue: #0372b7;
  --rr-teal: #3a9fa3;
  /* rating colours (muted traffic light) */
  --rr-low: #5f9e6a;
  --rr-some: #c9a33d;
  --rr-high: #c4625a;
}
html[data-theme="dark"] {
  /* page in the database overview's grey; panels (toc, main, right info)
     match the real back-button chrome (#2d383d from css/styles.css) */
  --rr-canvas: #313f45;
  --rr-surface: #2d383d;
  --rr-line: rgba(138, 150, 156, 0.3);
  --rr-ink: #e2e8eb;
  --rr-muted: #9fb0b8;
  --rr-blue: #4f9fd6;
  --rr-teal: #5ebabd;
  --rr-low: #6faf7a;
  --rr-some: #d2ad4c;
  --rr-high: #cf6d64;
}

/* html too: Chrome shows the root's colour when the page is overscrolled */
html,
body,
html[data-theme="dark"] body { /* dark-mode.css sets its own */
  background-color: var(--rr-canvas) !important;
}
/* no rubber-band bounce at the top/bottom (Chrome on macOS): inside the
   iframe it would pull the sticky top stripe down and show the white
   frame behind it */
html,
body {
  overscroll-behavior-y: none;
}

/* ---- Panels: sidebar, main card, info boxes ------------------------------ */
#sidebar .bg-light,
#main-div,
[id^="infobox-"] {
  background-color: var(--rr-surface) !important;
  border: 1px solid var(--rr-line);
  border-radius: 0;
  box-shadow: none !important;
}
/* dark mode: the left menu on the page background (the site's dark .bg-light) */
html[data-theme="dark"] #sidebar .bg-light {
  background-color: var(--rr-surface) !important;
}
/* light mode: the main card's frame a little thicker (same colour), so it
   reads clearly where it overlaps the stripe */
html:not([data-theme="dark"]) #main-div {
  border-width: 2px 2px 3px;
}
/* main card and info boxes: square top, rounded bottom, and the same
   heavier underside as the contents panel (as the handbook) */
#main-div,
[id^="infobox-"] {
  border-bottom-width: 3px;
  border-radius: 0 0 0.5rem 0.5rem;
}
/* contents: as the handbook's, glued to the left edge with rounded right
   corners (the fixed column moves to the edge; the brand keeps its place) */
@media (min-width: 994px) { /* the app's own mobile layout runs to 993px */
  #sidebar > div {
    left: 0;
    width: calc(23% + 12px) !important;
  }
  #sidebar > div {
    top: calc(var(--rr-top-h) + var(--rr-top-gap)) !important; /* level with the main card */
  }
  /* the main card rises over the stripe (its top at the stripe's middle) */
  #main-div {
    z-index: 25;
    margin-top: calc(-1 * (var(--rr-top-gap) + var(--rr-top-h) / 2));
  }
  #sidebar .bg-light {
    border-left: 0;
    border-bottom-width: 3px;
    border-radius: 0 0.5rem 0.5rem 0;
  }
}
/* an info box without content (e.g. on the notes steps): no frame at all */
[id^="infobox-"]:not(:has(*)) {
  border: 0;
}
/* faint glow from the top-right corner, as on the /rob tiles */
#main-div,
[id^="infobox-"] {
  isolation: isolate;
}
#main-div {
  position: relative;
}
#main-div::before,
[id^="infobox-"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    60% 45% at 100% 0%,
    color-mix(in srgb, var(--rr-blue) 9%, transparent),
    transparent 70%
  );
}
[id^="infobox-"]::before {
  background: radial-gradient(
    75% 80% at 100% 0%,
    color-mix(in srgb, var(--rr-teal) 12%, transparent),
    transparent 70%
  );
}
html[data-theme="dark"] #main-div::before,
html[data-theme="dark"] [id^="infobox-"]::before {
  display: none;
}

/* dark mode: links in a lighter, softer blue (the site blue is too dark on
   the grey panels) */
html[data-theme="dark"] #main-div a:not(.btn):not(.rr-link-quiet),
html[data-theme="dark"] [id^="infobox-"] a:not(.btn) {
  color: #7dbbe4 !important;
}
html[data-theme="dark"] #main-div a:not(.btn):not(.rr-link-quiet):hover,
html[data-theme="dark"] [id^="infobox-"] a:not(.btn):hover {
  color: #a9d2ee !important;
}

/* light / dark switch under the information box (placed by the app's script) */
.rr-theme-switch {
  position: fixed;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--rr-muted);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--rr-muted) 40%, transparent);
  border-radius: 999px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}
.rr-theme-switch:hover,
.rr-theme-switch:focus-visible {
  color: var(--rr-ink);
  border-color: color-mix(in srgb, var(--rr-muted) 70%, transparent);
}
.rr-theme-switch .rr-ico-moon,
html[data-theme="dark"] .rr-theme-switch .rr-ico-sun {
  display: none;
}
html[data-theme="dark"] .rr-theme-switch .rr-ico-moon {
  display: inline;
}
@media (max-width: 991.98px) {
  .rr-theme-switch {
    display: none;
  }
}

/* the step buttons float (Proceed right): keep them inside the card */
#main-div > [id^="main-content"]::after {
  content: "";
  display: block;
  clear: both;
}

/* ---- Phones / tablets (the app's own mobile layout runs to 993px) ----------
   The app strips all padding inside the main card there (styles.css
   `.p-mobile > div`), so text and inputs sat flush on its frame. The card
   gets its own inner padding instead, and the rounded mobile corners. */
@media (max-width: 993px) {
  #main-div {
    padding: 1.5rem 1.15rem 1.75rem !important;
    border-width: 1px 1px 3px !important;
    border-radius: 1rem !important;
  }
  #main-div > [id^="main-content"] {
    padding: 0 !important;
  }
  /* the explanation sits on the card itself (no white / dark slab) */
  html body #main-div .explanation-div .collapse {
    padding: 0.75rem 0 0 !important;
    background-color: transparent !important;
  }
  html[data-theme="dark"] #main-div {
    background-color: var(--rr-surface) !important; /* styles.css forces white */
  }
}

/* ---- Top stripe: brand · version / cite · documentation ---------------------- */
:root {
  --rr-top-h: 2.75rem;
  --rr-top-gap: 1.6rem; /* stripe to the three panels (contents, main, info) */
}
.rr-topbar + .container-fluid {
  margin-top: var(--rr-top-gap) !important;
}
.rr-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: var(--rr-top-h);
  padding: 0 1.25rem;
  background-color: color-mix(in srgb, var(--rr-muted) 8%, var(--rr-canvas));
  border-bottom: 1px solid var(--rr-line);
}
html[data-theme="dark"] .rr-topbar {
  background-color: color-mix(in srgb, #000 14%, var(--rr-canvas));
}
.rr-topbar .rr-brand {
  margin: 0;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.rr-topbar .rr-brand__icon {
  font-size: 1.25rem;
}
.rr-topbar__meta {
  margin: 0;
  padding-left: 0.85rem;
  border-left: 1px solid var(--rr-line);
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--rr-muted);
  white-space: nowrap;
  user-select: none;
}
.rr-topbar__docs {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--rr-ink) !important;
  text-decoration: none !important;
  background-color: var(--rr-surface);
  border: 1px solid var(--rr-line);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 160ms ease, color 160ms ease;
}
.rr-topbar__docs:hover,
.rr-topbar__docs:focus-visible {
  color: var(--rr-blue) !important;
  border-color: color-mix(in srgb, var(--rr-blue) 45%, var(--rr-line));
}
.rr-topbar__docs svg {
  color: var(--rr-muted);
}
.rr-topbar__ext {
  font-size: 0.75em;
  color: var(--rr-muted);
}
/* the main card rises over the stripe: where it would cover the version
   (narrow desktops), the version steps aside */
@media (min-width: 994px) and (max-width: 1299.98px) {
  .rr-topbar__meta {
    display: none;
  }
}
@media (max-width: 575.98px) {
  .rr-topbar {
    gap: 0.6rem;
    padding: 0 0.85rem;
  }
  .rr-topbar__meta {
    display: none;
  }
}

/* ---- Sidebar ---------------------------------------------------------------- */
.rr-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--rr-muted) !important; /* muted, as before */
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}
.rr-brand:hover,
.rr-brand:focus-visible {
  color: var(--rr-ink) !important;
  outline: none;
}
/* shield sizing matches handbook (1.9rem on a 16-unit grid) */
.rr-brand__icon {
  position: relative;
  flex: none;
  width: 0.95em;
  height: 0.95em;
  font-size: 1.9rem;
}
.rr-brand__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}
/* traffic-light dots: still at rest; convey through the shield on hover */
.rr-brand__dot {
  position: absolute;
  left: calc(50% - 0.07125em);
  top: calc(2.9 * 0.059375em - 0.07125em);
  width: 0.1425em;
  height: 0.1425em;
  border-radius: 50%;
  background: #6aa874;
  animation: rr-dot-flow 2.7s linear infinite;
  animation-delay: -0.459s;
  animation-play-state: paused;
}
.rr-brand__dot:nth-of-type(2) {
  background: #d2ad4c;
  animation-delay: -1.35s;
}
.rr-brand__dot:nth-of-type(3) {
  background: #cf6d64;
  animation-delay: -2.241s;
}
.rr-brand:hover .rr-brand__dot,
.rr-brand:focus-visible .rr-brand__dot {
  animation-play-state: running;
}
@keyframes rr-dot-flow {
  0% {
    transform: translateY(0) scale(0);
  }
  15% {
    transform: translateY(0.0775em) scale(1);
  }
  85% {
    transform: translateY(0.4391em) scale(1);
  }
  100% {
    transform: translateY(0.5166em) scale(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .rr-brand__dot {
    animation: none;
    transform: translateY(0.0861em);
  }
  .rr-brand__dot:nth-of-type(2) {
    transform: translateY(0.2583em);
  }
  .rr-brand__dot:nth-of-type(3) {
    transform: translateY(0.4305em);
  }
}
#v-badge {
  color: var(--rr-muted) !important;
}
.btn-active {
  background-color: color-mix(in srgb, var(--rr-blue) 10%, var(--rr-surface)) !important;
  color: var(--rr-blue) !important;
  border-radius: 0 !important;
}
html[data-theme="dark"] .btn-active {
  background-color: color-mix(in srgb, var(--rr-blue) 18%, var(--rr-surface)) !important;
  color: #cfe3ee !important;
}

/* ---- Headings, question numbers, rules -------------------------------------- */
#main-div h2,
#main-div h4 {
  color: var(--rr-ink) !important;
  font-weight: 600;
  letter-spacing: -0.01em;
}
#main-div .badge {
  background-color: color-mix(in srgb, var(--rr-blue) 12%, var(--rr-surface)) !important;
  color: var(--rr-blue) !important;
  font-weight: 600 !important;
  border-radius: 0;
}
#main-div hr {
  color: var(--rr-line);
  opacity: 1;
}
/* header images that open / close the explanation below them (inline script) */
#main-div img.rr-explain-img {
  cursor: pointer;
}
/* header images: square top, rounded bottom (as elsewhere on the site) */
#main-div img.rounded {
  border-radius: 0 0 0.5rem 0.5rem !important;
}

/* ---- Rating buttons (No/PN · No Information · Yes/PY) ------------------------
   unselected: a light tint with coloured text; selected: the solid colour */
#main-div .btn-group > .btn-danger { --rr-c: var(--rr-high); }
#main-div .btn-group > .btn-warning { --rr-c: var(--rr-some); }
#main-div .btn-group > .btn-success { --rr-c: var(--rr-low); }
#main-div .btn-group > .btn-check + .btn {
  background-color: color-mix(in srgb, var(--rr-muted) 6%, var(--rr-surface)) !important;
  border: 1px solid var(--rr-line) !important;
  color: var(--rr-muted) !important;
  box-shadow: none !important;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
/* unselected stays neutral; its colour only hints on hover */
#main-div .btn-group > .btn-check:not(:checked) + .btn:hover {
  background-color: color-mix(in srgb, var(--rr-c) 12%, var(--rr-surface)) !important;
  border-color: color-mix(in srgb, var(--rr-c) 35%, var(--rr-surface)) !important;
  color: color-mix(in srgb, var(--rr-c) 75%, #000) !important;
}
html[data-theme="dark"] #main-div .btn-group > .btn-check:not(:checked) + .btn:hover {
  color: color-mix(in srgb, var(--rr-c) 70%, #fff) !important;
}
#main-div .btn-group > .btn-check:checked + .btn,
html[data-theme="dark"] #main-div .btn-group > .btn-check:checked + .btn {
  background-color: var(--rr-c) !important;
  border-color: var(--rr-c) !important;
  color: #fff !important;
}
/* square buttons; the last one follows the image's rounded bottom corner */
#main-div .btn-group > .btn {
  border-radius: 0 !important;
}
#main-div .btn-group > .btn:last-child {
  border-bottom-right-radius: 0.5rem !important;
}
#main-div .btn-group > .btn-check:focus-visible + .btn {
  outline: 2px solid color-mix(in srgb, var(--rr-c) 60%, transparent);
  outline-offset: 2px;
}
/* the frame around the floating button group takes the panel colour */
html[data-theme="dark"] #main-div .btn-group {
  background-color: var(--rr-surface) !important;
  border-color: var(--rr-surface) !important;
  border-top-color: var(--rr-surface) !important;
  border-left-color: var(--rr-surface) !important;
}

/* ---- Buttons ---------------------------------------------------------------- */
#main-div .btn-muted {
  background-color: var(--rr-surface) !important;
  border: 1px solid var(--rr-line) !important;
  color: var(--rr-ink) !important;
  box-shadow: none !important;
}
#main-div .btn-muted:hover {
  border-color: color-mix(in srgb, var(--rr-muted) 45%, var(--rr-line)) !important;
}

/* ---- Results: rating squares in the muted traffic-light colours -------------- */
#main-content-results .rating.bg-success {
  background-color: var(--rr-low) !important;
  border-color: var(--rr-low) !important;
}
#main-content-results .rating.bg-warning {
  background-color: var(--rr-some) !important;
  border-color: var(--rr-some) !important;
}
#main-content-results .rating.bg-danger {
  background-color: var(--rr-high) !important;
  border-color: var(--rr-high) !important;
}
#main-content-results .card {
  border-color: var(--rr-line) !important;
  border-radius: 0;
}

/* ==========================================================================
   Results page
   ========================================================================== */

/* ---- Overall verdict card ------------------------------------------------- */
#main-content-results .rr-verdict-img {
  display: block;
  border: 1px solid var(--rr-line);
  border-bottom: 0;
}
#main-content-results .rr-verdict {
  --v: var(--rr-line);
  position: relative;
  border: 1px solid var(--rr-line) !important;
  border-radius: 0 0 0.5rem 0.5rem;
  background-color: var(--rr-surface) !important;
  padding-right: 5rem !important;
}
/* the verdict colour follows what app.js sets on the (hidden) old symbol */
#main-content-results .rr-verdict:has(#rating-overall-symbol[style*="success"]) { --v: var(--rr-low); }
#main-content-results .rr-verdict:has(#rating-overall-symbol[style*="warning"]) { --v: var(--rr-some); }
#main-content-results .rr-verdict:has(#rating-overall-symbol[style*="danger"]) { --v: var(--rr-high); }
#main-content-results #rating-overall-symbol {
  display: none;
}
/* once rated: a faint tint of the verdict colour, and the verdict in it */
#main-content-results .rr-verdict:has(#rating-overall-symbol[style*="var"]),
html[data-theme="dark"] #main-content-results .rr-verdict:has(#rating-overall-symbol[style*="var"]) {
  background-color: color-mix(in srgb, var(--v) 7%, var(--rr-surface)) !important;
}
#main-content-results #overall-rating {
  color: color-mix(in srgb, var(--v) 80%, #000) !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em;
}
html[data-theme="dark"] #main-content-results #overall-rating {
  color: color-mix(in srgb, var(--v) 75%, #fff) !important;
}
#main-content-results .rr-verdict:not(:has(#rating-overall-symbol[style*="var"])) #overall-rating {
  color: var(--rr-ink) !important;
}
/* shield with only the matching dot lit */
.rr-verdict-shield {
  position: absolute;
  top: 50%;
  right: 1.25rem;
  width: 3.25rem;
  height: 3.25rem;
  transform: translateY(-50%);
  color: var(--rr-muted);
}
.rr-verdict-shield circle {
  fill: var(--rr-muted);
  opacity: 0.25;
}
.rr-verdict-shield .rr-dot-low { fill: var(--rr-low); }
.rr-verdict-shield .rr-dot-some { fill: var(--rr-some); }
.rr-verdict-shield .rr-dot-high { fill: var(--rr-high); }
.rr-verdict:has(#rating-overall-symbol[style*="success"]) .rr-dot-low,
.rr-verdict:has(#rating-overall-symbol[style*="warning"]) .rr-dot-some,
.rr-verdict:has(#rating-overall-symbol[style*="danger"]) .rr-dot-high {
  opacity: 1;
}

/* ---- Quieter link and buttons ------------------------------------------------ */
.rr-link-quiet {
  color: var(--rr-muted) !important;
  text-decoration: none;
  font-size: 0.95rem;
}
.rr-link-quiet:hover {
  color: var(--rr-blue) !important;
}
/* export: "Download (long)" stays the primary (blue) action; the rest are quiet */
#main-content-results .rob-export-btn,
#infobox-results .rob-rate-new-btn {
  border-radius: 0 !important;
}
.rr-btn-quiet,
.rr-btn-quiet.btn-primary,
.rr-btn-quiet.btn-secondary {
  background-color: var(--rr-surface) !important;
  border: 1px solid var(--rr-line) !important;
  color: var(--rr-ink) !important;
  box-shadow: none !important;
  transition: border-color 160ms ease, color 160ms ease;
}
.rr-btn-quiet svg {
  color: var(--rr-blue);
}
.rr-btn-quiet:hover,
.rr-btn-quiet:focus-visible {
  border-color: color-mix(in srgb, var(--rr-muted) 45%, var(--rr-line)) !important;
}
/* copied: app.js swaps btn-primary for btn-secondary for 2 s and shows a check */
#btn-clipboard.rr-btn-quiet.btn-secondary,
#btn-clipboard.rr-btn-quiet.btn-secondary svg {
  color: var(--rr-low) !important;
}
#btn-clipboard.rr-btn-quiet.btn-secondary {
  border-color: color-mix(in srgb, var(--rr-low) 50%, var(--rr-line)) !important;
}

/* ==========================================================================
   Step navigation: larger "Proceed" / "Go Back" buttons (easier to hit)
   ========================================================================== */
#main-div [id^="main-content-"] > button.btn-primary.mt-3,
#main-div [id^="main-content-"] > button.btn-muted.mt-3 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3rem;
  padding: 0.7rem 1.35rem !important;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.2;
  border-radius: 6px !important;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease,
    transform 90ms ease, box-shadow 90ms ease;
}
/* 3D, as the original buttons: a darker bottom edge and a light top
   highlight; pressing moves the button down onto its edge */
#main-div [id^="main-content-"] > button.btn-primary.mt-3 {
  min-width: 10rem;
  background-color: #0372b7 !important;
  border: 1px solid #035f99 !important;
  border-bottom: 3px solid #024a77 !important;
  color: #fff !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 2px rgba(3, 60, 95, 0.25) !important;
}
#main-div [id^="main-content-"] > button.btn-primary.mt-3:hover,
#main-div [id^="main-content-"] > button.btn-primary.mt-3:focus-visible {
  background-color: #0367a6 !important;
}
#main-div [id^="main-content-"] > button.btn-muted.mt-3 {
  min-width: 8rem;
  border: 1px solid rgba(49, 63, 69, 0.18) !important;
  border-bottom: 3px solid rgba(49, 63, 69, 0.28) !important;
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(36, 50, 58, 0.08) !important;
}
html[data-theme="dark"] #main-div [id^="main-content-"] > button.btn-muted.mt-3 {
  border-color: rgba(108, 117, 125, 0.4) !important;
  /* grey edge like the panels' undersides (black read as a stray line) */
  border-bottom-color: rgba(108, 117, 125, 0.65) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}
#main-div [id^="main-content-"] > button.mt-3:active {
  transform: translateY(2px);
  border-bottom-width: 1px !important;
  margin-bottom: 2px;
  box-shadow: none !important;
}
/* arrows nudge in their direction */
#main-div [id^="main-content-"] > button.mt-3 svg {
  flex: none;
  transition: transform 200ms ease;
}
#main-div [id^="main-content-"] > button.btn-primary.mt-3:hover svg {
  transform: translateX(0.2rem);
}
#main-div [id^="main-content-"] > button.btn-muted.mt-3:hover svg {
  transform: translateX(-0.2rem);
}
#main-div [id^="main-content-"] > button.mt-3:focus-visible {
  outline: 2px solid color-mix(in srgb, #0372b7 55%, transparent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  #main-div [id^="main-content-"] > button.mt-3:hover svg,
  #main-div [id^="main-content-"] > button.mt-3:active {
    transform: none;
  }
}
