/* --- Variables --- */
:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --surface2: #222228;
  --border: #2d2d35;
  --text: #e8e8ec;
  --textMuted: #9090a0;
  --accent: #6366f1;
  --accentDim: rgba(99, 102, 241, 0.2);
  --green: #22c55e;
  --greenDim: rgba(34, 197, 94, 0.2);
  --amber: #f59e0b;
  --amberDim: rgba(245, 158, 11, 0.2);
  --red: #ef4444;
  --redDim: rgba(239, 68, 68, 0.2);
  --radius: 12px;
  --radiusLg: 16px;
  --font: 'DM Sans', system-ui, sans-serif;
  --gaugeSize: 140px;
  --gaugeSizeLg: 180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.title {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--textMuted);
  font-size: 0.95rem;
}

/* --- Form --- */
.scan-form {
  margin-bottom: 2rem;
}

.input-wrap {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.url-input {
  flex: 1;
  min-width: 200px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input::placeholder {
  color: var(--textMuted);
}

.url-input:hover {
  border-color: #3d3d48;
}

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

.submit-btn {
  padding: 0.75rem 1.5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.submit-btn:hover {
  background: #5558e3;
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--textMuted);
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: 3rem 1rem;
}

.loading[aria-hidden="true"] {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  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 p {
  margin: 0;
  color: var(--textMuted);
  font-size: 0.9rem;
}

/* --- Report --- */
.report {
  display: none;
}

.report[aria-hidden="false"] {
  display: block;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.report-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.report-link {
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: none;
}

.report-link:hover {
  text-decoration: underline;
}

/* --- Sections --- */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radiusLg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.section-title {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* --- Gauges --- */
.gauges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  justify-items: center;
}

.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.gauge-wrap {
  position: relative;
  width: var(--gaugeSize);
  height: var(--gaugeSize);
}

.gauge-wrap--large {
  width: var(--gaugeSizeLg);
  height: var(--gaugeSizeLg);
  margin: 0 auto;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 10;
}

.gauge-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.8s ease-out, stroke 0.3s;
}

.gauge-value {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 700;
}

.gauge-wrap--large .gauge-value {
  font-size: 2rem;
}

.gauge-label {
  font-size: 0.9rem;
  color: var(--textMuted);
}

.single-gauge {
  margin-bottom: 1rem;
}

/* Score colors */
.gauge-fill.score--green { stroke: var(--green); }
.gauge-fill.score--amber { stroke: var(--amber); }
.gauge-fill.score--red { stroke: var(--red); }
.gauge-value.score--green { color: var(--green); }
.gauge-value.score--amber { color: var(--amber); }
.gauge-value.score--red { color: var(--red); }

/* --- Audit list (Accessibility) --- */
.audit-list {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.audit-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.audit-item .icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.audit-item.pass .icon { color: var(--green); }
.audit-item.warn .icon { color: var(--amber); }
.audit-item.fail .icon { color: var(--red); }

.audit-item .title {
  font-weight: 500;
  color: var(--text);
}

.audit-item .desc {
  margin: 0.15rem 0 0;
  color: var(--textMuted);
  font-size: 0.85rem;
}

/* --- SEO checklist --- */
.seo-checklist {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.seo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.seo-item:last-child {
  border-bottom: none;
}

.seo-item .status {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.seo-item .status.pass {
  background: var(--greenDim);
  color: var(--green);
}

.seo-item .status.warn {
  background: var(--amberDim);
  color: var(--amber);
}

.seo-item .status.fail {
  background: var(--redDim);
  color: var(--red);
}

.seo-item .label {
  font-weight: 500;
  color: var(--text);
}

.seo-item .detail {
  margin: 0.2rem 0 0;
  color: var(--textMuted);
  font-size: 0.85rem;
  font-weight: 400;
}

/* --- Report actions --- */
.report-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.download-pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.download-pdf-btn:hover {
  background: #5558e3;
}

.download-pdf-btn:active {
  transform: scale(0.98);
}

.download-pdf-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Error --- */
.error-banner {
  display: none;
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--redDim);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius);
  color: var(--red);
}

.error-banner[aria-hidden="false"] {
  display: block;
}

.error-banner p {
  margin: 0;
  font-size: 0.95rem;
}
