/* SPDX-License-Identifier: Apache-2.0 */
/* RAWATTA project page. No framework, no build step. Light and dark follow prefers-color-scheme. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1c1e21;
  --muted: #545a63;
  --faint: #6b717a;
  --border: #dfe2e6;
  --surface: #f5f6f8;
  --surface-2: #eceef1;
  --accent: #a84a08;          /* RAWATTA orange, darkened for contrast on white */
  --accent-soft: #fdf0e6;
  --link: #0a58a8;
  --btn-bg: #1f2328;
  --btn-fg: #ffffff;
  --btn-hover: #3a4048;
  --btn-off-bg: #e6e8eb;
  --btn-off-fg: #50565e;
  --code-bg: #f3f4f6;
  --fig-bg: #ffffff;          /* figures are drawn on white; a soft grey panel in dark mode */
  --ctx: #9ecae1;
  --match: #cb181d;
  --anchor: #fec44f;
  --row-hi: #fff6ee;
  --radius: 10px;
  --maxw: 960px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --fg: #e7e9ec;
    --muted: #b0b6bf;
    --faint: #9aa1ab;
    --border: #2c3138;
    --surface: #1a1d22;
    --surface-2: #22262c;
    --accent: #f39a52;
    --accent-soft: #2a1d13;
    --link: #82bcff;
    --btn-bg: #e7e9ec;
    --btn-fg: #111317;
    --btn-hover: #c9ced5;
    --btn-off-bg: #2a2e34;
    --btn-off-fg: #a9b0b9;
    --code-bg: #1a1d22;
    --row-hi: #241b14;
    --fig-bg: #e6e7ea;        /* a soft grey instead of white, so the figures do not glare */
  }
  .fig-frame img { filter: brightness(0.92); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  overflow-wrap: break-word;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 4px; }
code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
:not(pre) > code { white-space: nowrap; }
pre code { background: none; padding: 0; }
sub, sup { line-height: 0; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 16px; top: 8px; background: var(--bg); padding: 6px 10px; z-index: 10; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }

/* ---------- header ---------- */
.hero { text-align: center; padding: 48px 16px 16px; }  /* keeps the 16px side gutter of .wrap */
.eyebrow { margin: 0 0 10px; font-size: 0.86rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0 auto; max-width: 860px; font-size: clamp(1.5rem, 1.05rem + 2.2vw, 2.45rem); line-height: 1.22; font-weight: 700; letter-spacing: -0.01em; }
.authors { margin: 20px 0 4px; font-size: 1.1rem; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 28px; }
.authors sup { font-size: 0.7em; margin-left: 1px; color: var(--muted); }
.affils { margin: 0; color: var(--muted); font-size: 0.98rem; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 22px; }
.affils sup { font-size: 0.7em; margin-right: 2px; }

.links { margin: 22px 0 6px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 0; list-style: none; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 8px 18px; border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg); text-decoration: none;
  font-weight: 600; font-size: 0.97rem; line-height: 1.2; border: 0; cursor: pointer;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn[aria-disabled="true"] { background: var(--btn-off-bg); color: var(--btn-off-fg); cursor: default; }
.btn .soon { font-weight: 500; font-size: 0.8em; opacity: 0.95; }

/* ---------- sections ---------- */
section { padding: 30px 0 6px; scroll-margin-top: 12px; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); line-height: 1.25; margin: 0 0 14px; letter-spacing: -0.005em; }
h2 a.anchor { color: inherit; text-decoration: none; }
h2 a.anchor:hover::after { content: " #"; color: var(--faint); }
h3 { font-size: 1.12rem; margin: 22px 0 8px; }
p { margin: 0 0 14px; }
.lead { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.src { color: var(--muted); font-size: 0.86em; white-space: nowrap; }

.tldr {
  margin: 18px auto 0; padding: 16px 20px; border-radius: var(--radius);
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  font-size: 1.08rem;
}
.tldr strong { color: var(--accent); }
.tldr p { margin: 0; }

.stats { list-style: none; padding: 0; margin: 18px auto 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stats li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stats b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 0.92rem; }

/* ---------- figures ---------- */
figure { margin: 18px 0 22px; }
.fig-frame { display: block; background: var(--fig-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.fig-frame img { display: block; width: 100%; height: auto; }
.fig-frame.small { max-width: 560px; margin: 0 auto; }
.fig-frame.wide { overflow-x: auto; -webkit-overflow-scrolling: touch; }
figcaption { margin-top: 10px; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
figcaption b { color: var(--fg); }
.zoom-hint { font-size: 0.85rem; color: var(--faint); }

/* ---------- regime cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin: 8px 0 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; border-top: 5px solid var(--c, var(--border)); }
.card.ctx { --c: var(--ctx); }
.card.match { --c: var(--match); }
.card.anchor { --c: var(--anchor); }
.card h3 { margin: 0 0 2px; font-size: 1.1rem; }
.card .blocks { margin: 0 0 10px; color: var(--muted); font-size: 0.88rem; }
.card p { font-size: 0.95rem; margin-bottom: 10px; }
.card .verdict { display: inline-block; font-weight: 700; font-size: 0.86rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); margin-bottom: 8px; }
.card .verdict.ok { color: #1f6f3f; background: #e3f4ea; }
.card .verdict.cond { color: #7a4a00; background: #fbefd5; }
.card .verdict.no { color: #9b1c1c; background: #fbe4e4; }
@media (prefers-color-scheme: dark) {
  .card .verdict.ok { color: #9fe0b7; background: #183323; }
  .card .verdict.cond { color: #f6cf8a; background: #33270f; }
  .card .verdict.no { color: #ffb3b3; background: #3a1717; }
}

/* ---------- method steps ---------- */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 6px 0 14px; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 14px 46px; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 700; font-size: 0.95rem;
}
.steps h3 { margin: 3px 0 4px; }
.steps p { margin: 0 0 6px; }

/* ---------- speed breakdown ---------- */
.chain { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.chain li { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; }
.chain .what { flex: 1 0 auto; }
.chain .what { display: block; font-size: 0.85rem; color: var(--muted); }
.chain .ms { display: block; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chain .step { display: block; font-size: 0.88rem; color: var(--accent); font-weight: 600; }
.chain li.base .step { color: var(--muted); font-weight: 500; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.table-cap { margin: 0 0 8px; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.scroll-hint { display: none; margin: 0 0 4px; color: var(--faint); font-size: 0.82rem; }
td.wrap-cell, th.wrap-cell { text-align: left; white-space: normal; min-width: 120px; }
td.gpu-cell, th.gpu-cell { min-width: 84px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface); font-weight: 600; font-size: 0.86rem; vertical-align: bottom; }
thead tr.group th { border-bottom: 0; padding-bottom: 0; text-align: center; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tr.hi td { background: var(--row-hi); }
tr.hi td:first-child { font-weight: 700; }
tr.sep td { border-top: 2px solid var(--border); }
td.sub { padding-left: 26px; color: var(--muted); }
.pm { color: var(--muted); font-size: 0.85em; }
.oom { color: var(--muted); }
.table-note { font-size: 0.86rem; color: var(--muted); margin: 4px 0 18px; }

/* ---------- code blocks ---------- */
.codeblock { position: relative; margin: 10px 0 16px; }
.codeblock pre {
  margin: 0; padding: 40px 16px 14px; overflow-x: auto; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: var(--radius); line-height: 1.5; font-size: 0.86rem;
}
.copy {
  position: absolute; top: 8px; right: 8px; font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer;
}
.copy:hover { background: var(--surface-2); }
.req { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 8px 0 16px; padding: 0; list-style: none; }
.req li { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); font-size: 0.95rem; }
.req b { display: block; }
.note { margin: 8px 0 16px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.95rem; }
/* long paths and image names in the instructions may wrap on a phone instead of widening the page */
#use p > code, .viewer-caption code { white-space: normal; overflow-wrap: anywhere; }

/* ---------- limitations ---------- */
.limits { padding-left: 20px; }
.limits li { margin-bottom: 10px; }

/* ---------- viewer ---------- */
.viewer { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #15171b; }
.viewer-canvas { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 72vh; touch-action: none; }
.viewer-canvas canvas { display: block; width: 100%; height: 100%; }
.viewer-status { position: absolute; left: 12px; bottom: 10px; color: #d7dbe0; font-size: 0.82rem; background: rgba(0, 0, 0, 0.45); padding: 3px 9px; border-radius: 6px; pointer-events: none; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--border); color: var(--fg); font-size: 0.9rem; }
.viewer-bar .scenes { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 0.86rem; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.viewer-bar label { display: inline-flex; align-items: center; gap: 6px; }
.viewer-bar input[type="range"] { width: 110px; }
.viewer-caption { margin-top: 8px; }

/* ---------- bibtex / footer ---------- */
.bib pre { white-space: pre-wrap; word-break: break-word; }
footer { margin-top: 40px; padding: 26px 0 40px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; }
footer p { margin: 0 0 8px; }

@media (max-width: 700px) {
  .scroll-hint { display: block; }
  .fig-frame.wide img { width: 720px; max-width: none; }
  /* keep the row label visible while a wide table scrolls */
  .table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg); box-shadow: 1px 0 0 var(--border); }
  .table-wrap thead th:first-child { background: var(--surface); }
  .table-wrap tr.hi td:first-child { background: var(--row-hi); }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .hero { padding-top: 32px; }
  .btn { padding: 8px 14px; font-size: 0.92rem; }
  th, td { padding: 7px 8px; }
  .fig-frame { padding: 6px; }
  .steps > li { padding-left: 42px; }
}
