/* ============================================================
   TechScope — Design System & Component Styles
   Structure:
     1. Custom properties (tokens)
     2. Reset & base
     3. Layout utilities
     4. Typography
     5. Header
     6. Hero & search form
     7. Results meta bar
     8. Result grid & sidebar
     9. Technology cards
    10. Category tabs
    11. Security score ring
    12. Check list
    13. Detail list (SSL/DNS)
    14. Headers table
    15. Collapsible
    16. Badges & labels
    17. Error state
    18. Footer
    19. Animations
    20. Responsive
   ============================================================ */

/* ── 1. Custom Properties ─────────────────────────────────── */
:root {
  /* Palette */
  --color-bg:           #080c14;
  --color-surface:      #0e1520;
  --color-surface-2:    #141d2e;
  --color-border:       #1e2d45;
  --color-border-light: #243450;

  --color-accent:       #3b82f6;
  --color-accent-dim:   #1d4ed8;
  --color-accent-glow:  rgba(59,130,246,0.15);

  --color-text:         #e2e8f0;
  --color-text-muted:   #64748b;
  --color-text-faint:   #334155;

  --color-green:        #22c55e;
  --color-red:          #ef4444;
  --color-yellow:       #f59e0b;
  --color-purple:       #a855f7;
  --color-cyan:         #06b6d4;
  --color-orange:       #f97316;

  /* Semantic status */
  --color-ok:     var(--color-green);
  --color-warn:   var(--color-yellow);
  --color-error:  var(--color-red);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   0.72rem;
  --text-sm:   0.825rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Borders */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px var(--color-border);
  --shadow-glow: 0 0 0 3px var(--color-accent-glow);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

img, svg { display: block; }

/* ── 3. Layout Utilities ──────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--narrow { max-width: 720px; }

/* ── 4. Typography ────────────────────────────────────────── */
.mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

/* ── 5. Header ────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding-block: var(--space-4);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.logo:hover { text-decoration: none; }

.logo-icon {
  font-size: 1.4rem;
  color: var(--color-accent);
  line-height: 1;
}

.logo-text strong { color: var(--color-accent); }

.header-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ── 6. Hero & Search ─────────────────────────────────────── */
.hero {
  padding-block: var(--space-16) var(--space-12);
  text-align: center;
}

.hero-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
  background: linear-gradient(135deg, var(--color-text) 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
  line-height: 1.7;
}

.search-form {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-4) 0 calc(var(--space-4) * 2 + 18px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  outline: none;
}

.search-input::placeholder { color: var(--color-text-faint); }

.search-input:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}

.search-input.is-invalid {
  border-color: var(--color-red);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}

.form-error {
  margin-top: var(--space-3);
  color: var(--color-red);
  font-size: var(--text-sm);
  text-align: left;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 52px;
  padding-inline: var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
  outline-offset: 3px;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: var(--color-accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--color-accent-dim); }

.btn--secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn--secondary:hover:not(:disabled) { background: var(--color-border); }

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── 7. Result Meta Bar ───────────────────────────────────── */
.results { flex: 1; padding-bottom: var(--space-16); }

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.result-meta__url {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.result-meta__url a {
  color: var(--color-text);
  word-break: break-all;
}

.result-meta__url a:hover { color: var(--color-accent); }

.result-meta__stats {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-end;
}

/* ── 8. Result Grid ───────────────────────────────────────── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
  align-items: start;
  margin-bottom: var(--space-6);
}

.result-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card--compact { padding: var(--space-5); }

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-5);
}

.card-title svg { color: var(--color-text-muted); flex-shrink: 0; }

/* ── 9. Technology List ───────────────────────────────────── */
.tech-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.tech-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base);
}

.tech-item:hover { border-color: var(--color-border-light); }

.tech-item--hidden { display: none; }

.tech-name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  grid-column: 1;
  grid-row: 1;
}

.tech-category {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}

.tech-evidence {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.evidence-pill {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px var(--space-3);
  line-height: 1.6;
}

/* Confidence bar (overlaid in tech-name row) */
.confidence-row {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.confidence-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.confidence-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.confidence-value {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* version tag */
.tech-version {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  margin-left: var(--space-2);
}

.empty-state {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  padding: var(--space-6) 0;
  text-align: center;
}

/* ── 10. Category Tabs ────────────────────────────────────── */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 28px;
  padding-inline: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.tab-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.tab-btn[aria-selected="true"] {
  background: var(--color-accent-glow);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tab-btn .tab-count {
  font-size: var(--text-xs);
  background: var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 5px;
  line-height: 1.6;
}

/* ── 11. Security Score Ring ──────────────────────────────── */
.security-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.score-ring {
  position: relative;
  width: 80px;
  height: 80px;
}

.score-svg {
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);
}

.score-track {
  fill: none;
  stroke: var(--color-surface-2);
  stroke-width: 6;
}

.score-fill {
  fill: none;
  stroke: var(--color-green);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 213.6; /* 2π × 34 */
  stroke-dashoffset: 213.6;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  font-family: var(--font-mono);
}

.score-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── 12. Check List (Security booleans) ───────────────────── */
.check-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
}

.check-item__label { color: var(--color-text-muted); }

.check-pill {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

.check-pill--ok   { background: rgba(34,197,94,0.12);  color: var(--color-green); }
.check-pill--warn { background: rgba(245,158,11,0.12); color: var(--color-yellow); }
.check-pill--no   { background: rgba(239,68,68,0.10);  color: var(--color-red); }

/* ── 13. Detail List (SSL / DNS) ──────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  align-items: baseline;
}

.detail-list dt {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.detail-list dd {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--color-text);
  word-break: break-all;
}

/* ── 14. Headers Table ────────────────────────────────────── */
.headers-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

.headers-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

.headers-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.headers-table td:first-child {
  font-family: var(--font-mono);
  color: var(--color-cyan);
  white-space: nowrap;
  width: 240px;
}

.headers-table td:last-child {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  word-break: break-all;
}

.headers-table tr:last-child td { border-bottom: none; }
.headers-table tr:hover td { background: var(--color-surface-2); }

/* ── 15. Collapsible ──────────────────────────────────────── */
.collapsible summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  margin-bottom: 0;
}

.collapsible summary::-webkit-details-marker { display: none; }

.collapsible summary .chevron {
  margin-left: auto;
  transition: transform var(--transition-base);
}

.collapsible[open] summary .chevron { transform: rotate(180deg); }

.collapsible[open] summary { margin-bottom: var(--space-2); }

/* ── 16. Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  padding: 2px 10px;
}

.badge--ok   { background: rgba(34,197,94,0.12);  color: var(--color-green); }
.badge--warn { background: rgba(245,158,11,0.12); color: var(--color-yellow); }
.badge--err  { background: rgba(239,68,68,0.10);  color: var(--color-red); }

.count-badge {
  margin-left: auto;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: var(--weight-normal);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  color: var(--color-text-muted);
}

/* Category colour map */
.cat-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  white-space: nowrap;
}

.cat--frontend   { background: rgba(59,130,246,0.12); color: #60a5fa; }
.cat--backend    { background: rgba(168,85,247,0.12); color: #c084fc; }
.cat--cms        { background: rgba(249,115,22,0.12); color: #fb923c; }
.cat--hosting    { background: rgba(6,182,212,0.12);  color: #22d3ee; }
.cat--cdn        { background: rgba(6,182,212,0.12);  color: #22d3ee; }
.cat--analytics  { background: rgba(34,197,94,0.12);  color: #4ade80; }
.cat--tag        { background: rgba(34,197,94,0.12);  color: #4ade80; }
.cat--payment    { background: rgba(245,158,11,0.12); color: #fbbf24; }
.cat--security   { background: rgba(239,68,68,0.10);  color: #f87171; }
.cat--dns        { background: rgba(107,114,128,0.15);color: #9ca3af; }
.cat--email      { background: rgba(107,114,128,0.15);color: #9ca3af; }
.cat--server     { background: rgba(107,114,128,0.15);color: #9ca3af; }
.cat--other      { background: rgba(107,114,128,0.12);color: #6b7280; }

/* ── 17. Error State ──────────────────────────────────────── */
.error-state {
  padding-block: var(--space-12);
}

.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-10);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.error-icon {
  font-size: 2.5rem;
  color: var(--color-yellow);
}

.error-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

.error-message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 420px;
}

/* ── 18. Footer ───────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-5);
}

.site-footer p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* ── 19. Animations ───────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fade-up 0.3s ease both;
}

/* ── 20. Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .hero { padding-block: var(--space-10) var(--space-8); }
  .hero-title { font-size: var(--text-2xl); }
  .hero-sub { font-size: var(--text-base); }

  .search-form { flex-direction: column; }
  .btn { width: 100%; }

  .site-header .container { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
  .header-tagline { display: none; }

  .result-meta { flex-direction: column; align-items: flex-start; }
  .result-meta__stats { flex-direction: row; }
  .stat { align-items: flex-start; }

  .result-sidebar { grid-template-columns: 1fr; }

  .headers-table td:first-child { width: 140px; }
}
