/* Decoded — Redesigned Dark Theme
   Design language: Clarity, urgency, emotion.
   Accent: Teal (transparency). Traffic lights for risk. */

:root {
  --bg-primary: #0a0c10;
  --bg-secondary: #12151c;
  --bg-tertiary: #1a1e28;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a8;
  --text-muted: #5f6672;
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.08);
  --green-border: rgba(34, 197, 94, 0.25);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.08);
  --yellow-border: rgba(234, 179, 8, 0.25);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.06);
  --red-border: rgba(239, 68, 68, 0.25);
  --accent: #06b6d4;
  --accent-dim: rgba(6, 182, 212, 0.12);
  --accent-glow: rgba(6, 182, 212, 0.25);
  --border: #1e2230;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

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

/* ===== AMBIENT CANVAS ===== */

#ambientCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ===== LAYOUT ===== */

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* ===== HERO ===== */

.hero {
  text-align: center;
  padding: 100px 24px 56px;
  position: relative;
  z-index: 1;
}

.hero-brand {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--accent);
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  font-size: 19px;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto 44px;
  line-height: 1.5;
}

/* URL Input — commanding presence */
.url-form {
  display: flex;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}

.url-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  color: var(--text-primary);
  font-size: 17px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input::placeholder { color: var(--text-muted); }
.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-analyze {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 18px 36px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.btn-analyze:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-analyze:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.url-error {
  color: var(--red);
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* ===== SHOWCASE ===== */

.showcase {
  padding: 40px 24px 56px;
  position: relative;
  z-index: 1;
}

.showcase-title {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.showcase-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 36px;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
}

.showcase-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.showcase-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  text-decoration: none;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-company {
  font-size: 18px;
  font-weight: 700;
}

.card-score {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  flex-shrink: 0;
}

.card-score.green { background: rgba(34, 197, 94, 0.12); color: var(--green); }
.card-score.yellow { background: rgba(234, 179, 8, 0.12); color: var(--yellow); }
.card-score.red { background: rgba(239, 68, 68, 0.12); color: var(--red); }

.card-verdict {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-verdict.green { color: var(--green); }
.card-verdict.yellow { color: var(--yellow); }
.card-verdict.red { color: var(--red); }

.card-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.showcase-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 14px;
}

/* ===== EXTENSION CTA ===== */

.ext-cta {
  text-align: center;
  padding: 48px 24px;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.ext-cta h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ext-cta p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.btn-ext {
  display: inline-block;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  transition: border-color 0.15s;
}

.btn-ext:hover {
  border-color: var(--accent);
  text-decoration: none;
}

/* ===== FOOTER ===== */

.site-footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.footer-brand {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.footer-brand span {
  color: var(--accent);
  font-weight: 700;
}

.footer-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: 6px;
}

/* ===== LOADING OVERLAY ===== */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 100;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
}

.loading-subtext {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: -12px;
}

.loading-stage {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  min-height: 18px;
}

/* =========================================================
   RESULT PAGE
   ========================================================= */

.result-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
  position: relative;
  z-index: 1;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 32px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); text-decoration: none; }

/* Header */
.result-header {
  margin-bottom: 24px;
}

.result-header .company-name {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 10px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.doc-type-badge {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 4px;
}

.header-detail {
  font-size: 12px;
  color: var(--text-muted);
}

/* Score Section — with share */
.score-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 36px 0;
  gap: 12px;
}

.score-circle {
  position: relative;
  width: 160px;
  height: 160px;
  animation: pulse var(--pulse-speed, 2.5s) ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

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

.score-circle .track {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.score-circle .fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.score-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: 800;
}

.verdict-label {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.verdict-green { color: var(--green); }
.verdict-yellow { color: var(--yellow); }
.verdict-red { color: var(--red); }

/* Share buttons */
.share-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-share {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-share:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-share.copied {
  border-color: var(--green);
  color: var(--green);
}

/* Quick Facts — BOLD BADGES (hero of result page) */
.quick-facts-section {
  margin-bottom: 24px;
}

.quick-facts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fact-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.fact-badge.bad {
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  color: var(--red);
}

.fact-badge.good {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  color: var(--green);
}

.fact-badge.neutral {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.fact-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

/* Summary — prominent, no card wrapper */
.summary-section {
  margin-bottom: 28px;
}

.summary-text {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-primary);
}

/* Section titles */
.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 14px;
}

/* Cards — base */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

/* Red Flags — alarming tint */
.red-flags-section {
  margin-bottom: 20px;
}

.red-flag {
  background: var(--red-dim);
  border-radius: var(--radius);
  margin-bottom: 10px;
  border-left: 3px solid var(--red);
  overflow: hidden;
}

.red-flag summary {
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

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

.red-flag summary::before {
  content: "\25B8";
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.15s;
}

.red-flag[open] summary::before {
  transform: rotate(90deg);
}

.severity-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  margin-left: auto;
  flex-shrink: 0;
}

.severity-high {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
}

.severity-medium {
  background: rgba(234, 179, 8, 0.2);
  color: var(--yellow);
}

.red-flag-body {
  padding: 0 18px 16px;
}

.red-flag-explanation {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.red-flag-quote {
  font-size: 13px;
  color: var(--text-muted);
  border-left: 2px solid var(--red-border);
  padding-left: 12px;
  font-style: italic;
  line-height: 1.5;
}

/* Good Parts — reassuring tint */
.good-parts-section {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.good-part {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.good-part:last-child { margin-bottom: 0; }

.good-check {
  color: var(--green);
  font-size: 18px;
  line-height: 1.3;
  flex-shrink: 0;
}

.good-part-content { flex: 1; }

.good-part-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.good-part-explanation {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Dimensions — collapsible */
.breakdown-toggle {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
  text-align: left;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.breakdown-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.breakdown-toggle .toggle-arrow {
  transition: transform 0.2s;
  font-size: 12px;
}

.breakdown-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}

.dimensions-section {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  display: none;
}

.dimensions-section.visible {
  display: block;
}

.dimensions-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dimension-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dimension-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dimension-name {
  font-size: 14px;
  color: var(--text-secondary);
}

.dimension-score {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.dimension-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.dimension-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.dimension-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== CONSENT RECEIPT ===== */

.receipt-section {
  margin: 28px 0;
}

.receipt {
  background: #1a1710;
  border: 1px solid #2a2518;
  border-radius: var(--radius);
  padding: 28px 24px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #d4c8a0;
  position: relative;
  overflow: hidden;
}

.receipt::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 4px,
    #2a2518 4px,
    #2a2518 8px
  );
}

.receipt-header {
  text-align: center;
  margin-bottom: 16px;
  font-weight: 700;
}

.receipt-company {
  font-size: 18px;
  color: #e8d9a0;
}

.receipt-date {
  font-size: 11px;
  color: #8a7d5a;
}

.receipt-divider {
  border: none;
  border-top: 1px dashed #2a2518;
  margin: 12px 0;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.receipt-line.bad .receipt-value { color: var(--red); }
.receipt-line.good .receipt-value { color: var(--green); }

.receipt-total {
  font-weight: 700;
  font-size: 14px;
  color: #e8d9a0;
}

.receipt-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 11px;
  color: #6a5d3a;
}

.receipt-copy-btn {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  border: 1px dashed #2a2518;
  color: #8a7d5a;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}

.receipt-copy-btn:hover {
  color: #d4c8a0;
  border-color: #d4c8a0;
}

.receipt-copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
}

/* ===== PROTECT YOURSELF ===== */

.protect-section {
  margin-bottom: 24px;
}

.protect-card {
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  border-radius: var(--radius);
  padding: 22px;
}

.protect-intro {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.protect-list {
  list-style: none;
  counter-reset: protect;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.protect-item {
  counter-increment: protect;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 32px;
  position: relative;
}

.protect-item::before {
  content: counter(protect);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.protect-action {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.protect-why {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Result footer */
.result-footer {
  text-align: center;
  padding: 24px 0 8px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.result-footer .footer-brand {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.result-footer .footer-brand span {
  color: var(--accent);
  font-weight: 700;
}

.result-footer .footer-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: 6px;
}

.result-footer .footer-cta {
  margin-top: 12px;
}

/* Error state */
.error-page {
  text-align: center;
  padding: 120px 24px;
}

.error-page h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 12px;
}

.error-page p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 600px) {
  .hero { padding: 64px 20px 40px; }
  .hero h1 { font-size: 32px; }
  .hero-sub { font-size: 16px; }
  .url-form { flex-direction: column; }
  .url-input { font-size: 16px; padding: 16px 18px; }
  .btn-analyze { padding: 16px; }
  .showcase-title { font-size: 22px; }
  .showcase-grid { grid-template-columns: 1fr; }
  .result-header .company-name { font-size: 26px; }
  .score-circle { width: 130px; height: 130px; }
  .score-circle svg { width: 130px; height: 130px; }
  .score-number { font-size: 38px; }
  .quick-facts-grid { grid-template-columns: 1fr; }
  .summary-text { font-size: 16px; }
  .receipt { padding: 20px 16px; font-size: 12px; }
  .share-row { flex-direction: column; }
}
