/* ============================================================
   RNAmotifs 2.0 tutorial — styled to match R2NiTO design system
   (mirrors css/nothing.css tokens; standalone for iframe use)
   ============================================================ */

:root {
  --bg:        #fafafa;
  --bg-alt:    #f2f2f2;
  --fg:        #111;
  --fg-muted:  #777;
  --fg-label:  #999;
  --border:    #e0e0e0;
  --accent:    #e1001a;
  --white:     #fff;
  --radius:    6px;
  --font-head: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Space Grotesk', sans-serif;
  --ease:      cubic-bezier(.25,.1,.25,1);
}

* , *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 3rem 1.6rem 5rem; }

/* ---- tutorial top bar / breadcrumb ---- */
.tut-nav {
  display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center;
  padding-bottom: 1.4rem; margin-bottom: 2.2rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: .78rem;
  letter-spacing: .02em; text-transform: uppercase;
}
.tut-nav a { color: var(--fg-muted); }
.tut-nav a:hover { color: var(--accent); }
.tut-nav .here { color: var(--fg); }
.tut-nav .sep { color: var(--border); }

/* ---- headings ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head); font-weight: 700;
  line-height: 1.2; color: var(--fg);
}
h1 { font-size: 2.1rem; margin: 0 0 1.4rem; letter-spacing: -.02em; }

/* ---- intro logo ---- */
.tut-logo { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto 2rem; }

/* ---- inline figures (example maps) ---- */
.tut-fig {
  display: block; width: 100%; height: auto; margin: 0 auto 1.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--white);
}
h2 {
  font-size: 1.4rem; margin: 2.6rem 0 1rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
h3 { font-size: 1.12rem; margin: 1.8rem 0 .7rem; }

p { margin: 0 0 1.1rem; }

a { color: var(--accent); text-decoration: none; transition: color .2s var(--ease); }
a:hover { text-decoration: underline; }
::selection { background: var(--fg); color: var(--white); }

strong { font-weight: 700; }

/* ---- download button ---- */
.tut-download {
  display: inline-block; margin: 0 0 1.4rem;
  padding: .7rem 1.2rem; border-radius: var(--radius);
  background: var(--accent); color: var(--white) !important;
  font-family: var(--font-mono); font-size: .82rem; font-weight: 500;
  letter-spacing: .02em; text-decoration: none;
  transition: filter .2s var(--ease);
}
.tut-download:hover { filter: brightness(.88); text-decoration: none; }

/* ---- inline code ---- */
code {
  font-family: var(--font-mono); font-size: .85em;
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: .08em .38em; border-radius: 4px;
}

/* ---- code blocks ---- */
pre {
  font-family: var(--font-mono); font-size: .82rem; line-height: 1.55;
  background: #111; color: #f2f2f2;
  padding: 1.05rem 1.2rem; border-radius: var(--radius);
  overflow-x: auto; margin: 0 0 1.4rem;
}
pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

/* ---- lists ---- */
ul, ol { margin: 0 0 1.2rem; padding-left: 1.4rem; }
li { margin: .35rem 0; }
li > ul, li > ol { margin: .35rem 0; }

/* ---- blockquotes / callouts ---- */
blockquote {
  margin: 0 0 1.3rem; padding: .85rem 1.1rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
blockquote p { margin: 0 0 .5rem; }
blockquote p:last-child { margin-bottom: 0; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; }
table {
  border-collapse: collapse; width: 100%;
  font-size: .9rem;
}
th, td {
  text-align: left; padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
thead th {
  font-family: var(--font-mono); font-size: .76rem;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--fg-label); border-bottom: 2px solid var(--border);
}
tbody tr:hover { background: var(--bg-alt); }
td code, th code { white-space: nowrap; }

/* ---- horizontal rule ---- */
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }

/* ---- footer back-link ---- */
.tut-foot {
  margin-top: 3rem; padding-top: 1.3rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--fg-muted);
}

@media (max-width: 600px) {
  h1 { font-size: 1.7rem; }
  .wrap { padding: 2rem 1.1rem 3.5rem; }
}

/* ---- copy-to-clipboard on runnable R blocks (KDM) ---- */
.code-wrap { position: relative; margin: 0 0 1.4rem; }
.code-wrap pre { margin: 0; padding-right: 4.5rem; }

.code-copy {
  position: absolute; top: .5rem; right: .5rem;
  padding: .22rem .6rem;
  font-family: var(--font-mono); font-size: .68rem;
  letter-spacing: .04em; text-transform: uppercase;
  color: #bbb; background: #2a2a2a;
  border: 1px solid #3d3d3d; border-radius: 4px;
  cursor: pointer; opacity: 0;
  transition: opacity .2s var(--ease), color .2s var(--ease),
              background .2s var(--ease);
}
.code-wrap:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--white); background: var(--accent); border-color: var(--accent); }
.code-copy.ok { opacity: 1; color: var(--white); background: #2e7d32; border-color: #2e7d32; }

/* touch devices have no hover - keep the button visible */
@media (hover: none) { .code-copy { opacity: 1; } }

/* ---- printed console output ---- */
pre.r-out {
  background: var(--bg-alt); color: var(--fg);
  border: 1px solid var(--border);
  font-size: .78rem;
}
pre.r-out.scroll { max-height: 26rem; overflow: auto; }
pre.schematic { opacity: .95; }

/* ---- function parameter tables ---- */
.fn-head {
  font-family: var(--font-mono); font-size: .86rem; font-weight: 500;
  text-transform: none; letter-spacing: 0;
  margin: 1.8rem 0 .7rem;
}
.tbl-cap {
  font-size: .9rem; color: var(--fg-muted); margin: 0 0 .5rem;
}

/* inline formulas in prose (not code - never meant to be pasted) */
.formula {
  font-family: var(--font-mono); font-size: .92em;
  white-space: nowrap;
}
.formula sub { font-size: .78em; }

/* ---- figures ---- */
.tut-figure { margin: 0 0 1.6rem; }
.tut-figure .tut-fig { margin-bottom: .6rem; }
.tut-figure figcaption {
  font-size: .88rem; color: var(--fg-muted); line-height: 1.55;
}

/* ---- sortable / filterable report table (KDM) ---- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.table-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem;
  margin: 0 0 .9rem;
}
.tt-label {
  font-family: var(--font-mono); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--fg-label);
}
.tt-filter {
  flex: 1 1 14rem; min-width: 0;
  padding: .45rem .7rem;
  font-family: var(--font-mono); font-size: .82rem; color: var(--fg);
  background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.tt-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tt-count {
  margin: 0; font-family: var(--font-mono); font-size: .72rem;
  color: var(--fg-muted);
}

/* keep the header in view while scrolling a long table */
.table-scroll { max-height: 70vh; overflow: auto; }
.table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sortable thead th { position: sticky; top: 0; z-index: 1; background: var(--bg); }

.sortable th { padding: 0; }
.sortable thead th { border-bottom: 2px solid var(--border); }
.sortable tbody th[scope="row"] {
  padding: .55rem .8rem; font-family: var(--font-body); font-weight: 400;
  border-bottom: 1px solid var(--border);
}

.th-sort {
  display: flex; align-items: center; gap: .35rem;
  width: 100%; padding: .55rem .8rem;
  font-family: var(--font-mono); font-size: .76rem;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--fg-label); text-align: left;
  background: none; border: 0; cursor: pointer;
  transition: color .2s var(--ease);
}
.th-sort:hover { color: var(--accent); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.th-arrow { font-size: .9em; opacity: 0; }
.th-sort:hover .th-arrow { opacity: .45; }
.th-arrow::before { content: "\2195"; }
th[aria-sort="ascending"]  .th-arrow { opacity: 1; }
th[aria-sort="descending"] .th-arrow { opacity: 1; }
th[aria-sort="ascending"]  .th-arrow::before { content: "\2191"; }
th[aria-sort="descending"] .th-arrow::before { content: "\2193"; }
th[aria-sort="ascending"]  .th-sort,
th[aria-sort="descending"] .th-sort { color: var(--accent); }

.sortable tbody tr.filtered-out { display: none; }
.sortable td { white-space: nowrap; }

@media (max-width: 600px) {
  .table-tools { gap: .5rem; }
  .tt-label { flex-basis: 100%; }
}
