/* =========================================================================
   Jigsaw Generator — shared design system
   Aesthetic: laser-cutter workbench. Dark cutting mat, scorched-amber
   accents (the caramel edge burn you get cutting plywood), a hairline
   alignment grid like a cutter bed, and the puzzle tab curve itself
   used as the recurring signature mark.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root{
  --ink:        #16130f;
  --ink-2:      #1d1810;
  --panel:      #221c14;
  --panel-2:    #2a2216;
  --line:       #3c3122;
  --line-soft:  #2e2618;
  --paper:      #f2ead9;
  --paper-2:    #e8dcc4;
  --paper-line: #cbb98f;
  --text-hi:    #f5efe1;
  --text-mid:   #c8bca4;
  --text-dim:   #8d8069;
  --text-dark:  #241c10;
  --scorch:     #c96a2c;
  --scorch-hi:  #ff9a4d;
  --laser:      #e63b2e;
  --laser-hi:   #ff5a45;
  --blue:       #3d6fd6;

  --radius-sm: 4px;
  --radius: 10px;
  --radius-lg: 18px;

  --font-display: 'JetBrains Mono', ui-monospace, monospace;
  --font-body: 'Manrope', system-ui, sans-serif;
}

*, *::before, *::after{ box-sizing: border-box; }

html{ color-scheme: dark; }

body{
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 1px 1px, var(--line-soft) 1px, transparent 1.6px) 0 0 / 26px 26px,
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: var(--text-mid);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a{ color: var(--scorch-hi); text-decoration: none; }
a:hover{ text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible{
  outline: 2px solid var(--scorch-hi);
  outline-offset: 2px;
}

h1, h2, h3{
  font-family: var(--font-display);
  color: var(--text-hi);
  margin: 0;
  letter-spacing: -0.01em;
}

.eyebrow{
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--scorch-hi);
}

/* ---------- shell ---------- */

.shell{
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-hi);
  font-size: 15px;
}

.brand .tab-mark{ width: 26px; height: 18px; flex: none; }

.topbar nav{ display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: flex-end; font-family: var(--font-display); font-size: 12.5px; }
.topbar nav a{ color: var(--text-dim); white-space: nowrap; }
.topbar nav a.current, .topbar nav a:hover{ color: var(--scorch-hi); }

/* ---------- signature tab-curve divider ---------- */

.tab-divider{
  width: 100%;
  height: 34px;
  margin: 22px 0 34px;
  overflow: hidden;
}
.tab-divider svg{ width: 100%; height: 100%; display: block; }
.tab-divider path{
  fill: none;
  stroke: var(--line);
  stroke-width: 1.4;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: draw-in 1.4s ease-out forwards;
}
@media (prefers-reduced-motion: reduce){
  .tab-divider path{ animation: none; stroke-dashoffset: 0; }
}
@keyframes draw-in{ to{ stroke-dashoffset: 0; } }

/* ---------- hero ---------- */

.hero{
  padding: 40px 4px 8px;
}
.hero h1{
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
}
.hero p.lede{
  max-width: 54ch;
  color: var(--text-mid);
  font-size: 16px;
  margin-top: 14px;
}

/* ---------- cards (index landing) ---------- */

.card-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 34px;
}

.gen-card{
  position: relative;
  display: block;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  color: var(--text-mid);
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease;
}
.gen-card:hover{
  border-color: var(--scorch);
  transform: translateY(-2px);
  text-decoration: none;
}
.gen-card .thumb{
  width: 100%;
  aspect-ratio: 16/10;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 1px 1px, var(--line-soft) 1px, transparent 1.6px) 0 0 / 20px 20px,
    var(--ink);
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.gen-card .thumb svg{ width: 78%; height: 78%; }
.gen-card h2{ font-size: 19px; color: var(--text-hi); margin-bottom: 6px; }
.gen-card p{ font-size: 13.5px; color: var(--text-dim); margin: 0; }
.gen-card .go{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--scorch-hi);
  letter-spacing: .04em;
}

.footnote{
  margin-top: 46px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- workspace (generator pages) ---------- */

.workspace{
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
  align-items: start;
  margin-top: 22px;
  min-width: 0;
}
.workspace > *{ min-width: 0; }
@media (max-width: 860px){
  .workspace{ grid-template-columns: 1fr; }
}

.panel{
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  color: var(--text-dark);
  border-radius: var(--radius-lg);
  border: 1px solid var(--paper-line);
  padding: 20px 20px 22px;
  box-shadow: 0 18px 40px -22px rgba(0,0,0,.7);
}
.panel-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--paper-line);
}
.panel-head h2{
  color: var(--text-dark);
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.panel-head span{ font-family: var(--font-display); font-size: 11px; color: #6b5f45; }

.field{ margin-bottom: 16px; }
.field:last-child{ margin-bottom: 0; }
.field-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.field label{
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #5c4f38;
}
.field .readout{
  display: flex;
  align-items: center;
}
.field .readout input[type="text"]{
  width: 64px;
  text-align: right;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-dark);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
}
.field .readout .unit{ font-size: 11px; color: #8a7c5e; margin-left: 5px; font-family: var(--font-display); }

.field .dims{
  display: flex;
  align-items: center;
  gap: 8px;
}
.field .dims input[type="text"]{
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-dark);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  text-align: center;
}
.field .dims .x{ color: #8a7c5e; font-family: var(--font-display); font-size: 12px; }

input[type="range"]{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track{
  height: 4px;
  background: var(--paper-line);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  margin-top: -7px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--scorch);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--scorch);
}
input[type="range"]::-moz-range-track{
  height: 4px;
  background: var(--paper-line);
  border-radius: 2px;
}
input[type="range"]::-moz-range-thumb{
  width: 12px; height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--scorch);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--scorch);
}

.checkfield{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}
.checkfield label{
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #5c4f38;
}
.switch{
  position: relative;
  width: 40px; height: 22px;
  flex: none;
}
.switch input{ position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track{
  position: absolute; inset: 0;
  background: var(--paper-line);
  border-radius: 999px;
  transition: background .15s ease;
}
.switch .thumb{
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform .15s ease;
}
.switch input:checked + .track{ background: var(--scorch); }
.switch input:checked + .track + .thumb{ transform: translateX(18px); }

/* export block */
.export{
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--paper-line);
}
.export .lb-tag{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6b5f45;
  margin-bottom: 10px;
}
.export .lb-tag .dot{ width: 7px; height: 7px; border-radius: 50%; background: var(--scorch); }
.export p.hint{
  font-size: 12px;
  color: #6b5f45;
  margin: 0 0 14px;
  line-height: 1.5;
}
.export .layers{
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.export .layers span{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 10.5px;
  color: #5c4f38;
}
.export .layers i{ width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.fire-btn{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff2ea;
  background: linear-gradient(180deg, var(--laser-hi), var(--laser));
  border: none;
  border-radius: var(--radius);
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: 0 10px 22px -10px rgba(230,59,46,.65), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s ease, box-shadow .12s ease;
}
.fire-btn:hover{ transform: translateY(-1px); box-shadow: 0 14px 26px -10px rgba(230,59,46,.75), inset 0 1px 0 rgba(255,255,255,.25); }
.fire-btn:active{ transform: translateY(0); }
.fire-btn svg{ width: 15px; height: 15px; flex: none; }

/* ---------- bed / preview ---------- */

.bed{
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 1.6px) 0 0 / 22px 22px,
    var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  position: relative;
}
.bed .bed-tag{
  position: absolute;
  top: 16px; left: 18px;
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.bed .bed-dims{
  position: absolute;
  top: 16px; right: 18px;
  font-family: var(--font-display);
  font-size: 10.5px;
  color: var(--text-dim);
}
.bed svg#puzzlecontainer{
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 10px 28px rgba(0,0,0,.55));
}
#puzzlepath_h{ stroke: var(--blue); }
#puzzlepath_v{ stroke: var(--laser-hi); }
#puzzlepath_b{ stroke: var(--paper); }

.back-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 26px;
}
.back-link:hover{ color: var(--scorch-hi); }
