/* Pages: question bank filters, homework list, homework session. */

/* ---- Question bank ---- */

.filters {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .filters {
    grid-template-columns: 2fr 1fr 1fr;
    align-items: end;
  }
}

.filters .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.filters .field label {
  font-size: var(--t-s);
  font-weight: 500;
}

.filters .field select {
  width: 100%;
  min-width: 0;
}

.filters__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 44px;
  margin: 1rem 0 2rem;
  font-size: var(--t-s);
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
}

.filters__meta p {
  margin: 0;
}

.filters__meta .btn--quiet {
  padding-inline: 0;
}

.bank__empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.bank__empty .state {
  margin: 0;
}

/* Workspace: questions, a draggable divider, and the Desmos calculator.
   Narrow screens stack the calculator under the questions. */

.workspace__divider {
  display: none;
}

.workspace__calculator {
  height: min(75vh, 36rem);
  margin-top: 2.5rem;
}

/* Focusable only so a click on the graph keeps arrow keys in the calculator. */
.workspace__calculator:focus {
  outline: none;
}

.workspace__desmos {
  width: 100%;
  height: 100%;
}

/* Wide screens: side by side, filling the rest of the viewport, each pane
   scrolling on its own. --split is the left pane's share, set by workspace.js. */
@media (min-width: 800px) {
  body:has(> main > .workspace) {
    display: flex;
    flex-direction: column;
  }

  main:has(> .workspace) {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 1.5rem;
  }

  .workspace {
    --divider: 1.5rem;
    flex: 1 0 0;
    min-height: 22rem;
    display: grid;
    grid-template-columns:
      minmax(0, calc((100% - var(--divider)) * var(--split, 0.5)))
      var(--divider)
      minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  /* The pane scrolls, so it reaches 8px past the gutter to keep focus rings
     and the deck's slide-in clip visible. */
  .workspace__questions {
    margin-inline-start: -8px;
    padding: 4px 0.75rem 2rem 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .workspace__calculator {
    height: auto;
    margin: 0;
  }

  .workspace__divider {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    touch-action: none;
  }

  .workspace__divider::before {
    content: "";
    position: absolute;
    inset-block: 0;
    left: calc(50% - 0.5px);
    width: 1px;
    background: var(--rule);
  }

  .workspace__divider:hover::before,
  .workspace--dragging .workspace__divider::before {
    background: var(--ink);
  }

  .workspace__grip {
    position: relative;
    width: 0.875rem;
    height: 2.75rem;
    border-radius: 999px;
    background:
      linear-gradient(var(--paper), var(--paper)) calc(50% - 2px) 50% / 1.5px 1rem no-repeat,
      linear-gradient(var(--paper), var(--paper)) calc(50% + 2px) 50% / 1.5px 1rem no-repeat,
      var(--ink);
  }

  .workspace__divider:focus-visible {
    outline: none;
  }

  .workspace__divider:focus-visible .workspace__grip {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
  }

  .workspace--dragging {
    cursor: col-resize;
    user-select: none;
  }
}

@media (forced-colors: active) {
  .workspace__divider::before {
    background: CanvasText;
  }

  .workspace__grip {
    forced-color-adjust: none;
    background: CanvasText;
  }
}

/* ---- Homework list ---- */

.hw-intro {
  margin: 0.5rem 0 0;
  color: var(--graphite);
}

.hw-chapter h2 {
  margin: 2.5rem 0 1rem;
}

.hw-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1rem;
}

.hw-grid > li {
  display: flex;
}

.hw-box {
  display: flex;
  flex-direction: column;
  flex: 1;
  border: 1.5px solid var(--ink);
  border-radius: var(--r-box);
  padding: 1.1rem 1.1rem 1rem;
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
}

a.hw-box:hover {
  background: var(--wash);
}

.hw-box--optional {
  border-style: dashed;
}

.hw-box--reading {
  border: 1.5px dashed var(--graphite);
}

.hw-box__num {
  display: block;
  font-size: var(--t-xxl);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hw-box__title {
  display: block;
  margin: 0.5rem 0 1rem;
  font-size: var(--t-s);
  line-height: 1.35;
  color: var(--graphite);
}

.hw-box__meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: auto;
  font-size: var(--t-s);
  font-variant-numeric: tabular-nums;
}

.hw-box__line {
  display: block;
}

.hw-box__line--quiet,
.hw-box__task {
  color: var(--graphite);
}

.hw-box__bar {
  display: block;
  height: 4px;
  margin: 0.5rem 0 0.2rem;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}

.hw-box__fill {
  display: block;
  height: 100%;
  background: var(--blue);
}

.hw-box__done {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  background: var(--highlight);
  font-weight: 500;
}

/* ---- Homework session ---- */

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  font-size: var(--t-s);
}

.hw-session__sub {
  margin: 0.5rem 0 0;
  color: var(--graphite);
}

.hw-session__task {
  margin: 1.5rem 0 0;
}

.hw-session__deck:focus {
  outline: none;
}

.progress {
  margin: 1.5rem 0 2rem;
}

.progress__label {
  margin: 0 0 0.5rem;
  font-size: var(--t-s);
  font-variant-numeric: tabular-nums;
}

.progress__label strong {
  font-weight: 600;
}

.progress__bar {
  height: 8px;
  border-radius: 4px;
  background: var(--rule);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--blue);
  transition: width 220ms ease-out;
}

.hw-done {
  padding: 2rem 0 0;
  border-top: 1px solid var(--rule);
}

.hw-done h2 {
  margin: 0 0 1.25rem;
}

.hw-done h2:focus {
  outline: none;
}

.hw-done__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hw-done__actions a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .progress__fill {
    transition: none;
  }
}

/* Account progress uses the site's existing blue and yellow status accents. */
.sync-status {
  padding: 1rem var(--gutter) 0;
  font-size: var(--t-s);
  color: var(--graphite);
}

.sync-status > .btn {
  margin-top: .5rem;
}

.sync-status__note {
  max-width: 65ch;
  margin-top: .5rem;
}

.completion {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.completion__toggle--done {
  background: var(--highlight-soft);
}

.completion__toggle--done:hover {
  background: var(--highlight);
}

.completion__feedback {
  flex: 1 1 10rem;
  font-size: var(--t-s);
  color: var(--graphite);
}
