.learning-page {
  background:
    radial-gradient(circle at 9% 22%, rgb(159 216 180 / 22%), transparent 28rem),
    radial-gradient(circle at 92% 82%, rgb(116 213 223 / 15%), transparent 26rem),
    var(--paper);
}

.learning-breadcrumb,
.learning-hero,
.learning-tool,
.learning-summary {
  width: min(1180px, calc(100% - 2rem));
  margin-right: auto;
  margin-left: auto;
}

.learning-breadcrumb {
  margin-top: 1.35rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--navy-650);
  font-size: 0.78rem;
  font-weight: 750;
}

.learning-breadcrumb a {
  color: var(--navy-800);
  text-underline-offset: 0.2em;
}

.learning-hero {
  padding: clamp(2.25rem, 5vw, 4.5rem) 0 clamp(1.75rem, 4vw, 3rem);
}

.learning-hero h1 {
  max-width: none;
  margin: 0 0 1rem;
  font-size: clamp(2.7rem, 5vw, 4.15rem);
  letter-spacing: -0.065em;
}

.learning-intro {
  max-width: none;
  margin-bottom: 0;
  color: var(--navy-650);
  font-size: clamp(1rem, 2vw, 1.14rem);
}

.related-tool-link {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--navy-800);
  font-size: 0.9rem;
  font-weight: 850;
  text-underline-offset: 0.2em;
}

.learning-tool {
  overflow: hidden;
  border: 1px solid rgb(11 30 45 / 9%);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(11 30 45 / 12%);
}

.activity-tabs {
  padding: 0.8rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  border-bottom: 1px solid var(--line);
  background: #f5faf7;
}

.activity-tab,
.label-button,
.cell-target,
.match-button,
.reset-button {
  font: inherit;
  cursor: pointer;
}

.activity-tab {
  min-height: 4rem;
  padding: 0.75rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  color: var(--navy-650);
  background: transparent;
  font-size: 1.15rem;
  font-weight: 850;
}

.activity-tab span {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #28784c;
  background: #dff3e7;
  font-size: 0.9rem;
}

.activity-tab:hover {
  color: var(--navy-950);
  background: rgb(255 255 255 / 72%);
}

.activity-tab[aria-selected="true"] {
  border-color: rgb(40 120 76 / 16%);
  color: var(--navy-950);
  background: var(--surface);
  box-shadow: 0 5px 18px rgb(11 30 45 / 8%);
}

.activity-tab[aria-selected="true"] span {
  color: white;
  background: #28784c;
}

.activity-heading {
  padding: clamp(1.25rem, 3vw, 2rem);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
}

.activity-kicker {
  margin-bottom: 0.25rem;
  color: #28784c;
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.activity-heading h2 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  letter-spacing: -0.045em;
}

.activity-heading p:last-child {
  max-width: none;
  margin-bottom: 0;
  color: var(--navy-650);
  font-size: 0.88rem;
}

.activity-progress {
  width: min(220px, 100%);
  display: grid;
  gap: 0.45rem;
  flex: 0 0 auto;
  color: var(--navy-650);
  font-size: 0.7rem;
  font-weight: 800;
}

.activity-progress span {
  text-align: right;
}

.activity-progress progress {
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e8f0ec;
  accent-color: #28784c;
}

.activity-progress progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e8f0ec;
}

.activity-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #55b980, #168ca0);
}

.activity-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: #28784c;
}

.activity-panel {
  min-height: 550px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgb(11 30 45 / 2%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(11 30 45 / 2%) 1px, transparent 1px),
    #fbfdfa;
  background-size: 30px 30px;
}

.labelling-panel {
  padding: clamp(1rem, 2.5vw, 1.6rem);
  display: grid;
  grid-template-columns: minmax(190px, 0.32fr) minmax(0, 1fr);
  gap: clamp(1rem, 2.5vw, 1.7rem);
}

.label-tray {
  padding: 1rem;
  align-self: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 8px 24px rgb(11 30 45 / 6%);
}

.tray-heading {
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tray-heading h3 {
  margin-bottom: 0;
  font-size: 1.12rem;
}

.tray-heading span {
  color: var(--navy-650);
  font-size: 0.78rem;
  font-weight: 750;
}

.label-list {
  display: grid;
  gap: 0.55rem;
}

.label-button {
  width: 100%;
  min-height: 2.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cfe1d6;
  border-radius: 0.75rem;
  color: var(--navy-800);
  background: #f5fbf7;
  font-size: 0.95rem;
  font-weight: 800;
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.label-button:hover:not(:disabled),
.label-button[aria-pressed="true"] {
  border-color: #28784c;
  color: var(--navy-950);
  background: #e3f4e9;
  transform: translateY(-1px);
}

.label-button:disabled {
  border-color: var(--line);
  color: #73848e;
  background: #f1f5f3;
  cursor: default;
  text-decoration: line-through;
}

.label-button.is-dragging {
  opacity: 0.55;
}

.cell-stage {
  min-width: 0;
  display: grid;
  place-items: center;
}

.cell-diagram {
  width: 100%;
  max-width: 850px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgb(11 30 45 / 8%);
  border-radius: 22px;
  background: #fffcf5;
  box-shadow: 0 16px 38px rgb(11 30 45 / 9%);
}

.cell-diagram img {
  width: 100%;
  height: auto;
  display: block;
}

.cell-target {
  position: absolute;
  top: var(--target-y);
  left: var(--target-x);
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  border: 3px solid white;
  border-radius: 999px;
  color: white;
  background: var(--navy-950);
  box-shadow:
    0 0 0 2px rgb(11 30 45 / 28%),
    0 7px 18px rgb(11 30 45 / 22%);
  font-size: 0.75rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
  transition:
    background 150ms ease,
    transform 150ms ease;
  white-space: nowrap;
}

.cell-target:hover:not(:disabled),
.cell-target.is-drop-ready {
  background: #168ca0;
  transform: translate(-50%, -50%) scale(1.08);
}

.cell-target.is-correct {
  color: white;
  background: #28784c;
}

.cell-target.is-error {
  background: var(--coral-deep);
  animation: target-shake 260ms ease;
}

.activity-footer {
  min-height: 74px;
  padding: 0.9rem clamp(1.25rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  background: #fbfdfa;
}

.activity-feedback {
  margin: 0;
  color: var(--navy-650);
  font-size: 0.95rem;
  font-weight: 750;
}

.activity-feedback.is-success {
  color: #216b43;
}

.activity-feedback.is-error {
  color: #a74448;
}

.reset-button {
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--navy-800);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 850;
  white-space: nowrap;
}

.reset-button:hover {
  border-color: #28784c;
  background: #f0f9f3;
}

.matching-panel {
  padding: clamp(1rem, 3vw, 2rem);
  position: relative;
}

#match-lines {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.matching-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: clamp(4rem, 14vw, 10rem);
}

.match-column {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.match-heading {
  margin-bottom: 0.35rem;
}

.match-heading h3 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.match-button {
  min-height: 3.3rem;
  padding: 0.68rem 0.78rem;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  color: var(--navy-800);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 5px 16px rgb(11 30 45 / 5%);
  font-size: 0.9rem;
  font-weight: 750;
  text-align: left;
}

.match-button:hover:not(:disabled),
.match-button[aria-pressed="true"] {
  border-color: #168ca0;
  background: #eefafb;
}

.match-button.is-matched {
  border-color: #5bb47e;
  background: #e9f7ee;
}

.match-button.is-matched::after {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  position: absolute;
  top: 50%;
  right: 0.55rem;
  border-radius: 50%;
  color: white;
  background: #28784c;
  content: attr(data-match-number);
  font-size: 0.58rem;
  transform: translateY(-50%);
}

.function-button {
  padding-right: 2.2rem;
}

.match-button.is-error {
  border-color: var(--coral-deep);
  background: #fff1f0;
  animation: match-shake 260ms ease;
}

.learning-summary {
  padding: clamp(3.5rem, 7vw, 6rem) 0;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(2rem, 7vw, 7rem);
}

.learning-summary h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  letter-spacing: -0.05em;
}

.learning-summary ul {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  list-style: none;
}

.learning-summary li {
  padding: 1rem 1.1rem;
  border-left: 4px solid var(--green);
  border-radius: 0 0.8rem 0.8rem 0;
  color: var(--navy-650);
  background: rgb(255 255 255 / 68%);
  font-size: 0.87rem;
}

.learning-summary strong {
  color: var(--navy-950);
}

.noscript-note {
  margin: 0;
  padding: 1rem;
  color: #a74448;
  background: #fff1f0;
  font-size: 0.8rem;
}

.learning-page button:focus-visible,
.learning-breadcrumb a:focus-visible {
  outline: 3px solid var(--aqua-deep);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

@keyframes target-shake {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  35% {
    transform: translate(calc(-50% - 5px), -50%);
  }
  70% {
    transform: translate(calc(-50% + 5px), -50%);
  }
}

@keyframes match-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-5px);
  }
  70% {
    transform: translateX(5px);
  }
}

@media (max-width: 850px) {
  .labelling-panel {
    grid-template-columns: 1fr;
  }

  .label-tray {
    padding: 0.85rem;
  }

  .label-list {
    display: flex;
    flex-wrap: wrap;
  }

  .label-button {
    width: auto;
    flex: 1 1 145px;
  }
}

@media (max-width: 640px) {
  .learning-hero h1 {
    font-size: clamp(2.55rem, 13vw, 4rem);
  }

  .activity-tab {
    padding: 0.55rem 0.35rem;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.82rem;
    text-align: center;
  }

  .activity-tab span {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.78rem;
  }

  .activity-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }

  .activity-progress {
    width: 100%;
  }

  .activity-progress span {
    text-align: left;
  }

  .activity-panel {
    min-height: auto;
  }

  .cell-target {
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.3rem 0.48rem;
    border-width: 2px;
    font-size: 0.62rem;
  }

  .matching-grid {
    gap: 2.2rem;
  }

  .match-button {
    padding: 0.55rem 0.6rem;
    font-size: 0.8rem;
  }

  .function-button {
    padding-right: 1.9rem;
  }

  .activity-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .reset-button {
    align-self: flex-start;
  }

  .learning-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .learning-breadcrumb {
    font-size: 0.7rem;
  }

  .activity-tabs {
    padding: 0.55rem;
    gap: 0.3rem;
  }

  .activity-tab span {
    width: 1.6rem;
    height: 1.6rem;
    font-size: 0.72rem;
  }

  .activity-tab {
    font-size: 0.74rem;
  }

  .label-button {
    flex-basis: 115px;
    font-size: 0.84rem;
  }

  .labelling-panel,
  .matching-panel {
    padding: 0.7rem;
  }

  .cell-diagram {
    border-radius: 15px;
  }

  .matching-grid {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
    gap: 1rem;
  }

  #match-lines {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell-target.is-error,
  .match-button.is-error {
    animation: none;
  }
}
