/* Design-tokenit, reset, typografia ja jaetut komponentit.
   Kontrastit tarkistettu WCAG AA -tasolle valkoista/vaaleaa taustaa vasten. */
:root {
  --bg: #f2f4f9;
  --surface: #ffffff;
  --ink: #1a2233;
  --ink-soft: #46536b;
  --line: #c9d0dd;

  --nt: #0b6b6b;
  --nt-soft: #e0f2f2;
  --adhd: #a34700;
  --adhd-soft: #fdeedd;

  --accent: #2f4fae;
  --accent-soft: #e3e9f9;
  --ok: #1a7f37;
  --ok-soft: #dcfce7;
  --warn: #9a5b00;
  --warn-soft: #fef3c7;
  --danger: #b3261e;
  --danger-soft: #fde8e8;

  --dopamine: #6d28d9;
  --dopamine-faded: #94a3b8;

  --radius: 10px;
  --touch: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  margin: 0 0 0.35em;
  line-height: 1.2;
}

p {
  margin: 0.35em 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Painikkeet — kosketuskohde vähintään 44 px */
.btn {
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--ink-soft);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary,
.btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Sirupainikkeet (tilanteet, nopeudet) */
.chip {
  min-height: var(--touch);
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink-soft);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Mittari */
.meter {
  margin: 6px 0;
}

.meter-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.meter-track {
  position: relative;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e6e9f0;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--ok);
  transition: width 0.15s linear;
}

.meter[data-state="under"] .meter-fill {
  background: var(--dopamine-faded);
}

.meter[data-state="low"] .meter-fill {
  background: var(--warn);
}

.meter[data-state="negative"] .meter-fill {
  background: repeating-linear-gradient(
    45deg,
    var(--danger),
    var(--danger) 6px,
    #7f1d1d 6px,
    #7f1d1d 12px
  );
}

.meter-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  background: var(--ink);
}

.meter-value {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* Tilamerkit — muoto + teksti, ei pelkkä väri */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 1.4em;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
}

.badge-overloaded {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge-underAroused {
  color: var(--ink-soft);
  background: #eceff5;
}

.badge-hyperfocus {
  color: #5b21b6;
  background: #ede9fe;
}

/* Tekstivastine ja faktalaatikko */
.explain {
  margin: 10px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.explain summary {
  font-weight: 700;
  cursor: pointer;
  min-height: 32px;
}

.facts {
  margin: 10px 0 0;
  background: var(--accent-soft);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.facts h3 {
  font-size: 0.95rem;
}

.facts p {
  font-size: 0.9rem;
}

.insight {
  background: var(--warn-soft);
  border-left: 5px solid var(--warn);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-weight: 600;
}

/* Dialogi */
.info-dialog {
  max-width: 34rem;
  border: 2px solid var(--ink-soft);
  border-radius: var(--radius);
  padding: 16px;
}

.info-dialog::backdrop {
  background: rgba(26, 34, 51, 0.6);
}

.info-dialog .disclaimer {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
