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

:root {
  --brand:         #cd1316;
  --brand-dark:    #a50e10;
  --brand-light:   #e51518;
  --text:          #393838;
  --text-muted:    #666666;
  --surface:       #ffffff;
  --bg:            #fafafa;
  --bg-section:    #f5f5f5;
  --border:        #e0e0e0;
  --border-input:  #cccccc;
  --shadow:        0 0 10px rgba(113,113,113,.25);
  --shadow-lg:     0 2px 20px rgba(113,113,113,.3);
  --radius-card:   4px;
  --radius-btn:    9999px;
  --result-color:      #27ae60;
  --result-color-dark: #1e8449;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: .9375rem; /* ~15px */
}

/* ─── App Header ──────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(90deg, #012139 0%, #cd1316 100%);
  color: #fff;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.app-header .header-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px 8px 8px 0;
}

.app-header h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.app-header h1 span {
  display: block;
  font-size: .72rem;
  font-weight: 400;
  opacity: .85;
  margin-top: 1px;
}

/* ─── Layout ──────────────────────────────────────────────────────────── */
.main-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 5rem;
}

/* ─── View system ─────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ─── Intro View ──────────────────────────────────────────────────────── */
.intro-hero {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem 2.5rem;
  text-align: center;
  margin-bottom: 2rem;
}

.hero-icon { font-size: 3.5rem; display: block; margin-bottom: .9rem; }

.intro-hero h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .75rem;
  line-height: 1.25;
}

.intro-hero h2 em {
  font-style: normal;
  color: var(--brand);
}

.intro-hero p {
  font-size: .9375rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.intro-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2.25rem;
}

.meta-pill {
  background: var(--bg-section);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: .3rem .85rem;
  font-size: .8125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.intro-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .85rem;
  margin-bottom: 2.25rem;
  text-align: left;
}

.intro-cat-card {
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-card);
  padding: .9rem 1rem;
  transition: box-shadow .2s;
}

.intro-cat-card:hover { box-shadow: var(--shadow); }

.intro-cat-card .icon { font-size: 1.3rem; margin-bottom: .3rem; }
.intro-cat-card strong { display: block; font-size: .875rem; color: var(--text); font-weight: 600; }
.intro-cat-card span { font-size: .775rem; color: var(--text-muted); }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: .65rem 1.8rem;
  transition: background .18s, box-shadow .18s, transform .12s;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 10px rgba(205,19,22,.3);
}

.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 4px 16px rgba(205,19,22,.4);
}

.btn-dark {
  background: #32373c;
  color: #fff;
}

.btn-dark:hover { background: #1e2226; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-input);
}

.btn-ghost:hover {
  background: var(--bg-section);
  color: var(--text);
  border-color: #aaa;
}

.btn-large { font-size: 1.05rem; padding: .78rem 2.25rem; }

.btn-result {
  background: var(--result-color);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

.btn-result:hover { background: var(--result-color-dark); }

/* ─── Progress bar ────────────────────────────────────────────────────── */
.progress-wrapper {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: .85rem 1.25rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 55px;
  z-index: 90;
  border: 1px solid var(--border);
}

.progress-label {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 115px;
  font-weight: 600;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-section);
  border-radius: var(--radius-btn);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-btn);
  transition: width .4s ease;
  width: 0%;
}

/* ─── Category sections ───────────────────────────────────────────────── */
.category-section {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.category-header {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.category-icon { font-size: 1.75rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }

.category-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .2rem;
}

.category-desc { font-size: .8125rem; color: var(--text-muted); }

.category-number {
  margin-left: auto;
  font-size: .72rem;
  font-weight: 700;
  color: var(--brand);
  background: #fdf0f0;
  border: 1px solid #f5c0c0;
  border-radius: var(--radius-btn);
  padding: .2rem .6rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Question items ──────────────────────────────────────────────────── */
.question-item {
  padding: 1rem;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  margin-bottom: .75rem;
  background: var(--surface);
  transition: border-color .2s, background .2s;
}

.question-item:last-child { margin-bottom: 0; }

.question-item.answered {
  border-color: #d4d4d4;
  background: var(--bg-section);
}

.question-item.missing {
  border-color: var(--brand) !important;
  background: #fff5f5 !important;
  animation: shake .4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  60%       { transform: translateX(5px); }
}

.q-num {
  font-weight: 700;
  color: var(--brand);
  margin-right: .3rem;
  font-size: .8125rem;
}

.question-text {
  font-size: .9rem;
  margin-bottom: .8rem;
  color: var(--text);
  line-height: 1.55;
}

/* ─── Answer buttons ──────────────────────────────────────────────────── */
.answer-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.answer-btn {
  border: 1px solid var(--border-input);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-btn);
  padding: .4rem 1rem;
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  outline: none;
}

.answer-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg-section);
}

.answer-btn.selected[data-value="ja"] {
  background: #eaf7ee;
  border-color: #27ae60;
  color: #1a7a41;
}

.answer-btn.selected[data-value="teilweise"] {
  background: #fff8e6;
  border-color: #e6a817;
  color: #a07010;
}

.answer-btn.selected[data-value="nein"] {
  background: #feeeee;
  border-color: var(--brand);
  color: var(--brand-dark);
}

/* ─── Submit area ─────────────────────────────────────────────────────── */
.submit-area {
  text-align: center;
  padding: 2rem 0 1rem;
}

#submit-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.submit-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .65rem;
}

/* ─── Quiz top bar ────────────────────────────────────────────────────── */
.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.quiz-topbar h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── Results View ────────────────────────────────────────────────────── */
.results-header {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 2.5rem 2rem 2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* Score ring */
.score-ring-wrapper {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 1.5rem;
}

.score-ring-wrapper svg { transform: rotate(-90deg); }

#score-ring-bg  { fill: none; stroke: #e8e8e8; stroke-width: 9; }

#score-ring-fill {
  fill: none;
  stroke: var(--result-color);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 339.3;
  transition: stroke-dashoffset 1.6s cubic-bezier(.4,0,.2,1);
}

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#score-number {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--result-color);
  line-height: 1;
}

.score-label {
  font-size: .65rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: .08em;
  margin-top: 2px;
}

/* Result badge */
.result-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-radius: var(--radius-btn);
  padding: .25rem .85rem;
  margin-bottom: .7rem;
  border: 1.5px solid currentColor;
}

.badge-einsteiger      { color: #c47c00; background: #fff8e6; }
.badge-fortgeschritten { color: #005a8c; background: #e6f4fb; }
.badge-bereit          { color: #1a7a41; background: #eaf7ee; }

.results-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}

.result-tagline {
  font-size: .9375rem;
  color: var(--text-muted);
  margin-bottom: .9rem;
  font-weight: 600;
}

.result-description {
  font-size: .875rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ─── Results cards ───────────────────────────────────────────────────── */
.results-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.results-card h3 {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.2rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--brand);
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ─── Breakdown ───────────────────────────────────────────────────────── */
.breakdown-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.1rem 1.25rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--bg-section);
}

.breakdown-item:last-child { margin-bottom: 0; }

/* Bar row */
.breakdown-bar-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .6rem;
}

.breakdown-cat-label {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  min-width: 0;
  flex: 0 0 auto;
  max-width: 200px;
}

.breakdown-bar-track {
  flex: 1;
  height: 7px;
  background: #e5e5e5;
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  background: var(--result-color);
  border-radius: var(--radius-btn);
  transition: width .9s cubic-bezier(.4,0,.2,1);
}

.breakdown-pct {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--result-color);
  white-space: nowrap;
  flex: 0 0 auto;
  min-width: 36px;
  text-align: right;
}

/* Tier badge */
.breakdown-tier-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: var(--radius-btn);
  padding: .18rem .65rem;
  margin-bottom: .65rem;
  border: 1.5px solid currentColor;
}

.tier-low  { color: #c47c00; background: #fff8e6; }
.tier-mid  { color: #005a8c; background: #e6f4fb; }
.tier-high { color: #1a7a41; background: #eaf7ee; }

/* Assessment text */
.breakdown-text {
  font-size: .855rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: .85rem;
}

/* Per-category tips */
.breakdown-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
}

.breakdown-tips li {
  font-size: .845rem;
  color: var(--text);
  line-height: 1.6;
  padding: .45rem 0 .45rem 1.6rem;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.breakdown-tips li:last-child { border-bottom: none; padding-bottom: 0; }

.breakdown-tips li::before {
  content: "";
  position: absolute;
  left: .3rem;
  top: .85rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

/* ─── Recommendations ─────────────────────────────────────────────────── */
#recommendations-list {
  padding-left: 0;
  list-style: none;
}

#recommendations-list li {
  padding: .75rem .75rem .75rem 2rem;
  position: relative;
  font-size: .875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}

#recommendations-list li:last-child { border-bottom: none; }

#recommendations-list li::before {
  content: "";
  position: absolute;
  left: .6rem;
  top: .95rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
}

/* ─── MDZH Link boxes ─────────────────────────────────────────────────── */
.breakdown-links {
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}

.breakdown-links-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: .55rem;
}

.breakdown-links-list,
.mdzh-links-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.mdzh-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: #fdf0f0;
  border: 1px solid #f5c0c0;
  color: var(--brand-dark);
  border-radius: var(--radius-btn);
  padding: .3rem .8rem;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}

.mdzh-link::after {
  content: "↗";
  font-size: .7rem;
  opacity: .6;
}

.mdzh-link:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.mdzh-link:hover::after { opacity: 1; }

/* Level links in own card */
.mdzh-links-grid { padding: .25rem 0; }

/* ─── Results CTA ─────────────────────────────────────────────────────── */
.results-cta {
  background: #fdf0f0;
  border: 1.5px solid #f5c0c0;
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-card);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.cta-inner {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.5rem;
}

.cta-logo {
  font-size: 2.25rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: .1rem;
}

.cta-body strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
}

.cta-body p {
  font-size: .855rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.cta-links {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

/* ─── Results actions ─────────────────────────────────────────────────── */
.results-actions {
  display: flex;
  gap: .85rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* ─── Divider ─────────────────────────────────────────────────────────── */
.section-divider {
  height: 3px;
  background: var(--brand);
  border: none;
  margin: 0 0 1.75rem;
  border-radius: 2px;
  width: 40px;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .main-content { padding: 1.25rem .75rem 3.5rem; }
  .intro-hero { padding: 2rem 1.25rem 1.75rem; }
  .intro-hero h2 { font-size: 1.4rem; }
  .answer-group { gap: .4rem; }
  .answer-btn { padding: .38rem .85rem; }
  .btn-large { font-size: .95rem; padding: .72rem 1.75rem; }
  .results-actions { flex-direction: column; align-items: center; }
  .progress-wrapper { top: 50px; }
  .category-header { flex-wrap: wrap; }
  .results-header { padding: 2rem 1.25rem 1.5rem; }
  .cta-inner { flex-direction: column; gap: .85rem; }
  .cta-logo { font-size: 1.75rem; }
  .cta-links { flex-direction: column; }
  .cta-links .btn { justify-content: center; }
  .breakdown-cat-label { font-size: .8rem; max-width: 140px; }
}

@media print {
  .app-header, .quiz-topbar, .results-actions, .progress-wrapper { display: none; }
  .view.active { display: block; }
  body { background: #fff; }
  .results-card, .results-header { box-shadow: none; border: 1px solid #ddd; }
}

/* ─── Footer ──────────────────────────────────────────────────────────── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.app-footer img {
  height: 100px;
  width: auto;
  object-fit: contain;
}
