/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure hidden attribute always wins over display:flex/grid */
[hidden] { display: none !important; }

:root {
  --bg:       #f3f4f6;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --border:   #e5e7eb;
  --border2:  #dbe3f2;
  --blue:     #2563eb;
  --blue-lt:  #eff6ff;
  --blue-md:  #dbeafe;
  --blue-dk:  #1e40af;
  --blue-bd:  #bfdbfe;
  --text:     #111827;
  --muted:    #6b7280;
  --muted2:   #94a3b8;
  --green:    #16a34a;
  --green-lt: #dcfce7;
  --orange:   #d97706;
  --orange-lt:#fef3c7;
  --red:      #dc2626;
  --red-lt:   #fee2e2;
  --radius:   12px;
  --radius-sm:8px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:0 4px 12px rgba(0,0,0,.08);
  --font:     ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:'Consolas', 'Cascadia Code', 'Fira Mono', monospace;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Page wrapper ───────────────────────────────────────────────────────────── */
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Page header (matches WCAG scanner pattern) ─────────────────────────────── */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1.5rem; padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.page-head-left { flex: 1; min-width: 0; }
.page-head h1   { font-size: 32px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.page-sub       { color: var(--muted); font-size: 0.88rem; }
.dex-back-link  { font-size: 0.78rem; font-weight: 400; color: var(--muted); text-decoration: none; white-space: nowrap; vertical-align: baseline; margin-left: 0.5rem; }
.dex-back-link:hover { color: var(--blue); }
.brand          { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; flex-shrink: 0; }
.brand img      { display: block; max-height: 48px; width: auto; object-fit: contain; }

/* ── Scan bar ───────────────────────────────────────────────────────────────── */
.scan-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.5rem; flex-wrap: wrap;
}
.scan-form {
  flex: 1; display: flex; gap: 0.35rem; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.3rem 0.3rem 0.85rem;
  box-shadow: var(--shadow);
}
.url-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 0.95rem; font-family: var(--font-mono);
  min-width: 0;
}
.url-input::placeholder { color: var(--muted2); }
.scan-bar-right { display: flex; gap: 0.4rem; flex-shrink: 0; }
.scan-error { color: var(--red); margin-bottom: 0.75rem; font-size: 0.85rem; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-foot {
  max-width: 1100px; margin: 2rem auto 0; padding: 1rem 1.5rem 1.5rem;
  color: var(--muted); font-size: 0.78rem; text-align: center;
  border-top: 1px solid var(--border);
}
.site-foot a { color: var(--blue); text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.btn-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes pulse-text { 0%,100% { opacity:1; } 50% { opacity:0.45; } }
.scan-status {
  color: var(--muted); font-size: 0.85rem; margin-bottom: 0.75rem;
  animation: pulse-text 1.5s ease-in-out infinite;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--blue);
  color: #fff; border: 1px solid var(--blue); border-radius: var(--radius-sm);
  padding: 0.6rem 1.5rem; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
  display: flex; align-items: center; gap: 0.4rem;
  white-space: nowrap; font-family: var(--font);
}
.btn-primary:hover  { background: var(--blue-dk); border-color: var(--blue-dk); }
.btn-primary:active { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: var(--surface); color: var(--blue);
  border: 1px solid var(--blue-bd); border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s; font-family: var(--font);
}
.btn-ghost:hover { background: var(--blue-lt); }
.btn-sm { padding: 0.28rem 0.65rem; font-size: 0.78rem; }

.tiny-link {
  display: inline-block; color: #1d4ed8; background: #f8fafc;
  border: 1px solid #dbe3f2; border-radius: 999px;
  padding: 7px 18px; font-size: 0.82rem; white-space: nowrap;
  cursor: pointer; font-family: var(--font); font-weight: 600;
}
.tiny-link:hover { background: #dbeafe; }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.btn-spinner { display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Notice card (rate limit / server busy) ─────────────────────────────────── */
.notice-card {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--orange-lt); border: 1px solid #fcd34d;
  border-radius: var(--radius); padding: 1rem 1.25rem;
  margin-bottom: 0.75rem; box-shadow: var(--shadow);
}
.notice-icon { font-size: 1.5rem; flex-shrink: 0; }
.notice-body { flex: 1; }
.notice-body strong { font-size: 0.9rem; color: var(--text); display: block; }
.notice-body p { font-size: 0.84rem; color: var(--muted); margin-top: 0.2rem; }
.notice-retry { flex-shrink: 0; }

/* ── Results layout ─────────────────────────────────────────────────────────── */
.results { margin-top: 1.25rem; padding-bottom: 2rem; }

.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.1rem; gap: 1rem; flex-wrap: wrap;
}
.result-meta { font-size: 0.82rem; color: var(--muted); }
.result-meta a { color: var(--blue); text-decoration: none; }
.result-meta a:hover { text-decoration: underline; }
.result-actions { display: flex; gap: 0.4rem; }

/* ── Summary row ────────────────────────────────────────────────────────────── */
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.summary-card { flex: 1 1 150px; }
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex; flex-direction: column; gap: 0.15rem;
  box-shadow: var(--shadow);
}
.summary-card .sc-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 600;
}
.summary-card .sc-value {
  font-size: 1rem; font-weight: 700; color: var(--text);
}
.summary-card .sc-sub { font-size: 0.75rem; color: var(--muted); }
.summary-card.highlight {
  border-color: var(--blue-bd);
  background: var(--blue-lt);
}
.summary-card.highlight .sc-value { color: var(--blue); }

/* ── Detail grid ────────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 0.75rem;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.detail-card .card-header {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.6rem 1rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.card-header .card-icon { font-size: 0.95rem; }
.detail-card .card-body { padding: 0.75rem 1rem; }

/* ── Tech list ──────────────────────────────────────────────────────────────── */
.tech-list { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.tech-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
}
.tech-name { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.tech-version {
  font-size: 0.72rem; color: var(--blue);
  background: var(--blue-lt); border: 1px solid var(--blue-bd);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}

/* ── Key-value pairs ────────────────────────────────────────────────────────── */
.kv-list { display: flex; flex-direction: column; gap: 0.4rem; }
.kv-row  { display: flex; gap: 0.5rem; font-size: 0.84rem; align-items: flex-start; }
.kv-key  { color: var(--muted); min-width: 90px; flex-shrink: 0; font-size: 0.8rem; }
.kv-val  { word-break: break-all; color: var(--text); }
.kv-val a { color: var(--blue); text-decoration: none; }
.kv-val a:hover { text-decoration: underline; }

/* ── Tags / chips ───────────────────────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 8px;
  font-size: 0.77rem; color: var(--text);
}
.tag.accent { border-color: var(--blue-bd); color: var(--blue); background: var(--blue-lt); }
.tag.green  { border-color: #86efac; color: var(--green); background: var(--green-lt); }
.tag.orange { border-color: #fcd34d; color: var(--orange); background: var(--orange-lt); }
.tag.red    { border-color: #fca5a5; color: var(--red);    background: var(--red-lt); }

/* ── Security header table ──────────────────────────────────────────────────── */
.sec-grid { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.75rem; font-size: 0.8rem; }
.sec-key  { color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem; align-self: center; }
.sec-present { color: var(--green); font-weight: 700; }
.sec-missing  { color: var(--red-lt); }
.sec-missing  { color: var(--red); font-size: 0.75rem; }
.sec-score-bar { height: 5px; background: var(--border); border-radius: 3px; margin-bottom: 0.65rem; overflow: hidden; }
.sec-score-fill { height: 100%; border-radius: 3px; transition: width 0.5s;
  background: linear-gradient(90deg, var(--red) 0%, var(--orange) 50%, var(--green) 100%); }

/* ── DNS records ────────────────────────────────────────────────────────────── */
.dns-record { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text); }
.dns-type   { display: inline-block; min-width: 42px; color: var(--blue); font-weight: 700; }

/* ── Analytics ──────────────────────────────────────────────────────────────── */
.analytics-item { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.55rem; }
.analytics-name { font-size: 0.86rem; font-weight: 600; }
.analytics-id   { font-family: var(--font-mono); font-size: 0.77rem; color: var(--blue);
  background: var(--blue-lt); border: 1px solid var(--blue-bd);
  border-radius: 4px; padding: 1px 7px; display: inline-block; }

/* ── TLS expiry ─────────────────────────────────────────────────────────────── */
.tls-expiry { font-weight: 700; }
.tls-expiry.ok     { color: var(--green); }
.tls-expiry.warn   { color: var(--orange); }
.tls-expiry.danger { color: var(--red); }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 820px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 0.88rem; background: var(--surface2);
}
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.modal-close:hover { color: var(--text); }
.modal-json {
  padding: 1rem; overflow: auto; flex: 1;
  font-family: var(--font-mono); font-size: 0.77rem;
  line-height: 1.5; color: var(--text); white-space: pre;
  background: #fafafa;
}

/* ── History panel ──────────────────────────────────────────────────────────── */
.history-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 360px; background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200; display: flex; flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
}
.history-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 0.88rem;
  background: var(--surface2);
}
.history-list { overflow-y: auto; flex: 1; padding: 0.5rem; }
.history-item {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 0.4rem; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.history-item:hover { border-color: var(--blue-bd); background: var(--blue-lt); }
.history-url  { font-size: 0.8rem; font-family: var(--font-mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }
.history-cms  { font-size: 0.72rem; color: var(--blue); margin-top: 0.1rem; font-weight: 600; }

/* ── Empty / divider ────────────────────────────────────────────────────────── */
.empty   { text-align: center; color: var(--muted); padding: 1.5rem; font-size: 0.86rem; }
.divider { height: 1px; background: var(--border); margin: 0.55rem 0; }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Prevent any element from causing horizontal overflow */
  body { overflow-x: hidden; }

  /* Tighter side padding on narrow screens */
  .wrap { padding: 0 0.875rem; }

  /* Page header: shrink h1, reduce logo, tighten spacing */
  .page-head    { gap: 0.65rem; padding: 1rem 0 0.85rem; }
  .page-head h1 { font-size: 1.5rem; }
  .brand img    { max-height: 36px; }

  /* Scan bar: stack form above History button */
  .scan-bar       { flex-direction: column; align-items: stretch; }
  .scan-bar-right { display: flex; justify-content: flex-end; }
  .scan-form      { flex-direction: column; padding: 0.5rem; }
  .btn-primary    { width: 100%; justify-content: center; }

  /* Results header: stack meta URL above action buttons */
  .results-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }

  /* Notice card: allow icon+text+button to wrap on very small screens */
  .notice-card { flex-wrap: wrap; }

  /* Detail grid: single column */
  .detail-grid { grid-template-columns: 1fr; }

  /* History panel: full-width drawer */
  .history-panel { width: 100%; }
}
