/* ==============================================
   COGNITIVE SCREENING TOOL — STYLES
   Design: Clinical, high-contrast, large touch targets
   Font: Inter (Google Fonts)
   ============================================== */

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

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-bg: #eaf2f8;
  --secondary: #27ae60;
  --secondary-light: #2ecc71;
  --warning: #e67e22;
  --warning-bg: #fef5e7;
  --alert: #c0392b;
  --alert-bg: #fdedec;
  --clear: #27ae60;
  --clear-bg: #eafaf1;
  --neutral-900: #1a1a2e;
  --neutral-700: #333;
  --neutral-600: #555;
  --neutral-400: #888;
  --neutral-200: #ddd;
  --neutral-100: #f4f4f8;
  --neutral-50: #fafafa;
  --white: #fff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --transition: 0.2s ease;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--neutral-700);
  background: var(--neutral-100);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 120px;
}

/* --- Typography --- */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--neutral-900);
  line-height: 1.3;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--neutral-900);
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 0.75rem;
}

p:last-child {
  margin-bottom: 0;
}

strong {
  font-weight: 600;
}

/* --- Layout --- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* --- Views --- */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* --- Progress Bar --- */
#progress-bar-container {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--neutral-200);
}

#progress-bar-container.hidden {
  display: none;
}

#progress-bar {
  height: 8px;
  background: var(--neutral-200);
  border-radius: 4px;
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
}

#progress-fill {
  height: 100%;
  background: var(--primary-light);
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
}

#progress-label {
  text-align: center;
  font-size: 0.75rem;
  color: var(--neutral-400);
  margin-top: 0.35rem;
  font-weight: 500;
}

/* --- Welcome Header --- */
.welcome-header {
  text-align: center;
  padding: 2rem 0 1rem;
}

.welcome-header h1 {
  font-size: 2.2rem;
}

.tagline {
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 500;
  font-style: italic;
  margin-top: 0.25rem;
  margin-bottom: 0.1rem;
}

.subtitle {
  color: var(--neutral-600);
  font-size: 1rem;
  margin-top: 0.25rem;
}

/* --- Stage Header --- */
.stage-header {
  padding: 1.5rem 0 1rem;
}

.stage-badge {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 0.5rem;
}

/* --- Cards --- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.info-card {
  border-left: 4px solid var(--primary-light);
}

/* --- Callout --- */
.callout {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.callout.callout-clear {
  background: var(--clear-bg);
  border-left-color: var(--clear);
}

.callout.callout-alert {
  background: var(--alert-bg);
  border-left-color: var(--alert);
}

.callout.callout-info {
  background: var(--primary-bg);
  border-left-color: var(--primary-light);
}

/* --- Caregiver Notes --- */
.caregiver-note {
  background: var(--primary-bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* --- Option Buttons (Yes/No, selections) --- */
.option-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.option-group.vertical {
  flex-direction: column;
}

.option-btn {
  flex: 1;
  min-height: 52px;
  min-width: 100px;
  padding: 0.75rem 1.25rem;
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--neutral-700);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  line-height: 1.4;
}

.option-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.option-btn:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.option-group.vertical .option-btn {
  flex: none;
  text-align: left;
}

/* CDT option buttons — taller for description text */
.cdt-option {
  min-height: 60px;
  font-size: 0.9rem;
}

/* --- Question Blocks --- */
.question-block {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--neutral-100);
}

.question-block:last-child {
  border-bottom: none;
}

.question-text {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

/* --- SCD-Q Item Cards --- */
.scdq-item-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.scdq-item-card .item-number {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--neutral-400);
  min-width: 2rem;
}

.scdq-item-card .item-text {
  flex: 1;
  font-size: 0.95rem;
}

.scdq-item-card .option-group {
  flex-shrink: 0;
  margin-top: 0;
}

.scdq-item-card .option-btn {
  min-height: 44px;
  min-width: 70px;
  text-align: center;
  flex: none;
  padding: 0.5rem 1rem;
}

/* --- SLUMS Item Cards --- */
.slums-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.slums-card .read-aloud {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0.75rem 0;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--neutral-900);
  line-height: 1.5;
}

.slums-card .read-aloud::before {
  content: 'Read aloud:';
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.slums-card .scoring-note {
  font-size: 0.85rem;
  color: var(--neutral-600);
  margin-top: 0.5rem;
}

/* --- Score Input --- */
.score-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.score-input-group label {
  font-weight: 500;
  font-size: 0.9rem;
}

.score-input {
  width: 70px;
  height: 48px;
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 1.2rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--primary);
  transition: border-color var(--transition);
}

.score-input:focus {
  outline: none;
  border-color: var(--primary-light);
}

.score-max {
  font-size: 0.85rem;
  color: var(--neutral-400);
}

/* --- Timer --- */
.timer-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.timer-display {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  min-width: 80px;
  text-align: center;
}

.timer-display.timer-warning {
  color: var(--warning);
}

.timer-display.timer-done {
  color: var(--alert);
}

.btn-timer {
  min-height: 48px;
  padding: 0.5rem 1.5rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-timer:hover {
  background: var(--primary-bg);
}

.btn-timer.running {
  background: var(--alert);
  border-color: var(--alert);
  color: var(--white);
}

/* --- Word List Display --- */
.word-list {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.word-chip {
  background: var(--primary);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* --- Primary & Secondary Buttons --- */
.nav-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding: 1.5rem 0;
  flex-wrap: wrap;
}

.btn-primary {
  min-height: 52px;
  padding: 0.75rem 2rem;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-light);
}

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

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

.btn-secondary {
  min-height: 52px;
  padding: 0.75rem 2rem;
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--primary-bg);
}

/* --- Results Cards --- */
.result-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.result-card.result-clear {
  border-left: 5px solid var(--clear);
}

.result-card.result-warning {
  border-left: 5px solid var(--warning);
}

.result-card.result-alert {
  border-left: 5px solid var(--alert);
}

.result-card.result-info {
  border-left: 5px solid var(--primary-light);
}

.result-score {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.result-score-label {
  font-size: 0.85rem;
  color: var(--neutral-400);
  margin-top: 0.25rem;
}

.result-classification {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.75rem;
}

.result-explanation {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--neutral-600);
}

.result-next-step {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* --- Summary / Print View --- */
.summary-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.summary-section h2 {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--neutral-100);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-label {
  font-weight: 500;
  color: var(--neutral-600);
}

.summary-value {
  font-weight: 600;
  text-align: right;
}

.summary-recommendation {
  background: var(--neutral-50);
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.summary-referral-text {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: inherit;
}

/* --- Mini-Cog Word Selection --- */
.word-set-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.word-set-btn {
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--neutral-700);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  line-height: 1.4;
}

.word-set-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.word-set-btn.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

/* --- IQCODE Likert Scale --- */
.iqcode-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}

.iqcode-item .item-text {
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  font-weight: 500;
}

.likert-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.likert-group .option-btn {
  flex: 1;
  min-width: 60px;
  min-height: 48px;
  padding: 0.4rem 0.25rem;
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.3;
}

@media (max-width: 480px) {
  .likert-group {
    flex-wrap: wrap;
  }
  .likert-group .option-btn {
    flex: 0 0 calc(50% - 0.2rem);
    min-width: auto;
  }
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.75rem;
  color: var(--neutral-400);
  line-height: 1.6;
  max-width: 720px;
  margin: 0 auto;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  html {
    font-size: 16px;
  }

  .container {
    padding: 0.75rem;
  }

  .scdq-item-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .scdq-item-card .option-group {
    width: 100%;
  }

  .scdq-item-card .option-btn {
    flex: 1;
  }

  .option-group:not(.vertical) {
    flex-direction: row;
  }

  .word-chip {
    font-size: 1rem;
    padding: 0.5rem 1rem;
  }
}

/* --- Print Styles --- */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: white;
    font-size: 11pt;
    padding: 0;
  }

  #progress-bar-container {
    display: none !important;
  }

  .site-footer {
    display: none;
  }

  .view {
    display: none !important;
  }

  #view-summary {
    display: block !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .summary-section {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .stage-header {
    padding-top: 0;
  }

  .stage-badge {
    background: #333;
  }
}
