/* Problem sets
   Compact curriculum and practice-list surfaces built on the shared RiseOJ
   tokens. Everything is scoped so legacy tool pages remain untouched. */

.problemset-page {
  background: var(--bg);
  color: var(--ink);
}

.ps-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 72px;
}

.ps-shell a {
  text-underline-offset: 3px;
}

.ps-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 28px;
  color: var(--dim);
  font-size: 12.5px;
}

.ps-breadcrumb a {
  color: var(--dim);
  text-decoration: none;
}

.ps-breadcrumb a:hover {
  color: var(--ink);
}

.ps-breadcrumb span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 40px;
  align-items: end;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--hair);
}

.ps-eyebrow {
  margin-bottom: 10px;
  color: var(--dim);
  font-family: var(--font-mono-ds);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.ps-eyebrow::before {
  content: "+ ";
  color: var(--indigo);
}

.ps-hero h1,
.ps-directory-head h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  font-stretch: 107%;
  font-weight: 780;
  letter-spacing: -.025em;
  line-height: 1.08;
}

.ps-summary {
  max-width: 72ch;
  margin: 13px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.7;
}

.ps-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  margin-top: 16px;
  color: var(--dim);
  font-size: 12.5px;
}

.ps-meta span {
  position: relative;
}

.ps-meta span + span::before {
  position: absolute;
  left: -10px;
  color: var(--hair);
  content: "/";
}

.ps-meta a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.ps-hero-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.ps-progress {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(120px, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--hair);
}

.ps-progress > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.ps-progress-label {
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
}

.ps-progress strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.ps-progress-track,
.ps-stage-mini-track {
  display: block;
  overflow: hidden;
  height: 5px;
  background: color-mix(in srgb, var(--hair) 76%, transparent);
  border-radius: 999px;
}

.ps-progress-track > span,
.ps-stage-mini-track > i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ac);
  border-radius: inherit;
  transition: width 220ms cubic-bezier(.22, 1, .36, 1);
}

.ps-progress-percent {
  min-width: 40px;
  color: var(--dim);
  font-size: 12px;
  text-align: right;
}

.ps-stage-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-right: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  margin: 22px 0 0;
}

.ps-stage-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 11px 12px;
  border-top: 1px solid var(--hair);
  border-left: 1px solid var(--hair);
  color: var(--text-2);
  font-size: 12px;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}

.ps-stage-link > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-stage-link > span:first-child,
.ps-stage-link small {
  color: var(--dim);
  font-size: 10.5px;
}

.ps-stage-link:hover,
.ps-stage-link:focus-visible {
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.ps-stage-link:focus-visible {
  box-shadow: inset 0 0 0 2px var(--indigo);
}

.ps-tool-panel {
  margin-top: 16px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
}

.ps-tool-panel > summary {
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
}

.ps-tool-panel > summary::-webkit-details-marker {
  display: none;
}

.ps-tool-panel > summary::after {
  margin-left: auto;
  color: var(--dim);
  content: "+";
  font-family: var(--font-mono-ds);
  font-size: 16px;
  font-weight: 400;
}

.ps-tool-panel[open] > summary::after {
  content: "−";
}

.ps-summary-hint {
  color: var(--dim);
  font-size: 11.5px;
  font-weight: 450;
}

.ps-tool-body,
.ps-mock-form {
  padding: 14px;
  border-top: 1px solid var(--hair);
}

.ps-add-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.ps-add-form .field,
.ps-mock-form .field {
  margin: 0;
}

.ps-add-form .btn,
.ps-mock-form .btn {
  min-height: 38px;
}

.ps-search-form {
  max-width: 640px;
  margin-top: 16px;
}

.ps-search-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.ps-search-results {
  max-width: 760px;
  margin-top: 10px;
  border-top: 1px solid var(--hair);
}

.ps-search-result {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 12.5px;
}

.ps-search-result > span:first-child {
  color: var(--dim);
  font-size: 11.5px;
}

.ps-mock-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 220px) auto auto;
  gap: 10px;
  align-items: end;
}

.ps-mock-form .is-locked {
  opacity: .55;
}

.ps-content {
  margin-top: 38px;
}

.ps-stage {
  scroll-margin-top: 112px;
  padding: 0 0 48px;
}

.ps-stage + .ps-stage {
  padding-top: 12px;
}

.ps-stage-head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

.ps-stage-number {
  color: var(--indigo);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .08em;
}

.ps-stage-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--dim);
  font-family: var(--font-mono-ds);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ps-stage h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 22px;
  font-stretch: 107%;
  font-weight: 760;
  letter-spacing: -.018em;
  line-height: 1.18;
}

.ps-stage-score {
  display: grid;
  grid-template-columns: auto 68px;
  gap: 10px;
  align-items: center;
  color: var(--dim);
  font-size: 11.5px;
}

.ps-stage-mini-track {
  height: 4px;
}

.ps-stage-description {
  max-width: 78ch;
  margin: 0 0 20px 60px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.72;
}

.ps-problem-list {
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}

.ps-problem-head,
.ps-problem-row {
  display: grid;
  grid-template-columns: 18px 36px 90px minmax(200px, 1fr) 150px minmax(80px, 110px);
  gap: 12px;
  align-items: center;
}

.ps-problem-list:has(.ps-remove-form) .ps-problem-head,
.ps-problem-list:has(.ps-remove-form) .ps-problem-row {
  grid-template-columns: 18px 36px 90px minmax(200px, 1fr) 150px minmax(80px, 110px) 28px;
}

.ps-problem-head {
  min-height: 35px;
  padding: 0 14px;
  border-bottom: 1px solid var(--hair);
  background: color-mix(in srgb, var(--panel) 62%, transparent);
  color: var(--dim);
  font-family: var(--font-mono-ds);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ps-problem-row {
  position: relative;
  min-height: 49px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--hair);
  background: transparent;
  transition: background 160ms ease;
}

.ps-problem-row:last-child {
  border-bottom: 0;
}

.ps-problem-row:hover {
  background: var(--panel);
}

.ps-problem-row.is-solved {
  background: color-mix(in srgb, var(--ac) 7%, transparent);
  box-shadow: inset 3px 0 0 var(--ac);
}

.ps-problem-row.is-solved:hover {
  background: color-mix(in srgb, var(--ac) 11%, var(--panel));
}

.ps-problem-status {
  width: 8px;
  height: 8px;
  justify-self: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}

.ps-problem-row.is-solved .ps-problem-status {
  border-color: var(--ac);
  background: var(--ac);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ac) 16%, transparent);
}

.ps-problem-row.is-attempted .ps-problem-status {
  border-color: var(--wa);
}

.ps-problem-number,
.ps-problem-id {
  color: var(--dim);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.ps-problem-id,
.ps-problem-title,
.ps-problem-tier {
  text-decoration: none;
}

.ps-problem-id:hover {
  color: var(--indigo);
}

.ps-problem-title {
  display: flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 610;
}

.ps-problem-title > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-problem-row.is-solved .ps-problem-title {
  color: var(--ac);
}

.ps-problem-row.is-solved .ps-problem-number,
.ps-problem-row.is-solved .ps-problem-id {
  color: color-mix(in srgb, var(--ac) 82%, var(--ink));
}

.ps-problem-row:hover .ps-problem-title:not(:hover) {
  color: var(--ink);
}

.ps-problem-row.is-solved:hover .ps-problem-title:not(:hover) {
  color: var(--ac);
}

.ps-problem-title:hover {
  text-decoration: underline;
}

.ps-problem-mobile-meta {
  display: none;
}

.ps-problem-tier {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-self: start;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 11.5px;
}

.ps-problem-tier:hover span {
  text-decoration: underline;
}

.ps-problem-source {
  overflow: hidden;
  color: var(--dim);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-remove-form {
  margin: 0;
}

.ps-remove {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font: 17px/1 var(--font-body);
}

.ps-remove:hover,
.ps-remove:focus-visible {
  border-color: color-mix(in srgb, var(--wa) 45%, var(--hair));
  background: var(--danger-soft);
  color: var(--wa);
  outline: none;
}

.ps-empty-inline {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  color: var(--dim);
  font-size: 13px;
}

/* Directory */
.ps-directory {
  max-width: 1040px;
}

.ps-directory-head {
  display: flex;
  gap: 28px;
  align-items: end;
  justify-content: space-between;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--hair);
}

.ps-directory-head p {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 13.5px;
}

.ps-set-list {
  overflow: hidden;
  margin-top: 22px;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}

.ps-set-head,
.ps-set-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 80px 150px 90px;
  gap: 18px;
  align-items: center;
  padding: 0 16px;
}

.ps-set-head {
  min-height: 36px;
  border-bottom: 1px solid var(--hair);
  background: color-mix(in srgb, var(--panel) 62%, transparent);
  color: var(--dim);
  font-family: var(--font-mono-ds);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ps-set-row {
  min-height: 68px;
  border-bottom: 1px solid var(--hair);
  color: var(--text-2);
  font-size: 12.5px;
  text-decoration: none;
  transition: background 160ms ease;
}

.ps-set-row:last-child {
  border-bottom: 0;
}

.ps-set-row:hover,
.ps-set-row:focus-visible {
  background: var(--panel);
  outline: none;
}

.ps-set-row:focus-visible {
  box-shadow: inset 0 0 0 2px var(--indigo);
}

.ps-set-primary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ps-set-primary strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-set-primary small {
  overflow: hidden;
  color: var(--dim);
  font-size: 11.5px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-set-count,
.ps-visibility {
  color: var(--dim);
}

.ps-empty-state {
  padding: 56px 0;
  border-bottom: 1px solid var(--hair);
}

.ps-empty-state h2 {
  margin: 0;
  font-size: 18px;
}

.ps-empty-state p {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 13.5px;
}

@media (max-width: 900px) {
  .ps-stage-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ps-problem-head,
  .ps-problem-row,
  .ps-problem-list:has(.ps-remove-form) .ps-problem-head,
  .ps-problem-list:has(.ps-remove-form) .ps-problem-row {
    grid-template-columns: 18px 32px 82px minmax(180px, 1fr) 130px 28px;
  }

  .ps-problem-source,
  .ps-problem-head > span:nth-child(6) {
    display: none;
  }

  .ps-set-head,
  .ps-set-row {
    grid-template-columns: minmax(240px, 1fr) 72px 130px;
  }

  .ps-set-head > span:last-child,
  .ps-set-row > span:last-child {
    display: none;
  }
}

@media (max-width: 700px) {
  .ps-shell {
    width: min(100% - 28px, 1180px);
    padding-top: 24px;
  }

  .ps-hero {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .ps-hero-actions {
    justify-content: flex-start;
  }

  .ps-progress {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .ps-progress-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .ps-stage-nav {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    scrollbar-width: thin;
  }

  .ps-stage-link {
    grid-template-columns: auto minmax(100px, auto) auto;
    flex: 0 0 auto;
    min-width: 180px;
    border-right: 1px solid var(--hair);
  }

  .ps-add-form,
  .ps-mock-form {
    grid-template-columns: 1fr;
  }

  .ps-add-form .btn,
  .ps-mock-form .btn {
    width: 100%;
  }

  .ps-summary-hint {
    display: none;
  }

  .ps-stage-head {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .ps-stage-description {
    margin-left: 44px;
  }

  .ps-problem-head {
    display: none;
  }

  .ps-problem-row,
  .ps-problem-list:has(.ps-remove-form) .ps-problem-row {
    grid-template-columns: 14px 28px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 58px;
    padding: 8px 10px;
  }

  .ps-problem-id {
    display: none;
  }

  .ps-problem-title {
    display: grid;
    gap: 2px;
    align-items: center;
  }

  .ps-problem-title > span:first-child {
    font-size: 13px;
  }

  .ps-problem-mobile-meta {
    display: block;
    overflow: hidden;
    color: var(--dim);
    font-size: 10.5px;
    font-weight: 450;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ps-problem-tier {
    justify-self: end;
  }

  .ps-problem-tier span {
    display: none;
  }

  .ps-remove-form {
    position: absolute;
    top: 29px;
    right: 6px;
  }

  .ps-problem-list:has(.ps-remove-form) .ps-problem-tier {
    margin-right: 24px;
  }

  .ps-directory-head {
    align-items: flex-start;
  }

  .ps-set-head {
    display: none;
  }

  .ps-set-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    min-height: 72px;
    padding: 10px 13px;
  }

  .ps-set-row > span:nth-child(3),
  .ps-set-row > span:nth-child(4) {
    display: none;
  }
}

@media (max-width: 430px) {
  .ps-hero-actions,
  .ps-directory-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ps-hero-actions .btn,
  .ps-directory-head .btn {
    width: 100%;
  }

  .ps-stage-score {
    grid-template-columns: auto;
  }

  .ps-stage-mini-track {
    display: none;
  }

  .ps-stage-description {
    margin-left: 0;
  }

  .ps-search-form > div {
    grid-template-columns: 1fr;
  }

  .ps-search-result {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .ps-search-result form {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ps-progress-track > span,
  .ps-stage-mini-track > i,
  .ps-stage-link,
  .ps-problem-row,
  .ps-set-row {
    transition: none;
  }
}
