/* scrollbox.net — site styles */

:root {
  --paper: #ECEAF4;
  --surface: #F8F7FC;
  --ink: #1E1A3C;
  --muted: #5F5A80;
  --line: #D3CFE4;
  --accent: #4B2BFF;
  --accent-ink: #FFFFFF;
  --thumb: #FFC93C;
  --screen: #17142E;
  --code-bg: #17142E;
  --code-ink: #E7E3FF;

  --font: 'Onest', ui-sans-serif, system-ui, sans-serif;
  --display: 'Unbounded', 'Onest', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  --s-1: .8125rem;
  --s0: 1rem;
  --s1: 1.25rem;
  --s2: 1.5625rem;
  --s3: 1.953rem;
  --s4: 2.441rem;
  --s5: 3.815rem;
  --s6: 5.96rem;

  --gutter: clamp(16px, 4vw, 48px);
  --radius-screen: 10px;
  --radius-ui: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14122A;
    --surface: #1D1A37;
    --ink: #EDEAFB;
    --muted: #A49FC6;
    --line: #332F58;
    --accent: #9A88FF;
    --accent-ink: #14122A;
    --screen: #0C0A1C;
    --code-bg: #0E0C20;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14122A; --surface: #1D1A37; --ink: #EDEAFB; --muted: #A49FC6; --line: #332F58;
  --accent: #9A88FF; --accent-ink: #14122A; --screen: #0C0A1C; --code-bg: #0E0C20; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
html::-webkit-scrollbar { width: 0; }
html { scrollbar-width: none; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 var(--s0)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); }

/* ── The page rail: the whole site is a scrollbox ── */
.page-rail {
  position: fixed; top: 10px; bottom: 10px; right: 4px; width: 8px; z-index: 50;
  border-radius: 4px; background: color-mix(in srgb, var(--ink) 8%, transparent);
  pointer-events: none;
}
.page-rail i { position: absolute; left: 0; right: 0; border-radius: 4px; background: var(--thumb); box-shadow: 0 0 0 1.5px var(--ink); }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.125rem; letter-spacing: -.02em; }
.logo-mark { width: 22px; height: 26px; border: 2px solid var(--ink); border-radius: 5px; position: relative; }
.logo-mark::after { content: ''; position: absolute; right: 2px; top: 3px; width: 4px; height: 9px; border-radius: 2px; background: var(--thumb); box-shadow: 0 0 0 1px var(--ink); animation: logo-thumb 6s ease-in-out infinite; }
@keyframes logo-thumb { 0%, 15% { top: 3px; } 45%, 60% { top: 11px; } 90%, 100% { top: 3px; } }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: var(--radius-ui); color: var(--muted); font-weight: 550; }
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
@media (max-width: 560px) { .nav a.nav-optional { display: none; } }

/* ── Screens (live previews) ── */
.screen {
  position: relative; background: var(--screen); border-radius: var(--radius-screen);
  border: 1.5px solid var(--ink); overflow: hidden; isolation: isolate;
}
.screen-viewport { position: absolute; inset: 0 14px 0 0; overflow: hidden; }
.screen-viewport iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; pointer-events: none; background: #fff; opacity: 0; transition: opacity .35s; }
.screen.is-loaded iframe { opacity: 1; }
.screen-rail { position: absolute; top: 0; right: 0; bottom: 0; width: 14px; background: var(--surface); border-left: 1.5px solid var(--ink); }
.screen-rail i { position: absolute; left: 3px; right: 3px; top: 0; height: 20%; border-radius: 3px; background: color-mix(in srgb, var(--ink) 25%, transparent); transition: background .2s; }
.screen.is-playing .screen-rail i { background: var(--thumb); box-shadow: 0 0 0 1px var(--ink); }

/* ── Hero ── */
.hero { padding: clamp(40px, 7vw, 96px) 0 clamp(40px, 6vw, 80px); }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(28px, 5vw, 72px); align-items: center; }
.hero h1 {
  margin: 0 0 28px; font-family: var(--display); font-size: clamp(2.1rem, 4.4vw, 4.25rem); line-height: 1.04; letter-spacing: -.025em;
  font-weight: 700; text-wrap: balance;
}
.hero-lede { font-size: var(--s1); line-height: 1.5; color: var(--muted); max-width: 34ch; margin: 0 0 32px; }
.search { position: relative; max-width: 460px; }
.search input {
  width: 100%; height: 56px; padding: 0 56px 0 20px; border-radius: var(--radius-ui);
  border: 1.5px solid var(--ink); background: var(--surface); font-size: var(--s1);
}
.search input::placeholder { color: var(--muted); }
.search kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font: 600 .8rem var(--mono); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; color: var(--muted); }
.hero-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; color: var(--muted); }
.hero-links a { color: var(--ink); font-weight: 600; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }

.feature { position: relative; }
.feature .screen { aspect-ratio: 4 / 3.1; border-width: 2px; box-shadow: 10px 10px 0 var(--ink); }
.feature .screen-rail { width: 18px; }
.feature .screen-viewport { right: 18px; }
.feature-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.feature-now { min-width: 0; }
.feature-now small { display: block; color: var(--muted); font-size: var(--s-1); }
.feature-now a { font-weight: 700; font-size: var(--s1); text-decoration: none; letter-spacing: -.01em; }
.feature-now a:hover { text-decoration: underline; text-underline-offset: 4px; }
.feature-dots { display: flex; gap: 6px; }
.feature-dots button { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; padding: 0; cursor: pointer; }
.feature-dots button[aria-current="true"] { background: var(--thumb); }

@media (max-width: 880px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .feature .screen { box-shadow: 6px 6px 0 var(--ink); }
}

/* ── Toolbar ── */
.toolbar { position: sticky; top: 64px; z-index: 30; background: var(--paper); border-block: 1px solid var(--line); }
.toolbar .wrap { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.chips { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); padding-right: 48px; }
.chip {
  flex: none; display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 12px; border-radius: var(--radius-ui);
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap;
}
.chip sup { font-size: .72em; color: var(--muted); font-weight: 500; top: 0; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip[aria-pressed="true"] sup { color: inherit; opacity: .7; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--hue) 75% 55%); align-self: center; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); flex: none; }
.sort select { border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--radius-ui); padding: 7px 10px; font-weight: 600; color: var(--ink); }
@media (max-width: 700px) { .sort label span { display: none; } .sort select { max-width: 132px; } }

/* ── Library ── */
.library { padding: 40px 0 80px; min-height: 60vh; }
.result-line { color: var(--muted); margin: 0 0 28px; }
.group { margin-bottom: 72px; }
.group-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; padding-bottom: 14px; border-bottom: 1.5px solid var(--ink); }
.group-head h2 { margin: 0; font-family: var(--display); font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.group-head .count { font-weight: 600; color: hsl(var(--hue) 70% 45%); }
:root[data-theme="dark"] .group-head .count { color: hsl(var(--hue) 80% 70%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .group-head .count { color: hsl(var(--hue) 80% 70%); } }
.group-head p { margin: 0; color: var(--muted); flex-basis: 100%; }
@media (min-width: 760px) { .group-head p { flex-basis: auto; margin-left: auto; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 40px 28px; }

.card-link { display: block; text-decoration: none; border-radius: var(--radius-screen); }
.card .screen { aspect-ratio: 4 / 3; transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s; }
.card-link:hover .screen, .card-link:focus-visible .screen { transform: translate(-4px, -4px); box-shadow: 6px 6px 0 hsl(var(--hue) 75% 55%); }
.card-body { padding: 14px 2px 0; }
.card-title { margin: 0 0 4px; font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.card-desc { margin: 0 0 10px; color: var(--muted); font-size: .95rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; justify-content: space-between; gap: 12px; margin: 0; font-size: var(--s-1); color: var(--muted); }
.cat-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.cat-tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--hue) 75% 55%); }

.empty { padding: 60px 0; max-width: 46ch; }
.empty h2 { margin: 0 0 8px; font-family: var(--display); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.empty p { color: var(--muted); margin: 0 0 20px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px;
  border-radius: var(--radius-ui); border: 1.5px solid var(--ink); background: var(--surface); color: var(--ink);
  font-weight: 650; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 7%, var(--surface)); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); }
.btn svg { width: 18px; height: 18px; }

/* ── About ── */
.about { border-top: 1.5px solid var(--ink); padding: 72px 0; background: var(--surface); }
.about h2 { margin: 0 0 40px; font-family: var(--display); font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; max-width: 20ch; }
.about-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 32px 48px; }
.about-cols h3 { margin: 0 0 8px; font-size: var(--s1); letter-spacing: -.01em; }
.about-cols p { margin: 0; color: var(--muted); max-width: 40ch; }

/* ── Footer ── */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: .95rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ── Demo page ── */
.crumbs { padding-top: 28px; color: var(--muted); font-size: .95rem; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { text-underline-offset: 3px; }
.demo-head { padding: 12px 0 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 32px; align-items: end; }
.demo-head h1 { margin: 0 0 12px; font-family: var(--display); font-size: clamp(1.8rem, 3.8vw, 3.1rem); line-height: 1.05; letter-spacing: -.025em; font-weight: 700; }
.demo-head p { margin: 0; color: var(--muted); font-size: var(--s1); max-width: 52ch; }
.pager { display: flex; gap: 8px; }
@media (max-width: 760px) { .demo-head { grid-template-columns: 1fr; } }

.demo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
@media (max-width: 980px) { .demo-layout { grid-template-columns: 1fr; } }

.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: var(--radius-ui); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stage-hint { color: var(--muted); font-size: .95rem; }

.stage { background: repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in srgb, var(--ink) 5%, transparent) 10px 11px), var(--surface); border: 1.5px solid var(--ink); border-radius: var(--radius-screen); padding: 0; display: flex; justify-content: center; overflow: hidden; }
.stage iframe { display: block; width: 100%; height: min(76vh, 780px); border: 0; background: #fff; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.stage.is-phone { padding: 24px 0; }
.stage.is-phone iframe { width: 390px; max-width: calc(100% - 24px); height: min(72vh, 760px); border: 1.5px solid var(--ink); border-radius: 22px; }

.facts { background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--radius-screen); padding: 22px; position: sticky; top: 88px; }
.facts dl { margin: 0 0 20px; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.facts .support { font-size: .92rem; color: var(--muted); margin: 0 0 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.facts .support strong { display: block; color: var(--ink); margin-bottom: 4px; }
.facts .actions { display: grid; gap: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }
.tags li { font-size: .85rem; padding: 3px 9px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted); }

.explain { padding: 56px 0 24px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 24px 48px; }
.explain h2 { margin: 0; font-family: var(--display); font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.explain p { margin: 0; font-size: var(--s1); line-height: 1.55; max-width: 60ch; }
@media (max-width: 760px) { .explain { grid-template-columns: 1fr; } }

.code { margin: 24px 0 72px; border-radius: var(--radius-screen); overflow: hidden; border: 1.5px solid var(--ink); background: var(--code-bg); color: var(--code-ink); }
.code-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 8px 8px 8px; border-bottom: 1px solid rgba(255,255,255,.12); flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; }
.tabs button { background: transparent; border: 0; color: rgba(231,227,255,.65); padding: 8px 14px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.tabs button:hover { color: #fff; }
.tabs button[aria-selected="true"] { background: rgba(255,255,255,.1); color: #fff; }
.tabs button sup { font-size: .7em; opacity: .6; margin-left: 4px; top: 0; }
.copy-btn { background: var(--thumb); color: #1E1A3C; border: 0; border-radius: 6px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.code pre { margin: 0; padding: 22px 24px; overflow: auto; max-height: 560px; font: 400 .9rem/1.65 var(--mono); tab-size: 2; }
.code pre:focus-visible { outline-offset: -3px; }
.tok-c { color: #8C86B5; font-style: italic; }
.tok-s { color: #B5F2A0; }
.tok-k { color: #C9A6FF; }
.tok-n { color: #FFC93C; }
.tok-t { color: #7FD4FF; }
.tok-a { color: #FFB38A; }
.tok-p { color: #7FD4FF; }

.more { padding-bottom: 80px; }
.more h2 { margin: 0 0 24px; font-family: var(--display); font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--radius-ui); font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.not-found { padding: 80px 0 120px; max-width: 50ch; }
.not-found h1 { font-family: var(--display); font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; letter-spacing: -.025em; line-height: 1.05; margin: 0 0 16px; }
.not-found p { color: var(--muted); font-size: var(--s1); margin: 0 0 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
