/* Material-inspired warm theme — responsive for phone / tablet / desktop */

:root {
  --md-sys-color-primary: #9e6b7a;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #ffd9e3;
  --md-sys-color-surface: #fff8f6;
  --md-sys-color-surface-container: #ffffff;
  --md-sys-color-outline: #857374;
  --md-sys-color-on-surface: #22191c;
  --md-sys-color-on-surface-variant: #524345;
  --md-elevation-1: 0 1px 3px rgba(60, 40, 45, 0.12), 0 1px 2px rgba(60, 40, 45, 0.08);
  --md-elevation-2: 0 4px 12px rgba(60, 40, 45, 0.12);
  --radius-lg: 16px;
  --radius-md: 12px;
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --step-max: 560px;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface);
  background: linear-gradient(165deg, #fff5f2 0%, #f8e8ee 45%, #eef4f8 100%);
  background-attachment: fixed;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--md-sys-color-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 18%, transparent);
}

.app-header__inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.logo {
  font-weight: 500;
  font-size: 1.125rem;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-primary);
}

.progress-wrap {
  flex: 1;
  max-width: 240px;
  min-width: 0;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 0.25rem;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-sys-color-primary) 22%, white);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--md-sys-color-primary);
  transition: width 0.35s ease;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.screen {
  display: none;
  animation: fadeIn 0.35s ease;
}

.screen.is-active {
  display: block;
}

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

.hero-card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--radius-lg);
  box-shadow: var(--md-elevation-2);
  padding: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: 1.5rem;
}

.hero-card h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.5rem, 4.5vw, 1.85rem);
  font-weight: 500;
  line-height: 1.25;
  color: var(--md-sys-color-on-surface);
}

.hero-card .lead {
  margin: 0 0 1rem;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1rem;
}

.hero-card .instruction {
  margin: 0;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
}

/* Buttons — filled / text Material-like */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-start;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.5rem;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.btn--filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-elevation-1);
}

.btn--filled:hover {
  filter: brightness(1.05);
  box-shadow: var(--md-elevation-2);
}

.btn--filled:active {
  transform: scale(0.98);
}

.btn--text {
  background: transparent;
  color: var(--md-sys-color-primary);
}

.btn--text:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent);
}

.btn--outlined {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 55%, transparent);
}

.btn--outlined:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Question card */
.question-shell {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--radius-lg);
  box-shadow: var(--md-elevation-2);
  overflow: hidden;
}

.stage-badge {
  padding: 0.75rem 1.25rem;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--md-sys-color-primary) 14%, white),
    color-mix(in srgb, var(--md-sys-color-primary) 6%, white)
  );
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 12%, transparent);
}

.stage-badge h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.stage-badge p {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
}

.question-body {
  padding: clamp(1.25rem, 3vw, 1.75rem);
}

.question-meta {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 0.75rem;
}

.question-text {
  margin: 0 0 1.25rem;
  font-size: clamp(1.0625rem, 2.8vw, 1.125rem);
  line-height: 1.45;
  font-weight: 400;
}

/* True / not true — large touch targets */
.choice-group {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 52px;
  padding: 0.625rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 28%, transparent);
  background: var(--md-sys-color-surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.choice:hover {
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 45%, transparent);
  background: color-mix(in srgb, var(--md-sys-color-primary) 5%, white);
}

.choice:has(input:checked) {
  border-color: var(--md-sys-color-primary);
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, white);
}

.choice input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--md-sys-color-primary);
  flex-shrink: 0;
}

.choice span {
  font-size: 0.9375rem;
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 14%, transparent);
}

.question-actions .btn-row {
  margin-left: auto;
}

/* Stage transition */
.transition-card {
  text-align: center;
  padding: 2rem 1.25rem;
}

.transition-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 500;
}

.transition-card p {
  margin: 0 0 1.5rem;
  color: var(--md-sys-color-on-surface-variant);
}

/* Results */
.results-card header {
  margin-bottom: 1.25rem;
}

.results-card h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 3.5vw, 1.45rem);
}

.results-card .sub {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.style-label--anxious {
  color: #a85c72;
}

.style-label--secure {
  color: #3d7a62;
}

.style-label--avoidant {
  color: #4a6fa8;
}

.chart-block {
  margin-bottom: 1.75rem;
}

.chart-block__title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.chart-block__hint {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
}

/* Bar chart — relative heights */
.bar-chart {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  align-items: end;
  min-height: 200px;
}

.bar-chart__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.bar-chart__track {
  width: 100%;
  max-width: 72px;
  height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--md-sys-color-outline) 12%, white);
  overflow: hidden;
}

.bar-chart__fill {
  width: 100%;
  height: 0%;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: height 0.45s ease;
  min-height: 0;
}

.bar-chart__fill--anxious {
  background: linear-gradient(180deg, #c97a8f 0%, #a85c72 100%);
}

.bar-chart__fill--secure {
  background: linear-gradient(180deg, #6cb896 0%, #3d7a62 100%);
}

.bar-chart__fill--avoidant {
  background: linear-gradient(180deg, #7a9ccd 0%, #4a6fa8 100%);
}

.bar-chart__label {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.3;
}

.bar-chart__value {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.quadrant-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--md-elevation-1);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 14%, transparent);
}

.quadrant-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72vw, 380px);
}

.quadrant-svg__axis {
  fill: var(--md-sys-color-on-surface-variant);
  font-family: var(--font);
}

.quadrant-svg__tag {
  fill: var(--md-sys-color-on-surface);
  font-family: var(--font);
  font-weight: 500;
  opacity: 0.88;
}

.quadrant-svg__dot {
  fill: #5c3d48;
  stroke: #fff;
  stroke-width: 0.9;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.quadrant-caption {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
}

.result-narrative {
  margin-bottom: 1.25rem;
}

.result-narrative__lead {
  margin: 0;
  font-size: 0.975rem;
  line-height: 1.55;
  color: var(--md-sys-color-on-surface);
}

.read-more {
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 20%, transparent);
  background: color-mix(in srgb, var(--md-sys-color-surface) 80%, white);
  padding: 0 1rem;
}

.read-more summary {
  cursor: pointer;
  padding: 0.875rem 0;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--md-sys-color-primary);
  list-style: none;
}

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

.read-more summary::after {
  content: "";
  float: right;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: 0.35rem;
  opacity: 0.7;
}

.read-more[open] summary::after {
  transform: rotate(-135deg);
  margin-top: 0.5rem;
}

.read-more__body {
  padding-bottom: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 12%, transparent);
  padding-top: 0.75rem;
}

.read-more__body p {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.55;
}

.read-more__body section:last-child p {
  margin-bottom: 0;
}

.read-more__h {
  margin: 0 0 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.note {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--md-sys-color-outline) 10%, white);
}

.footer-note {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  line-height: 1.5;
}

/* Install hint */
.install-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  background: var(--md-sys-color-primary-container);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 22%, transparent);
}

.install-banner.is-visible {
  display: flex;
}

.install-banner p {
  margin: 0;
  font-size: 0.875rem;
  flex: 1;
  min-width: 0;
}

/* Tablet */
@media (min-width: 600px) {
  .choice-group {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .choice {
    flex: 1;
    min-width: 200px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
