/*
  Mobile layout (Figma "mobile" frame, 375px reference), also used for
  tablets up to 1199px: the desktop layout needs ~1150px of width, and
  shrinking it further makes the text unreadably small, so tablets get
  the single-column layout (with tablet tweaks at the end of this file).
  Scoped entirely inside this breakpoint so the desktop styles in style.css
  are untouched from 1200px up. Root font-size is re-based to the mobile
  frame (1rem = 16px at 375px width) instead of style.css's 1920px-based
  clamp, so px values from the Figma mobile frame convert to rem by /16.
*/
@media (max-width: 1199px) {
  html {
    font-size: clamp(14px, calc(100vw * 16 / 375), 18px);
  }

  main { gap: 5rem; }

  /*
    Belt-and-suspenders: every heading/body paragraph should fill its
    container's width (Figma's "Fill" sizing) rather than relying on
    inherited flex-stretch defaults, so none of them can ever wrap
    short or clip regardless of what a parent's align-items is doing.
  */
  .heading,
  .body-text,
  .footer-heading,
  .hero__title,
  .hero__tagline,
  .team__author { width: 100%; max-width: 100%; }

  /*
    Every multi-line heading/paragraph outside the hero is hard-broken
    into several .line-mask spans at desktop's much wider column width
    (e.g. "...сформировалась" / "в 2018 году." as two separate lines).
    At mobile width those breaks land in the wrong place: a line ends
    early with room to spare, and the wrap looks broken. Switching
    .line-mask to inline-block lets consecutive chunks flow onto the
    same line when they fit (the whitespace already in the HTML source
    between adjacent spans renders as the word-space), while each
    chunk still masks/slides independently for the reveal animation.
    The hero already reads correctly as-is, so it is excluded.
  */
  [data-reveal-lines] .line-mask {
    display: inline-block;
    vertical-align: top;
  }
  .hero [data-reveal-lines] .line-mask {
    display: block;
    vertical-align: initial;
  }

  /* ===== header (fixed to the top of the viewport, 8px offset) ===== */

  /*
    Each header element gets its own independent position:fixed (not a
    fixed+z-indexed wrapper) on purpose: a positioned, z-indexed parent
    establishes its own stacking context, which isolates mix-blend-mode
    on its children so they only blend against each other instead of
    the hero video behind them. Same pitfall as the desktop .logo rule
    above.
  */
  .site-header {
    order: 0;
    position: static;
    height: auto;
    width: auto;
    overflow: visible;
    pointer-events: none;
  }

  .logo {
    position: fixed;
    left: calc(0.75rem + env(safe-area-inset-left, 0px));
    top: calc(0.5rem + env(safe-area-inset-top, 0px));
    width: 5.75rem;
    height: 1.75rem;
    pointer-events: auto;
  }

  .site-nav {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    background: rgba(26, 23, 19, 0.96);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
  }
  .site-nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .site-nav a {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    mix-blend-mode: difference;
    color: var(--light);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 2.5rem;
    text-align: center;
  }

  .nav-toggle {
    position: fixed;
    top: calc(0.5rem + env(safe-area-inset-top, 0px));
    right: calc(0.75rem + env(safe-area-inset-right, 0px));
    z-index: 50;
    width: 2rem;
    height: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    mix-blend-mode: difference;
    pointer-events: auto;
  }
  .nav-toggle span {
    display: block;
    width: 1.5rem;
    height: 1.5px;
    background: var(--light);
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  .nav-toggle.is-open span:nth-child(1) { transform: translateY(0.25rem) rotate(45deg); }
  .nav-toggle.is-open span:nth-child(2) { transform: translateY(-0.25rem) rotate(-45deg); }

  /* ===== hero ===== */

  /*
    Sized to the large viewport (100lvh: full screen with browser bars
    retracted) so the video reaches the physical edges of the phone.
    Only static viewport units are used: lvh and svh never change while
    Safari's bar expands/collapses (dvh does, which made the content
    slide up and down). (100lvh - 100svh) is the full height of the
    expanded browser bars, so the button always clears them, and the
    layout stays put when they collapse.
  */
  .hero {
    padding: calc(2rem + env(safe-area-inset-top, 0px)) 0.75rem calc(2rem + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(2rem + (100lvh - 100svh) + env(safe-area-inset-bottom, 0px));
    min-height: 100vh;
    min-height: 100lvh;
    height: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .hero__row {
    display: contents;
  }

  .hero__stats {
    order: 1;
    position: relative;
    z-index: 1;
    width: 100%;
    align-items: flex-start;
    gap: 1.25rem;
  }
  .stats-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .stat__num { font-size: 2rem; opacity: 0.3; }
  .stat__label { font-size: 0.875rem; }
  .hero__tagline {
    text-align: right;
    font-size: 1.48rem;
    letter-spacing: -0.0148rem;
  }

  .hero__action {
    order: 2;
    position: relative;
    z-index: 1;
    width: 100%;
    gap: 1rem;
  }
  .hero__title { font-size: 1.48rem; letter-spacing: -0.0148rem; }

  .btn {
    padding: 0.875rem 1rem;
    gap: 0.5rem;
    font-size: 0.875rem;
  }

  /* ===== intro (2 блок) ===== */

  .intro {
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding: 0 0.75rem;
  }
  .intro__content {
    display: contents;
  }
  .intro__content .heading,
  .intro__content .intro__cols {
    order: 1;
  }
  .intro__content .heading { font-size: 1.48rem; margin-bottom: 1rem; }
  .intro__content .intro__cols {
    flex-direction: column;
    gap: 1rem;
    font-size: 0.875rem;
    margin-bottom: 2rem;
  }
  .intro__cols > p:nth-child(1),
  .intro__cols > p:nth-child(2) { display: none; }
  .intro__cols-mobile { display: block; width: 100%; margin: 0; }

  .intro__media {
    order: 2;
    flex: none;
    width: 100%;
    aspect-ratio: 351 / 364;
    margin-bottom: 2rem;
  }
  /* Fill the frame edge to edge (the desktop auto-width image is narrower than this box) */
  .intro__media img,
  .intro__media:hover img {
    left: 0;
    width: 100%;
    transform: none;
  }

  .intro__content .intro__routes { order: 3; gap: 1.25rem; }
  .intro__routes > p { font-size: 0.875rem; }
  .route-tags {
    flex-direction: column;
    gap: 1rem;
  }
  .route-tags span { font-size: 1.125rem; }

  /* ===== collage (3 блок) ===== */

  .collage {
    width: 100%;
    height: auto;
    padding: 0 0.75rem;
  }
  .collage__text--right { display: none; }
  .collage__text--left {
    position: static;
    padding: 0;
    inset: auto;
  }
  .collage__text--left { gap: 1rem; }
  .collage__text--left .heading { width: 100%; font-size: 1.48rem; }
  .collage__text--left .body-text { font-size: 0.875rem; }

  .collage__photos {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    height: auto;
    margin-top: 2rem;
    /* Wide photo on top, then two independent columns of different height */
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 0.5rem;
  }
  .collage__photos > .cph--1 { grid-column: 1 / -1; }
  .collage__photos-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
  }
  .collage__photos-col .cph { width: 100%; }
  .cph { position: static; transform: none; }
  .cph--1 { aspect-ratio: 359 / 240; }
  .cph--3 { aspect-ratio: 176 / 240; }
  .cph--2 { aspect-ratio: 175 / 302; }
  .cph--4 { aspect-ratio: 176 / 178; }
  .cph--5 { aspect-ratio: 175 / 178; }

  /* ===== ritual (4 блок) ===== */

  .ritual {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
    padding: 0 0.75rem;
  }
  .ritual__text { display: contents; }
  .ritual__text .heading { order: 1; font-size: 1.48rem; margin-bottom: 1rem; }
  .body-stack { display: contents; }
  .ritual__text .body-stack p:first-child { order: 1; margin-bottom: 2rem; }
  .ritual__text .body-stack p:last-child { order: 3; margin-top: 2rem; }
  .body-stack p { font-size: 0.875rem; }

  .ritual__photos {
    order: 2;
    position: static;
    width: 100%;
    height: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .rph {
    position: static;
    transform: none;
    flex: 1 1 0;
  }
  .rph--1 { aspect-ratio: 171.5 / 295.25; }
  .rph--2 { aspect-ratio: 171.5 / 235.2; }

  /* ===== random shots (5 блок) ===== */

  .random-shots {
    width: 100%;
    gap: 0;
    padding: 0 0.75rem;
  }
  .random-shots .heading { order: 1; font-size: 1.48rem; margin-bottom: 1rem; }
  .random-shots { display: flex; flex-direction: column; }
  .shots-caption { display: contents; }
  .random-shots .shots-caption p:first-child { order: 2; margin-bottom: 2rem; }
  .random-shots .shots-strip { order: 3; margin-bottom: 2rem; }
  .random-shots .shots-caption p:last-child { order: 4; }
  .shots-caption p { font-size: 0.875rem; width: 100% !important; }

  .shot--sm { width: 7rem; height: 7.0625rem; }
  .shot--md { width: 10.8125rem; height: 14.875rem; }
  .shot--lg { width: 18.4375rem; height: 22.5625rem; }
  .shot { margin-right: 4.25rem; }

  /* ===== team (пацаны) ===== */

  .team {
    width: 100%;
    flex-direction: column;
    padding: 0 0.75rem;
  }
  /*
    Mobile order per member (Figma): quote + author, then photo, then
    body text. On desktop the texts and photos live in two separate
    columns, so every wrapper (including each .team__member-text) is
    flattened with display:contents and the pieces are re-ordered as
    direct flex items of .team. The desktop markup stays untouched.
  */
  .team__text-col,
  .team__photo-col,
  .team__text-sticky,
  .team__photo-stack,
  .team__text-stack,
  .team__member-text {
    display: contents;
  }
  .team__text-triggers { display: none; }
  .team__member-text { pointer-events: auto !important; }

  .team__photo {
    position: static !important;
    inset: auto;
    clip-path: none !important;
    width: 100%;
    height: auto;
  }
  .team__quote-block { gap: 0.25rem; width: 100%; }
  .team__member-text .heading { font-size: 1.48rem; }
  .team__author { font-size: 0.875rem; }
  .team__member-text .body-text { font-size: 0.875rem; max-width: none; }

  .team__photo { aspect-ratio: 351 / 426; }

  /* Per member (Figma): photo, 16px, quote + author (4px apart), 16px, body text; 48px between members. */
  .team__photo,
  .team__member-text > .team__quote-block { margin-bottom: 1rem; }
  .team__member-text > .body-text { margin-bottom: 3rem; }
  .team__member-text[data-team-index="3"] > .body-text { margin-bottom: 0; }

  .team__photo[data-team-index="0"] { order: 1; }
  .team__member-text[data-team-index="0"] > .team__quote-block { order: 2; }
  .team__member-text[data-team-index="0"] > .body-text { order: 3; }
  .team__photo[data-team-index="1"] { order: 4; }
  .team__member-text[data-team-index="1"] > .team__quote-block { order: 5; }
  .team__member-text[data-team-index="1"] > .body-text { order: 6; }
  .team__photo[data-team-index="2"] { order: 7; }
  .team__member-text[data-team-index="2"] > .team__quote-block { order: 8; }
  .team__member-text[data-team-index="2"] > .body-text { order: 9; }
  .team__photo[data-team-index="3"] { order: 10; }
  .team__member-text[data-team-index="3"] > .team__quote-block { order: 11; }
  .team__member-text[data-team-index="3"] > .body-text { order: 12; }

  /* ===== footer ===== */

  .site-footer {
    flex-direction: column;
    width: 100%;
    height: auto;
    gap: 3.75rem;
    padding: 0 0.75rem;
  }
  .site-footer__media {
    width: 100%;
    height: auto;
    aspect-ratio: 359 / 452;
    flex: none;
  }
  .site-footer__content {
    width: 100%;
    height: auto;
    padding: 0;
    gap: 3.75rem;
  }
  .footer-blocks { gap: 3.75rem; }
  .footer-block { gap: 1rem; }
  .footer-heading { font-size: 1.48rem; }
  .footer-block .body-text { font-size: 0.875rem; }

  .footer-bottom { font-size: 0.875rem; }
}

/*
  Tablets (iPad mini, iPad Air, Surface Pro in portrait, small landscape
  tablets): the same single-column layout as phones, but the content sits
  in a centered column of book-page width with roomier margins, instead
  of stretching edge to edge. The hero and the photo strip stay full-bleed.
*/
@media (min-width: 768px) and (max-width: 1199px) {
  main { gap: 7rem; }

  .intro,
  .collage,
  .ritual,
  .random-shots,
  .team,
  .site-footer {
    max-width: 44rem;
    margin-inline: auto;
    padding: 0 2rem;
  }

  .hero {
    padding-left: 2rem;
    padding-right: 2rem;
  }
  .logo { left: calc(2rem + env(safe-area-inset-left, 0px)); top: calc(1.25rem + env(safe-area-inset-top, 0px)); }
  .nav-toggle { right: calc(2rem + env(safe-area-inset-right, 0px)); top: calc(1.25rem + env(safe-area-inset-top, 0px)); }

  .shot--sm { width: 10.5rem; height: 10.625rem; }
  .shot--md { width: 16.25rem; height: 22.3125rem; }
  .shot--lg { width: 27.625rem; height: 33.875rem; }
  .shot { margin-right: 6rem; }

  .site-footer { margin-bottom: 2rem; }
}
