@font-face { font-family: "Silkscreen"; src: url("fonts/Silkscreen-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("fonts/Silkscreen-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

/* The plugins' own theme (src/common/LoomUI.h) */
:root {
  --bg: #05070d;
  --panel: #080c16;
  --panel-hi: #0f1828;
  --line: #16233a;
  --line-hi: #2a3a55;
  --text: #dfe8f5;
  --dim: #8195b3;
  --faint: #33455f;
  --gold: #f2c14e;
  --cyan: #7fd8ff;
  --warn: #ff5a6e;
  /* MasterLoom's colour for each kind of Loom */
  --comp: #ff6685;
  --guit: #ffa866;
  --heir: #8566ff;
  --pendu: #ffd966;
  --sh: #ff66e7;
  --reso: #b666ff;
  --granu: #66a8ff;
  --keys: #8195b3;
  --max: 1160px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, sans-serif;
}
/* The Looms' cloth behind everything (page.js), under a scrim so text reads */
.page-cloth { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -2; display: block; }
.has-cloth body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: rgba(5,7,13,.38); pointer-events: none; }

a { color: var(--cyan); }
b { color: #fff; font-weight: 600; }
kbd { font: 12px "Silkscreen", monospace; border: 1px solid var(--line-hi); padding: 0 4px; color: var(--gold); }
.pixel { font-family: "Silkscreen", monospace; font-weight: 400; letter-spacing: .08em; }

/* ---------------------------------------------------------------- top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px max(20px, calc((100% - var(--max)) / 2));
  background: rgba(5,7,13,.88); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: "Silkscreen", monospace; color: var(--gold); text-decoration: none; letter-spacing: .12em; font-size: 14px; }
.brand span { color: var(--dim); }
.top nav { display: flex; gap: 22px; flex-wrap: wrap; }
.top nav a { color: var(--dim); text-decoration: none; font-size: 14px; }
.top nav a:hover { color: var(--text); }
@media (max-width: 720px) { .top nav { display: none; } }

main { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-block; cursor: pointer;
  font: 13px "Silkscreen", monospace; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text); background: var(--panel-hi); text-decoration: none;
  border: 1px solid var(--line-hi); padding: 11px 18px;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); color: #120d00; border-color: var(--gold); }
.btn.primary:hover { background: #ffd56e; }
.btn.small { padding: 7px 12px; font-size: 11px; }
.btn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.btn:focus-visible, .stage:focus-visible, .key:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------------------------------------------------------------- hero */
.hero { padding: 64px 0 72px; text-align: center; }
.brandline { margin: 0 0 20px; font-size: 15px; letter-spacing: .28em; color: var(--gold); text-shadow: 0 0 18px rgba(242,193,78,.45); }
.hero h1 {
  font-size: clamp(26px, 4.4vw, 50px); line-height: 1.18; margin: 0 auto; max-width: 900px;
  color: var(--text); text-transform: uppercase; letter-spacing: .04em;
}
.lede { max-width: 700px; margin: 24px auto 40px; font-size: 19px; color: #c3cfe1; }
.hero .sim { text-align: left; scroll-margin-top: 70px; }
.sim-how { color: #b4c1d6; font-size: 15px; max-width: 820px; margin: 16px 0 0; }
.btn.primary[aria-pressed="true"] { background: var(--panel-hi); color: var(--gold); }
.aside { color: var(--dim); font-size: 15px; max-width: 760px; margin: 24px 0 0; }
.k { color: var(--keys); } .cp { color: var(--comp); } .gt { color: var(--guit); } .h { color: var(--heir); } .p { color: var(--pendu); } .s { color: var(--sh); } .g { color: var(--granu); } .r { color: var(--reso); }

/* ---------------------------------------------------------------- sections */
.block { padding: 72px 0; border-top: 1px solid var(--line); }
.head { max-width: 760px; margin-bottom: 36px; }
.head h2 { font-size: clamp(24px, 3.6vw, 36px); margin: 0 0 12px; color: var(--text); }
.head p { color: #b4c1d6; margin: 0; }

/* ---------------------------------------------------------------- live chain */
.sim { background: var(--panel); border: 1px solid var(--line); padding: 18px; }
.sim-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.sim-ctl { display: flex; gap: 8px; }
.sim-note { color: var(--dim); font-size: 13px; margin: 14px 0 0; }

.keys { position: relative; height: 74px; width: 280px; flex: none; }
.key {
  position: absolute; top: 0; cursor: pointer; padding: 0;
  border: 1px solid var(--line-hi);
  font: 9px "Silkscreen", monospace; color: var(--faint);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
}
.key.w { width: 40px; height: 74px; background: #c9d3e2; z-index: 1; }
.key.b { width: 26px; height: 44px; background: #0f1828; z-index: 2; color: var(--dim); }
.key.on { background: var(--gold); color: #120d00; border-color: var(--gold); box-shadow: 0 0 14px rgba(242,193,78,.45); }

.row { display: grid; grid-template-columns: 210px 1fr; gap: 0; position: relative; }
.wire { grid-column: 1; height: 26px; position: relative; }
.wire::before { content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 2px; background: var(--line-hi); }
.wire .dot { position: absolute; left: 19px; width: 8px; height: 8px; border-radius: 50%; top: -4px; animation: drop .45s linear forwards; }
@keyframes drop { to { top: 22px; opacity: .2; } }
.row.off + .row .wire::before, .row.off .wire::before { background: repeating-linear-gradient(var(--line-hi) 0 4px, transparent 4px 8px); }

.stage {
  grid-column: 1; text-align: left; cursor: pointer; color: var(--text);
  background: var(--panel-hi); border: 1px solid var(--line); border-left: 3px solid var(--c);
  padding: 10px 12px; font: inherit; height: 96px; display: flex; flex-direction: column; justify-content: space-between;
}
.stage:hover { border-color: var(--line-hi); border-left-color: var(--c); }
.stage .nm { font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.stage .nm .led { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background .08s; }
.stage .nm .led.lit { background: var(--c); box-shadow: 0 0 8px var(--c); }
.stage .kd { font-size: 12px; color: var(--c); }
.stage .from { font-size: 12px; color: var(--dim); }
.stage .from b { color: var(--text); font-weight: 500; }
.row.off .stage { opacity: .45; border-left-style: dashed; }
.row.off .stage .kd::after { content: ", unhooked"; color: var(--warn); }
.roll { grid-column: 2; width: 100%; height: 96px; display: block; background: #060a13; border: 1px solid var(--line); border-left: 0; }
.row.off .roll { opacity: .3; }

@media (max-width: 720px) {
  .row { grid-template-columns: 1fr; }
  .stage { height: auto; gap: 4px; border-bottom: 0; }
  .roll { grid-column: 1; border-left: 1px solid var(--line); height: 80px; }
  .wire { height: 18px; }
  .wire .dot { animation-name: dropS; }
  @keyframes dropS { to { top: 14px; opacity: .2; } }
  .keys { transform-origin: left bottom; }
}

/* ---------------------------------------------------------------- diagram */
.diagram { margin: 0 0 40px; background: var(--panel); border: 1px solid var(--line); padding: 18px; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .tracks text { font: 10px "Silkscreen", monospace; fill: var(--dim); letter-spacing: .1em; }
.diagram .tracks line { stroke: var(--line-hi); stroke-dasharray: 2 6; }
.diagram .n { fill: var(--panel-hi); stroke: var(--line-hi); stroke-width: 1; }
.diagram .n.s { stroke: var(--sh); } .diagram .n.p { stroke: var(--pendu); } .diagram .n.g { stroke: var(--granu); } .diagram .n.r { stroke: var(--reso); }
.diagram .nt { fill: var(--text); font: 600 15px "Segoe UI", system-ui, sans-serif; }
.diagram .ns { fill: var(--dim); font: 12px "Segoe UI", system-ui, sans-serif; }
.diagram .w { fill: none; stroke-width: 2.5; }
.diagram .w.s { stroke: var(--sh); } .diagram .w.p { stroke: var(--pendu); } .diagram .w.r { stroke: var(--reso); }
.diagram figcaption { color: var(--dim); font-size: 14px; margin-top: 12px; max-width: 760px; }

.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.rule { background: var(--panel); border: 1px solid var(--line); padding: 18px 20px; }
.rule h3 { margin: 0 0 8px; font-size: 16px; color: var(--gold); font-weight: 600; }
.rule p { margin: 0; color: #b4c1d6; font-size: 15px; }

/* ---------------------------------------------------------------- the Looms */
.loom {
  display: grid; grid-template-columns: minmax(280px, 5fr) 7fr; gap: 36px; align-items: center;
  padding: 36px 0; border-bottom: 1px solid var(--line);
}
.loom:nth-of-type(even) { grid-template-columns: 7fr minmax(280px, 5fr); }
.loom:nth-of-type(even) .loom-text { order: 2; }
.loom:last-child { border-bottom: 0; }
.loom img { width: 100%; height: auto; display: block; border: 1px solid var(--line-hi); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 24px 60px -20px color-mix(in srgb, var(--c) 35%, transparent); }
.loom .role { font-size: 13px; color: var(--c); margin: 0 0 6px; letter-spacing: .04em; }
.loom h3 { font-size: 30px; margin: 0 0 10px; color: var(--c); }
.loom .one { font-size: 19px; color: #fff; margin: 0 0 10px; }
.loom p { color: #b4c1d6; }
.io { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 16px 0 0; font-size: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--c); }
.io dt { font: 11px "Silkscreen", monospace; color: var(--dim); letter-spacing: .1em; padding-top: 3px; }
.io dd { margin: 0; }
@media (max-width: 860px) {
  .loom, .loom:nth-of-type(even) { grid-template-columns: 1fr; }
  .loom:nth-of-type(even) .loom-text { order: 0; }
}

/* ---------------------------------------------------------------- recipes */
.recipes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .recipes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .recipes { grid-template-columns: 1fr; } }
.recipe { background: var(--panel); border: 1px solid var(--line); padding: 18px 20px; }
.recipe h3 { margin: 16px 0 8px; font-size: 17px; font-weight: 600; }
.recipe p { margin: 0; color: #b4c1d6; font-size: 15px; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.links li { font: 11px "Silkscreen", monospace; letter-spacing: .06em; border: 1px solid currentColor; padding: 6px 9px; background: var(--panel-hi); align-self: flex-start; }
.links li + li { margin-top: 14px; position: relative; }
.links li + li::before { content: ""; position: absolute; left: 12px; top: -15px; width: 2px; height: 14px; background: currentColor; opacity: .7; }

/* ---------------------------------------------------------------- get */
.get-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 32px; }
.get h3 { font-size: 16px; color: var(--gold); margin: 0 0 10px; font-weight: 600; }
.get p { color: #b4c1d6; }
.formats { border-collapse: collapse; font-size: 14px; width: 100%; }
.formats th, .formats td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); }
.formats th { font: 10px "Silkscreen", monospace; color: var(--dim); letter-spacing: .1em; }
.formats td:first-child { color: #fff; }
.formats td { color: #b4c1d6; }

footer {
  max-width: var(--max); margin: 0 auto; padding: 32px 20px 48px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--dim); font-size: 13px;
}
footer .pixel { color: var(--gold); }

/* ---------------------------------------------------------------- MasterLoom window */
.diagram:has(.ml) { padding: 0; background: none; border: 0; }
.ml { width: 100%; overflow-x: auto; }
.ml-scale { position: relative; }
.ml-win {
  position: absolute; left: 0; top: 0; width: 1200px; height: 620px; transform-origin: 0 0;
  background: var(--bg); overflow: hidden; user-select: none;
  box-shadow: 0 0 0 1px var(--line-hi), 0 30px 80px -30px rgba(58,160,255,.35);
  font-family: "Segoe UI", system-ui, sans-serif;
}
.ml-cloth { position: absolute; inset: 0; width: 1200px; height: 620px; }
.ml-cloth.fallback { background: radial-gradient(ellipse at 50% 40%, #1a1730, var(--bg) 75%); }
.ml-header {
  position: absolute; left: 0; top: 0; width: 1200px; height: 52px; box-sizing: border-box;
  background: rgba(8,12,22,.55); border-bottom: 1px solid var(--line-hi);
  display: flex; align-items: center; padding: 12px 16px; gap: 0;
}
.ml-title { width: 150px; flex: none; white-space: nowrap; font: 15.5px "Silkscreen", monospace; letter-spacing: .06em;
  text-shadow: 2px 2px 0 rgba(20,60,160,.8), 0 0 10px rgba(58,160,255,.8), 0 0 16px rgba(58,160,255,.6); }
.ml-title .t-own { color: var(--gold); } .ml-title .t-loom { color: var(--cyan); }
.ml-label { font: 9.5px "Silkscreen", monospace; letter-spacing: .06em; color: var(--dim); white-space: nowrap; flex: none; }
.ml-header .ml-label { width: 100px; }
.ml-num {
  font: 600 16px "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--panel-hi);
  border: 1px solid transparent; width: 40px; height: 28px; cursor: pointer; padding: 0;
}
.ml-num:hover { border-color: var(--line-hi); }
.ml-num.own { color: var(--gold); background: rgba(242,193,78,.22); }
.ml-slash { width: 14px; text-align: center; color: var(--dim); font-size: 16px; }
.ml-btn {
  font: 9.5px "Silkscreen", monospace; letter-spacing: .08em; white-space: nowrap; flex: none; color: var(--dim); background: var(--panel-hi);
  border: 1px solid var(--line); height: 22px; padding: 0 10px; cursor: pointer;
}
.ml-btn:hover { border-color: var(--line-hi); color: var(--text); }
.ml-btn.on { color: var(--warn); background: rgba(255,90,110,.3); border-color: var(--warn); }
.ml-header [data-act="muteall"] { width: 92px; margin-left: 16px; }
.ml-header [data-act="reset"] { width: 64px; margin-left: 8px; }
.ml-status { margin-left: auto; color: var(--dim); font-size: 11.5px; }
.diagram .ml-graph { position: absolute; left: 0; top: 52px; width: 942px; height: 568px; overflow: visible; touch-action: none; }
.ml-graph .nn { font: 700 13px "Segoe UI", system-ui, sans-serif; }
.ml-graph .ni { font: 10.5px "Segoe UI", system-ui, sans-serif; fill: var(--dim); white-space: pre; }
.ml-graph .nc { font: 700 10.5px "Segoe UI", system-ui, sans-serif; text-anchor: middle; }
.ml-graph .ns { font: 11px "Segoe UI", system-ui, sans-serif; fill: var(--dim); }
.ml-graph .nm { font: 700 8.5px "Segoe UI", system-ui, sans-serif; fill: var(--dim); text-anchor: middle; }
.ml-graph .nk { font: 700 9px "Segoe UI", system-ui, sans-serif; text-anchor: middle; pointer-events: none; }
.ml-insp {
  position: absolute; right: 0; top: 52px; width: 258px; height: 568px; box-sizing: border-box; padding: 14px 16px;
  background: rgba(8,12,22,.88); border-left: 1px solid var(--line-hi); font-size: 11px; color: var(--dim);
}
.ml-insp .ml-name { font: 700 19px "Segoe UI", system-ui, sans-serif; color: var(--text); height: 26px; margin: 0 0 2px -1px; }
.ml-insp .ml-kind, .ml-insp .ml-dim { font-size: 11px; line-height: 16px; white-space: pre; }
.ml-insp p.ml-dim { white-space: normal; font-size: 11.5px; }
.ml-insp .ml-line { display: flex; align-items: center; height: 28px; margin-top: 6px; }
.ml-insp .ml-line:first-of-type { margin-top: 12px; }
.ml-insp .ml-line .ml-label { width: 50px; }
.ml-insp .ml-num { width: 36px; height: 28px; font-size: 15px; }
.ml-insp .ml-ro { display: inline-flex; align-items: center; justify-content: center; width: 50px; cursor: default; }
.ml-insp .ml-mute { width: 80px; margin-left: 16px; }
.ml-insp .ml-takes { display: block; margin: 20px 0 8px; }
.ml-hint { font-size: 12px; line-height: 1.45; margin: 0 0 12px; }
.ml-src {
  display: flex; align-items: center; width: 100%; height: 24px; background: none; border: 0; padding: 0;
  color: var(--text); font: 12.5px "Segoe UI", system-ui, sans-serif; cursor: pointer; text-align: left;
}
.ml-src:disabled { color: var(--faint); cursor: default; }
.ml-box { width: 12px; height: 12px; border: 1.2px solid var(--line-hi); margin: 0 12px 0 2px; flex: none; box-sizing: border-box; }
.ml-src.on .ml-box { background: var(--gold); border-color: var(--gold); }
.ml-src:not(:disabled):hover .ml-box { border-color: var(--dim); }
.ml-sn { flex: 1; }
.ml-note { color: var(--faint); font-size: 11px; }
.ml-tip {
  position: absolute; z-index: 3; max-width: 260px; padding: 5px 8px; pointer-events: none;
  background: #0f1828; border: 1px solid var(--line-hi); color: var(--text); font-size: 11.5px; line-height: 1.35;
}

/* ---------------------------------------------------------------- beginner guides (guide-*.html) */
.guide { max-width: 820px; margin: 0 auto; padding: 56px 0 72px; }
.guide .brandline { text-align: left; }
.guide h1 { font-size: clamp(24px, 3.8vw, 40px); line-height: 1.2; margin: 0 0 16px; text-transform: uppercase; letter-spacing: .04em; color: var(--c, var(--text)); }
.guide .lede { margin: 0 0 32px; max-width: none; }
.guide h2 { font-size: clamp(18px, 2.4vw, 24px); margin: 56px 0 14px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--text); scroll-margin-top: 80px; }
.guide h3 { font-size: 17px; margin: 32px 0 10px; color: var(--gold); font-weight: 600; scroll-margin-top: 80px; }
.guide p, .guide li { color: #c3cfe1; }
.guide ol, .guide ul { padding-left: 24px; }
.guide li { margin: 6px 0; }
.guide li > ul { margin: 6px 0; }
.guide code { font: 14px ui-monospace, Menlo, Consolas, monospace; color: var(--gold); background: var(--panel-hi); padding: 1px 6px; border: 1px solid var(--line); }
.guide pre { background: var(--panel); border: 1px solid var(--line-hi); border-left: 3px solid var(--gold); padding: 14px 16px; overflow-x: auto; margin: 12px 0 16px; }
.guide pre code { background: none; border: 0; padding: 0; font-size: 15px; }
.guide figure { margin: 24px 0 8px; }
.guide figure img { width: 100%; height: auto; display: block; border: 1px solid var(--line-hi); }
.guide figcaption { color: var(--dim); font-size: 14px; margin-top: 8px; }
.guide .note { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--cyan); padding: 12px 16px; margin: 16px 0; }
.guide .note p { margin: 0; }
.guide .toc { list-style: none; padding: 14px 18px; margin: 0 0 8px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 22px; }
.guide .toc li { margin: 0; }
.guide .toc a { color: var(--dim); text-decoration: none; font-size: 14px; }
.guide .toc a:hover { color: var(--text); }
.guide table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 12px 0 16px; }
.guide th, .guide td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.guide th { font: 10px "Silkscreen", monospace; color: var(--dim); letter-spacing: .1em; font-weight: 400; }
.guide td { color: #b4c1d6; }
.guide td:first-child { color: #fff; white-space: nowrap; }
@media (max-width: 560px) { .guide td:first-child { white-space: normal; } }
.guide .next { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 48px; }
.top nav a[aria-current="page"] { color: var(--gold); }
