/* Keep the lesson entrance motion inside its section at all viewport widths. */
.foundation { overflow-x: clip; }

/* Phone layout: show the visual story early and keep touch targets comfortable. */
@media (max-width: 760px) {
  .header,
  .header.wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand tools" "nav nav";
    align-items: center;
    gap: 8px 10px;
    min-height: 0;
    padding: 12px 18px 0;
    position: relative;
  }
  .header .brand { grid-area: brand; min-width: 0; gap: 7px; }
  .header .brand-symbol { display: block; flex: none; width: 36px; height: 36px; }
  .header .brand-symbol img { width: 36px; }
  .header .brand-type { font-size: 15px; line-height: 1.05; }
  .header .brand-type > span { font-size: 11px; }
  .header .header-tools { grid-area: tools; display: flex; width: auto; flex-wrap: nowrap; gap: 7px; }
  .header .theme-toggle {
    display: grid;
    place-items: center;
    flex: none;
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 0;
  }
  .header .theme-toggle::after { content: "☾"; font: 24px/1 Arial, sans-serif; }
  [data-theme=dark] .header .theme-toggle::after { content: "☀"; font-size: 22px; }
  .header .header-contact {
    min-height: 42px;
    padding: 9px 12px;
    max-width: none;
    white-space: nowrap;
    font-size: 12px;
    gap: 5px;
  }
  .header .header-contact span { font-size: 18px; }
  .header nav {
    grid-area: nav;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 22px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 0;
    border-top: 1px solid var(--line);
    white-space: nowrap;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .header nav::-webkit-scrollbar { display: none; }
  .header nav a {
    display: inline-flex;
    align-items: center;
    flex: none;
    min-height: 44px;
    padding: 8px 0;
    font-size: 12px;
    scroll-snap-align: start;
  }

  .audience-bar {
    display: block;
    padding-top: 13px;
    padding-bottom: 0;
  }
  .audience-bar > p { display: none; }
  .audience-switch { display: flex; width: 100%; padding: 3px; }
  .audience-switch button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 42px;
    padding: 7px 6px;
    white-space: nowrap;
    font-size: 13px;
  }
  .audience-switch span { margin-left: 3px; }

  body:not(.business-view) .hero {
    padding: 18px 18px 26px;
    min-height: 0;
  }
  body:not(.business-view) .hero-topline { display: none; }
  body:not(.business-view) .hero .hero-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    height: auto;
    padding: 0;
  }
  body:not(.business-view) .hero .hero-copy { display: contents; }
  body:not(.business-view) .hero #hero-title { grid-row: 1; }
  body:not(.business-view) .hero .hero-description {
    grid-row: 2;
    margin: 13px 0 0;
    font-size: 16px;
    line-height: 1.42;
  }
  body:not(.business-view) .hero .cube-stage {
    grid-row: 3;
    width: 100%;
    max-width: none;
    margin: 22px 0 0;
  }
  body:not(.business-view) .hero .visual-world .world-view {
    aspect-ratio: 1.32;
    border-radius: 18px;
    box-shadow: 0 20px 42px #0c21414a;
  }
  body:not(.business-view) .hero .visual-world figcaption { padding-top: 12px; }
  body:not(.business-view) .hero .world-buttons { gap: 8px; }
  body:not(.business-view) .hero .world-buttons button {
    min-height: 64px;
    padding: 10px 13px;
    gap: 5px;
  }
  body:not(.business-view) .hero .world-buttons button strong { font-size: 16px; }
  body:not(.business-view) .hero .world-buttons button small { font-size: 10px; }
  body:not(.business-view) .hero .world-drag-hint { font-size: 10px; padding: 6px 10px; }
  body:not(.business-view) .hero .hero-subline {
    grid-row: 4;
    margin: 23px 0 0;
    font-size: 13px;
    line-height: 1.6;
  }
  body:not(.business-view) .hero .actions {
    grid-row: 5;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 9px;
    margin-top: 18px;
  }
  body:not(.business-view) .hero .actions .button {
    width: 100%;
    min-height: 50px;
    justify-content: space-between;
    font-size: 13px;
  }
  body:not(.business-view) .hero .actions .text-link { width: fit-content; min-height: 44px; }
  body:not(.business-view) .hero .hero-next {
    grid-row: 6;
    position: static;
    justify-self: center;
    transform: none;
    margin-top: 15px;
  }

  body.business-view .hero {
    width: 100%;
    max-width: none;
    padding: 24px 18px 48px;
  }
  body.business-view .hero .hero-main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 25px;
    padding: 10px 0 0;
  }
  body.business-view .hero .hero-topline { margin-bottom: 8px; }
  body.business-view .hero #hero-title { font-size: clamp(35px, 9vw, 47px); }
  body.business-view .hero .hero-description { margin-top: 22px; font-size: 16px; line-height: 1.6; }
  body.business-view .hero .hero-subline { font-size: 13px; line-height: 1.55; }
  body.business-view .hero .actions { margin-top: 20px; }
  body.business-view .business-hero-visual { min-height: 300px; padding: 24px; }
  body.business-view .business-hero-visual .eyebrow { color: #c7d7ff; }

  .foundation .section { padding-block: 70px 76px; }
  .foundation-intro .lead { font-size: 18px; }
  .foundation-intro .foundation-visual { max-width: none; }
  .foundation-lessons { gap: 10px; }
  .foundation-lessons article {
    border-radius: 15px;
    padding: 20px;
  }
  .foundation-lessons h3 { font-size: 16px; }
  .foundation-lessons p { font-size: 13px; line-height: 1.55; }
  .lesson-number { margin-bottom: 15px; }

  .story .chapter-note { font-size: 11px; line-height: 1.35; letter-spacing: .025em; }
  .story .chapter-number { font-size: 30px; }
  .story .chapter-controls button { min-height: 44px; font-size: 10px; padding: 9px 6px; }
  .story .story-description { font-size: 13px; }

  .showcase-stage .showcase-arrow { width: 44px; height: 44px; }
  .showcase-stage-controls button { min-height: 42px; font-size: 12px; }

  .pricing .tariff-card,
  .pricing .tariff-card.featured,
  .business-price-list article {
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 12px 27px #152b5010;
  }
  .pricing .tariff-intro > p,
  .business-price-list p { font-size: 14px; line-height: 1.55; }
  .pricing .tariff-price { font-size: 27px; }
  .pricing .tariff-card > .button {
    justify-self: stretch;
    width: 100%;
    min-height: 50px;
    font-size: 13px;
  }
  .pricing .tariff-details summary { min-height: 44px; display: flex; align-items: center; }
  .business-price-list a { width: 100%; min-height: 48px; }
  .contact-section .application-panel { border-radius: 18px; }
  .contact-section .application-panel input:not([type=checkbox]),
  .contact-section .application-panel select,
  .contact-section .application-panel textarea { min-height: 48px; border-radius: 9px; }
}

@media (min-width: 361px) and (max-width: 760px) {
  .foundation-lessons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foundation-lessons article { padding: 18px 15px; }
}

@media (max-width: 360px) {
  .header,
  .header.wrap { padding-inline: 13px; gap: 7px; }
  .header .brand-symbol,
  .header .brand-symbol img { width: 31px; height: 31px; }
  .header .brand-type { font-size: 13px; }
  .header .brand-type > span { font-size: 10px; }
  .header .theme-toggle { width: 38px; height: 38px; min-height: 38px; }
  .header .header-contact { min-height: 38px; padding: 7px 9px; font-size: 11px; }
  body:not(.business-view) .hero { padding-inline: 15px; }
  body.business-view .business-visual-orbit { width: 210px; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .header nav { scroll-behavior: auto; }
}
