/* ============================================================
   Graph Paper Hub — styles.css
   Aesthetic: a drafting table. Graphite chrome, hairline rules,
   monospace readouts, a luminous sheet of paper on a blueprint
   workbench, one hot signal-orange accent.
   ============================================================ */

:root {
  --display: 'Bricolage Grotesque', 'Hanken Grotesk', sans-serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'Martian Mono', ui-monospace, monospace;
  --accent: #ff5a1f;
  --accent-soft: rgba(255, 90, 31, .14);
  --radius: 12px;
}

/* dark — the workshop at night. The site is dark-only, so these tokens
   live on :root and there is no theme switch to stamp anything. */
:root,
:root[data-theme='dark'] {
  --bg: #0c0e12;
  --chrome: #14171e;
  --chrome-2: #1a1e26;
  --rail: #111319;
  --edge: rgba(255, 255, 255, .09);
  --edge-2: rgba(255, 255, 255, .05);
  --text: #e9ebf0;
  --muted: #8b93a2;
  --muted-2: #5c6472;
  --field: #0e1015;
  --field-line: rgba(255, 255, 255, .1);
  --bench-1: #0a0c10;
  --bench-2: #0e1116;
  --bench-grid: rgba(120, 160, 220, .05);
  --sheet-shadow: 0 30px 60px -18px rgba(0, 0, 0, .8), 0 6px 16px -8px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
::selection { background: var(--accent); color: #fff; }

/* ---- top bar --------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  height: 58px; padding: 0 18px;
  background: var(--chrome);
  border-bottom: 1px solid var(--edge);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark svg { width: 30px; height: 30px; display: block; }
.brand-mark rect { fill: #101319; }
.brand-mark path { stroke: var(--accent); stroke-width: 1.6; }
.brand-word {
  font-family: var(--mono); font-weight: 600; font-size: 16px;
  letter-spacing: -.02em; text-transform: lowercase;
}
.brand-word b { color: var(--accent); font-weight: 600; }
.brand-word .tld { color: var(--muted-2); }
.tagline {
  margin: 0; font-family: var(--display); font-weight: 600;
  font-size: 14px; color: var(--muted); letter-spacing: .01em;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ghost {
  background: transparent; border: 1px solid var(--edge);
  color: var(--text); padding: 8px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 600; transition: .15s;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---- studio layout --------------------------------------- */
.studio { flex: 1 1 auto; display: grid; grid-template-columns: 344px 1fr; min-height: 0; }

.rail-scroll {
  overflow-y: auto; border-right: 1px solid var(--edge);
  background: var(--rail); display: flex; flex-direction: column;
}
.rail-scroll::-webkit-scrollbar { width: 10px; }
.rail-scroll::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 8px; border: 3px solid var(--rail); }
#rail { padding: 6px 0 4px; }

/* control groups */
.group { padding: 16px 18px; border-bottom: 1px solid var(--edge-2); animation: rise .4s both; }
.group:nth-child(1) { animation-delay: .02s; }
.group:nth-child(2) { animation-delay: .06s; }
.group:nth-child(3) { animation-delay: .10s; }
.group:nth-child(4) { animation-delay: .14s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.group h3 {
  margin: 0 0 13px; font-family: var(--mono); font-weight: 500;
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted-2); display: flex; align-items: center; gap: 10px;
}
.group h3::after { content: ''; flex: 1; height: 1px; background: var(--edge-2); }
.group-body { display: flex; flex-direction: column; gap: 14px; }

/* template tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tile {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 10px 11px; border-radius: 10px; text-align: left;
  background: var(--chrome); border: 1px solid var(--edge-2);
  transition: .16s; position: relative; overflow: hidden;
}
.tile:hover { border-color: var(--edge); transform: translateY(-1px); }
.tile.on { border-color: var(--accent); background: var(--accent-soft); }
.tile-ic { color: var(--muted); }
.tile.on .tile-ic { color: var(--accent); }
.tile-ic svg { width: 30px; height: 30px; display: block; }
.tile-name { font-weight: 700; font-size: 13px; margin-top: 2px; }
.tile-tag { font-size: 10px; color: var(--muted-2); font-family: var(--mono); letter-spacing: -.01em; }

/* generic control */
.ctl { display: flex; flex-direction: column; gap: 7px; }
.ctl-head { display: flex; justify-content: space-between; align-items: baseline; }
.ctl label, .ctl-lab { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ctl-val { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 500; }
.ctl-inline { flex-direction: row; align-items: center; justify-content: space-between; }
.ctl-inline label { color: var(--muted); }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: var(--field-line); border-radius: 4px; accent-color: var(--accent); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--rail); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); cursor: grab;
}
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 3px solid var(--rail); cursor: grab; }

select, .num, .hex {
  background: var(--field); border: 1px solid var(--field-line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-family: var(--body); font-size: 12.5px; outline: none; transition: .15s;
}
select:focus, .num:focus, .hex:focus { border-color: var(--accent); }
select { min-width: 130px; }
.num { width: 92px; text-align: right; font-family: var(--mono); }

/* segmented control */
.seg { display: flex; background: var(--field); border: 1px solid var(--field-line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 6px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; transition: .14s;
}
.seg button.on { background: var(--accent); color: #fff; }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 20px; background: var(--field-line);
  position: relative; transition: .18s; flex: 0 0 auto;
}
.switch .track::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-lab { font-size: 12.5px; font-weight: 600; }

/* colour control */
.ctl-color { flex-direction: row; align-items: center; justify-content: space-between; }
.color-pair { display: flex; align-items: center; gap: 8px; }
input[type=color] {
  -webkit-appearance: none; appearance: none; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--field-line); border-radius: 8px; background: none; cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 5px; }
.hex { width: 84px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; }

/* palettes */
.palettes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; }
.pal {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 6px;
  border: 1px solid var(--edge); border-radius: 20px; font-size: 10.5px; font-weight: 600;
  color: var(--muted); transition: .15s;
}
.pal:hover { border-color: var(--accent); color: var(--text); }
.pal span { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pal-a { margin-right: -3px; } .pal-b { margin-right: -3px; }
.pal em { font-style: normal; }

.rail-foot { margin-top: auto; padding: 16px 18px 22px; }
.rail-foot p { margin: 0; font-size: 11px; line-height: 1.5; color: var(--muted-2); }
.rail-foot b { color: var(--muted); }

/* ---- stage ----------------------------------------------- */
/* min-height:0 so the stage can shrink to its grid row instead of being
   pushed open by the sheet; canvas-wrap scrolls if the sheet is taller. */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 50px; padding: 0 18px; border-bottom: 1px solid var(--edge); background: var(--chrome);
}
.stage-title { display: flex; align-items: center; gap: 10px; }
#stage-name { font-family: var(--display); font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.chip { font-family: var(--mono); font-size: 10px; color: var(--muted); background: var(--chrome-2); border: 1px solid var(--edge-2); padding: 3px 8px; border-radius: 20px; }
.zoom { display: flex; align-items: center; gap: 4px; }
.zoom button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--edge); background: transparent; font-size: 16px; line-height: 1; transition: .14s; }
.zoom button:hover { border-color: var(--accent); color: var(--accent); }
.zoom .fit { width: auto; padding: 0 11px; font-size: 12px; font-weight: 700; font-family: var(--mono); }
#zoom-val { font-family: var(--mono); font-size: 11px; color: var(--muted); width: 44px; text-align: center; }

/* workbench */
.canvas-wrap {
  flex: 1 1 auto; overflow: auto; display: grid; place-items: center; padding: 28px;
  background:
    linear-gradient(var(--bench-grid) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, var(--bench-grid) 1px, transparent 1px) 0 0 / 26px 26px,
    radial-gradient(120% 120% at 50% 0%, var(--bench-2), var(--bench-1));
}
.sheet { line-height: 0; border-radius: 2px; box-shadow: var(--sheet-shadow); animation: settle .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes settle { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
#preview svg { display: block; border-radius: 2px; }

/* export bar */
.export-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px; border-top: 1px solid var(--edge); background: var(--chrome); flex-wrap: wrap;
}
.dim-readout { display: flex; align-items: baseline; gap: 9px; }
.dim-readout .k { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2); }
#dim { font-family: var(--mono); font-size: 14px; font-weight: 500; }
.export-actions { display: flex; align-items: center; gap: 10px; }
.dpi { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; }
.dpi select { min-width: 0; padding: 7px 8px; }
.dl {
  display: flex; align-items: center; justify-content: center; line-height: 1.1;
  padding: 12px 18px; border-radius: 10px; border: 1px solid var(--edge);
  background: var(--chrome-2); transition: .15s; min-width: 74px;
}
.dl b { font-size: 13px; font-weight: 700; }
.dl:hover { border-color: var(--accent); transform: translateY(-1px); }
.dl.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 18px -8px var(--accent); }
.dl.primary:hover { filter: brightness(1.06); }

/* toast */
.toast {
  position: fixed; bottom: 78px; left: 50%; transform: translate(-50%, 12px);
  background: #111319; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--edge);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- responsive ------------------------------------------ */
@media (max-width: 920px) {
  .tagline { display: none; }
  .studio { display: flex; flex-direction: column; }
  .stage { flex: 1 1 auto; min-height: 52vh; }
  .rail-scroll { border-right: none; border-top: 1px solid var(--edge); max-height: 46vh; }
}
@media (max-width: 560px) {
  .topbar { gap: 10px; height: 52px; padding: 0 12px; }
  .top-actions .ghost { padding: 8px 10px; font-size: 12px; }
  .export-bar { gap: 10px; }
  .dl { min-width: 60px; padding: 7px 12px; }
  .canvas-wrap { padding: 16px; }
}

/* ============================================================
   Multi-page site (homepage gallery + per-template pages)
   ============================================================ */
body.doc { display: block; height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
.doc .topbar { position: sticky; top: 0; z-index: 30; }
.doc a { color: inherit; }
.brand-link { text-decoration: none; }

/* crumb / template name in the top bar */
.crumb { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.crumb b { color: var(--text); font-weight: 500; }

/* ---- homepage ------------------------------------------- */
.home { max-width: 1180px; margin: 0 auto; padding: 0 22px 60px; }
.hero { padding: 62px 0 40px; max-width: 760px; }
.hero h1 { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 5vw, 50px); line-height: 1.04; letter-spacing: -.02em; margin: 0 0 18px; }
.hero h1 b { color: var(--accent); font-weight: 800; }
.hero p { font-size: 17px; line-height: 1.6; color: var(--muted); margin: 0 0 10px; max-width: 620px; }
/* row of quick links under the hero copy (404 page) */
.hero .links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.section-label { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted-2); margin: 28px 0 14px; display: flex; align-items: center; gap: 12px; }
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--edge-2); }
.card { display: flex; flex-direction: column; background: var(--chrome); border: 1px solid var(--edge-2); border-radius: 14px; overflow: hidden; text-decoration: none; transition: .18s; }
.card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .7); }
/* The thumbnail sheet is generated at the same 4:3 ratio (see gallery.js), so
   it fills the frame edge to edge with no letterboxing. */
.card-preview { position: relative; aspect-ratio: 4 / 3; background: var(--chrome-2); display: block; overflow: hidden; border-bottom: 1px solid var(--edge-2); }
.card-preview svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.card-body { padding: 13px 15px 16px; }
.card-body h2 { font-family: var(--display); font-weight: 700; font-size: 16px; margin: 0 0 3px; }
.card-body .tag { font-family: var(--mono); font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.card-body p { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 7px 0 0; }
.home-copy { max-width: 760px; margin: 54px 0 0; }
.home-copy h2 { font-family: var(--display); font-weight: 700; font-size: 22px; margin: 30px 0 10px; }
.home-copy p { color: var(--muted); line-height: 1.7; font-size: 15px; margin: 0 0 12px; }

/* ---- per-template page ---------------------------------- */
.page-head { max-width: 1180px; margin: 0 auto; padding: 26px 22px 18px; }
.page-head h1 { font-family: var(--display); font-weight: 800; font-size: clamp(24px, 3.4vw, 34px); letter-spacing: -.015em; margin: 0 0 8px; }
.page-head .lede { font-size: 15.5px; color: var(--muted); line-height: 1.55; margin: 0; max-width: 720px; }

.studio.page { display: grid; grid-template-columns: 224px 1fr 340px; height: clamp(500px, 74vh, 840px); border-top: 1px solid var(--edge); border-bottom: 1px solid var(--edge); overflow: hidden; }
/* Grid items default to min-height:auto, so tall content (the sheet) would
   spill out of the fixed-height studio and collide with the footer. */
.studio.page > * { min-height: 0; }
.studio.page .rail-scroll { border-right: none; border-left: 1px solid var(--edge); }

.tpl-nav { overflow-y: auto; border-right: 1px solid var(--edge); background: var(--rail); padding: 14px 0; }
.tpl-nav h3 { margin: 15px 16px 6px; font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); }
.tpl-nav h3:first-child { margin-top: 2px; }
.tpl-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; transition: .12s; }
.tpl-nav a:hover { color: var(--text); background: var(--chrome); }
.tpl-nav a.on { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.tpl-nav a svg { width: 20px; height: 20px; flex: 0 0 auto; opacity: .85; }
.rail-head { padding: 15px 18px 4px; font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); }

/* SEO content below the tool */
.content { max-width: 780px; margin: 0 auto; padding: 40px 22px 60px; }
.content h2 { font-family: var(--display); font-weight: 700; font-size: 21px; margin: 30px 0 10px; }
.content h2:first-child { margin-top: 0; }
.content p { color: var(--muted); line-height: 1.75; font-size: 15px; margin: 0 0 12px; }
.content ul { margin: 0 0 14px; padding-left: 20px; color: var(--muted); line-height: 1.7; font-size: 15px; }
.content li { margin: 3px 0; }
.related { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.related a { font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none; border: 1px solid var(--edge); padding: 7px 13px; border-radius: 20px; transition: .15s; }
.related a:hover { border-color: var(--accent); color: var(--accent); }

/* footer */
.site-foot { border-top: 1px solid var(--edge); background: var(--chrome); }
.site-foot .inner { max-width: 1180px; margin: 0 auto; padding: 30px 22px; display: flex; flex-wrap: wrap; gap: 24px 40px; justify-content: space-between; }
.site-foot .cols { display: flex; flex-wrap: wrap; gap: 40px; }
.foot-col h4 { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); margin: 0 0 10px; }
.foot-col a { display: block; font-size: 13px; color: var(--muted); text-decoration: none; padding: 3px 0; }
.foot-col a:hover { color: var(--accent); }
.site-foot .note { font-size: 12px; color: var(--muted-2); max-width: 280px; line-height: 1.6; }

@media (max-width: 940px) {
  .studio.page { display: flex; flex-direction: column; height: auto; overflow: visible; }
  .studio.page .tpl-nav { display: flex; gap: 4px; overflow-x: auto; padding: 10px; border-right: none; border-bottom: 1px solid var(--edge); }
  .studio.page .tpl-nav h3 { display: none; }
  .studio.page .tpl-nav a { white-space: nowrap; border-left: none; border-radius: 8px; padding: 8px 12px; }
  .studio.page .tpl-nav a.on { border-left: none; }
  .studio.page .stage { min-height: 56vh; }
  .studio.page .rail-scroll { border-left: none; border-top: 1px solid var(--edge); max-height: 46vh; }
}
