/* ============================================
   ROB RELIABILITY — Resources section styles
   Shared by resources/index.html and all
   resource summary articles.
   ============================================ */

/* ===== Listing page ===== */

.res-intro {
  max-width: 760px;
}
.res-intro p {
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.res-group { margin-top: 56px; }
.res-group:first-of-type { margin-top: 24px; }
.res-group-head { margin-bottom: 22px; }
.res-group-head h2 {
  font-size: clamp(22px, 2.6vw, 30px);
  margin: 0 0 8px;
}
.res-group-head p {
  font-size: 14.5px;
  color: var(--text-muted);
  max-width: 64ch;
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1080px) { .res-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .res-grid { grid-template-columns: 1fr; } }

.res-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: white;
  border: 1px solid var(--grey-border);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  transition: all .25s;
}
.res-card.has-banner {
  padding: 0;
  background: #fff;
}
.res-card-banner {
  position: relative;
  line-height: 0;
  overflow: hidden;
  background: #eef3f8;
}
.res-card-banner img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.45s ease;
}
.res-card.has-banner:hover .res-card-banner img {
  transform: scale(1.04);
}
.res-card-banner::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 56px;
  background: linear-gradient(to bottom, transparent, #fff);
  pointer-events: none;
}
.res-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  z-index: 1;
  margin-top: -10px;
  padding: 0 22px 22px;
  background: #fff;
}
.res-card-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.res-card-headline .stars {
  flex-shrink: 0;
  margin-top: 2px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.18);
  font-size: 11px;
  letter-spacing: 1.5px;
}
.res-card.has-banner h3 {
  margin: 0 0 4px;
  font-size: 16.5px;
  line-height: 1.3;
}
.res-card.has-banner .res-author {
  margin: 0;
}
.res-card-body > p:not(.res-author) {
  flex: 1;
  margin-top: 10px;
}
.res-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(0,184,214,0.4);
}

.res-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.res-card .uc-icon { margin-bottom: 0; }

.stars {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--orange);
  white-space: nowrap;
}
.stars .off { color: var(--rr-steel); }

.res-card h3 { font-size: 17px; margin: 0 0 4px; }
.res-card .res-author {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.res-card > p:not(.res-author),
.res-card-body > p:not(.res-author) {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  flex: 1;
  margin: 0;
}

.res-card-foot {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.res-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--grey-border);
  color: var(--text-secondary);
  transition: all .2s;
}
.res-btn:hover { border-color: var(--rr-cyan-shade); color: var(--text-primary); }
.res-btn svg { width: 13px; height: 13px; }
.res-btn.primary {
  background: linear-gradient(135deg, var(--rr-cyan-shade), var(--rr-deep));
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(10, 18, 32, 0.14);
}
.res-btn.primary:hover { filter: brightness(1.08); color: white; }

.res-soon {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(138,148,166,0.14);
  color: var(--text-muted);
}

/* ===== Article pages ===== */

/* Shell — sticky side TOC */
.article-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding: 0 0 80px;
}
@media (max-width: 1080px) {
  .article-shell { grid-template-columns: 1fr; gap: 0; }
}

.article-toc {
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
}
@media (max-width: 1080px) {
  .article-toc {
    position: sticky;
    top: 72px;
    z-index: 25;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0 -20px 28px;
    padding: 10px 20px;
    background: rgba(245,248,251,0.92);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--grey-border);
    -webkit-overflow-scrolling: touch;
  }
}

.article-toc-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 14px;
}
@media (max-width: 1080px) { .article-toc-label { display: none; } }

.article-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--grey-border);
}
@media (max-width: 1080px) {
  .article-toc-list {
    display: flex;
    gap: 8px;
    border-left: none;
    padding-bottom: 2px;
  }
}
.article-toc-list li { margin: 0; }
.article-toc-list a {
  display: block;
  padding: 7px 0 7px 16px;
  margin-left: -2px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.35;
  transition: color 0.15s ease, border-color 0.15s ease;
}
@media (max-width: 1080px) {
  .article-toc-list a {
    flex: 0 0 auto;
    padding: 7px 14px;
    margin-left: 0;
    border-left: none;
    border: 1px solid var(--grey-border);
    border-radius: 999px;
    background: var(--white);
    font-size: 12.5px;
    white-space: nowrap;
  }
}
.article-toc-list a:hover { color: var(--accent-a); }
.article-toc-list a.is-active {
  color: var(--accent-a);
  font-weight: 600;
  border-left-color: var(--accent-a);
}
@media (max-width: 1080px) {
  .article-toc-list a.is-active {
    border-color: var(--accent-a);
    background: rgba(0,184,214,0.08);
  }
}

.article-body { min-width: 0; }
.article-body .section { padding-top: 48px; padding-bottom: 48px; }
.article-body .section:first-child { padding-top: 12px; }
.article-section { scroll-margin-top: 100px; }
.article-body .section-head { max-width: none; margin-bottom: 24px; }
.article-body .section-head h2 { margin: 0 0 12px; color: var(--text-primary); }
.article-body .section-head p {
  margin-top: 0;
  font-size: 16px;
  line-height: 1.6;
  max-width: 62ch;
  text-align: justify;
  hyphens: auto;
}

/* Article header */
.article-head { padding: 30px 0 14px; }
.article-head .eyebrow { margin-bottom: 18px; }
.article-head h1 {
  font-size: clamp(32px, 4.6vw, 52px);
  line-height: 1.07;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  max-width: 20ch;
}
.article-lede {
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 56ch;
  margin: 0;
  text-align: justify;
  hyphens: auto;
}
.article-date {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--grey-border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Prose */
.prose { max-width: 720px; }
.prose.wide { max-width: none; }
.prose p {
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 18px;
  text-align: justify;
  hyphens: auto;
}
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text-primary); }
.prose ul, .prose ol {
  margin: 0 0 18px;
  padding-left: 24px;
  color: var(--text-secondary);
  font-size: 15.5px;
  line-height: 1.65;
}
.prose li { margin-bottom: 6px; }
.prose li strong { color: var(--text-primary); }
.prose h3 { font-size: clamp(18px, 1.9vw, 22px); margin: 28px 0 12px; letter-spacing: -0.01em; }
.prose a.link {
  color: var(--accent-a);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(0,184,214,0.35);
  overflow-wrap: anywhere;
}
.prose a.link:hover { border-bottom-color: var(--accent-a); }
.prose h2 { font-size: clamp(24px, 2.6vw, 30px); margin: 0 0 14px; letter-spacing: -0.01em; }
.lede-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-a);
  margin: 0 0 10px;
}

.title-hand-line {
  display: inline-block;
  position: relative;
  padding-bottom: 10px;
}
.title-hand-line::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 280 7' preserveAspectRatio='none'%3E%3Cpath d='M1 4.8 C 38 6.2, 72 2.4, 108 4.6 S 188 6.4, 224 3.8 S 262 5.6, 279 4.2' fill='none' stroke='%2300B8D6' stroke-width='1.4' stroke-linecap='round' opacity='0.42'/%3E%3C/svg%3E") no-repeat left bottom / 100% 100%;
  pointer-events: none;
}

/* Source citation block */
.res-cite {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin: 26px 0 0;
  padding: 20px 22px;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-left: 3px solid var(--rr-cyan-shade);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.res-cite-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(0,184,214,0.08);
  border: 1px solid rgba(0,184,214,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rr-cyan-shade);
}
.res-cite-icon svg { width: 20px; height: 20px; }
.res-cite-body { min-width: 0; }
.res-cite-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.res-cite-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
  line-height: 1.35;
}
.res-cite-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.res-cite-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .res-cite { flex-direction: column; }
}

/* Figures (SVG diagrams) */
.res-figure {
  margin: 32px 0;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: 14px;
  padding: 24px 24px 18px;
  box-shadow: var(--shadow-md);
}
.res-figure svg { width: 100%; height: auto; }
.res-figure figcaption {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--grey-border);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
@media (max-width: 560px) { .res-figure { padding: 14px 14px 12px; } }

/* Data tables */
.res-table-wrap { margin: 28px 0; overflow-x: auto; }
.res-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 13.5px;
}
.res-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 12px 16px;
  border-bottom: 1px solid var(--grey-border);
}
.res-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--grey-border);
  color: var(--text-secondary);
  vertical-align: top;
  line-height: 1.5;
}
.res-table tr:last-child td { border-bottom: none; }
.res-table td strong { color: var(--text-primary); }
.res-table .mono { font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; }

/* Key takeaway callout */
.res-callout {
  margin: 32px 0;
  padding: 22px 26px;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-left: 3px solid var(--rr-cyan-shade);
  border-radius: 12px;
}
.res-callout .res-callout-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-a);
  margin: 0 0 8px;
}
.res-callout p {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
  text-align: justify;
  hyphens: auto;
}
.res-callout p strong { color: var(--text-primary); }

/* Numbered concept list (e.g. the 7 RCM questions) */
.num-list {
  list-style: none;
  margin: 28px 0;
  padding: 0;
  display: grid;
  gap: 10px;
  counter-reset: numlist;
}
.num-list li {
  counter-increment: numlist;
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.num-list li::before {
  content: counter(numlist);
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-a);
  background: rgba(0,184,214,0.1);
  border: 1px solid rgba(0,184,214,0.18);
  border-radius: 8px;
}
.num-list li strong { color: var(--text-primary); }

/* References list */
.ref-list {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.ref-list li {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.ref-list li strong { color: var(--text-primary); }
.ref-list li a {
  color: var(--accent-a);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.ref-list li a:hover { text-decoration: underline; }

/* Legal / attribution disclaimer (discreet) */
.res-disclaimer {
  margin: 28px 0 0;
  padding: 14px 18px;
  background: transparent;
  border-top: 1px solid var(--grey-border);
}
.res-disclaimer p {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
  text-align: justify;
}
.res-disclaimer a {
  color: var(--text-muted);
  text-decoration: underline;
}

/* Closing CTA strip back to resources */
.res-back {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============= FIGURE ANIMATIONS (SVG) =============
   Triggered by the existing reveal-on-scroll: script.js adds .in
   to .res-figure.reveal when it enters the viewport. Each animated
   element sets its own delay with style="--d:.4s".
   - .a-draw : line/path draws itself (element needs pathLength="1")
   - .a-pop  : marker pops in with a slight overshoot
   - .a-fade : label/box fades in and rises
   - .a-grow : bar grows from the left
   - .a-pulse: infinite soft radar pulse (decorative ring)          */

.res-figure .a-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
}
.res-figure.in .a-draw {
  animation: resDraw 1.3s cubic-bezier(.45,.05,.35,1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes resDraw {
  0%   { stroke-dashoffset: 1; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

.res-figure .a-pop {
  opacity: 0;
  transform: scale(0);
  transform-box: fill-box;
  transform-origin: center;
}
.res-figure.in .a-pop {
  animation: resPop .5s cubic-bezier(.34,1.56,.64,1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes resPop {
  0%   { opacity: 0; transform: scale(0); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

.res-figure .a-fade {
  opacity: 0;
  transform: translateY(8px);
}
.res-figure.in .a-fade {
  animation: resFadeUp .6s ease-out forwards;
  animation-delay: var(--d, 0s);
}
@keyframes resFadeUp {
  to { opacity: 1; transform: translateY(0); }
}

.res-figure .a-grow {
  transform: scaleX(0);
  transform-box: fill-box;
  transform-origin: left center;
}
.res-figure.in .a-grow {
  animation: resGrowX .9s cubic-bezier(.25,.7,.3,1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes resGrowX {
  to { transform: scaleX(1); }
}

.res-figure .a-pulse { opacity: 0; }
.res-figure.in .a-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: resPulse 2.4s ease-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes resPulse {
  0%   { transform: scale(.5); opacity: .8; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}


/* opacity-only fade — for SVG elements that carry their own transform attribute
   (a CSS transform animation would override attribute transforms) */
.res-figure .a-fade-o { opacity: 0; }
.res-figure.in .a-fade-o {
  animation: resFadeO .6s ease-out forwards;
  animation-delay: var(--d, 0s);
}
@keyframes resFadeO { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .res-figure .a-draw,
  .res-figure .a-pop,
  .res-figure .a-fade,
  .res-figure .a-fade-o,
  .res-figure .a-grow {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
  .res-figure .a-pulse,
  .res-figure.in .a-pulse { animation: none !important; opacity: 0 !important; }
}
