/* Driving Risk Calculator Styles */

:root {
  --color-very-low: #22c55e;
  --color-low: #84cc16;
  --color-average: #6b7280;
  --color-elevated: #f59e0b;
  --color-high: #ef4444;
  --color-very-high: #dc2626;

  --bg-color: #f9fafb;
  --card-bg: #ffffff;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --accent-color: #3b82f6;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Two-column layout for wide screens */
@media (min-width: 1024px) {
  main {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    align-items: start;
  }

  .calculator {
    grid-column: 1;
  }

  .results {
    grid-column: 2;
    grid-row: 1 / span 3;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }

  .methodology {
    grid-column: 1;
  }
}

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

header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.disclaimer {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #92400e;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.disclaimer strong {
  color: #78350f;
}

/* Calculator Section */
.calculator {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.section-description {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.severity-calculator {
  border-left: 4px solid var(--color-elevated);
}

/* Factor Fieldset */
.factor {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.factor:last-child {
  margin-bottom: 0;
}

.factor legend {
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0 0.5rem;
}

.factor-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.factor-disclaimer {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 0.75rem;
  margin-top: 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #78350f;
}

.factor-disclaimer strong {
  color: #92400e;
  font-weight: 600;
}

/* Options */
.options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option {
  display: flex;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.option:hover {
  background-color: #f3f4f6;
}

.option input[type="radio"] {
  margin-right: 0.75rem;
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.option input[type="radio"]:checked + .option-text {
  font-weight: 500;
}

.option:has(input:checked) {
  border-color: var(--accent-color);
  background-color: #eff6ff;
}

.option-text {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex: 1;
  gap: 1rem;
}

.option-label {
  flex: 1;
}

.option-multiplier {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.option-multiplier.has-interaction {
  color: var(--accent-color);
  font-weight: 500;
  cursor: help;
}

.factor-source {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.factor-source a {
  color: var(--accent-color);
  text-decoration: none;
}

.factor-source a:hover {
  text-decoration: underline;
}

/* Factor Details (collapsible explanation) */
.factor-details {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.factor-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent-color);
  font-weight: 500;
  padding: 0.25rem 0;
}

.factor-details summary:hover {
  text-decoration: underline;
}

.factor-details-content {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-color);
  border-radius: 4px;
}

.factor-methodology {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
  color: var(--text-color);
}

.option-explanations {
  font-size: 0.85rem;
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.option-explanations li {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.option-explanations li:last-child {
  margin-bottom: 0;
}

.factor-details .factor-source {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
}

/* Results Section */
.results {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.results h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* Result Blocks */
.result-block {
  padding: 1rem;
  border-radius: 6px;
  background: var(--bg-color);
  margin-bottom: 1.5rem;
}

.result-block:last-child {
  margin-bottom: 0;
}

.result-block-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
  color: var(--text-color);
}

.fatality-block {
  border: 2px solid var(--color-elevated);
  background: #fffbeb;
}

.result-details-single {
  grid-template-columns: 1fr;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* Fatality explanation */
.fatality-explanation {
  background: var(--bg-color);
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.fatality-explanation p {
  margin-bottom: 0.5rem;
}

.fatality-explanation p:last-child {
  margin-bottom: 0;
}

.formula-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: monospace;
  font-size: 0.95rem;
  padding: 0.75rem;
  background: white;
  border-radius: 4px;
  margin-top: 0.5rem;
}

.formula-part {
  padding: 0.25rem 0.5rem;
  background: #e5e7eb;
  border-radius: 4px;
}

.formula-operator {
  font-weight: bold;
  color: var(--text-muted);
}

.formula-result {
  background: var(--color-elevated);
  color: white;
}

.breakdown-content h4 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

.result-summary {
  text-align: center;
  margin-bottom: 1.5rem;
}

.result-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0.5rem;
}

.multiplier {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
}

.multiplier-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-comparison {
  font-size: 1.25rem;
  font-weight: 500;
}

/* Risk level colors */
.very-low, .very-low .multiplier { color: var(--color-very-low); }
.low, .low .multiplier { color: var(--color-low); }
.average, .average .multiplier { color: var(--color-average); }
.elevated, .elevated .multiplier { color: var(--color-elevated); }
.high, .high .multiplier { color: var(--color-high); }
.very-high, .very-high .multiplier { color: var(--color-very-high); }

/* Result Details */
.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-card {
  background: var(--bg-color);
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
}

.detail-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.detail-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Breakdown Section */
.breakdown-section {
  margin-top: 1rem;
}

.breakdown-section summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--accent-color);
  padding: 0.5rem 0;
}

.breakdown-content {
  margin-top: 1rem;
}

.formula {
  background: var(--bg-color);
  padding: 0.75rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.breakdown-table th,
.breakdown-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.breakdown-table th {
  font-weight: 600;
  background: var(--bg-color);
}

.breakdown-table td a {
  color: var(--accent-color);
  text-decoration: none;
  font-size: 0.8rem;
}

.breakdown-table td a:hover {
  text-decoration: underline;
}

.breakdown-table .safer {
  color: var(--color-low);
}

.breakdown-table .riskier {
  color: var(--color-high);
}

.total-row {
  background: var(--bg-color);
}

/* Methodology Section */
.methodology {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.methodology summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--accent-color);
}

.methodology-content {
  margin-top: 1rem;
}

.methodology-content h3 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

.methodology-content h3:first-child {
  margin-top: 0;
}

.methodology-content p,
.methodology-content ul {
  margin-bottom: 0.75rem;
}

.methodology-content ul {
  padding-left: 1.5rem;
}

.methodology-content code {
  background: var(--bg-color);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.methodology-content a {
  color: var(--accent-color);
  text-decoration: none;
}

.methodology-content a:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .multiplier {
    font-size: 2.5rem;
  }

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

  .option-text {
    flex-direction: column;
    gap: 0.25rem;
  }

  .breakdown-table {
    font-size: 0.8rem;
  }

  .breakdown-table th:nth-child(4),
  .breakdown-table td:nth-child(4) {
    display: none;
  }

  .formula-visual {
    font-size: 0.85rem;
    flex-direction: column;
  }

  .formula-operator {
    display: block;
  }

  .result-block {
    padding: 0.75rem;
  }
}

/* Floating Mobile Summary */
.floating-summary {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.75rem 1rem;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.floating-summary.visible {
  transform: translateY(0);
}

.floating-summary-content {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
  gap: 1rem;
}

.floating-summary-item {
  text-align: center;
  flex: 1;
}

.floating-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}

.floating-summary-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.floating-summary-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
}

/* Show floating summary only on smaller screens */
@media (max-width: 1023px) {
  .floating-summary {
    display: block;
  }

  /* Add padding to bottom of page so content isn't hidden behind floating summary */
  body {
    padding-bottom: 80px;
  }
}

/* Annual Miles Input */
.miles-input-section {
  margin-top: 1rem;
}

.miles-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.miles-input-wrapper input[type="number"] {
  width: 150px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit;
}

.miles-input-wrapper input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.miles-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}
