/* AUTOGRAPH — arcade chrome and local signing workspace */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;
  --control-line: #5e5e80;
  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(16px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(69, 240, 255, 0.05), transparent 70%), var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(69, 240, 255, 0.3); }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(60px); }
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
}
a { color: var(--cyan); }

.site-header {
  padding: 26px var(--space-gutter) 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.lab-link {
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.15s, text-shadow 0.15s;
}
.lab-link:hover { color: var(--cyan); text-shadow: var(--glow-cyan); }
.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}
.wordmark {
  margin: 6px 0 4px;
  font-family: var(--pixel);
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.55), 3px 3px 0 var(--magenta);
}
.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}
.cursor { color: var(--cyan); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

main {
  flex: 1;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px var(--space-gutter) 72px;
}
.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tab, .btn, .file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.tab:hover, .btn:hover, .file-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.tab.is-active {
  background: rgba(69, 240, 255, 0.1);
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }
.btn-primary:hover { box-shadow: 0 0 18px rgba(69, 240, 255, 0.5); }
.btn-ghost { background: transparent; }
.btn-big { font-family: var(--pixel); font-size: 11px; padding: 14px 18px; }

.tab-panel { min-width: 0; }
.draw-layout, .sign-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.panel-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(69, 240, 255, 0.4);
}
.note, .privacy-note {
  margin: 0;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
}
.privacy-note { margin-top: 16px; text-align: center; }

.canvas-wrap {
  background: repeating-conic-gradient(#1c1c2c 0% 25%, #14141f 0% 50%) 0 0 / 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 300px;
  touch-action: none;
}
#signatureCanvas {
  display: block;
  width: 100%;
  height: 320px;
  cursor: crosshair;
}
.controls { gap: 14px; }
.chip-row, .action-grid, .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 6px 10px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.chip:hover { border-color: var(--cyan); color: var(--text); }
.chip.is-active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(69, 240, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(69, 240, 255, 0.35);
}
label, .field-row > label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
}
input, select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  background: var(--bg);
  border: 1px solid var(--control-line);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font: 13px var(--mono);
}
input[type="range"] { accent-color: var(--cyan); padding: 0; }
.field-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}
.field-row output {
  color: var(--gold);
  font-family: var(--mono);
  text-align: right;
}
.type-tools {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.privacy-badge {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(65, 255, 139, 0.45);
  border-radius: 8px;
  background: rgba(65, 255, 139, 0.06);
  text-align: center;
}
.privacy-badge strong {
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--green);
}
.privacy-badge span { color: var(--dim); font-size: 12px; }
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 26px 16px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface-2), rgba(18, 18, 29, 0.3));
}
.drop-zone.is-over {
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(69, 240, 255, 0.12), inset 0 0 48px rgba(69, 240, 255, 0.04);
}
.drop-title {
  margin: 0 0 8px;
  font-family: var(--pixel);
  font-size: 12px;
}
.drop-sub { margin: 0 0 14px; color: var(--dim); font-size: 13px; }
.full { width: 100%; }
.page-actions {
  justify-content: space-between;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px;
}
.page-actions output { font-family: var(--mono); color: var(--gold); }
.pdf-workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.thumb-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.thumb-btn {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--dim);
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 6px;
  cursor: pointer;
  font: 11px var(--mono);
}
.thumb-btn.is-active { border-color: var(--cyan); color: var(--cyan); }
.thumb-btn canvas { max-width: 72px; max-height: 96px; background: #fff; }
.page-scroller {
  overflow: auto;
  min-height: 360px;
  max-height: min(72vh, 880px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.page-stage {
  position: relative;
  margin: 0 auto;
  min-width: 1px;
  min-height: 1px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}
#pageCanvas {
  display: block;
  background: #fff;
}
.placement-layer {
  position: absolute;
  inset: 0;
}
.placement {
  position: absolute;
  border: 1px solid rgba(69, 240, 255, 0.85);
  background: rgba(69, 240, 255, 0.06);
  cursor: move;
  touch-action: none;
}
.placement.is-selected {
  border-color: var(--magenta);
  box-shadow: 0 0 0 2px rgba(255, 61, 139, 0.22);
}
.placement img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.placement span:not(.resize-handle) {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 2px 6px;
  color: #111;
  font: 700 14px -apple-system, "Segoe UI", sans-serif;
  pointer-events: none;
  white-space: nowrap;
}
.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--cyan);
  background: var(--bg);
  border-radius: 4px;
  cursor: nwse-resize;
}
.placement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.placement-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
}
.placement-list li.is-selected { border-color: var(--magenta); }
.mini-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font: 10px var(--mono);
}
.mini-btn:hover { border-color: var(--cyan); color: var(--cyan); }

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s var(--ease-out) both;
}
.toast-info { border-left-color: var(--cyan); }
.toast-success { border-left-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.site-footer p { margin: 0 0 6px; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

@media (min-width: 820px) {
  .draw-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .sign-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .pdf-workspace { grid-template-columns: 112px minmax(0, 1fr); }
  .thumb-rail { flex-direction: column; max-height: 78vh; }
}
@media (max-width: 520px) {
  .panel-head, .field-row { grid-template-columns: 1fr; flex-direction: column; }
  .action-grid > *, .page-actions > * { flex: 1 1 100%; }
  .wordmark { letter-spacing: 1px; }
  #signatureCanvas { height: 280px; }
  .placement-list li { grid-template-columns: 1fr; }
}
@media (pointer: coarse) {
  .tab, .btn, .file-btn, .chip { min-height: 44px; }
  .resize-handle { width: 22px; height: 22px; right: -8px; bottom: -8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor { animation: none; }
}
