/* ============================================================
   SignatureForge — app UI styles
   Palette: deep ink + mint/teal accent + warm off-white.
   Fonts: Sora (display) + Inter (body).
   ============================================================ */

:root {
  --ink: #0b1020;
  --ink-2: #141b30;
  --ink-3: #1d2740;
  --line: #2a3450;
  --paper: #f6f7fb;
  --paper-2: #ffffff;
  --text: #e8ecf6;
  --text-dim: #9aa6c2;
  --muted: #6b7796;
  --accent: #54f0c8;
  --accent-2: #3ad1ff;
  --accent-ink: #04261d;
  --danger: #ff7a7a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.6);
  --maxw: 1180px;
  --field-bg: #0e1426;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(58, 209, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(84, 240, 200, 0.10), transparent 55%),
    var(--ink);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); }

h1, h2, h3, legend, .brand-text {
  font-family: "Sora", "Inter", sans-serif;
  letter-spacing: -0.01em;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 0 0 10px 0; font-weight: 600; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(11, 16, 32, 0.72);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; }
.brand-text { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand-accent { color: var(--accent); }
.header-cta {
  font-size: 0.85rem; color: var(--text-dim); text-decoration: none;
  border: 1px solid var(--line); padding: 7px 14px; border-radius: 999px;
  transition: border-color 0.2s, color 0.2s;
}
.header-cta:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Hero ---------- */
.hero { padding: 54px 20px 26px; text-align: center; }
.hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 3.1rem);
  margin: 0 0 14px; font-weight: 700;
  background: linear-gradient(180deg, #fff, #c8d2ea);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { max-width: 720px; margin: 0 auto; color: var(--text-dim); font-size: 1.06rem; }
.lede strong { color: var(--text); }

/* ---------- App layout ---------- */
.app {
  display: grid; gap: 26px; padding-bottom: 60px;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
}

/* ---------- Editor ---------- */
.editor {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 22px 22px;
  box-shadow: var(--shadow);
}
fieldset { border: none; padding: 0; margin: 0; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
fieldset:first-of-type { border-top: none; margin-top: 8px; padding-top: 10px; }
legend {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--accent); padding: 0; margin-bottom: 4px;
}
.opt { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.78rem; }

.field { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 520px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

label { font-size: 0.85rem; font-weight: 500; color: var(--text-dim); }

input[type="text"], input[type="tel"], input[type="email"], input[type="url"], select {
  width: 100%; font: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--field-bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: #56618a; }
input:focus, select:focus, input[type="color"]:focus-visible, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(84, 240, 200, 0.25);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

input[type="file"] { font-size: 0.85rem; color: var(--text-dim); }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 0.82rem;
  margin-right: 12px; padding: 8px 14px; cursor: pointer;
  color: var(--text); background: var(--ink-3);
  border: 1px solid var(--line); border-radius: 8px;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); }

.color-row { display: flex; gap: 10px; align-items: center; }
input[type="color"] {
  width: 52px; height: 44px; padding: 4px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--field-bg); cursor: pointer;
}
#accentHex { max-width: 130px; text-transform: lowercase; font-variant: tabular-nums; }

.hint, .privacy-note { font-size: 0.8rem; color: var(--muted); margin: 2px 0 0; }
.privacy-note { margin-top: 20px; color: var(--text-dim); }

/* ---------- Template chips ---------- */
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
@media (min-width: 520px) { .template-grid { grid-template-columns: repeat(4, 1fr); } }
.template-chip { position: relative; cursor: pointer; }
.template-chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip-body {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--field-bg); transition: border-color 0.15s, background 0.15s, transform 0.1s;
  height: 100%;
}
.chip-name { font-weight: 600; color: var(--text); font-size: 0.92rem; }
.chip-desc { font-size: 0.74rem; color: var(--muted); }
.template-chip:hover .chip-body { border-color: #3a4768; }
.template-chip input:focus-visible + .chip-body { box-shadow: 0 0 0 3px rgba(84, 240, 200, 0.25); border-color: var(--accent); }
.template-chip input:checked + .chip-body {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(84, 240, 200, 0.12), rgba(84, 240, 200, 0.04));
}

/* ---------- Output column ---------- */
.output-sticky { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-head h2 { margin: 0; font-size: 1.15rem; }
.preview-badge {
  font-size: 0.72rem; color: var(--accent); border: 1px solid rgba(84, 240, 200, 0.4);
  padding: 4px 10px; border-radius: 999px; background: rgba(84, 240, 200, 0.06);
}

.preview-frame {
  background: var(--paper); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.preview-mailmeta {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 18px;
  font-size: 0.78rem; color: #8a93a8; background: #eceef4;
  border-bottom: 1px solid #dde0ea;
}
.preview-body { padding: 22px 22px 26px; color: #1d2333; }
.preview-greeting { margin: 0 0 18px; color: #3b4256; font-size: 0.95rem; font-family: Arial, sans-serif; }
#sig-preview { color: #1d2333; }
/* Ensure pasted table styles render predictably inside preview */
#sig-preview img { max-width: 100%; }

/* ---------- Actions ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 12px 18px; font-size: 0.92rem;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); flex: 1 1 auto; }
.btn-primary:hover { background: #6cf6d3; }
.btn-secondary { background: var(--ink-3); color: var(--text); border-color: var(--line); flex: 1 1 auto; }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; align-self: flex-start; }
.btn-lg { padding: 15px 26px; font-size: 1rem; }

.copy-status { min-height: 1.2em; margin: 0; font-size: 0.85rem; color: var(--accent); font-weight: 500; }
.copy-status.err { color: var(--danger); }

.source-box {
  margin: 0; max-height: 320px; overflow: auto;
  background: #06090f; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; font-size: 0.78rem; line-height: 1.5;
  color: #b8c4e0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- Instructions ---------- */
.instructions {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 18px;
}
.instructions summary {
  cursor: pointer; font-weight: 600; padding: 14px 4px; list-style: none;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.instructions summary::-webkit-details-marker { display: none; }
.instructions summary::before { content: "▸"; color: var(--accent); transition: transform 0.2s; }
.instructions[open] summary::before { transform: rotate(90deg); }
.instr-grid { display: grid; gap: 18px; padding: 4px 4px 18px; }
@media (min-width: 720px) { .instr-grid { grid-template-columns: repeat(3, 1fr); } }
.instr-grid h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--accent); }
.instr-grid ol { margin: 0; padding-left: 18px; font-size: 0.86rem; color: var(--text-dim); }
.instr-grid li { margin-bottom: 5px; }
.instr-grid strong { color: var(--text); }

/* ---------- CTA band ---------- */
.cta-band {
  background: linear-gradient(120deg, rgba(84, 240, 200, 0.10), rgba(58, 209, 255, 0.10));
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cta-inner {
  display: flex; flex-wrap: wrap; gap: 22px; align-items: center; justify-content: space-between;
  padding: 38px 20px;
}
.cta-inner h2 { margin: 0 0 6px; font-size: 1.5rem; }
.cta-inner p { margin: 0; color: var(--text-dim); max-width: 560px; }

/* ---------- Footer ---------- */
.site-footer { padding: 28px 20px; text-align: center; }
.footer-inner p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--accent); }
