/* GBP Optimizer — "blueprint redline" identity.
   The product's core act is marking up a business profile like a
   contractor redlines a drawing: strike the old, mark the new in red.
   Light = pale drafting paper. Dark = an actual blueprint. */

:root {
  --ink: #152233;
  --paper: #eef3f8;
  --bg: var(--paper);
  --line: #c3d0dc;
  --muted: #5b6b7c;
  --accent: #c0311c;        /* redline red — brand, CTAs, "after" markup */
  --accent-quiet: #2f6690;  /* steel blue — links, secondary */
  --ok: #2f7a53;
  --warn: #a6710a;
  --danger: #c0311c;
  --grid: rgba(47, 102, 144, 0.07);
  --surface: rgba(21, 34, 51, 0.035);

  --font-display: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: var(--font-display);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #dbe7f2;
    --paper: #0d2036;
    --line: #24405c;
    --muted: #8fa6bd;
    --accent: #ff6a4d;
    --accent-quiet: #7fb8e0;
    --ok: #5cc491;
    --warn: #e0b04d;
    --danger: #ff6a4d;
    --grid: rgba(219, 231, 242, 0.05);
    --surface: rgba(219, 231, 242, 0.04);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 6rem;
}

@media (max-width: 26rem) {
  .wrap { padding: 2.5rem 1rem 4rem; }
}

/* --- header / footer ----------------------------------------------------- */

header {
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

header .wrap {
  padding: 1.1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.logo::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  background: var(--accent);
  flex: none;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
  font-family: var(--font-mono);
}

footer .wrap {
  padding: 1.5rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
footer a:hover { color: var(--accent); }

/* --- type ------------------------------------------------------------------ */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-quiet);
  margin: 0 0 0.9rem;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4.6vw, 2.6rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
}

h2 {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 3px solid var(--accent);
  display: inline-block;
}

h3 {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.5rem 0 0.75rem;
}

.lede {
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 38rem;
  margin: 0 0 2.25rem;
}

.meta {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.8125rem;
}

p { margin: 0 0 1rem; }

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

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

/* how-it-works: a real sequence, so bracket step numbers are earned */
ol {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  counter-reset: step;
}

ol li {
  counter-increment: step;
  position: relative;
  padding: 0 0 0 3rem;
  margin-bottom: 1.4rem;
  border-left: 1px solid var(--line);
  padding-top: 0.05rem;
  padding-bottom: 1.1rem;
}

ol li:last-child { border-left-color: transparent; margin-bottom: 0; }

ol li::before {
  content: "[" counter(step, decimal-leading-zero) "]";
  position: absolute;
  left: -0.05rem;
  top: 0;
  transform: translateX(-50%);
  background: var(--bg);
  padding: 0 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

ul { padding-left: 1.15rem; }
ul li { margin-bottom: 0.5rem; }

.note {
  border: 1px dashed var(--line);
  border-radius: 2px;
  padding: 1rem 1.25rem;
  margin: 2rem 0;
  color: var(--muted);
  font-size: 0.9375rem;
  position: relative;
}

.note.warn { border-color: var(--warn); color: var(--ink); }

/* --- app ---------------------------------------------------------------- */

.panel {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.25rem;
  margin: 2rem 0;
  background: var(--surface);
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

input[type=url], select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ink);
  font: 0.9375rem/1.4 var(--font-mono);
}

input[type=url]:focus, select:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type=checkbox] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

.row { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.75rem; flex-wrap: wrap; }
.row input { flex: 1; min-width: 10rem; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: var(--muted); color: var(--ink); }

.fine { font-size: 0.8125rem; color: var(--muted); }

.log {
  margin: 1.25rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  max-height: 12rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--muted);
}
.log-line { padding: 0.15rem 0 0.15rem 1.1rem; position: relative; }
.log-line::before { content: "›"; position: absolute; left: 0; color: var(--line); }
.log-line.ok { color: var(--ok); font-weight: 700; }
.log-line.ok::before { content: "✓"; color: var(--ok); }
.log-line.warn { color: var(--warn); }
.log-line.warn::before { content: "!"; color: var(--warn); }
.log-line.error, .error { color: var(--danger); }
.log-line.error::before { content: "×"; color: var(--danger); }
.error { font-size: 0.9375rem; }

.findings { list-style: none; padding: 0; margin: 0 0 2rem; }
.findings li {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 2px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
}
.findings .sev-critical { border-left-color: var(--danger); }
.findings .sev-high { border-left-color: var(--warn); }
.findings .sev-medium { border-left-color: var(--accent-quiet); }
.findings .sev-low { border-left-color: var(--line); }
.findings strong { font-size: 1rem; }
.findings p { margin: 0.4rem 0 0; color: var(--muted); }
.findings .fix { color: var(--ink); }
.findings .fix::before { content: "Fix: "; font-weight: 700; color: var(--accent-quiet); }

.tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  vertical-align: middle;
}
.tag.risky { border-color: var(--warn); color: var(--warn); }

.diff {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
}
.diff-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.diff-head label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  text-transform: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}
.diff-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 0.75rem; }
.diff-cols .fine {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.diff-cols p { margin: 0; }
.col.before .fine { color: var(--muted); }
.col.before p { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); text-decoration-thickness: 1.5px; }
.col.after .fine { color: var(--accent); }
.col.after p {
  color: var(--ink);
  font-weight: 600;
  padding-left: 0.9rem;
  border-left: 2px solid var(--accent);
}

/* --- flow order ----------------------------------------------------------- */

/* Cold visitor: the URL form is the hero action, connect comes after the teaser.
   Connected: the profile picker moves above the form it prefills. */
.flow { display: flex; flex-direction: column; }
.flow #tool { order: 1; }
.flow #connection { order: 2; }
body.is-connected .flow #connection { order: 0; }
/* Once the teaser is up, its gate is the connect CTA — don't show it twice. */
body.has-teaser .flow #connection { display: none; }

.form-hint { margin: 0.6rem 0 0; }

.panel-title { margin: 0 0 0.6rem; color: var(--ink); }
.connect-panel .btn { margin-top: 0.35rem; }
.connect-panel .fine { margin: 0.9rem 0 0; }

/* --- teaser --------------------------------------------------------------- */

.teaser-count {
  font-family: var(--font-mono);
  font-size: 1rem;
  margin: 0 0 1.25rem;
  color: var(--muted);
}
.teaser-count strong { color: var(--ink); }

.teaser-stats { margin: 0 0 2rem; }

.stat {
  border-left: 3px solid var(--accent-quiet);
  padding: 0.15rem 0 0.15rem 0.9rem;
  margin-bottom: 1rem;
}
.stat-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.stat-value { margin: 0; overflow-wrap: anywhere; }

/* A drawn padlock — cheaper and more on-brand than an emoji. */
.lock-glyph {
  position: relative;
  display: inline-block;
  flex: none;
  width: 0.7rem;
  height: 0.6rem;
  margin-top: 0.25rem;
  border: 2px solid var(--accent);
  border-radius: 1px;
}
.lock-glyph::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  width: 0.44rem;
  height: 0.3rem;
  border: 2px solid var(--accent);
  border-bottom: 0;
  border-radius: 0.3rem 0.3rem 0 0;
}

/* Redaction, not blur: blacked-out lines on a drawing. Nothing sits underneath. */
.redact-block { display: block; margin-top: 0.55rem; }
.redact {
  display: block;
  height: 0.6rem;
  margin-bottom: 0.32rem;
  border-radius: 1px;
  background: var(--ink);
  opacity: 0.16;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0 3px,
    rgba(255, 255, 255, 0.35) 3px 4px
  );
}
.redact:last-child { margin-bottom: 0; }

@media (prefers-color-scheme: dark) {
  .redact { opacity: 0.22; }
}

.locked-list { margin-bottom: 2rem; }
.locked-row { opacity: 0.92; }
.locked-row-head { display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.lock-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.locked-row .tag { margin-left: 0; }

.locked {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}

.locked-body { padding: 1.25rem; }

.locked-item { padding: 0.85rem 0; border-bottom: 1px dashed var(--line); }
.locked-item:last-child { border-bottom: 0; padding-bottom: 0; }
.locked-item:first-child { padding-top: 0; }
.locked-item-head { display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.locked-item-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.locked-item .tag { margin-left: 0; }

.locked-gate {
  border-top: 3px solid var(--accent);
  background: var(--bg);
  padding: 1.4rem 1.25rem;
  text-align: center;
}
.gate-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 1rem;
}
.locked-gate .fine { margin: 0.9rem 0 0; max-width: 30rem; margin-inline: auto; }

.diff details { margin-top: 0.9rem; }
.diff summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent-quiet);
}
.diff details ul { margin-top: 0.6rem; }

/* --- small screens -------------------------------------------------------- */

@media (max-width: 34rem) {
  body { font-size: 15px; }

  .diff-cols { grid-template-columns: 1fr; gap: 0.9rem; }
  .diff { padding: 0.9rem 1rem; }

  /* Full-width tap targets — a 44px-min button beats a small inline one. */
  .btn { width: 100%; text-align: center; padding: 0.8rem 1rem; }
  .btn.ghost { width: auto; }
  .row { flex-direction: column; align-items: stretch; }
  .row input { width: 100%; min-width: 0; }

  .panel { padding: 1rem; margin: 1.5rem 0; }
  .findings li { padding: 0.75rem 0.9rem; }
  .lede { font-size: 1.0625rem; }
  h1 { font-size: clamp(1.5rem, 7.5vw, 2rem); }

  /* On desktop the [01] markers straddle the list border via translateX(-50%).
     A phone has no margin to straddle into — they pin to the screen edge and
     clip. Keep them fully inside and drop the border they'd overlap. */
  ol li { padding-left: 2.9rem; border-left: none; padding-bottom: 0.2rem; }
  ol li::before { transform: none; left: 0; }

  .note { padding: 0.85rem 1rem; }
  pre { font-size: 0.6875rem; }

  /* iOS zooms any input under 16px on focus — keep it at 16 to stop the jump. */
  input[type=url], select { font-size: 16px; }

  /* Teaser: tighter padding, and the gate CTA runs full width like every button. */
  .teaser-count { font-size: 0.9375rem; }
  .stat { padding-left: 0.75rem; }
  .locked-body { padding: 1rem; }
  .locked-gate { padding: 1.15rem 1rem; }
  .gate-title { font-size: 1rem; }
  .locked-row .locked-row-head,
  .locked-item .locked-item-head { gap: 0.4rem; }
  .lock-label, .locked-item-label { font-size: 0.75rem; }

  /* Long log lines and status rows must wrap, never widen the page. */
  .log { padding: 0.75rem 0.85rem; max-height: 10rem; }
  .status { font-size: 0.875rem; }
  .status li { overflow-wrap: anywhere; }
  .apply-row .fine { margin-top: 0.25rem; }
}

/* Last-resort guard: no element may push the page sideways at any width. */
body { overflow-x: hidden; }
.stat-value, .lock-label, .locked-item-label, .gate-title, .status li,
.note, .panel p, .findings .fix { overflow-wrap: anywhere; }

/* Overflow guards at any width: long URLs, business names, JSON. */
input[type=url], select { max-width: 100%; }
.diff-cols p, .findings p, .findings strong, .log-line { overflow-wrap: anywhere; }
select { text-overflow: ellipsis; }

.apply-row { margin-top: 1.75rem; align-items: center; }

.status { list-style: none; padding: 0; font-family: var(--font-mono); font-size: 0.9375rem; }
.status li { padding: 0.3rem 0; }
.status li::before { content: "●"; margin-right: 0.5rem; font-size: 0.7em; }
.st-live { color: var(--ok); font-weight: 700; }
.st-pending { color: var(--warn); }
.st-failed { color: var(--danger); }

pre {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.9rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
