/*
  Shared styles for everything under /tools/.
  Loaded *after* /styles.css, so it may rely on the design tokens defined there
  (--bg, --bg-card, --border, --accent, --mono, ...).
*/

.tools-intro { padding-top: 56px; }

.tools-grid { align-items: start; }

/* Breadcrumb above a tool's title */
.tool-crumbs {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.tool-crumbs a { color: var(--text-dim); }
.tool-crumbs a:hover { color: var(--accent); }
.tool-crumbs .sep { color: var(--border); margin: 0 6px; }

.tool-lead {
  color: var(--text-dim);
  max-width: 640px;
  margin-bottom: 32px;
}

/* Two-column tool layout: controls on the left, output on the right.
   The output column is kept wide enough for a default 520px signature preview
   plus its frame padding, so nothing overflows horizontally. */
.tool-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 24px;
  align-items: start;
}

.tool-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.tool-panel + .tool-panel { margin-top: 24px; }

.tool-panel > h2,
.tool-panel > h3 {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-panel .panel-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 18px;
}

/* Sticky output column on wide screens so the preview follows the form. */
.tool-output { position: sticky; top: 88px; }

/* Form */
.field-group {
  border: none;
  padding: 0;
  margin: 0 0 22px;
}

.field-group legend {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  padding: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }

.field > label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.field input[type='text'],
.field input[type='email'],
.field input[type='url'],
.field input[type='tel'],
.field input[type='number'],
.field select {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  transition: border-color 0.2s ease;
}

.field input::placeholder { color: #5c6773; }

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.field 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) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

.field .hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Colour picker + hex input side by side */
.color-field { display: flex; align-items: center; gap: 8px; }

.color-field input[type='color'] {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  cursor: pointer;
}

.color-field input[type='color']::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type='color']::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-field input[type='color']::-moz-color-swatch { border: none; border-radius: 5px; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
}

.checkbox input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Toolbars */
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.btn-sm { padding: 8px 14px; font-size: 0.82rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Preview */
.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: none;
  padding: 7px 12px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { color: var(--accent); }
.seg button[aria-pressed='true'] { background: var(--accent); color: #04181a; }

/* Layout picker: schematic cards standing in for the old <select>.
   The radios are real (native grouping, keyboard arrows, :checked styling) and
   only visually hidden, so focus and the accessible name stay intact. */
.layout-picker {
  border: none;
  padding: 0;
  margin: 0 0 16px;
}

.layout-picker legend {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding: 0;
}

.layout-grid {
  display: grid;
  /* 86px keeps all six cards on one row in the output column, and still falls
     back to a tidy 3x2 once the layout goes single-column. */
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 10px;
}

.layout-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
}

.layout-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.layout-thumb {
  display: flex;
  gap: 6px;
  height: 58px;
  padding: 9px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.layout-name {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  transition: color 0.2s ease;
}

.layout-card:hover .layout-thumb { border-color: var(--accent-dim); }
.layout-card:hover .layout-name { color: var(--text); }

.layout-card input:checked ~ .layout-thumb {
  border-color: var(--accent);
  background: rgba(0, 255, 255, 0.06);
}

.layout-card input:checked ~ .layout-name { color: var(--accent); }

.layout-card input:focus-visible ~ .layout-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Thumbnail internals — miniature stand-ins for logo, text and accent rule. */
.lt-row { flex-direction: row; align-items: flex-start; }
.lt-row.lt-mid { align-items: center; }
.lt-col { flex-direction: column; align-items: flex-start; }
.lt-col.lt-center { align-items: center; }

.lt-logo {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.8;
}

.lt-lines {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.lt-center .lt-lines { align-items: center; }

.lt-bar {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--text-dim);
  opacity: 0.5;
}

.lt-bar.lt-name {
  width: 62%;
  height: 4px;
  background: var(--text);
  opacity: 0.85;
}

.lt-bar.lt-sm { width: 80%; opacity: 0.32; }

.lt-rule {
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.85;
}

/* Full-height accent rule of the compact layout */
.lt-vrule {
  flex: 0 0 2px;
  width: 2px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.85;
}

.lt-dots { display: flex; gap: 4px; }

.lt-dot {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: var(--text-dim);
  opacity: 0.45;
}

.preview-frame {
  width: 100%;
  /* JS grows this to fit the rendered signature; this is just the floor. */
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  display: block;
  /* No height transition here on purpose: a backgrounded tab stops servicing
     animation frames, which leaves the frame stuck at its pre-transition size. */
}

/* Generated code */
.code-output {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

.code-output:focus { outline: none; border-color: var(--accent-dim); }

/* Inline status / warning messages */
.notice {
  font-family: var(--mono);
  font-size: 0.78rem;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 14px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.notice.warn {
  border-color: #7a5d1d;
  background: rgba(255, 189, 46, 0.08);
  color: #ffd479;
}

.notice[hidden] { display: none; }

.steps {
  list-style: none;
  counter-reset: step;
  margin-top: 8px;
}

.steps li {
  position: relative;
  padding: 6px 0 6px 26px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.steps li::before {
  counter-increment: step;
  content: counter(step) '.';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--mono);
}

.steps strong { color: var(--text); font-weight: 600; }

/* Copy confirmation toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 80;
  background: var(--accent);
  color: #04181a;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Offscreen node used for the rich-text clipboard fallback */
.clipboard-stage {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 700px;
  opacity: 0;
}

@media (max-width: 980px) {
  .tool-layout { grid-template-columns: 1fr; }
  .tool-output { position: static; }
}

@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
