/* /stock-photo-royalty-rates (static/stock-photo-royalty-rates.html; the table, estimator rows and
   data come from backend/core/royalty_rates.py, the estimator is static/js/royalty-calc.js).
   Loaded after app.css and public.css, every colour an app token so both themes follow.
   Every selector starts with #rr (tests/test_royalty_rates_page.py scans for that).

   The table is the hero: one sheet a contributor or an assistant can quote, the share column the
   one gold thing, a source link on every row. The estimator below draws each agency's photo share
   as a range on one 0 to 50% scale. */

#rr {
  --rr-link: var(--pk-link, var(--gold));
  --rr-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  width: 100%; max-width: var(--pk-max); box-sizing: border-box; margin: 0 auto; padding: 0 24px 40px;
}
#rr ::selection { background: rgba(var(--gold-rgb), .35); color: var(--text); }
#rr [hidden] { display: none !important; }

/* ── Hero: H1 with the trust line beside it, then the answer ── */
#rr .rr-hero { padding: 40px 0 24px; }
/* app.css pads every <section> 60px/28px; these sections set their own. */
#rr .rr-sheet { padding: 0; }
#rr .rr-crumbs { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
#rr .rr-crumbs a { color: var(--muted); text-decoration: none; border: 0; }
#rr .rr-crumbs a:hover { color: var(--rr-link); }
#rr .rr-crumbs span { margin: 0 8px; }
#rr .rr-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: end; }
#rr h1 { margin: 0; font-size: clamp(2.1rem, 4vw, 3.3rem); font-weight: 750; line-height: 1.04; letter-spacing: -.025em;
  text-wrap: balance; color: var(--text); }
#rr h1 em { font-style: normal; color: var(--rr-link); }
#rr .rr-trust { max-width: 46ch; margin: 0; font-size: 15px; line-height: 1.55; color: var(--dim); }
#rr .rr-trust b { font-weight: 600; color: var(--text); }
#rr p[data-answer] { max-width: 78ch; margin: 24px 0 0; font-size: 1.06rem; line-height: 1.6; color: var(--text); }
@media (min-width: 1000px) {
  #rr .rr-hero { padding: 48px 0 32px; }
  #rr .rr-head { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 48px; }
}

/* ── The sheet ── */
#rr .rr-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--s1); }
#rr .rr-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
#rr .rr-table thead th { position: sticky; top: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--s2);
  text-align: left; font-size: 12px; font-weight: 600; color: var(--dim); white-space: nowrap; }
#rr .rr-table tbody th, #rr .rr-table td { padding: 16px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; color: var(--text); }
#rr .rr-table tbody tr:first-child th, #rr .rr-table tbody tr:first-child td { border-top: 0; }
#rr .rr-table tbody th { font-size: 15px; font-weight: 600; white-space: nowrap; }
#rr .rr-table td:nth-child(2) { min-width: 16ch; }
#rr .rr-table td:nth-child(3) { min-width: 26ch; }
#rr .rr-pct { display: block; font-size: 20px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; color: var(--rr-link); white-space: nowrap; font-variant-numeric: tabular-nums; }
#rr .rr-pct-note { display: block; margin-top: 4px; font-size: 12px; line-height: 1.45; color: var(--muted); }
#rr .rr-none { color: var(--muted); }
#rr .rr-src { margin: 0; padding: 0; list-style: none; }
#rr .rr-src li + li { margin-top: 4px; }
#rr .rr-src a { font-size: 13px; color: var(--rr-link); text-decoration: underline; text-decoration-color: rgba(var(--gold-rgb), .4);
  text-underline-offset: 3px; border: 0; }
#rr .rr-src a:hover { text-decoration-color: currentColor; }
#rr .rr-table tbody tr:hover > * { background: color-mix(in srgb, var(--gold) 4%, transparent); }
#rr .rr-foot { max-width: 78ch; margin: 12px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); }

/* A phone gets one card per agency, labelled from the cells' own data-label. */
@media (max-width: 760px) {
  #rr .rr-table-wrap { overflow: visible; border: 0; background: none; }
  #rr .rr-table thead { display: none; }
  #rr .rr-table, #rr .rr-table tbody, #rr .rr-table tr, #rr .rr-table tbody th, #rr .rr-table td { display: block; width: 100%; box-sizing: border-box; }
  #rr .rr-table tr { margin-bottom: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--s1); }
  #rr .rr-table tbody th { padding: 16px 16px 4px; border: 0; font-size: 17px; }
  #rr .rr-table td { min-width: 0 !important; padding: 8px 16px; border: 0; }
  #rr .rr-table td:last-child { padding-bottom: 16px; }
  #rr .rr-table td::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
  #rr .rr-table tbody tr:hover > * { background: none; }
}

/* ── Sections ── */
#rr .rr-sec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px 48px; padding: 40px 0; border-top: 1px solid var(--border); margin-top: 40px; }
#rr .rr-sec + .rr-sec { margin-top: 0; }
#rr .rr-sec-head h2 { margin: 0 0 8px; font-size: clamp(1.3rem, 2vw, 1.6rem); font-weight: 700; line-height: 1.2; letter-spacing: -.015em; color: var(--text); }
#rr .rr-sec-head p { max-width: 52ch; margin: 0; font-size: 15px; line-height: 1.6; color: var(--dim); }
#rr .rr-prose p { max-width: 68ch; margin: 0 0 16px; font-size: 1rem; line-height: 1.65; color: var(--dim); }
@media (min-width: 1000px) {
  #rr .rr-sec { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  #rr .rr-sec-head { position: sticky; top: 88px; align-self: start; }
}

/* ── Estimator ── */
#rr .rr-calc { padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--s1); }
#rr .rr-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
#rr .rr-field span { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text); }
#rr .rr-field input { display: block; width: 100%; box-sizing: border-box; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; font-variant-numeric: tabular-nums; }
#rr .rr-field input::placeholder { color: var(--muted); }
#rr .rr-field input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#rr .rr-field-cur { grid-column: 1 / -1; max-width: 160px; }
@media (min-width: 640px) {
  #rr .rr-inputs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px; }
  #rr .rr-field-cur { grid-column: auto; max-width: none; }
}

#rr .rr-rows { margin: 24px 0 0; padding: 0; list-style: none; }
#rr .rr-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name share" "bar bar" "amt amt";
  gap: 8px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
#rr .rr-name { grid-area: name; font-size: 15px; font-weight: 600; color: var(--text); }
#rr .rr-share { grid-area: share; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#rr .rr-bar { grid-area: bar; position: relative; height: 8px; border-radius: 999px; background: var(--s3); }
#rr .rr-bar i { position: absolute; top: 0; bottom: 0; left: calc(var(--lo) / 50 * 100%); border-radius: 999px; background: var(--gold);
  width: max(8px, calc((var(--hi) - var(--lo)) / 50 * 100%)); }
#rr .rr-amt { grid-area: amt; min-height: 1.4em; font: 600 15px/1.4 var(--rr-mono); color: var(--text); }
#rr .rr-calc:not(.rr-has) .rr-amt { display: none; }
@media (min-width: 640px) {
  #rr .rr-row { grid-template-columns: 160px minmax(0, 1fr) 110px minmax(0, 190px); grid-template-areas: "name bar share amt"; }
  #rr .rr-amt { text-align: right; }
  #rr .rr-calc:not(.rr-has) .rr-amt { display: block; }
}
#rr .rr-note { max-width: 68ch; margin: 16px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); }

#rr .rr-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; padding: 0; list-style: none; }
#rr .rr-links a { display: inline-flex; align-items: center; min-height: 32px; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--s1); font-size: 14px; color: var(--text); text-decoration: none; transition: border-color .15s; }
#rr .rr-links a:hover { border-color: rgba(var(--gold-rgb), .6); }

#rr a:focus-visible, #rr .faq-q:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

/* The one authored moment: on load the share bars draw out from the left. Visible without it. */
@media (prefers-reduced-motion: no-preference) {
  #rr .rr-bar i { transform-origin: left center; animation: rr-draw .9s cubic-bezier(.16, 1, .3, 1) both; }
  #rr .rr-row:nth-child(2) .rr-bar i { animation-delay: .06s; }
  #rr .rr-row:nth-child(3) .rr-bar i { animation-delay: .12s; }
  #rr .rr-row:nth-child(4) .rr-bar i { animation-delay: .18s; }
  #rr .rr-row:nth-child(5) .rr-bar i { animation-delay: .24s; }
}
@keyframes rr-draw { from { transform: scaleX(.15); opacity: .5; } }

@media (max-width: 640px) {
  #rr { padding: 0 16px 32px; }
  #rr .rr-hero { padding-top: 24px; }
  #rr .rr-calc { padding: 16px; }
}
