/* ──────────────────────────────────────────────
   Base styles — shared across all pages
────────────────────────────────────────────── */

:root {
  --riso-pink: #ff48b0;
  --riso-blue: #0078bf;
  --riso-yellow: #ffe800;
  --riso-orange: #ff6c2f;
  --riso-black: #1a1a1a;
  --riso-paper: #f5f0e8;
  --riso-paper-dark: #ece5d8;
  --demo-accent: var(--riso-pink);
  --demo-accent2: var(--riso-blue);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--riso-paper);
  color: var(--riso-black);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grain texture overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 100;
}

h1 {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
}

header {
  max-width: 860px;
  margin: 0 auto;
}


/* ──────────────────────────────────────────────
   Demo pages — sub-folder index.html files
────────────────────────────────────────────── */

.demo-page header {
  padding: 100px 2rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.back {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: #999;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}

.back:hover {
  color: var(--riso-blue);
  border-color: var(--riso-blue);
}

.demo-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}


.demo-page h1 {
  font-size: 1.2rem;
  line-height: 1.2;
}

.desc {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 2rem 1.25rem;
  font-size: 0.85rem;
  color: #777;
  line-height: 1.5;
}

canvas {
  display: block;
  margin: 0 auto 2rem;
  border: 1px solid var(--riso-paper-dark);
}

.explanation {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

.explanation h2 {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 3.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--demo-accent);
  display: inline-block;
}

.explanation h2:first-child {
  margin-top: 0;
}

.explanation h3 {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: var(--demo-accent2);
}

.explanation p {
  font-size: 0.88rem;
  line-height: 1.65;
  margin-bottom: 0.6rem;
  color: #444;
}

.explanation code {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  background: var(--riso-paper-dark);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.explanation pre {
  background: var(--riso-black);
  color: #e8e1d5;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  margin: 0.5rem 0 1rem;
  overflow-x: auto;
}

.explanation pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.8rem;
  line-height: 1.6;
}

.explanation ul, .explanation ol {
  font-size: 0.88rem;
  line-height: 1.65;
  color: #444;
  margin: 0.4rem 0 0.8rem 1.25rem;
}

.explanation li {
  margin-bottom: 0.35rem;
}

.explanation a {
  color: var(--riso-blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.explanation a:hover {
  border-color: var(--riso-blue);
}

.explanation strong {
  color: var(--riso-black);
}

/* Glossary cross-reference links — wrap <code> in <a class="gref"> */
.explanation a.gref,
.desc a.gref {
  text-decoration: none;
  border-bottom: none;
  color: inherit;
}

.explanation a.gref code,
.desc a.gref code {
  color: var(--riso-blue);
  border-bottom: 1px dashed color-mix(in srgb, var(--riso-blue) 50%, transparent);
  transition: background 0.1s;
}

.explanation a.gref:hover code,
.desc a.gref:hover code {
  background: #e8f2f9;
  border-bottom-style: solid;
}

/* Data download link — demos 10 and 11 */
.data-download {
  max-width: 860px;
  margin: 0 auto;
  padding: 0.75rem 2rem 2.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-download a {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-decoration: none;
  background: var(--demo-accent);
  border-radius: 3px;
  padding: 0.35rem 0.8rem;
  transition: opacity 0.12s;
}

.data-download a:hover {
  opacity: 0.8;
}

/* Template download box — demo 00-template */
.download-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

.download-box {
  background: var(--riso-paper-dark);
  border: 1px solid #d8d0c4;
  border-radius: 6px;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.download-info {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
}

.download-info strong {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  color: var(--riso-black);
  margin-bottom: 0.35rem;
}

.download-info code {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  background: rgba(0,0,0,0.06);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.download-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--riso-paper);
  background: var(--riso-blue);
  text-decoration: none;
  padding: 0.65rem 1.25rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.download-btn:hover {
  background: #005f99;
}


/* ──────────────────────────────────────────────
   Sidebar navigation
────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 210px;
  background: var(--riso-black);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  border-right: 1px solid #2a2a2a;
}

body.has-sidebar {
  padding-left: 210px;
}

.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}

.sidebar-logo {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  display: block;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-logo-pink { color: var(--riso-pink); }
.sidebar-logo-blue { color: var(--riso-blue); }

.sidebar-sub {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  color: #555;
  margin-top: 0.3rem;
  letter-spacing: 0.03em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.nav-category-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.7rem 1rem 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #3a3a3a;
  text-align: left;
  transition: color 0.1s;
}

.nav-category-btn:hover {
  color: #666;
}

.nav-chevron {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid #3a3a3a;
  border-bottom: 1.5px solid #3a3a3a;
  transform: rotate(45deg);
  margin-bottom: 0.15rem;
  flex-shrink: 0;
  transition: transform 0.2s ease, border-color 0.1s;
}

.nav-category-btn[aria-expanded="false"] .nav-chevron {
  transform: rotate(-45deg);
  margin-bottom: 0;
}

.nav-category-btn:hover .nav-chevron {
  border-color: #666;
}

.nav-category-items {
  overflow: hidden;
  transition: max-height 0.22s ease;
}

.nav-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  text-decoration: none;
  color: #888;
  font-size: 0.78rem;
  line-height: 1.4;
  transition: background 0.1s, color 0.1s;
}

.nav-item:hover {
  background: #1e1e1e;
  color: #ddd;
}

.nav-item.active {
  background: #222;
  color: #fff;
}


/* Hide the back link when sidebar handles navigation */
.has-sidebar .back { display: none; }


/* ──────────────────────────────────────────────
   Responsive
────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  body.has-sidebar { padding-left: 0; }
  .has-sidebar .back { display: inline; }
}

@media (max-width: 600px) {
.demo-page header { padding: 1.25rem 1.25rem 0.75rem; }
  .desc { padding: 0 1.25rem 1rem; }
  .explanation { padding: 0 1.25rem 2rem; }
  .data-download { padding: 0 1.25rem 1rem; }
  .download-section { padding: 1rem 1.25rem 2rem; }
  .download-box { flex-direction: column; align-items: flex-start; }
}
