/* Listening Practice — teacher resource library.
   A reading page, not a dashboard: one column, generous rows, and the three
   things a lesson needs (play, view, download) always in the same place. */

.lp-main {
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
  padding: var(--space-6) var(--space-5) var(--space-10);
}

.lp-intro {
  margin-bottom: var(--space-6);
}

.lp-h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.lp-sub {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Filters ───────────────────────────────────────────────────────────────── */

.lp-filters {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.lp-search {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 300px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  outline: none;
}

.lp-search:focus-visible,
.lp-select:focus-visible {
  border-color: var(--accent);
}

.lp-select {
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}

.lp-levels {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lp-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* ── Chips ─────────────────────────────────────────────────────────────────── */

.lp-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.lp-chip--level {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: transparent;
  letter-spacing: 0.04em;
}

.lp-chip--btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}

.lp-chip--btn:hover {
  color: var(--text);
}

.lp-chip--on {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* ── Exercise row ──────────────────────────────────────────────────────────── */

.lp-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.lp-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.lp-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.lp-titles {
  flex: 1;
  min-width: 0;
}

.lp-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.3;
  text-wrap: balance;
}

.lp-desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.lp-meta {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── Player ────────────────────────────────────────────────────────────────── */

.lp-player {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}

.lp-player--failed {
  opacity: 0.75;
}

.lp-play {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, filter 0.12s;
}

.lp-play svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.lp-play:hover:not(:disabled) {
  filter: brightness(1.08);
}

.lp-play:active:not(:disabled) {
  transform: scale(0.95);
}

.lp-play:disabled {
  background: var(--surface-3);
  color: var(--muted-2);
  cursor: not-allowed;
}

.lp-transport {
  flex: 1 1 260px;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.lp-time {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 38px;
}

.lp-time--total {
  text-align: right;
}

/* The seek bar. A native range keeps keyboard and touch behaviour; the track is
   painted from --lp-pct so progress and the thumb never drift apart. */
.lp-track {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.lp-track input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.lp-track input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--lp-pct, 0%),
    var(--surface-3) var(--lp-pct, 0%),
    var(--surface-3) 100%
  );
}

.lp-track input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--lp-pct, 0%),
    var(--surface-3) var(--lp-pct, 0%),
    var(--surface-3) 100%
  );
}

.lp-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}

.lp-track input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.lp-track input[type="range"]:disabled::-webkit-slider-thumb {
  background: var(--muted-2);
}

.lp-track input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-full);
}

/* Speed. Fixed steps, all visible: during a lesson this is one tap, never a menu. */
.lp-speeds {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.lp-speed {
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.14s, color 0.14s;
}

.lp-speed:hover {
  color: var(--text);
}

.lp-speed--on {
  background: var(--accent-dim);
  color: var(--accent);
}

.lp-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--muted);
}

.lp-volume-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.lp-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 74px;
  height: 16px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.lp-volume input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
}

.lp-volume input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
}

.lp-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--muted);
}

.lp-volume input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: none;
  border-radius: 50%;
  background: var(--muted);
}

.lp-failed {
  flex: 1 1 100%;
  font-size: 0.75rem;
  color: var(--danger);
  word-break: break-all;
}

/* ── Actions ───────────────────────────────────────────────────────────────── */

.lp-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.lp-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s, border-color 0.12s, color 0.12s;
}

.lp-btn:hover {
  filter: brightness(1.08);
}

.lp-btn--quiet {
  background: transparent;
  border-color: var(--border-2);
  color: var(--text);
}

.lp-btn--quiet:hover {
  border-color: var(--accent);
  color: var(--accent);
  filter: none;
}

.lp-btn-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── PDF viewer ────────────────────────────────────────────────────────────── */

.lp-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.lp-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1000px;
  height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.lp-modal-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lp-modal-title {
  flex: 1;
  min-width: 0;
  font-weight: 650;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-modal-bar .lp-btn {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.lp-modal-close {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.lp-modal-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--surface-2);
}

/* ── Small screens ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .lp-main {
    padding: var(--space-5) var(--space-4) var(--space-8);
  }

  .lp-row {
    padding: var(--space-4);
  }

  .lp-player {
    gap: var(--space-3);
  }

  .lp-transport {
    order: 3;
    flex-basis: 100%;
  }

  .lp-speeds {
    order: 4;
  }

  .lp-volume {
    order: 5;
    margin-left: auto;
  }

  .lp-actions .lp-btn {
    flex: 1;
    justify-content: center;
  }

  .lp-modal {
    height: 94dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lp-play,
  .lp-btn,
  .lp-speed,
  .lp-chip--btn {
    transition: none;
  }
}

/* ── Authoring ─────────────────────────────────────────────────────────────── */

.lp-intro-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.lp-intro-row .lp-h1 {
  flex: 1;
  min-width: 0;
}

.lp-form {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.lp-form-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.lp-form-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  flex: 1;
}

.lp-form-delete {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font: inherit;
  font-size: 0.78rem;
  padding: 5px 12px;
  cursor: pointer;
}

.lp-form-delete:hover {
  border-color: var(--danger);
}

.lp-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}

.lp-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.lp-field--wide {
  grid-column: 1 / -1;
}

.lp-field > span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.lp-field > span em {
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted-2);
  margin-left: 6px;
}

.lp-field input,
.lp-field select,
.lp-field textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  box-sizing: border-box;
  outline: none;
}

.lp-field textarea {
  resize: vertical;
  line-height: 1.5;
  font-size: 0.82rem;
  min-height: 140px;
  /* Indentation carries meaning in these boxes, so keep it visible as typed. */
  tab-size: 2;
}

.lp-field input:focus-visible,
.lp-field select:focus-visible,
.lp-field textarea:focus-visible {
  border-color: var(--accent);
}

/* Upload */

.lp-upload {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.lp-upload-btn {
  cursor: pointer;
  flex-shrink: 0;
}

.lp-upload-state {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lp-upload-state--ok {
  color: var(--green);
}

.lp-upload-bar {
  display: block;
  width: 120px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
  flex-shrink: 0;
}

.lp-upload-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.2s;
}

/* The three sheets, side by side on a wide screen. */
.lp-sheets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-3);
}

.lp-form-hint {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted-2);
  line-height: 1.5;
}

.lp-form-error {
  margin: 0;
  font-size: 0.82rem;
  color: var(--danger);
}

.lp-form-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ── Sheet buttons on a row ────────────────────────────────────────────────── */

.lp-sheet-pair {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}

.lp-sheet-pair .lp-btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.lp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.lp-icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* The answer key is a teacher's copy, and should never be picked up by mistake. */
.lp-btn--key {
  background: transparent;
  border-color: var(--border-2);
  color: var(--muted);
}

.lp-btn--key:hover {
  border-color: var(--amber, #f0c060);
  color: var(--amber, #f0c060);
  filter: none;
}

.lp-nosheet {
  font-size: 0.8rem;
  color: var(--muted-2);
  align-self: center;
}

/* A sheet is being drawn; the press has landed even though nothing moved yet. */
.lp-list--busy {
  cursor: progress;
}

@media (max-width: 640px) {
  .lp-sheets {
    grid-template-columns: 1fr;
  }
}

/* How much writing room each outline point gets — set beside the box it affects. */
.lp-lines {
  margin-left: 8px;
  padding: 1px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

/* Which kind of test this is. Two cards, because the choice changes the form. */
.lp-kinds {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.lp-kind {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}

.lp-kind em {
  font-style: normal;
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--muted-2);
}

/* Declared after --on would win on equal specificity, so exclude the chosen
   card: hovering the selection must not repaint it as an unselected one. */
.lp-kind:not(.lp-kind--on):hover {
  color: var(--text);
}

.lp-kind--on {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.lp-kind--on em {
  color: var(--accent);
  opacity: 0.75;
}

/* Two boxes instead of three get more room each. */
.lp-sheets--two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* The line-count sits inside its label, not under it: .lp-field's full-width
   rule for selects would otherwise turn it into a field of its own. */
.lp-field > span > .lp-lines {
  width: auto;
  display: inline-block;
  vertical-align: middle;
}

/* ── Choosing the kind of practice ─────────────────────────────────────────── */

.lp-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.lp-pick {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, transform 0.12s;
}

.lp-pick:not(.lp-pick--on):hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.lp-pick--on {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.lp-pick-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

.lp-pick--on .lp-pick-icon {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
}

.lp-pick-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lp-pick-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.lp-pick-title {
  font-size: 0.95rem;
  font-weight: 650;
}

.lp-pick--on .lp-pick-title {
  color: var(--accent);
}

.lp-pick-sub {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.lp-pick-count {
  flex-shrink: 0;
  align-self: flex-start;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.lp-pick--on .lp-pick-count {
  color: var(--accent);
}
