/*
 * sd-problems / sd-solution — Solutions page: problem list and answers (Session 4.5; Blueprint 5.22, 9.28, 11.34)
 * Problem list (owner choice F-11 B, Session 5.2): the six themes as a vertical list on the left (tabs; one theme at a
 * time), the questions of the chosen theme on the right as large rows with an arrow, the theme introduction above
 * them, and the service where SisuDent starts below. Below 1024px the themes form one scrollable row above the
 * questions. The script (shared/components.js, data-sd-component="problem-list") builds the tabs from the panel
 * titles (WAI-ARIA tabs: one tab stop, arrow keys, Home / End). Without JavaScript every panel is shown with its title.
 * Selecting a question scrolls to its answer (smooth unless reduced motion), moves focus to it, and marks it
 * (blue surface + copper line at the start — never colour alone: the answer is also focused and named).
 * Each answer links to its service page. Without JavaScript the links are normal anchors and :target marks the answer.
 */

/* ---------- Problem list ---------- */

.sd-problems { display: grid; gap: var(--sd-space-6); }

.sd-problems__tabs { display: flex; gap: var(--sd-space-2); overflow-x: auto; padding-bottom: var(--sd-space-1); }

.sd-problems__tab {
  display: grid;
  flex: none;
  gap: 0.125rem;
  min-height: var(--sd-target-min);
  padding: var(--sd-space-3) var(--sd-space-4);
  border: var(--sd-border-width) solid var(--sd-color-border-subtle);
  border-radius: var(--sd-radius-md);
  background: var(--sd-color-white);
  color: var(--sd-color-text-default);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--sd-transition-feedback);
}

.sd-problems__tab-title { font-weight: var(--sd-font-weight-medium); }
.sd-problems__tab-count { color: var(--sd-color-text-muted); font-size: var(--sd-font-size-label); }
.sd-problems__tab:hover { background: var(--sd-color-blue-050); }

.sd-problems__tab[aria-selected="true"] {
  border-color: var(--sd-color-brand-blue);
  background: var(--sd-color-surface-selected, var(--sd-color-blue-050));
  box-shadow: inset 3px 0 0 var(--sd-color-accent-copper);
  color: var(--sd-color-brand-blue);
}

.sd-problems__tab:focus-visible { outline: var(--sd-focus-ring-width) solid var(--sd-focus-ring-color); outline-offset: 2px; }

.sd-problems__panel { display: grid; align-content: start; gap: var(--sd-space-4); }
.sd-problems__panels { display: grid; gap: var(--sd-space-7); }

.sd-problems__title {
  margin: 0;
  color: var(--sd-color-text-heading);
  font-size: var(--sd-font-size-h4);
  line-height: var(--sd-line-height-h4);
  font-weight: var(--sd-font-weight-semibold);
}

/* With tabs the tab names the panel, so the panel title is not repeated on screen */
.sd-problems[data-ready] .sd-problems__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.sd-problems__intro { max-width: 60ch; color: var(--sd-color-text-muted); }

.sd-problems__service { color: var(--sd-color-text-muted); font-size: var(--sd-font-size-small); }

.sd-problems__list {
  display: grid;
  margin: 0;
  padding: 0;
  border-top: var(--sd-border-width) solid var(--sd-color-border-subtle);
  list-style: none;
}

.sd-problems__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sd-space-4);
  min-height: 3.75rem;
  padding: var(--sd-space-3) var(--sd-space-2);
  border-bottom: var(--sd-border-width) solid var(--sd-color-border-subtle);
  color: var(--sd-color-text-heading);
  font-size: var(--sd-font-size-body-lg);
  line-height: var(--sd-line-height-body);
  text-decoration: none;
  transition: background-color var(--sd-transition-feedback);
}

.sd-problems__link svg { width: 1.25rem; height: 1.25rem; flex: none; color: var(--sd-color-brand-blue); transition: transform var(--sd-transition-ui); }
.sd-problems__link:hover { background: var(--sd-color-blue-050); }
.sd-problems__link:hover svg { transform: translateX(0.25rem); }
.sd-problems__link:focus-visible { outline: var(--sd-focus-ring-width) solid var(--sd-focus-ring-color); outline-offset: 0; }

@media (min-width: 1024px) {
  .sd-problems[data-ready] { grid-template-columns: 4fr 8fr; column-gap: var(--sd-space-7); align-items: start; }
  .sd-problems__tabs { flex-direction: column; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .sd-problems__link svg { transition: none; }
}

/* ---------- Answers ---------- */

.sd-solution {
  display: grid;
  gap: var(--sd-space-6);
}

@media (min-width: 1024px) {
  .sd-solution { grid-template-columns: 5fr 7fr; column-gap: var(--sd-space-8); align-items: start; }
  .sd-solution__aside { position: sticky; top: calc(var(--sd-scroll-offset) + var(--sd-space-4)); }
}

.sd-solution__aside { display: grid; gap: var(--sd-space-4); align-content: start; }
.sd-solution__aside .sd-section-header { margin-bottom: 0; }

.sd-solution__answers { display: grid; gap: var(--sd-space-3); margin: 0; padding: 0; list-style: none; }

.sd-solution-answer {
  display: grid;
  gap: var(--sd-space-2);
  padding: var(--sd-space-4) var(--sd-space-5);
  border: var(--sd-border-width) solid var(--sd-color-card-divider);
  border-left: 3px solid var(--sd-color-line-secondary);
  border-radius: var(--sd-radius-md);
  background: var(--sd-color-white);
  transition: background-color var(--sd-transition-ui), border-color var(--sd-transition-ui);
}

.sd-solution-answer:focus { outline: none; }
.sd-solution-answer:focus-visible { outline: var(--sd-focus-ring-width) solid var(--sd-focus-ring-color); outline-offset: var(--sd-focus-ring-offset); }

/* Selected answer: copper start line + light blue surface + "Selected problem" text (not colour alone) */
.sd-solution-answer:target,
.sd-solution-answer[data-state="selected"] {
  border-left-color: var(--sd-color-accent-copper);
  background: var(--sd-color-blue-050);
}

.sd-solution-answer__selected { display: none; color: var(--sd-color-text-muted); font-size: var(--sd-font-size-label); font-weight: var(--sd-font-weight-medium); }
.sd-solution-answer:target .sd-solution-answer__selected,
.sd-solution-answer[data-state="selected"] .sd-solution-answer__selected { display: block; }

.sd-solution-answer__question {
  margin: 0;
  color: var(--sd-color-text-heading);
  font-size: var(--sd-font-size-body-lg);
  line-height: var(--sd-line-height-h4);
  font-weight: var(--sd-font-weight-semibold);
}

.sd-solution-answer__text { max-width: 62ch; }

.sd-solution-answer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sd-space-1) var(--sd-space-4);
  font-size: var(--sd-font-size-small);
}

/* Touch target (Blueprint 15.27; Session 5.2, R-04) */
.sd-solution-answer__back { display: inline-flex; align-items: center; min-height: var(--sd-target-min); color: var(--sd-color-text-muted); }
