/* RGB101 — page styles. Theme colours come from themes.json via CSS variables set in app.js */
:root {
  --bg1: #b6b2dd; --bg2: #a29ecf; --bg3: #cbc7ea;
  --ink: #2c2a4a; --ink-soft: #4d4b6c;
  --surface: rgba(255, 255, 255, .76); --line: rgba(0, 0, 0, .08);
  --scrim: rgba(20, 18, 40, .32);
  --code-bg: #15141f; --code-line: rgba(255, 255, 255, .08);
  --glow-a: rgba(255, 255, 255, .35); --glow-b: rgba(255, 255, 255, .2);
  --logo-font: system-ui, sans-serif; --logo-weight: 700; --logo-size: 30px; --logo-ls: 0;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- ambient background ---------- */
.ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.ambient::before, .ambient::after { content: ""; position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; will-change: transform; }
.ambient::before { left: -20vmax; top: -25vmax; background: radial-gradient(circle, var(--glow-a), transparent 62%); animation: glow-a 40s ease-in-out infinite alternate; }
.ambient::after  { right: -25vmax; bottom: -30vmax; background: radial-gradient(circle, var(--glow-b), transparent 62%); animation: glow-b 48s ease-in-out infinite alternate; }
@keyframes glow-a { to { transform: translate(10vmax, 8vmax); } }
@keyframes glow-b { to { transform: translate(-8vmax, -10vmax); } }

/* ---------- brand + footer ---------- */
/* Logo is plain text; the typeface comes from the active theme's "font" entry in themes.json */
.brand {
  position: fixed; z-index: 5; top: clamp(18px, 3.2vh, 32px); left: clamp(20px, 3vw, 40px);
  font-family: var(--logo-font); font-weight: var(--logo-weight); font-size: var(--logo-size); letter-spacing: var(--logo-ls);
  line-height: 1; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.foot {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: clamp(14px, 2.6vh, 26px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 20px; color: var(--ink-soft); pointer-events: none; text-align: center;
}
.foot p { margin: 0; }
.foot-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 12px; }
#theme-name { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; }
.foot i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; align-self: center; }
#headline { font-size: clamp(14px, 1.5vw, 16px); letter-spacing: .005em; color: var(--ink); }
.foot-hint { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }

/* ---------- floating shapes ---------- */
.field { position: fixed; inset: 0; overflow: hidden; }
.float {
  position: absolute; width: 160px; height: 160px; will-change: transform;
  animation: drift var(--dur) ease-in-out var(--delay) infinite alternate, fade 1.8s ease var(--in) both;
}
.no-enter .float { animation: drift var(--dur) ease-in-out var(--delay) infinite alternate; }
.bob { width: 100%; height: 100%; animation: bob var(--bob) ease-in-out var(--bd) infinite alternate; }
.hit {
  display: grid; place-items: center; width: 160px; height: 160px; padding: 0; margin: 0; border: 0;
  background: none; font: inherit; color: inherit; cursor: pointer; border-radius: 32px;
  transform: scale(var(--s));
  transition: transform .7s cubic-bezier(.2, .8, .2, 1), filter .7s ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .hit:hover { transform: scale(calc(var(--s) * 1.09)); filter: saturate(1.1) brightness(1.04); } }
.hit:active { transform: scale(calc(var(--s) * .97)); }
.hit:focus-visible { outline: 2px solid var(--ink); outline-offset: 8px; }
.stage { width: 160px; height: 160px; display: grid; place-items: center; }
@keyframes drift { 0% { transform: translate3d(0, 0, 0) rotate(calc(var(--rot) * -1)); } 100% { transform: translate3d(var(--dx), var(--dy), 0) rotate(var(--rot)); } }
@keyframes bob   { from { transform: translateY(-7px); } to { transform: translateY(7px); } }
@keyframes fade  { from { opacity: 0; } to { opacity: 1; } }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  padding: clamp(12px, 3vw, 32px);
  visibility: hidden; opacity: 0; transition: opacity .35s ease, visibility 0s linear .35s;
}
.modal.open { visibility: visible; opacity: 1; transition: opacity .35s ease; }
.scrim { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.card {
  position: relative; box-sizing: border-box; width: min(980px, 100%); max-height: min(100%, 780px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(28px) saturate(140%); backdrop-filter: blur(28px) saturate(140%);
  transform: translateY(18px) scale(.97); transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}
.modal.open .card { transform: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 26px 4px; }
.card-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.card-head p { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-soft); max-width: 56ch; }
.close {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer;
  transition: background .2s ease;
}
.close:hover { background: rgba(127, 127, 127, .15); }
.close svg { width: 14px; height: 14px; }
.card-body {
  box-sizing: border-box; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.3fr); gap: 18px;
  padding: 16px 26px 26px; min-height: 0; flex: 1;
}
.preview {
  position: relative; display: grid; place-items: center; min-height: 240px; overflow: hidden;
  border-radius: 20px; background: var(--bg2); border: 1px solid var(--line);
}
.pv { animation: bob 8s ease-in-out infinite alternate; }
.pv .stage { transform: scale(1.3); }
.codes { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.code { display: flex; flex-direction: column; min-height: 0; border-radius: 16px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--code-line); }
.code.css { flex: 1 1 auto; }
.code.html pre { max-height: 148px; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 4px 16px; }
.code-head span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #8b93ad; }
.copy {
  padding: 5px 12px; font: 500 12px var(--font); color: #d9dcec; background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1); border-radius: 999px; cursor: pointer; transition: background .2s ease, color .2s ease;
}
.copy:hover { background: rgba(255, 255, 255, .14); }
.copy.done { color: #a8d89a; }
pre {
  margin: 0; padding: 4px 16px 16px; overflow: auto; flex: 1 1 auto; min-height: 0;
  font: 12.5px/1.7 var(--mono); color: #d9dcec; tab-size: 2; white-space: pre;
}
pre:focus-visible, .copy:focus-visible, .close:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.code pre:focus-visible, .code .copy:focus-visible { outline-color: #9ad1c7; }
.tk-c { color: #7f8aa3; font-style: italic; } .tk-s { color: #f6b17a; } .tk-k { color: #9ad1c7; }
.tk-v { color: #a8d89a; } .tk-n { color: #f2d37c; } .tk-f { color: #c3a6ff; }
.tk-h { color: #f2d37c; } .tk-t { color: #ff9aa8; } .tk-p { color: #8b93ad; }

@media (max-width: 760px) {
  .foot i { display: none; }
  .foot-line { flex-direction: column; align-items: center; gap: 4px; }
  .card-body { grid-template-columns: 1fr; overflow: auto; padding: 12px 16px 18px; }
  .card-head { padding: 18px 18px 2px; }
  .preview { min-height: 190px; }
  .pv .stage { transform: scale(1); }
  .code.html pre { max-height: 120px; }
  .code.css pre { max-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  .float, .bob, .pv, .ambient::before, .ambient::after, .stage * { animation: none !important; }
}
