/* ============================================================
   DVPRS Pain Scale — style.css
   Medical-warm aesthetic: clean, approachable, modern
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
  --bg-page: #f5f4f1;
  --bg-card: #ffffff;
  --bg-card-hover: #fdfcfb;

  --text-primary: #1a1a2e;
  --text-secondary: #5a5a72;
  --text-muted: #9494a8;
  --text-on-accent: #ffffff;

  --border-default: #e8e6e0;
  --border-focus: #2E7D5E;

  --accent-primary: #2E7D5E;
  --accent-primary-light: #e8f5ee;
  --accent-primary-dark: #1a5c44;

  --shadow-card: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-selected: 0 0 0 3px var(--accent-primary);

  --radius-card: 16px;
  --radius-inner: 10px;
  --radius-sm: 6px;
  --radius-pill: 100px;

  /* Pain color scale */
  --color-0: #9e9e9e;
  --color-1: #4CAF50;
  --color-2: #66BB6A;
  --color-3: #8BC34A;
  --color-4: #CDDC39;
  --color-5: #FFC107;
  --color-6: #FF9800;
  --color-7: #F57C00;
  --color-8: #F44336;
  --color-9: #D32F2F;
  --color-10: #B71C1C;

  /* Bar heights for pain levels 0-10 (px) */
  --bar-0: 0px;
  --bar-1: 8px;
  --bar-2: 14px;
  --bar-3: 20px;
  --bar-4: 28px;
  --bar-5: 36px;
  --bar-6: 44px;
  --bar-7: 54px;
  --bar-8: 64px;
  --bar-9: 76px;
  --bar-10: 90px;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  --transition-default: 0.2s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.2;
}

h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; }
h2 { font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 600; }

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-main {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-default);
  background: var(--bg-card);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-default);
  letter-spacing: 0.05em;
}

.lang-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-primary-light);
}

.lang-divider {
  color: var(--border-default);
  font-weight: 300;
}

body.lang-en .lang-en,
body.lang-de .lang-de {
  color: var(--accent-primary);
  font-weight: 700;
}

/* ---- Main Layout ---- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---- Card Base ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px 32px;
  border: 1px solid var(--border-default);
  transition: box-shadow var(--transition-smooth);
}

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

.section-header h2 {
  color: var(--text-primary);
  margin-bottom: 4px;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---- Intro Card ---- */
.intro-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #f0faf5 0%, #fff 60%);
  border-color: #c8e6d6;
}

.intro-card h1 {
  color: var(--text-primary);
  margin-bottom: 6px;
}

.intro-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 540px;
}

.intro-badge {
  flex-shrink: 0;
  background: var(--accent-primary);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  align-self: flex-start;
}

/* ---- Category Brackets ---- */
.category-brackets {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  padding: 0 4px;
}

.bracket {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.bracket-mild {
  flex: 3; /* 0-3, 4 items */
  color: #388E3C;
}

.bracket-moderate {
  flex: 2; /* 4-5, 2 items */
  color: #F57F17;
}

.bracket-severe {
  flex: 5; /* 6-10, 5 items */
  color: #C62828;
}

.bracket-line {
  flex: 1;
  height: 2px;
  border-radius: 2px;
}

.bracket-mild .bracket-line { background: #4CAF50; }
.bracket-moderate .bracket-line { background: #FFC107; }
.bracket-severe .bracket-line { background: #F44336; }

/* ---- Pain Scale Grid ---- */
.pain-scale-grid {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  overflow-x: auto;
  padding: 8px 4px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}

.pain-scale-grid::-webkit-scrollbar {
  height: 4px;
}

.pain-scale-grid::-webkit-scrollbar-track { background: transparent; }
.pain-scale-grid::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

/* ---- Individual Pain Card ---- */
.pain-card {
  flex: 1;
  min-width: 80px;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border-radius: var(--radius-inner);
  border: 2px solid transparent;
  padding: 10px 6px 8px;
  transition: all var(--transition-smooth);
  position: relative;
  background: #fafaf9;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Force uniform height so bars all align */
  min-height: 220px;
  justify-content: flex-start;
}

.pain-card:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  z-index: 2;
}

.pain-card.selected {
  border-color: var(--card-color, var(--accent-primary));
  background: white;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--card-color, var(--accent-primary)) 20%, transparent),
              var(--shadow-card-hover);
  transform: translateY(-4px) scale(1.03);
  z-index: 3;
}

.pain-card-number {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--card-color, var(--text-primary));
  transition: color var(--transition-smooth);
}

.pain-card.selected .pain-card-number {
  color: var(--card-color, var(--accent-primary));
}

.pain-card-face {
  width: 52px;
  height: 52px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.pain-card-desc {
  font-size: 0.6rem;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.3;
  height: 32px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: color var(--transition-smooth);
  width: 100%;
  word-break: break-word;
  hyphens: auto;
  lang: inherit;
}

.pain-card.selected .pain-card-desc {
  color: var(--text-primary);
  font-weight: 500;
}

.pain-card-bar-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: auto;
  padding-top: 8px;
  height: 90px;
  align-items: flex-end;
}

.pain-card-bar {
  width: 70%;
  border-radius: 4px 4px 2px 2px;
  background: var(--card-color, transparent);
  transition: height var(--transition-smooth), opacity var(--transition-smooth);
  opacity: 0.75;
  min-height: 2px;
}

.pain-card:hover .pain-card-bar,
.pain-card.selected .pain-card-bar {
  opacity: 1;
}

/* ---- Selected value display ---- */
.selected-value-display {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-inner);
  background: var(--accent-primary-light);
  border: 1px solid #c8e6d6;
  animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.selected-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.selected-number {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1;
  min-width: 2.5ch;
}

.selected-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  flex: 1;
}

/* ---- Supplemental Questions ---- */
.supplemental-questions {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.supp-question {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.supp-question-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.supp-question-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.supp-question-text {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.supp-question-text em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent-primary);
}

.supp-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.supp-slider-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: normal;
  width: 90px;
  flex-shrink: 0;
  line-height: 1.3;
  overflow: hidden;
}

.supp-slider-label.right {
  text-align: right;
}

.supp-slider-wrap {
  flex: 1;
  position: relative;
  padding: 4px 0;
}

/* Custom range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 100px;
  background: linear-gradient(to right, #4CAF50, #8BC34A, #CDDC39, #FFC107, #FF9800, #F57C00, #F44336, #B71C1C);
  outline: none;
  cursor: pointer;
  position: relative;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 2.5px solid var(--accent-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all var(--transition-default);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  border-color: var(--accent-primary-dark);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 2.5px solid var(--accent-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
}

.supp-value-display {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: color var(--transition-smooth);
}

.supp-question + .supp-question {
  padding-top: 4px;
  border-top: 1px solid var(--border-default);
}

/* ---- Summary Section ---- */
.summary-section {
  border: 2px solid var(--accent-primary-light);
  background: linear-gradient(135deg, #f8fdf9 0%, #fff 100%);
}

.summary-content {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px 32px;
  margin-bottom: 24px;
  align-items: start;
}

.summary-pain-display {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-inner);
  background: white;
  border: 1px solid var(--border-default);
}

.summary-pain-number-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}

.summary-pain-number {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.summary-pain-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.summary-pain-face {
  width: 64px;
  height: 64px;
}

.summary-pain-desc {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.summary-supp-grid {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.summary-supp-item {
  background: white;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-inner);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-supp-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.summary-supp-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-meta {
  grid-column: 1 / 3;
  display: flex;
  gap: 24px;
  font-size: 0.82rem;
  color: var(--text-muted);
  align-items: center;
  flex-wrap: wrap;
}

.summary-meta strong {
  color: var(--text-secondary);
}

.summary-total {
  grid-column: 1 / 3;
  padding: 12px 16px;
  border-radius: var(--radius-inner);
  background: var(--accent-primary-light);
  border: 1px solid #c8e6d6;
  font-size: 0.9rem;
  color: var(--accent-primary-dark);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.summary-total strong {
  font-weight: 700;
}

.summary-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-default);
  min-height: 44px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-primary-dark);
  box-shadow: 0 4px 12px rgba(46,125,94,0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-page);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--border-default);
  color: var(--text-primary);
}

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
  min-height: 36px;
}

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---- History Section ---- */
.history-section {
  overflow: hidden;
}

.history-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 4px;
}

.section-header.clickable {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-toggle-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform var(--transition-smooth);
  display: block;
  line-height: 1;
}

.history-toggle-icon.open {
  transform: rotate(180deg);
}

.history-body {
  margin-top: 16px;
}

.history-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 24px;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-page);
  border-radius: var(--radius-inner);
  border: 1px solid var(--border-default);
  font-size: 0.85rem;
  animation: fadeSlideIn 0.3s ease;
}

.history-entry-number {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.history-entry-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-entry-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-entry-scores {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.history-entry-score-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.history-score-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* ---- Disclaimer Section ---- */
.disclaimer-section {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: #fefce8;
  border-color: #fde68a;
  padding: 20px 24px;
}

.disclaimer-icon {
  flex-shrink: 0;
  color: #b45309;
  margin-top: 2px;
}

.disclaimer-content {
  flex: 1;
}

.disclaimer-content h3 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 8px;
}

.disclaimer-content p {
  font-size: 0.78rem;
  line-height: 1.55;
  color: #78350f;
  margin-bottom: 6px;
}

.disclaimer-content p:last-child {
  margin-bottom: 0;
  opacity: 0.85;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border-default);
  background: white;
  margin-top: 24px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-inner a {
  color: var(--accent-primary);
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.footer-legal {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-default);
}

.footer-legal a {
  font-weight: 500;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .pain-scale-grid {
    gap: 4px;
    padding-bottom: 8px;
  }

  .pain-card {
    min-width: 68px;
    padding: 8px 4px 6px;
  }

  .pain-card-number {
    font-size: 1.3rem;
  }

  .pain-card-face {
    width: 44px;
    height: 44px;
  }

  .summary-supp-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .main-content {
    padding: 16px 16px 40px;
    gap: 16px;
  }

  .card {
    padding: 20px 18px;
    border-radius: 12px;
  }

  .intro-card {
    flex-direction: column;
  }

  .category-brackets {
    display: none;
  }

  .pain-scale-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    overflow-x: visible;
  }

  .pain-card {
    min-width: unset;
    max-width: unset;
    width: 100%;
    padding: 8px 4px;
    min-height: 130px;
  }

  .pain-card-bar-wrap {
    height: 36px;
  }

  .pain-card-face {
    width: 36px;
    height: 36px;
  }

  .pain-card-number {
    font-size: 1.1rem;
  }

  .pain-card-desc {
    font-size: 0.52rem;
    height: 32px;
    -webkit-line-clamp: 2;
  }

  .supp-slider-label {
    width: 80px;
    font-size: 0.65rem;
  }

  .summary-supp-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-pain-display {
    flex-wrap: wrap;
    gap: 12px;
  }

  .selected-value-display {
    flex-wrap: wrap;
    gap: 8px;
  }

  .summary-content {
    gap: 12px 16px;
  }
}

@media (max-width: 400px) {
  .pain-scale-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---- Accessibility ---- */
.pain-card:focus-visible,
.btn:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ---- Utility ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
