/* UTM Builder widget. Loaded only on /tools/utm-builder/ via the page's
   extraCSS param. Inherits the site tokens from site.css, so it follows the
   cream/dark theme switch for free. */

.utm {
  margin-block: 12px 56px;
  padding: clamp(20px, 3vw, 34px);
  border: 3px solid var(--text);
  background: var(--surface-raised);
  box-shadow: 8px 8px 0 color-mix(in srgb, var(--shadow) 62%, transparent);
}

/* ---------- Presets ---------- */

.utm__presets {
  margin-bottom: 30px;
}

.utm__presets-label,
.utm__output-head span {
  display: block;
  margin-bottom: 12px;
  color: var(--text-soft);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.utm__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.utm__chips button {
  padding: 9px 14px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, transform 100ms ease;
}

.utm__chips button:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.utm__chips button:active {
  transform: translate(1px, 1px);
}

/* ---------- Fields ---------- */

.utm__field {
  margin-bottom: 22px;
}

.utm__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}

.utm label {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 700;
}

.utm label code {
  font-family: var(--font-mono);
  font-size: 14px;
}

.utm__req {
  color: var(--accent-deep);
}

.utm__opt {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 400;
}

.utm input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.utm input::placeholder {
  color: color-mix(in srgb, var(--text-soft) 72%, transparent);
}

.utm input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--accent) 34%, transparent);
}

.utm input[aria-invalid="true"] {
  border-color: var(--accent-deep);
}

.utm__hint {
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.5;
}

.utm__hint code {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.utm__err {
  margin: 7px 0 0;
  color: var(--accent-deep);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
}

.utm__err:empty {
  display: none;
}

/* ---------- Actions ---------- */

.utm__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 8px;
}

.utm__reset {
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.utm__reset:hover {
  color: var(--accent-deep);
}

/* ---------- Output ---------- */

.utm__output-block {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 3px solid color-mix(in srgb, var(--line) 80%, transparent);
}

.utm__output-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.utm__output-head span {
  margin-bottom: 0;
}

.utm__copy {
  padding: 9px 14px;
  border: 2px solid var(--text);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.utm__copy:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.utm__copy:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.utm__copy.is-copied {
  border-color: var(--forest);
  color: var(--forest);
}

/* user-select: all makes a single click grab the whole URL. */
.utm__output {
  display: block;
  margin-top: 12px;
  padding: 16px;
  min-height: 74px;
  border: 2px dashed var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  user-select: all;
  cursor: text;
  transition: border-color 180ms ease;
}

.utm__output.is-empty {
  border-style: dashed;
  color: var(--text-soft);
  font-family: var(--font-body);
  font-size: 15px;
  user-select: none;
  cursor: default;
}

.utm__output.is-set {
  border-style: solid;
  border-color: var(--text);
}

.utm__output.is-flash {
  border-color: var(--accent);
}

.utm__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .utm {
    padding: 18px 16px;
    box-shadow: 5px 5px 0 color-mix(in srgb, var(--shadow) 62%, transparent);
  }

  .utm__grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .utm__actions {
    gap: 14px;
  }
}
