/* Problems worth solving. Same look as the /resources hub (resources.css): white canvas, system type, grey cards.
   The navbar is styled by site-nav.css. Phone first; the filters move into a sticky side column from 980px.
   problems.js builds .pill (+ .pill-name, .pill-count, .pill-none, .pill-level-N, aria-pressed), li.problem,
   .meta, .level.level-N, .field, .source and toggles [hidden]: keep those hooks. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --ink-faint: #86868b;
  --line: #d2d2d7;
  --hair: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-ink: #0066cc;
  --radius: 24px;
  --ease: cubic-bezier(0.28, 0.11, 0.32, 1);
  --maxw: 1040px;
  --gutter: max(clamp(20px, 5vw, 40px), calc((100% - var(--maxw)) / 2));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  /* Difficulty marks: a small dot, light to dark as the problems get harder. */
  --level-1: #34c759;
  --level-2: #ff9f0a;
  --level-3: #bf4800;
  --level-4: #1d1d1f;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.47 var(--font);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font);
  text-wrap: balance;
}

p,
dl,
dd,
ol {
  margin: 0;
}

ol {
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

.paper {
  display: none;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  border-radius: 980px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Hero */
.hero {
  padding: clamp(56px, 9vw, 112px) var(--gutter) clamp(36px, 5vw, 60px);
  text-align: center;
}

.eyebrow {
  color: var(--ink-soft);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero h1 {
  max-width: 14ch;
  margin: 14px auto 0;
  font-size: clamp(44px, 8.4vw, 96px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.hero h1 em {
  font-style: normal;
}

.lede {
  max-width: 640px;
  margin: 22px auto 0;
  color: var(--ink-soft);
  font-size: clamp(19px, 2.2vw, 23px);
  line-height: 1.4;
  letter-spacing: -0.012em;
}

.lede span {
  color: var(--ink);
  font-weight: 600;
}

.levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: clamp(32px, 5vw, 52px);
  text-align: left;
}

.levels div {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: var(--bg-soft);
}

.levels dd {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.42;
}

/* Difficulty marks, shared by the legend and the cards */
.level {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.level::before {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  content: "";
}

.level-1::before {
  background: var(--level-1);
}

.level-2::before {
  background: var(--level-2);
}

.level-3::before {
  background: var(--level-3);
}

.level-4::before {
  background: var(--level-4);
}

/* Tool */
.tool {
  display: grid;
  gap: 28px;
  padding: 0 var(--gutter) clamp(56px, 8vw, 104px);
}

.filters {
  display: grid;
  gap: 20px;
  min-width: 0;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.group,
.search {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.group-label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.search input {
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--hair);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  letter-spacing: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder {
  color: var(--ink-faint);
}

.search input:focus {
  box-shadow: 0 0 0 1px var(--accent);
}

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

/* On a phone the twelve fields scroll sideways in one row instead of pushing the list down. */
.chips-fields {
  flex-wrap: nowrap;
  margin-inline: -20px;
  padding: 3px 20px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips-fields::-webkit-scrollbar {
  display: none;
}

.pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 16px;
  border: 0;
  border-radius: 980px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  letter-spacing: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.pill:hover {
  box-shadow: 0 0 0 1px var(--line);
}

.pill-name {
  display: inline-flex;
  align-items: center;
}

.pill-count {
  color: var(--ink-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.pill[aria-pressed="true"] {
  background: var(--ink);
  box-shadow: none;
  color: #fff;
}

.pill[aria-pressed="true"] .pill-count {
  color: #a1a1a6;
}

.pill-none {
  opacity: 0.45;
}

.pill-level-1 .pill-name::before,
.pill-level-2 .pill-name::before,
.pill-level-3 .pill-name::before,
.pill-level-4 .pill-name::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  content: "";
}

.pill-level-1 .pill-name::before {
  background: var(--level-1);
}

.pill-level-2 .pill-name::before {
  background: var(--level-2);
}

.pill-level-3 .pill-name::before {
  background: var(--level-3);
}

.pill-level-4 .pill-name::before {
  background: var(--level-4);
}

.pill-level-3[aria-pressed="true"] .pill-name::before {
  background: #ff7a33;
}

.pill-level-4[aria-pressed="true"] .pill-name::before {
  background: #fff;
}

/* Results */
.results {
  min-width: 0;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.count {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.sort select {
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 980px;
  background-color: var(--bg-soft);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  letter-spacing: inherit;
  cursor: pointer;
}

.reset {
  min-height: 40px;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 15px;
  letter-spacing: inherit;
  cursor: pointer;
}

.reset:hover {
  text-decoration: underline;
}

.list {
  display: grid;
  gap: clamp(14px, 1.8vw, 22px);
  margin-top: clamp(18px, 2.4vw, 26px);
  scroll-margin-top: 72px;
}

.problem {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
}

.meta .level {
  font-size: 13px;
}

.field {
  color: var(--ink-soft);
  font-size: 13px;
}

.problem h2 {
  font-size: clamp(21px, 2.2vw, 24px);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.022em;
}

.problem dl {
  display: grid;
  gap: 12px;
}

.problem dt {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.problem dd {
  margin-top: 2px;
  font-size: 16px;
  line-height: 1.42;
}

.problem dl div:last-child dd {
  font-weight: 600;
}

.source {
  padding-top: 14px;
  border-top: 1px solid var(--hair);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.source q {
  font-style: normal;
}

.source a {
  display: inline-block;
  margin-left: 6px;
  padding-block: 2px;
  color: var(--accent-ink);
  text-decoration: none;
  white-space: nowrap;
}

.source a:hover {
  text-decoration: underline;
}

.empty {
  display: grid;
  justify-items: start;
  gap: 14px;
  margin-top: clamp(18px, 2.4vw, 26px);
  padding: 32px 26px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--ink-soft);
}

.empty .reset {
  padding: 10px 20px;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  transition: background 0.2s;
}

.empty .reset:hover {
  background: #0077ed;
  text-decoration: none;
}

/* Closing statement: the black band */
.closing {
  padding: clamp(64px, 10vw, 120px) var(--gutter);
  background: #000;
  color: #f5f5f7;
  text-align: center;
}

.closing p {
  color: #a1a1a6;
  font-size: clamp(18px, 2vw, 21px);
}

.closing strong {
  display: block;
  max-width: 24ch;
  margin: 12px auto 0;
  font-size: clamp(28px, 4.6vw, 52px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.button {
  display: inline-block;
  margin-top: 32px;
  padding: 12px 22px;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  text-decoration: none;
  transition: background 0.2s;
}

.button:hover {
  background: #0077ed;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 22px var(--gutter) 40px;
  color: var(--ink-soft);
  font-size: 13px;
}

footer a {
  color: var(--accent-ink);
  text-decoration: none;
}

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

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .problem {
    padding: 22px;
  }
}

@media (min-width: 560px) {
  .levels div {
    padding: 18px 20px;
  }

  .levels dd {
    font-size: 15px;
  }
}

@media (min-width: 700px) {
  .list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  .levels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(10px, 1.4vw, 16px);
  }
}

@media (min-width: 980px) {
  .tool {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 36px;
    align-items: start;
  }

  .filters {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 92px);
    overflow-y: auto;
  }

  .chips-fields {
    flex-wrap: wrap;
    margin-inline: 0;
    padding: 0;
    overflow: visible;
  }

  .pill {
    min-height: 36px;
    padding: 5px 14px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
