/* ============================================================
   Spacefully Hyperlocal Tracking Link Builder
   Brand palette (spacefully.com):
     primary blue #38a1e2 · green #B3D88F · sand #DCD3C6 · dark #2c2d2d
   Coral #FF7B6B is reserved for one job only: marking what's clickable.
   ============================================================ */

:root {
  --brand-blue: #38a1e2;
  --brand-blue-dark: #2380bb;
  --brand-blue-soft: rgba(56, 161, 226, 0.12);
  --brand-green: #B3D88F;
  --brand-green-dark: #7da65b;
  --brand-green-soft: rgba(179, 216, 143, 0.22);
  --sand: #DCD3C6;
  --sand-soft: rgba(220, 211, 198, 0.25);
  --coral: #FF7B6B;
  --coral-dark: #e8604f;
  --coral-soft: rgba(255, 123, 107, 0.12);
  --dark: #2c2d2d;
  --ink: #343b41;
  --muted: #59646c;   /* darkened for legibility */
  --faint: #6e7a83;   /* darkened for legibility — still lighter than muted */
  --bg: #f6f9fb;
  --card: #ffffff;
  --line: #e4e9ed;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(44, 45, 45, 0.05), 0 8px 24px rgba(44, 45, 45, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* Google's own palette, used ONLY inside the GBP mockup for realism */
  --g-blue: #1a73e8;
  --g-text: #202124;
  --g-muted: #70757a;
  --g-line: #dadce0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(56, 161, 226, 0.10), transparent 60%),
    radial-gradient(900px 400px at 10% 0%, rgba(179, 216, 143, 0.12), transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header { padding: 40px 0 8px; text-align: center; }
.brand-row {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
/* Scales with the viewport like the headline does, so the logo stays the anchor
   of the header instead of shrinking into the pill beside it. */
.brand-logo { display: block; height: clamp(28px, 3.2vw, 36px); width: auto; }
.brand-pill {
  font-size: 12px; font-weight: 600; color: var(--brand-green-dark);
  background: var(--brand-green-soft); border: 1px solid rgba(125, 166, 91, 0.35);
  padding: 4px 12px; border-radius: 999px;
}
/* 1000px is wide enough for the headline to sit on one line on a desktop, which
   is the real orphan fix. Auto side margins because both still have a max-width
   and would otherwise sit left inside the 1180px container.

   The text-wrap rules and the nbsp pairs in index.html still earn their place at
   narrower widths, where these do wrap. `balance` evens the headline's lines,
   `pretty` keeps the subtitle's last line company. */
.site-header h1 {
  font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -0.03em;
  color: var(--dark); margin: 0 auto 12px; max-width: 1000px;
  text-wrap: balance;
}
.subtitle {
  font-size: 16.5px; color: var(--muted); max-width: 1000px; margin: 0 auto 8px;
  text-wrap: pretty;
}

/* ---------- Setup card ---------- */
.setup-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 28px; margin: 24px 0;
}
/* the destination URL is the only thing to fill in — make it feel that way */
.hero-field label { font-size: 17px; }
.hero-field input {
  font-size: 17px; padding: 14px 16px; max-width: 640px;
}
.hero-field .field-hint { font-size: 13.5px; }
.setup-field label {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; font-size: 14.5px; color: var(--dark); margin-bottom: 8px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px;
  background: var(--brand-blue); color: #fff; font-size: 12.5px; font-weight: 700;
  transition: background 0.25s;
}
.step-num.done { background: var(--brand-green-dark); }
.optional-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--faint); background: var(--sand-soft); padding: 1px 7px; border-radius: 999px;
}
.setup-field input, .utm-field input {
  width: 100%; font-family: var(--font); font-size: 15px; color: var(--ink);
  padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fbfdfe; transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.setup-field input:focus, .utm-field input:focus {
  border-color: var(--brand-blue); box-shadow: 0 0 0 3px var(--brand-blue-soft);
}
.field-hint { font-size: 12.5px; color: var(--faint); margin: 6px 2px 0; }
.field-warning {
  font-size: 13px; color: #a05716; background: #fdf3e4; border: 1px solid #f3ddb7;
  border-radius: 8px; padding: 8px 12px; margin: 8px 0 0;
}
.field-warning code { font-family: var(--mono); font-size: 12px; }

/* ---------- Builder grid ---------- */
.builder-grid {
  display: grid; grid-template-columns: 55fr 45fr; gap: 28px; align-items: start;
  margin-bottom: 48px;
}
/* long URLs must never blow the columns open */
.builder-grid > section { min-width: 0; }

.gbp-panel, .utm-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px 26px;
}
/* settings follow you while you scroll the (tall) profile mockup */
.utm-panel { position: sticky; top: 16px; }

.panel-heading { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.panel-heading .step-num { margin-top: 2px; }
.panel-heading h2 { font-size: 18px; letter-spacing: -0.015em; color: var(--dark); margin: 0 0 3px; }
.panel-heading p { font-size: 13.5px; color: var(--muted); margin: 0; }

/* ---------- GBP mockup ---------- */
.gbp-frame { position: relative; }
#gbpMockup { width: 100%; height: auto; display: block; font-family: Roboto, Arial, sans-serif; }

/* hotspot interaction zones — coral means "you can click this" */
.hotzone {
  fill: rgba(255, 123, 107, 0.05);
  stroke: var(--coral);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  opacity: 0.9;
  rx: 10;
  transition: opacity 0.18s, fill 0.18s, stroke-dasharray 0.18s;
}
/* one-time gentle pulse at load: "hey, these are clickable" */
@keyframes hotzone-pulse {
  0%, 100% { opacity: 0.9; stroke-width: 2; }
  50% { opacity: 0.45; stroke-width: 3; }
}
.hotspot .hotzone { animation: hotzone-pulse 1.5s ease-in-out 0.8s 2; }

.hotspot { cursor: pointer; outline: none; }
.hotspot:hover .hotzone, .hotspot:focus .hotzone {
  opacity: 1; fill: var(--coral-soft); stroke-dasharray: none; stroke-width: 2.5;
}
.hotspot.active .hotzone {
  opacity: 1; fill: rgba(255, 123, 107, 0.18); stroke: var(--coral-dark);
  stroke-dasharray: none; stroke-width: 3;
}
/* dim other hotspots when one is active */
#gbpMockup.has-active .hotspot:not(.active) .hotzone { opacity: 0.35; fill: transparent; }
#gbpMockup.has-active .hotspot:not(.active):hover .hotzone,
#gbpMockup.has-active .hotspot:not(.active):focus .hotzone { opacity: 1; fill: var(--coral-soft); }

/* non-trackable elements: no coral, subtle grey hover */
.notrack { cursor: help; }
.notrack .hotzone { stroke: transparent; fill: transparent; opacity: 1; }
.notrack:hover .hotzone { fill: rgba(152, 162, 171, 0.08); stroke: #c9d2d8; stroke-dasharray: 3 3; }

/* tooltip */
.svg-tooltip {
  position: absolute; z-index: 30; max-width: 260px; pointer-events: none;
  background: var(--dark); color: #f4f7f9; font-size: 12.5px; line-height: 1.45;
  padding: 8px 12px; border-radius: 8px; box-shadow: 0 6px 20px rgba(44, 45, 45, 0.3);
}
.svg-tooltip.tip-track { background: var(--coral-dark); font-weight: 600; }

.other-buttons {
  margin-top: 16px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; background: var(--sand-soft);
}
.other-buttons summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--brand-blue-dark);
}
.other-buttons p { font-size: 13.5px; color: var(--muted); margin: 10px 0 4px; }

.scope-note { font-size: 12.5px; color: var(--faint); margin: 14px 4px 0; }

/* ---------- Preset card ---------- */
.preset-card {
  border: 1px solid rgba(56, 161, 226, 0.35); background: var(--brand-blue-soft);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 18px;
  transition: opacity 0.25s;
}
.preset-card.fading { opacity: 0; }
.preset-empty-msg { font-size: 14px; color: var(--muted); margin: 2px 0; }
.preset-badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: #fff; background: var(--brand-blue);
  padding: 3px 10px; border-radius: 999px; margin-bottom: 8px;
}
.preset-content p { font-size: 13.5px; color: var(--ink); margin: 4px 0; }
.preset-tip { color: var(--brand-blue-dark) !important; font-weight: 550; }

/* ---------- UTM fields ---------- */
.utm-fields { display: flex; flex-direction: column; gap: 14px; }
.utm-field label {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 13.5px; font-weight: 650; color: var(--dark);
  margin-bottom: 5px;
}
.utm-field label code {
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--faint);
  background: var(--sand-soft); padding: 1px 6px; border-radius: 5px;
}
.utm-field .req {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--brand-blue-dark);
  background: var(--brand-blue-soft); padding: 1px 7px; border-radius: 999px;
}
.utm-field input { font-family: var(--mono); font-size: 13.5px; transition: background-color 0.4s; }
.utm-field input.flash { background-color: rgba(179, 216, 143, 0.28); }
.utm-explain { font-size: 12px; color: var(--faint); margin: 4px 2px 0; }
.utm-explain.nudge { color: var(--coral-dark); font-weight: 600; }

.advanced-fields { border-top: 1px dashed var(--line); padding-top: 10px; }
.advanced-fields summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.advanced-fields .utm-field { margin-top: 12px; }

/* ---------- Generate + result ---------- */
.output-area { margin-top: 22px; }

.generate-btn {
  display: block; width: 100%;
  font-family: var(--font); font-size: 16px; font-weight: 700; color: #fff;
  background: var(--brand-blue); border: none; border-radius: 12px; padding: 15px 20px;
  cursor: pointer; letter-spacing: -0.01em;
  box-shadow: 0 4px 14px rgba(56, 161, 226, 0.35);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.generate-btn:hover { background: var(--brand-blue-dark); transform: translateY(-1px); }
.generate-btn:active { transform: translateY(0); }
/* still clickable when not ready — clicking guides the user to what's missing */
.generate-btn.not-ready { background: #9ec8e2; box-shadow: 0 2px 8px rgba(56, 161, 226, 0.25); }
.generate-btn.not-ready:hover { background: #8bbedd; }
@keyframes btn-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.generate-btn.shake { animation: btn-shake 0.4s ease; }

.generate-hint { font-size: 12.5px; color: var(--faint); margin: 10px 2px 0; text-align: center; }

.result-block {
  margin-top: 18px; padding: 16px; border-radius: 12px;
  background: var(--brand-green-soft); border: 1px solid rgba(125, 166, 91, 0.4);
}
@keyframes result-pop {
  0% { transform: scale(0.97); opacity: 0.4; }
  60% { transform: scale(1.01); }
  100% { transform: scale(1); opacity: 1; }
}
.result-block.fresh { animation: result-pop 0.35s ease; }
.result-block.stale { opacity: 0.65; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.preview-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--brand-green-dark);
}
.url-preview {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--dark);
  background: #ffffff; border: 1.5px solid rgba(125, 166, 91, 0.4); border-radius: 10px;
  padding: 13px 15px;
  word-break: break-all; overflow-wrap: anywhere; white-space: normal;
  max-width: 100%; overflow: hidden;
}
.url-preview .utm-part { color: var(--brand-blue-dark); }
.stale-note { font-size: 12.5px; color: var(--coral-dark); font-weight: 600; margin: 10px 2px 0; }

.ga4-hint { font-size: 12.5px; color: var(--muted); margin: 12px 2px 0; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ghost-btn {
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--brand-blue-dark);
  background: #ffffff; border: 1.5px solid rgba(56, 161, 226, 0.45);
  border-radius: 9px; padding: 8px 14px; cursor: pointer; transition: background 0.15s;
}
.ghost-btn:hover { background: var(--brand-blue-soft); }
.ghost-btn.small { padding: 4px 12px; font-size: 12px; }
.ghost-btn.subtle { border-color: var(--line); color: var(--faint); font-weight: 500; background: transparent; }

/* ---------- History ---------- */
.history-section { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.history-section h3 { font-size: 14px; color: var(--dark); margin: 0 0 10px; }
#historyList { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#historyList li {
  display: flex; align-items: center; gap: 10px;
  background: #fbfdfe; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px;
}
.history-meta { flex: 1; min-width: 0; }
.history-preset { font-size: 11px; font-weight: 700; color: var(--brand-blue-dark); text-transform: uppercase; letter-spacing: 0.04em; }
.history-url {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.history-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.history-actions button {
  font-size: 11.5px; font-weight: 600; color: var(--brand-blue-dark); background: transparent;
  border: 1px solid rgba(56, 161, 226, 0.4); border-radius: 6px; padding: 4px 9px; cursor: pointer;
}
.history-actions button:hover { background: var(--brand-blue-soft); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(8px);
  background: var(--dark); color: #fff; font-size: 14.5px; font-weight: 600;
  padding: 12px 24px; border-radius: 999px; box-shadow: 0 10px 30px rgba(44, 45, 45, 0.35);
  opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 100; pointer-events: none;
  max-width: min(92vw, 560px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0 34px; margin-top: 20px; }
.site-footer p { font-size: 13.5px; color: var(--muted); margin: 0 0 4px; }
.site-footer a { color: var(--brand-blue-dark); font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.privacy-note { font-size: 12px !important; color: var(--faint) !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .builder-grid { grid-template-columns: 1fr; }
  .utm-panel { position: static; } /* sticky makes no sense stacked */
}

@media (max-width: 560px) {
  .container { padding: 0 14px; }
  .site-header { padding: 28px 0 4px; }
  .setup-card, .gbp-panel, .utm-panel { padding: 18px 16px; }
  .subtitle { font-size: 15.5px; }
  .url-preview { font-size: 11.5px; }
  #historyList li { flex-direction: column; align-items: stretch; gap: 6px; }
  .history-actions { justify-content: flex-end; }
  .toast { bottom: 18px; font-size: 13.5px; padding: 10px 18px; }
}
