/* What’s Wrong With My Tesla — TeslaZone-inspired brand restyle
   Matched from https://www.teslazone.com (css-variables.css + site CSS):
   - Font: Saira (Google Fonts) — TeslaZone --font-family-base / --font-family-second
   - Text #000000, secondary #6f6f6e, borders/theme #e7e7e7, bg #ffffff
   - Accent/CTA & link hover #ff3333; section indigo #333399
   - Sharper controls (near-square buttons) vs prior Apple-pill aesthetic
*/

:root {
  --bg: #ffffff;
  --bg-muted: #f5f5f5;
  --card: #ffffff;
  --text: #000000;
  --secondary: #6f6f6e;
  --action: #ff3333;
  --action-hover: #e62e2e;
  --accent-indigo: #333399;
  --border: #e7e7e7;
  --theme: #e7e7e7;
  --error: #ff3333;
  --focus: #333399;
  --radius-btn: 0;
  --radius-card: 4px;
  --radius-input: 4px;
  --radius-chip: 20px;
  --max: 760px;
  --font: "Saira", system-ui, -apple-system, "Segoe UI", sans-serif;
  --header-border: #e7e7e7;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(100% - 2.5rem, var(--max));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--action);
  color: #fff;
  border-radius: var(--radius-btn);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* Top affiliation disclaimer — secondary, always visible above header */
.top-disclaimer {
  margin: 0;
  padding: 0.4rem 0.85rem;
  font-size: 0.6875rem;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-align: center;
  color: var(--secondary);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 420px) {
  .top-disclaimer {
    font-size: 0.625rem;
    padding: 0.35rem 0.65rem;
  }
}

/* Header — TeslaZone white bar + brand mark */
.site-header {
  padding: 0.85rem 0;
  background: #ffffff;
  border-bottom: 1px solid var(--header-border);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-link:hover .brand-text {
  color: var(--action);
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
  /* black-on-transparent logo: visible on light header */
  background: transparent;
}

.brand-text {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  transition: color 0.15s ease;
}

/* Hero */
.hero {
  padding: 2.25rem 0 1.5rem;
  text-align: center;
}

.hero-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  object-fit: contain;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.65rem, 4.5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--text);
}

.subtitle {
  margin: 0 auto;
  max-width: 36em;
  color: var(--secondary);
  font-size: 1rem;
}

/* Cards & form */
.card {
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: none;
}

.form-card {
  padding: 1.75rem 1.5rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 600px) {
  .form-card {
    padding: 2rem 2rem;
  }
}

.field {
  margin-bottom: 1.35rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

@media (min-width: 600px) {
  .field-row {
    grid-template-columns: 0.85fr 1.15fr 1.35fr;
    gap: 0.85rem;
    align-items: start;
  }

  .field-row .field {
    margin-bottom: 1.35rem;
  }
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.optional {
  font-weight: 400;
  color: var(--secondary);
  text-transform: none;
  letter-spacing: 0;
}

.field select,
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 0.85rem 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236f6f6e' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-color: var(--bg-muted);
  padding-right: 2.5rem;
  cursor: pointer;
}

.field textarea {
  resize: vertical;
  min-height: 5.5rem;
}

.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(51, 51, 153, 0.2);
  background-color: #fff;
}

.field select.is-invalid,
.field textarea.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(255, 51, 51, 0.18);
}

.field-error {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  color: var(--error);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.9rem 1.75rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  background: var(--action);
  border: 1px solid var(--action);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

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

.btn:active:not(:disabled) {
  opacity: 0.92;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(51, 51, 153, 0.35);
}

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

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.form-actions .btn {
  margin-top: 0;
  width: 100%;
}

.form-actions .btn-ghost {
  width: 100%;
}

@media (min-width: 560px) {
  .form-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .form-actions .btn:first-child {
    flex: 1 1 14rem;
  }

  .form-actions .btn-ghost {
    width: auto;
    flex: 0 0 auto;
  }
}

.btn-ghost {
  width: auto;
  min-height: 2.75rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--text);
  color: var(--text);
}

.btn-ghost:active:not(:disabled) {
  background: var(--theme);
}

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

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


/* Optional alert photo / screenshot upload */
.field input[type="file"] {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.field input[type="file"]:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(51, 51, 153, 0.2);
  background-color: #fff;
}

.field input[type="file"].is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(255, 51, 51, 0.18);
}

.alert-image-preview-wrap {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
}

.alert-image-preview-wrap[hidden] {
  display: none !important;
}

.alert-image-preview {
  display: block;
  max-width: 100%;
  max-height: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--bg-muted);
}

.alert-image-preview-wrap .btn-ghost {
  width: auto;
  min-height: 2.25rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.75rem;
  margin-top: 0;
}

.form-note {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--secondary);
}

/* Results */
.results-section {
  padding-bottom: 3rem;
}

.results-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.results-header .btn-ghost {
  width: auto;
  margin-top: 0;
}

.results-header .btn-ghost:first-of-type {
  margin-left: auto;
}

.results-header h2,
.how h2,
.faq h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.demo-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--secondary);
  background: var(--bg-muted);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-chip);
  border: 1px solid var(--border);
}

.results-status {
  min-height: 1.5rem;
  margin-bottom: 1rem;
  color: var(--secondary);
  font-size: 0.9375rem;
}

.results-status.is-error {
  color: var(--error);
}

#retry-diagnose-btn {
  width: auto;
  margin: 0 0 1rem;
}

#retry-diagnose-btn[hidden] {
  display: none;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.results-disclaimer {
  margin: 1.25rem 0 0;
  padding: 0 0.15rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--secondary);
  max-width: 42rem;
}

@media (max-width: 480px) {
  .results-header .btn-ghost {
    margin-left: 0;
    width: 100%;
  }

  .results-header .btn-ghost:first-of-type {
    margin-left: 0;
  }
}

.issue-card {
  padding: 1.35rem 1.4rem;
}

.issue-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.issue-card h3 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.likelihood {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent-indigo);
  white-space: nowrap;
}

.issue-why,
.issue-next {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  color: var(--text);
}

.issue-next {
  margin-bottom: 0;
  color: var(--secondary);
}

.issue-label {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--secondary);
}

.issue-sources {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
}

.issue-sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue-sources-list a {
  color: var(--accent-indigo);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.results-empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--secondary);
  font-size: 0.9375rem;
}

/* How it works */
.how {
  padding-bottom: 3rem;
}

.how-list {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: how;
}

.how-list li {
  position: relative;
  padding: 1rem 0 1rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--secondary);
}

.how-list li:last-child {
  border-bottom: 1px solid var(--border);
}

.how-list li strong {
  color: var(--text);
  font-weight: 600;
}

.how-list li::before {
  counter-increment: how;
  content: counter(how);
  position: absolute;
  left: 0;
  top: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-indigo);
  border-radius: 0;
}

/* FAQ */
.faq {
  padding-bottom: 3.5rem;
}

.faq-list {
  margin-top: 1.25rem;
}

.faq details {
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: none;
  margin-bottom: 0.65rem;
  overflow: hidden;
}

.faq summary {
  list-style: none;
  cursor: pointer;
  padding: 1.1rem 1.25rem;
  font-weight: 600;
  letter-spacing: 0;
  font-size: 0.9875rem;
}

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

.faq summary::after {
  content: "+";
  float: right;
  font-weight: 400;
  color: var(--secondary);
  font-size: 1.25rem;
  line-height: 1;
}

.faq details[open] summary::after {
  content: "−";
}

.faq summary:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px rgba(51, 51, 153, 0.25);
}

.faq details p {
  margin: 0;
  padding: 0 1.25rem 1.15rem;
  color: var(--secondary);
  font-size: 0.9375rem;
}

/* Footer */
.site-footer {
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
}

.footer-brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.footer-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.footer-brand {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.footer-meta,
.footer-legal {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--secondary);
}

.footer-legal {
  margin-bottom: 0.45rem;
}

.footer-legal.footer-trademark {
  margin-bottom: 0;
  font-size: 0.75rem;
}

.footer-meta a,
.footer-legal a {
  color: var(--text);
  text-decoration: none;
}

.footer-meta a:hover,
.footer-legal a:hover {
  color: var(--action);
}

.issue-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.urgency-pill {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-chip);
  background: var(--bg-muted);
  color: var(--secondary);
  border: 1px solid var(--border);
}

.urgency-high .urgency-pill {
  background: rgba(255, 51, 51, 0.12);
  color: #cc0000;
  border-color: rgba(255, 51, 51, 0.35);
}

.urgency-medium .urgency-pill {
  background: rgba(51, 51, 153, 0.1);
  color: var(--accent-indigo);
  border-color: rgba(51, 51, 153, 0.3);
}

.urgency-low .urgency-pill {
  background: var(--bg-muted);
  color: var(--secondary);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 14px;
  color: var(--secondary);
}

/* Example symptom chips */
.example-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.chips-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-right: 0.15rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.chip:hover {
  background: #fff;
  border-color: var(--action);
  color: var(--action);
}

.chip:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(51, 51, 153, 0.25);
}

.chip.is-active {
  color: #fff;
  border-color: var(--action);
  background: var(--action);
}

/* Follow-up refine panel */
.followup-panel {
  margin-top: 1.5rem;
  padding: 1.35rem 1.4rem;
}

.followup-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.followup-panel .field-hint {
  margin: 0 0 0.85rem;
}

.followup-panel textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 0.85rem 1rem;
  resize: vertical;
  min-height: 4.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.followup-panel textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(51, 51, 153, 0.2);
  background-color: #fff;
}

.followup-panel textarea.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(255, 51, 51, 0.18);
}

.followup-panel .btn {
  width: auto;
  min-width: 12rem;
  margin-top: 0.85rem;
}

@media (max-width: 480px) {
  .followup-panel .btn {
    width: 100%;
  }
}

/* Dark surfaces (if added later): invert black logo for contrast */
.logo-on-dark {
  filter: invert(1);
}

/* Print results */
@media print {
  .skip-link,
  .site-header,
  .hero,
  .form-card,
  #diagnose-form,
  section.wrap:has(#diagnose-form),
  .how,
  .faq,
  .site-footer,
  .example-chips,
  .followup-panel,
  #copy-results-btn,
  #share-link-btn,
  #print-results-btn,
  .demo-badge {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .wrap {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .results-section {
    padding: 0;
  }

  .card,
  .issue-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .issue-card {
    color: #000;
  }

  .issue-next,
  .results-status,
  .results-disclaimer,
  .likelihood,
  .urgency-pill {
    color: #000 !important;
  }

  .results-header .btn-ghost {
    display: none !important;
  }
}


/* Primary diagnose CTA: TeslaZone indigo (not red) */
#submit-btn {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
}
#submit-btn:hover:not(:disabled) {
  background: #2a2a7a;
  border-color: #2a2a7a;
}
#submit-btn:active:not(:disabled) {
  background: #222266;
  border-color: #222266;
}
