/*
 * Mobile pilot for Geography.
 * Kept in a separate, subject-scoped layer so the approved desktop layout
 * and every other subject remain unchanged while the direction is reviewed.
 */

@media (max-width: 760px) {
  html:has(body[data-subject="geography"]) {
    overflow-x: clip;
  }

  body[data-subject="geography"] {
    --control-height: 44px;
  }

  body.page--subject[data-subject="geography"],
  body.page--classes[data-subject="geography"],
  body.page--scientists[data-subject="geography"] {
    background-color: #a8dce3;
    background-image:
      radial-gradient(circle at 94% 5%, rgba(240, 190, 95, 0.24) 0, rgba(240, 190, 95, 0) 25rem),
      radial-gradient(circle at -8% 42%, rgba(25, 167, 121, 0.22) 0, rgba(25, 167, 121, 0) 23rem),
      linear-gradient(155deg, #9fd8e4 0%, #a9dfdc 50%, #8fcddd 100%);
    background-attachment: scroll;
    background-blend-mode: normal;
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: auto;
    overflow-x: clip;
  }

  body[data-subject="geography"] .app-shell,
  body[data-subject="geography"] .app-shell--classes {
    width: calc(100% - 28px);
  }

  body[data-subject="geography"] .topbar {
    min-height: 44px;
  }

  body[data-subject="geography"] .language-switch {
    width: 126px;
  }

  body[data-subject="geography"] :is(.icon-button, .action-button, .language-switch) {
    min-height: 44px;
  }

  /* Subject landing: compact atlas-like rows with protected text zones. */
  .page--subject[data-subject="geography"] .subject-main {
    padding-top: 0;
  }

  .page--subject[data-subject="geography"] .subject-hero {
    height: 356px;
  }

  .page--subject[data-subject="geography"] .subject-hero::after {
    content: "";
    position: absolute;
    z-index: 1;
    right: -8px;
    bottom: 2px;
    width: calc(100% + 16px);
    height: 194px;
    background: url("../assets/subjects/geography/classes-hero.png") center bottom / contain no-repeat;
    filter: drop-shadow(0 20px 18px rgba(16, 71, 91, 0.18));
    pointer-events: none;
  }

  .page--subject[data-subject="geography"] .subject-hero__copy {
    top: 34px;
    right: 6px;
    left: 6px;
    width: auto;
  }

  .page--subject[data-subject="geography"] .subject-hero__copy h1 {
    min-height: 0;
    font-size: clamp(47px, 14vw, 54px);
    letter-spacing: -0.064em;
    line-height: 0.95;
  }

  .page--subject[data-subject="geography"] .subject-hero__copy > p:last-child {
    min-height: 0;
    max-width: 34rem;
    margin-top: 14px;
    color: #173c68;
    font-size: 15px;
    font-weight: 520;
    line-height: 1.48;
    -webkit-line-clamp: 3;
  }

  .page--subject[data-subject="geography"] .section-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .page--subject[data-subject="geography"] .section-card {
    height: 172px;
    border-color: rgba(255, 255, 255, 0.82);
    border-radius: 24px;
    background:
      radial-gradient(circle at 92% 8%, rgba(var(--accent-rgb), 0.15), transparent 43%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(237, 249, 247, 0.5));
    box-shadow: 0 15px 34px rgba(25, 76, 102, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.94);
  }

  .page--subject[data-subject="geography"] .section-card--active {
    border-color: rgba(25, 167, 121, 0.48);
    background:
      radial-gradient(circle at 91% 9%, rgba(72, 184, 213, 0.25), transparent 45%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(226, 249, 239, 0.62));
    box-shadow:
      0 0 0 3px rgba(25, 167, 121, 0.08),
      0 18px 38px rgba(25, 99, 104, 0.16),
      inset 0 1px 0 #fff;
  }

  .page--subject[data-subject="geography"] .section-card__art-wrap {
    right: -4px;
    bottom: 3px;
    width: 45%;
  }

  .page--subject[data-subject="geography"] .section-card:disabled .section-card__art {
    filter: saturate(0.82) drop-shadow(0 12px 12px rgba(32, 74, 86, 0.15));
    opacity: 0.8;
  }

  .page--subject[data-subject="geography"] .section-card__content {
    display: flex;
    width: 56%;
    height: 100%;
    padding: 19px 0 18px 19px;
    flex-direction: column;
  }

  .page--subject[data-subject="geography"] .section-card :is(h2, h3) {
    display: -webkit-box;
    margin: 0;
    font-size: clamp(19px, 5.3vw, 21px);
    font-weight: 720;
    letter-spacing: -0.038em;
    line-height: 1.08;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .page--subject[data-subject="geography"] .section-card p {
    margin-top: 9px;
    color: #36577a;
    font-size: 13px;
    font-weight: 510;
    line-height: 1.4;
    -webkit-line-clamp: 2;
  }

  .page--subject[data-subject="geography"] .section-card:disabled p {
    -webkit-line-clamp: 3;
  }

  .page--subject[data-subject="geography"] .section-card__state {
    display: inline-flex;
    min-height: 26px;
    margin-top: auto;
    padding: 0 10px;
    align-items: center;
    align-self: flex-start;
    border: 1px solid rgba(36, 92, 105, 0.11);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    color: #48677c;
    font-family: var(--font-head);
    font-size: 10px;
    font-weight: 760;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .page--subject[data-subject="geography"] .section-card:disabled .section-card__arrow {
    display: none;
  }

  .page--subject[data-subject="geography"] .section-card__arrow {
    left: 19px;
    bottom: 17px;
    width: 44px;
    height: 44px;
    background: linear-gradient(145deg, #19a779, #48b8d5);
    box-shadow: 0 10px 22px rgba(25, 130, 118, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.46);
    color: #fff;
  }

  .page--subject[data-subject="geography"] .topics-block {
    margin-top: 27px;
  }

  .page--subject[data-subject="geography"] .topics-block > h2 {
    margin: 0 2px 13px;
    font-size: 23px;
  }

  .page--subject[data-subject="geography"] .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .page--subject[data-subject="geography"] .topic-card {
    height: 72px;
    padding: 10px;
    gap: 9px;
    border-radius: 18px;
    background: rgba(245, 253, 252, 0.55);
    box-shadow: 0 10px 25px rgba(30, 81, 100, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }

  .page--subject[data-subject="geography"] .topic-card__number {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: rgba(25, 167, 121, 0.12);
    color: #128965;
  }

  .page--subject[data-subject="geography"] .topic-card strong {
    font-size: 12px;
    line-height: 1.24;
  }

  /* Scientists: a compact discovery flow and a swipeable people rail. */
  .page--scientists[data-subject="geography"] .scientists-main {
    padding-top: 12px;
  }

  .page--scientists[data-subject="geography"] .scientists-intro {
    display: grid;
    min-height: 0;
    padding: 22px 3px 0;
    align-items: start;
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .page--scientists[data-subject="geography"] .scientists-intro__copy h1 {
    min-height: 0;
    font-size: clamp(47px, 14vw, 52px);
    letter-spacing: -0.058em;
    line-height: 0.96;
  }

  .page--scientists[data-subject="geography"] .scientists-intro__copy > p:last-child {
    min-height: 0;
    margin: 14px 0 0;
    color: #173c68;
    font-size: 15px;
    font-weight: 510;
    line-height: 1.46;
    -webkit-line-clamp: 3;
  }

  .page--scientists[data-subject="geography"] .scientists-tools {
    gap: 9px;
  }

  .page--scientists[data-subject="geography"] .search {
    height: 52px;
    padding-inline: 16px;
    border-radius: 17px;
  }

  .page--scientists[data-subject="geography"] .search input {
    font-size: 16px;
  }

  .page--scientists[data-subject="geography"] .filter-list {
    display: flex;
    width: 100%;
    padding: 1px 2px 7px;
    align-items: center;
    gap: 8px;
    grid-template-columns: none;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .page--scientists[data-subject="geography"] .filter-list::-webkit-scrollbar,
  .page--scientists[data-subject="geography"] .scientist-grid::-webkit-scrollbar {
    display: none;
  }

  .page--scientists[data-subject="geography"] .filter-pill {
    width: auto;
    min-width: max-content;
    min-height: 44px;
    padding: 0 16px;
    flex: 0 0 auto;
    border-radius: 15px;
    color: #34566f;
    font-size: 12px;
    scroll-snap-align: start;
    text-overflow: clip;
  }

  .page--scientists[data-subject="geography"] .filter-pill.is-active {
    background: linear-gradient(125deg, #19a779, #48b8d5);
    box-shadow: 0 10px 22px rgba(25, 130, 118, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  }

  .page--scientists[data-subject="geography"] .scientist-hero {
    display: block;
    min-height: 624px;
    margin-top: 28px;
  }

  .page--scientists[data-subject="geography"] .scientist-hero__clip {
    border-radius: 26px;
    box-shadow: 0 22px 48px rgba(16, 58, 83, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  }

  .page--scientists[data-subject="geography"] .scientist-hero__surface {
    background:
      radial-gradient(circle at 20% 5%, rgba(72, 184, 213, 0.22), transparent 38%),
      linear-gradient(180deg, rgba(8, 21, 38, 0.05) 0%, rgba(8, 23, 40, 0.14) 39%, rgba(9, 26, 44, 0.79) 59%, rgba(8, 24, 41, 0.94) 100%);
  }

  .page--scientists[data-subject="geography"] .hero-grid {
    border-radius: 26px;
    opacity: 0.6;
    mask-image: linear-gradient(to bottom, #000, transparent 78%);
  }

  .page--scientists[data-subject="geography"] .hero-orbit {
    opacity: 0.52;
  }

  body.page--scientists[data-subject="geography"] .hero-portrait-slot {
    position: absolute;
    top: -24px;
    right: 0;
    left: 0;
    width: 100%;
    height: 330px;
    margin-top: 0;
    border-radius: 26px 26px 0 0;
    overflow: hidden;
    transform: none;
  }

  body.page--scientists[data-subject="geography"] .hero-portrait--image {
    top: var(--portrait-lift, 0px);
    right: 50%;
    bottom: auto;
    width: auto;
    height: 820px;
    max-width: none;
    object-position: center top;
    transform: translateX(50%);
  }

  .page--scientists[data-subject="geography"] .portrait-halo {
    right: 50%;
    bottom: -20px;
    width: 250px;
    height: 250px;
    transform: translateX(50%);
  }

  .page--scientists[data-subject="geography"] .hero-illustration {
    display: none;
  }

  .page--scientists[data-subject="geography"] .hero-content {
    position: absolute;
    right: 19px;
    bottom: 83px;
    left: 19px;
    padding: 0;
  }

  .page--scientists[data-subject="geography"] .hero-content__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .page--scientists[data-subject="geography"] .hero-content__heading h2 {
    max-width: 100%;
    font-size: clamp(27px, 8.2vw, 32px);
    line-height: 1.02;
    text-wrap: pretty;
  }

  .page--scientists[data-subject="geography"] .hero-content__heading span {
    font-size: 12px;
  }

  .page--scientists[data-subject="geography"] .hero-content__role {
    margin: 10px 0 14px;
    font-size: 13px;
    line-height: 1.42;
  }

  .page--scientists[data-subject="geography"] .hero-content__label {
    margin-bottom: 8px;
    font-size: 12px;
  }

  .page--scientists[data-subject="geography"] .discovery-list {
    font-size: 12px;
    gap: 7px;
  }

  .page--scientists[data-subject="geography"] .discovery-list li {
    align-items: flex-start;
  }

  .page--scientists[data-subject="geography"] .discovery-list li span {
    margin-top: 1px;
  }

  .page--scientists[data-subject="geography"] .details-button {
    right: 17px;
    bottom: 16px;
    left: 17px;
    width: auto;
    height: 52px;
    padding: 0 7px 0 18px;
    justify-content: space-between;
    border-radius: 17px;
    background: linear-gradient(120deg, #f0be5f 0%, #57c58e 52%, #48b8d5 100%);
    box-shadow: 0 14px 30px rgba(17, 102, 103, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.52);
    color: #102b4d;
  }

  .page--scientists[data-subject="geography"] .details-button__arrow {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: #168b71;
  }

  .page--scientists[data-subject="geography"] .scientist-list-heading {
    display: flex;
    margin: 24px 2px 10px;
    align-items: flex-end;
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
  }

  .page--scientists[data-subject="geography"] .scientist-list-heading h2 {
    font-size: 22px;
  }

  .page--scientists[data-subject="geography"] .scientist-list-heading > p {
    flex: 0 0 auto;
    margin-bottom: 2px;
  }

  .page--scientists[data-subject="geography"] .scientist-grid {
    display: grid;
    margin-right: -14px;
    padding: 3px 14px 18px 2px;
    grid-template-columns: none;
    grid-auto-columns: min(82vw, 318px);
    grid-auto-flow: column;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-padding-inline: 2px;
    scroll-snap-type: x mandatory;
  }

  .page--scientists[data-subject="geography"] .scientist-card {
    min-height: 162px;
    border-radius: 22px;
    grid-template-columns: 98px minmax(0, 1fr);
    scroll-snap-align: start;
  }

  .page--scientists[data-subject="geography"] .card-portrait {
    min-height: 146px;
  }

  body.page--scientists[data-subject="geography"] .card-portrait img {
    top: -2px;
    right: 50%;
    bottom: auto;
    height: 252px;
    max-width: none;
    object-position: center top;
    transform: translateX(50%);
  }

  .page--scientists[data-subject="geography"] .scientist-card__content {
    padding: 7px 12px;
  }

  .page--scientists[data-subject="geography"] .scientist-card__topline {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .page--scientists[data-subject="geography"] .scientist-card__topline strong {
    display: -webkit-box;
    max-width: 100%;
    font-size: 15px;
    line-height: 1.12;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .page--scientists[data-subject="geography"] .scientist-card__description {
    margin-top: 7px;
    color: #536d87;
    font-size: 11px;
    line-height: 1.38;
    -webkit-line-clamp: 2;
  }

  .page--scientists[data-subject="geography"] .tag-row {
    gap: 4px;
  }

  .page--scientists[data-subject="geography"] .tag {
    padding: 4px 6px;
    font-size: 10px;
  }

  .page--scientists[data-subject="geography"] .scientist-card__arrow {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 700px) {
  /* Classes: copy and art participate in normal flow, so translations cannot overlap. */
  .page--classes[data-subject="geography"] .classes-main {
    padding-top: 4px;
  }

  .page--classes[data-subject="geography"] .classes-hero {
    display: block;
    height: auto;
    min-height: 390px;
  }

  .page--classes[data-subject="geography"] .classes-hero__copy {
    width: auto;
    padding: 30px 4px 0;
  }

  .page--classes[data-subject="geography"] .classes-hero__copy h1 {
    min-height: 0;
    font-size: clamp(47px, 14vw, 52px);
    letter-spacing: -0.06em;
    line-height: 0.96;
  }

  .page--classes[data-subject="geography"] .classes-hero__copy p {
    min-height: 0;
    margin-top: 13px;
    color: #173c58;
    font-size: 14px;
    line-height: 1.5;
    -webkit-line-clamp: 6;
  }

  .page--classes[data-subject="geography"] .classes-hero__visual {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    height: 210px;
    margin-top: 3px;
  }

  .page--classes[data-subject="geography"] .classes-hero__halo {
    top: 38px;
    right: 12%;
    width: 76%;
    height: 145px;
  }

  .page--classes[data-subject="geography"] .grade-switch {
    position: sticky;
    z-index: 30;
    top: 8px;
    height: 60px;
    border-radius: 19px;
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
  }

  .page--classes[data-subject="geography"] .grade-tab {
    min-height: 48px;
    font-size: 13px;
  }

  .page--classes[data-subject="geography"] .lesson-heading {
    min-height: 62px;
    padding: 20px 2px 11px;
  }

  .page--classes[data-subject="geography"] .lesson-grid {
    gap: 10px;
  }

  .page--classes[data-subject="geography"] .lesson-card {
    height: 198px;
    border-radius: 23px;
    box-shadow: 0 14px 32px rgba(25, 70, 86, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.96);
  }

  .page--classes[data-subject="geography"] .lesson-card__content {
    width: calc(100% - 132px);
    padding: 19px 0 16px 18px;
  }

  .page--classes[data-subject="geography"] .lesson-card__kicker {
    margin-bottom: 7px;
    font-size: 9.5px;
  }

  .page--classes[data-subject="geography"] .lesson-card h3 {
    font-size: 19px;
  }

  .page--classes[data-subject="geography"] .lesson-card--long-title h3 {
    font-size: 17px;
    line-height: 1.08;
  }

  .page--classes[data-subject="geography"] .lesson-card--very-long-title h3 {
    font-size: 16px;
  }

  .page--classes[data-subject="geography"] .lesson-card__description {
    margin-top: 7px;
    font-size: 12.5px;
    line-height: 1.38;
    -webkit-line-clamp: 3;
  }

  .page--classes[data-subject="geography"] .lesson-card__art {
    top: 8px;
    right: 2px;
    width: 128px;
    height: calc(100% - 16px);
    transform: scale(0.95);
  }

  .page--classes[data-subject="geography"] .lesson-card__arrow {
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 380px) {
  body[data-subject="geography"] .topbar__left {
    gap: 8px;
  }

  body[data-subject="geography"] .brand img {
    width: 94px;
  }

  body[data-subject="geography"] .language-switch {
    width: 108px;
  }

  .page--classes[data-subject="geography"] .classes-hero {
    min-height: 410px;
  }

  .page--subject[data-subject="geography"] .section-card__content {
    width: 57%;
  }

  .page--subject[data-subject="geography"] .section-card__art-wrap {
    width: 44%;
  }
}

@media (max-width: 350px) {
  body[data-subject="geography"] .app-shell,
  body[data-subject="geography"] .app-shell--classes {
    width: calc(100% - 24px);
  }

  body[data-subject="geography"] .topbar {
    display: grid;
    min-height: 96px;
    align-items: center;
    grid-template-areas:
      "left instruction"
      "language language";
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-rows: 44px 44px;
    column-gap: 8px;
    row-gap: 8px;
  }

  body[data-subject="geography"] .topbar__left {
    grid-area: left;
    gap: 7px;
  }

  body[data-subject="geography"] .topbar__actions {
    display: contents;
  }

  body[data-subject="geography"] .topbar [data-instruction] {
    grid-area: instruction;
  }

  body[data-subject="geography"] .language-switch {
    width: 100%;
    grid-area: language;
  }

  body[data-subject="geography"] .brand img {
    width: 94px;
  }

  .page--subject[data-subject="geography"] .subject-hero {
    height: 365px;
  }

  .page--subject[data-subject="geography"] .subject-hero__copy {
    top: 28px;
  }

  .page--subject[data-subject="geography"] .subject-hero::after {
    height: 180px;
  }

  .page--subject[data-subject="geography"] .section-card {
    height: 180px;
  }

  .page--subject[data-subject="geography"] .section-card__content {
    width: 58%;
    padding-left: 17px;
  }

  .page--subject[data-subject="geography"] .section-card__art-wrap {
    width: 43%;
  }

  .page--subject[data-subject="geography"] .section-card :is(h2, h3) {
    font-size: 18px;
  }

  .page--subject[data-subject="geography"] .section-card__arrow {
    left: 17px;
  }

  .page--subject[data-subject="geography"] .topic-card {
    padding: 8px;
    gap: 7px;
  }

  .page--subject[data-subject="geography"] .topic-card strong {
    font-size: 11px;
  }

  .page--classes[data-subject="geography"] .classes-hero__copy {
    padding-top: 25px;
  }

  .page--classes[data-subject="geography"] .classes-hero {
    min-height: 382px;
  }

  .page--classes[data-subject="geography"] .classes-hero__visual {
    height: 190px;
  }

  .page--classes[data-subject="geography"] .lesson-card {
    height: 206px;
  }

  .page--classes[data-subject="geography"] .lesson-card__content {
    width: calc(100% - 116px);
    padding-left: 16px;
  }

  .page--classes[data-subject="geography"] .lesson-card__art {
    width: 114px;
  }

  .page--scientists[data-subject="geography"] .scientists-intro {
    padding-top: 19px;
  }

  .page--scientists[data-subject="geography"] .scientist-hero {
    min-height: 640px;
  }

  body.page--scientists[data-subject="geography"] .hero-portrait-slot {
    height: 318px;
  }

  body.page--scientists[data-subject="geography"] .hero-portrait--image {
    height: 760px;
  }

  .page--scientists[data-subject="geography"] .hero-content {
    right: 17px;
    left: 17px;
  }

  .page--scientists[data-subject="geography"] .scientist-grid {
    margin-right: -12px;
    padding-right: 12px;
    grid-auto-columns: calc(100vw - 42px);
  }

  .page--scientists[data-subject="geography"] .scientist-card {
    grid-template-columns: 90px minmax(0, 1fr);
  }
}
