/* style.css — RegexLab. Original stylesheet, single-page regex tester. */

:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1e2740;
  --line: #2a3450;
  --ink: #e6ebf5;
  --muted: #9aa7c2;
  --brand: #4f8cff;
  --brand-dark: #3b6fd6;
  --mark: #b78bff;
  --mark-bg: rgba(183, 139, 255, 0.22);
  --ok: #2ecc71;
  --err: #ff5c72;
  --ad-bg: #10182b;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: 40px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--line); border-radius: 9px; padding: 8px 16px; font-size: 14px; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Ad slots ---------- */
.ad-slot {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--ad-bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  overflow: hidden;
}
.ad-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.55; }

.ad-header { max-width: 1180px; margin: 16px auto 0; min-height: 96px; }

/* Smartlink banner: clickable sponsored CTA (smartlinks are redirect ads,
   so they open as a top-level link, not an embedded iframe) */
.ad-smartlink {
  max-width: 1180px; margin: 22px auto; min-height: 88px;
  padding: 16px 20px;
}
.smartlink-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; color: var(--ink); text-decoration: none;
}
.smartlink-cta:hover { text-decoration: none; }
.smartlink-text { display: flex; flex-direction: column; }
.smartlink-title { font-weight: 700; font-size: 16px; }
.smartlink-sub { color: var(--muted); font-size: 13px; }
.smartlink-btn {
  background: var(--brand); color: #fff; font-weight: 600; font-size: 14px;
  padding: 9px 18px; border-radius: 9px; white-space: nowrap;
}
.smartlink-cta:hover .smartlink-btn { background: var(--brand-dark); }
.ad-smartlink.closed { display: none; }

/* close button (shared by the smartlink banner) */
.sticky-close {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; line-height: 1;
}

/* ---------- Action row / share ---------- */
.action-row { display: flex; align-items: center; gap: 12px; margin: 2px 2px 6px; }
.share-msg { font-size: 12px; color: var(--ok); font-family: var(--mono); }
.share-msg.err { color: var(--err); }

/* ---------- Test cases ---------- */
.tests-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.case {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px; margin-bottom: 10px;
  background: var(--panel-2);
}
.case-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.case-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-left: auto;
}
.case-badge.pass { background: rgba(46, 204, 113, 0.18); color: var(--ok); }
.case-badge.fail { background: rgba(255, 92, 114, 0.18); color: var(--err); }
.case-badge.idle { background: var(--line); color: var(--muted); }
.case-del {
  background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.case-del:hover { color: var(--err); }
.case textarea {
  width: 100%; min-height: 52px; resize: vertical; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; font-family: var(--mono); font-size: 13px;
  padding: 7px 9px; outline: none;
}
.case select {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 7px; font-size: 12px; padding: 4px 6px; cursor: pointer;
}
.case-detail { font-size: 12px; color: var(--muted); margin-top: 5px; font-family: var(--mono); }

/* Anti-adblock bait: ad blockers hide this; we detect that. */
.ad-bait {
  position: absolute; width: 1px; height: 1px; left: -9999px;
  background: transparent; pointer-events: none;
}

/* ---------- Anti-adblock overlay ---------- */
.adblock-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(6, 9, 16, 0.82);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.adblock-overlay[hidden] { display: none; }
.adblock-box {
  max-width: 460px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px; box-shadow: var(--shadow);
}
.adblock-box h2 { margin: 0 0 10px; font-size: 20px; }
.adblock-box p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.adblock-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Header ---------- */
.site-header { padding: 18px 0 6px; }
.header-inner { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: block; flex: none;
}
.brand-text { font-size: 22px; letter-spacing: -0.3px; }
.brand-text strong { color: var(--brand); }
.tagline { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: 1fr 340px; gap: 22px;
  align-items: start; margin-top: 18px;
}

/* ---------- Editor column ---------- */
.editor-col { min-width: 0; }
.pattern-bar {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-family: var(--mono);
}
.slash { color: var(--muted); font-size: 18px; }
.pattern-input {
  flex: 1; background: transparent; border: 0; color: var(--ink);
  font-family: var(--mono); font-size: 16px; outline: none; min-width: 0;
}
.flags-input {
  width: 44px; background: transparent; border: 0; color: var(--mark);
  font-family: var(--mono); font-size: 16px; outline: none;
}
.flag-toggles { display: flex; gap: 4px; margin-left: 8px; }
.flag-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); font-family: var(--mono);
  cursor: pointer; font-size: 13px; padding: 0;
}
.flag-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.status { min-height: 20px; margin: 8px 2px; font-size: 13px; font-family: var(--mono); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.pane-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px 6px; }
.pane-head label { font-weight: 600; font-size: 14px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.pane-meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* Textarea + highlight overlay must share exact box metrics */
.editor-wrap { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.editor-wrap textarea,
.editor-wrap .hl {
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  padding: 12px 14px; margin: 0; white-space: pre-wrap; word-break: break-word;
  overflow-wrap: anywhere; tab-size: 2; border: 0;
}
.editor-wrap .hl {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  color: var(--ink); z-index: 0;
}
.editor-wrap textarea {
  position: relative; z-index: 1; display: block; width: 100%; min-height: 240px;
  background: transparent; color: transparent; caret-color: var(--ink);
  resize: vertical; outline: none;
}
.hl mark { background: var(--mark-bg); color: var(--mark); border-radius: 3px; outline: 1px solid rgba(183,139,255,0.5); }

.subst-input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-family: var(--mono); font-size: 14px; padding: 10px 12px; outline: none;
}
.subst-out {
  margin: 10px 0 0; padding: 12px 14px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; font-family: var(--mono);
  font-size: 14px; white-space: pre-wrap; word-break: break-word; min-height: 44px; color: var(--ink);
}
.subst-out:empty::before { content: "Substituted output appears here."; color: var(--muted); }

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: 16px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); border-radius: 9px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.tab-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; max-height: 340px; overflow: auto;
}
.empty { color: var(--muted); font-size: 13px; text-align: center; margin: 12px 0; }

.match-list { list-style: none; margin: 0; padding: 0; }
.match-list li { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.match-list li:last-child { border-bottom: 0; }
.match-head { display: flex; justify-content: space-between; font-family: var(--mono); color: var(--mark); }
.match-text { font-family: var(--mono); color: var(--ink); word-break: break-word; margin-top: 3px; }
.groups { margin: 5px 0 0; padding-left: 14px; color: var(--muted); font-family: var(--mono); font-size: 12px; }

.explain-list { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.explain-list li { display: flex; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.explain-list li:last-child { border-bottom: 0; }
.explain-tok { font-family: var(--mono); color: var(--mark); min-width: 90px; }
.explain-note { color: var(--muted); }

/* ---------- Page head (H1) ---------- */
.page-head { margin: 26px auto 18px; max-width: 900px; }
.page-title { font-size: 30px; line-height: 1.25; letter-spacing: -0.4px; margin: 0 0 8px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 15px; margin: 0; }

/* ---------- SEO content ---------- */
.seo-content { margin: 40px auto 24px; max-width: 860px; }
.seo-content h2 { font-size: 24px; letter-spacing: -0.3px; margin: 0 0 14px; }
.seo-content h3 { font-size: 18px; margin: 22px 0 8px; color: var(--ink); }
.seo-content p { color: var(--muted); font-size: 15px; margin: 0 0 14px; }
.seo-content strong { color: var(--ink); }
.seo-content code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 13px; }

/* ---------- GA4 example presets ---------- */
.ga4-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; align-items: center; }
.preset-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.preset {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.preset:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- SEO FAQ ---------- */
.seo-faq { margin: 12px auto 30px; max-width: 860px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.seo-faq h2 { font-size: 21px; margin: 0 0 10px; letter-spacing: -0.2px; }
.seo-faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.seo-faq summary { font-weight: 600; font-size: 15px; cursor: pointer; color: var(--ink); }
.seo-faq p { color: var(--muted); font-size: 14.5px; margin: 8px 0 2px; }
.seo-faq code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 13px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 20px; padding: 22px 0; }
.site-footer p { margin: 0 0 6px; font-size: 14px; }
.fine { color: var(--muted); font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .flag-toggles { flex-wrap: wrap; }
}
