/* ===== PosterTool — procedural typography engine ===== */
@font-face {
  font-family: "Fluxetype";
  src: url("assets/Fluxetype-VF.woff2") format("woff2-variations"),
       url("assets/Fluxetype-VF.woff2") format("woff2");
  font-weight: 100 700;
  font-display: block;
}

:root {
  --paper: #F5F3ED;
  --ink:   #0a0908;
  --accent: #FF005C;
  --neon-glow: 0 0 8px rgba(255, 0, 92, 0.4);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #181715;
  color: var(--paper);
  font-family: var(--mono);
  overflow: hidden;
}

/* ----- stage ----- */
#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

#poster-wrap {
  position: relative;
  height: 100%;
  max-height: calc(100vh - 48px);
  aspect-ratio: 4 / 5;
  background: var(--paper);
  box-shadow:
    0 1px 0 rgba(255,255,255,.04) inset,
    0 30px 60px -20px rgba(0,0,0,.6),
    0 0 0 1px rgba(255,255,255,.05);
  overflow: hidden;
  transition: aspect-ratio .25s ease;
}
#poster-wrap.format-square    { aspect-ratio: 1 / 1; }
#poster-wrap.format-story     { aspect-ratio: 9 / 16; }
#poster-wrap.format-portrait  { aspect-ratio: 4 / 5; }

#poster-wrap.bg-ink { background: var(--ink); }

#poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* meta corner readouts on poster */
.poster-meta {
  position: absolute;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink);
  mix-blend-mode: difference;
  pointer-events: none;
  text-transform: uppercase;
}
.bg-ink .poster-meta { color: var(--paper); }
.poster-meta.tl { top: 10px; left: 12px; }
.poster-meta.tr { top: 10px; right: 12px; text-align: right; }
.poster-meta.bl { bottom: 10px; left: 12px; }
.poster-meta.br { bottom: 10px; right: 12px; text-align: right; }
.poster-meta .dim { opacity: .55; }

/* ----- panel ----- */
#panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 32px);
  background: #0a0908;
  color: var(--paper);
  border: 1px solid rgba(255,255,255,.12);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  z-index: 50;
  display: flex;
  flex-direction: column;
  user-select: none;
}

#panel.collapsed .panel-body { display: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  cursor: grab;
  background: #000;
}
.panel-head:active { cursor: grabbing; }
.panel-head .title {
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.panel-head .title em {
  font-style: normal;
  font-family: "Fluxetype";
  font-variation-settings: "wght" 700, "XHGT" 78, "CTRS" 60;
  letter-spacing: 0;
  margin: 0 4px;
  color: var(--accent);
  text-shadow: var(--neon-glow);
}
.panel-head .actions { display: flex; gap: 6px; }
.panel-head button {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255,255,255,.2);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 6px;
  cursor: pointer;
}
.panel-head button:hover { background: rgba(255,255,255,.08); }

.panel-body {
  overflow: auto;
  padding: 4px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.section {
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  color: rgba(255,255,255,.55);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.section-head:hover { color: var(--paper); }
.section-head .chev { font-family: var(--mono); opacity:.6; }
.section.closed .section-body { display: none; }
.section.closed .section-head .chev::before { content: "+"; }
.section:not(.closed) .section-head .chev::before { content: "−"; }

.section-body { padding: 0 12px 10px; display: flex; flex-direction: column; gap: 8px; }

.row { display: flex; align-items: center; gap: 8px; }
.row .label { flex: 1; color: rgba(255,255,255,.7); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.row .val { font-variant-numeric: tabular-nums; color: var(--paper); min-width: 36px; text-align: right; font-size: 10px; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 1px;
  background: rgba(255,255,255,.25);
}
input[type=range]::-moz-range-track {
  height: 1px;
  background: rgba(255,255,255,.25);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  background: var(--paper);
  border-radius: 0;
  margin-top: -5px;
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 10px; height: 10px;
  background: var(--paper);
  border: none;
  border-radius: 0;
  cursor: pointer;
}

input[type=text], input[type=number], textarea, select {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255,255,255,.18);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 8px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--paper); }

textarea { min-height: 60px; resize: vertical; line-height: 1.35; }

.btn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.btn-grid.col-3 { grid-template-columns: repeat(3,1fr); }
.btn-grid.col-4 { grid-template-columns: repeat(4,1fr); }

.chip {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255,255,255,.2);
  padding: 6px 4px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
}
.chip:hover { background: rgba(255,255,255,.07); }
.chip.active {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
  box-shadow: 0 0 10px rgba(255,255,255,.2);
}

.big-btn {
  background: var(--paper);
  color: var(--ink);
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px;
  cursor: pointer;
  width: 100%;
}
.big-btn:hover { background: #fff; }
.big-btn.ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--paper);
}
.big-btn.ghost:hover { background: rgba(255,255,255,.08); }

/* color swatches */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px;
  border: 1px solid rgba(255,255,255,.2);
  cursor: pointer;
  position: relative;
}
.swatch.active {
  outline: 1px solid var(--paper);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.15), 0 0 10px rgba(255,255,255,.35);
}
.swatch.none::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent calc(50% - 0.5px), rgba(255,255,255,.5) 50%, transparent calc(50% + 0.5px));
}

/* DNA strip */
.dna-strip {
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.4;
  color: rgba(255,255,255,.65);
  background: rgba(255,255,255,.04);
  padding: 8px;
  border: 1px dashed rgba(255,255,255,.15);
  word-break: break-all;
  white-space: pre-wrap;
}

/* variants strip */
.variants {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 4px;
}
.variants .v {
  aspect-ratio: 4/5;
  background: var(--paper);
  border: 1px solid rgba(255,255,255,.1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.variants .v.bg-ink { background: var(--ink); }
.variants .v svg { width: 100%; height: 100%; display: block; }
.variants .v:hover { outline: 1px solid var(--paper); outline-offset: 1px; }

/* toolbar bottom-left */
#tool-corner {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 40;
  color: rgba(255,255,255,.55);
}
#tool-corner .tag {
  border: 1px solid rgba(255,255,255,.18);
  padding: 6px 10px;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}

/* recording indicator */
#rec-dot {
  position: fixed;
  top: 16px;
  left: 16px;
  display: none;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.2);
  padding: 6px 10px;
  z-index: 60;
  color: var(--paper);
}
#rec-dot.on { display: flex; }
#rec-dot .dot {
  width: 8px; height: 8px; background: #ff2d1c;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
