/* ============================================================
   UTM Builder — style.css
   ============================================================ */

/* --- Variables & Reset --- */
:root {
  --bg: #f5f3f0;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #ddd9d3;
  --border-hot: #ff4d00;
  --accent: #ff4d00;
  --accent2: #c8620a;
  --text: #1a1714;
  --muted: #8a8178;
  --green: #1a7a4a;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Mono', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Grain overlay --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* --- Top bar --- */
.top-bar {
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(245,243,240,0.95);
  backdrop-filter: blur(12px);
  z-index: 100;
  animation: slideDown 0.5s ease;
}

.logo {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.logo span { color: var(--muted); }

.badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 2px;
}

/* --- Layout --- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 120px;
}

/* --- Hero --- */
.hero {
  margin-bottom: 28px;
  animation: fadeUp 0.6s ease both;
  align-items: baseline;
}

.hero h1 {
  font-size: 32px;
  font-weight: 800;
  font-family: 'Syne', serif;
  line-height: 1;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  animation: fadeUp 0.6s 0.1s ease both;
}

.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
}

.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-r { background: #ff5f57; }
.dot-y { background: #ffbd2e; }
.dot-g { background: #28ca41; }

.card-title {
  margin-left: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.form-body { padding: 32px 24px; }

/* --- Fields --- */
.field {
  margin-bottom: 24px;
  animation: fadeUp 0.5s ease both;
}

.field:nth-child(1) { animation-delay: 0.15s; }
.field:nth-child(2) { animation-delay: 0.2s; }
.field:nth-child(3) { animation-delay: 0.25s; }
.field:nth-child(4) { animation-delay: 0.3s; }
.field:nth-child(5) { animation-delay: 0.35s; }
.field:nth-child(6) { animation-delay: 0.4s; }
.field:nth-child(7) { animation-delay: 0.45s; }

.field label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: #4a4540;
  letter-spacing: 0.01em;
  text-transform: none;
  margin-bottom: 8px;
}

.field label .param { color: var(--accent); }

.required-star {
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.field input,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  padding: 12px 16px;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}

.field input::placeholder { color: #c0b9b2; }

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,77,0,0.08);
}

.field input.filled {
  border-color: var(--border);
  background: #fafaf9;
}

.select-wrap { position: relative; }

.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 14px;
}

.field select { padding-right: 36px; cursor: pointer; }
.field select option { background: #fff; color: #1a1714; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Presets --- */
.presets-label {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: #8a8178;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.preset-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: #5a544e;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255,77,0,0.05);
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

/* --- Output --- */
.output-section {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}

.output-label {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #8a8178;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.output-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text);
  word-break: break-all;
  line-height: 1.75;
  min-height: 60px;
  position: relative;
  transition: border-color 0.3s;
}

.output-box.has-url { border-color: #2a2a2a; }

.url-base { color: var(--muted); }
.url-q    { color: var(--accent2); }
.url-param { color: var(--accent); }
.url-val  { color: var(--green); }
.url-amp  { color: var(--muted); }

.output-empty {
  color: #c5bfb8;
  font-size: 14px;
}

/* --- Actions --- */
.actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 12px 24px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #e04000; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--muted); color: var(--text); }

.btn-success {
  background: #1a7a4a !important;
  color: #fff !important;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1714;
  color: #f5f3f0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 12px 24px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

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

/* --- History --- */
.history-section {
  margin-top: 48px;
  animation: fadeUp 0.6s 0.3s ease both;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: #8a8178;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.clear-btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: #a09890;
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: color 0.15s;
}

.clear-btn:hover { color: var(--accent); }

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: fadeUp 0.3s ease both;
  transition: border-color 0.15s;
}

.history-item:hover { border-color: var(--border-hot); }

.history-url {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.history-copy {
  background: none;
  border: 1px solid var(--border);
  color: #6a6460;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.history-copy:hover { border-color: var(--accent); color: var(--accent); }

.empty-history {
  font-family: var(--mono);
  font-size: 13px;
  color: #c5bfb8;
  padding: 24px 0;
  text-align: center;
  border: 1px dashed #ddd9d3;
  border-radius: 3px;
}

/* --- Misc UI --- */
.field-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.hint      { font-family: var(--sans); font-size: 11px; color: #a09890; }
.char-count { font-family: var(--sans); font-size: 11px; color: #a09890; }

.field.error input { border-color: #ff4d4d; }

.error-msg {
  font-family: var(--mono);
  font-size: 14px;
  color: #ff4d4d;
  margin-top: 6px;
  display: none;
}

.field.error .error-msg { display: block; }

/* --- Live dot --- */
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulse 2s infinite;
  margin-right: 6px;
}

/* --- Animations --- */
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes fadeUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .grid-2    { grid-template-columns: 1fr; }
  .hero h1   { font-size: 22px; }
  .top-bar   { padding: 12px 16px; }
  .form-body { padding: 20px 16px; }
}
