/* ==========================================================================
   MOBILE (width up to 700 px). The desktop is not touched: every rule that changes something is inside the media queries.
   Loaded last on every page; the selectors start with `html:root` or `body` so that they win over the page stylesheets in whatever order those were loaded.

   1) The bar: ONE row, 01/WORKS 02/ABOUT 03/CONTACT 04/+, DM Mono capitals 12 px, space-between over the whole usable width, the current item underlined (the sliding line of
      the desktop); fixed on the top, with the margin of the phone.
   2) The scale, in px:  text, values and descriptions (Inter Tight) 16 px / 1.5;  labels and lists (DM Mono capitals) 12 px / 1.5, letter-spacing 0.04em;
      the big titles (Instrument Serif) clamp(34px, 11vw, 44px) / 1.0;  the sentences (Instrument Serif, not titles) 20 px / 1.25.  Nothing under 12 px; a line of text is
      never longer than about 40 characters (the column is 343 px wide at 390 px).
      ONE margin for the phone, --m-margin = 6vw (at least 20 px), on all four sides of every page: it becomes --space-margin, --pad, --about-margin...
   3) About: title, the three lines in mono, the photo (whole, never cropped: the full width of the column, the height that its own proportion gives). The sentence
      "Based in Trentino, available worldwide." is not here on a phone: it is a small caption above the list of Contact (.contact-note, only shown here).
   4) Contact: title, the email with the arrow at about two thirds of the height of the section, the small caption and the list of the contacts at the bottom (one column, left aligned).
   5) The sections: ONE long page like the desktop: Works, About, Contact, "+" one after the other, each at least as high as the window (100svh: svh, because the bar of Safari changes
      the usable height); the bar is fixed on top with no background, each section starts under it. Works: the names are centred in its screen.
   6) No effect of the mouse: the entrance (fade and rise) is off, the letters never move: all the text is at full opacity with no transform, on every page.
   ========================================================================== */
.contact-note { display: none; }                          /* the small caption of the phone version of Contact: not on the desktop */

@media (max-width: 700px) {
  html:root {
    --m-margin: max(6vw, 20px);
    --space-margin: var(--m-margin);
    --pad: var(--m-margin);
    --about-margin: var(--m-margin);
    --about-top-gap: var(--m-margin);
    --about-bottom-gap: var(--m-margin);
    --bar-top: var(--m-margin);

    --fs-label: 12px;  --fs-nav: 12px;  --ls-label: 0.04em;                 /* the labels and the lists, DM Mono capitals */
    --fs-body: 17px;   --lh-body: 1.5;                                       /* texts, values and descriptions, Inter Tight */
    --fs-display: clamp(44px, 15vw, 100px);  --lh-display: 0.84;  --ls-display: -0.04em;     /* the big titles, Instrument Serif, two tight lines (title-fit.js makes them smaller if a line would not fit) */
    --fs-sentence: 24px;  --lh-sentence: 1.3;                                /* the sentences that are not titles, Instrument Serif */
    --fs-email: 26px;                                                        /* (title-fit.js makes it smaller if it would not fit the column) */
    --bar-h: calc(var(--bar-top) + var(--fs-nav) * 1.5);                     /* the real height of the bar: one line of 1.5 */
  }
  body.page-home { --lh-label: 1.5; }

  html { scroll-padding-top: 0; }                                                                             /* a section starts at the top of the window (its own padding clears the bar) */

  /* ---- the bar: one row over the whole width, fixed, no background (as on the desktop) ---- */
  body.page-home .topbar ul { display: flex; flex-direction: row; justify-content: space-between; align-items: baseline; }

  /* ---- the sections follow one another, each at least as high as the window ---- */
  body.page-home .section, body.page-home .home, body.page-home .contact { min-height: 100vh; min-height: 100svh;   min-height: 100lvh; }   /* lvh: with the bar of Safari folded away the window is taller than svh, and the title of the next section would show at the bottom */

  /* ---- Works: the names centred between the bar and the bottom margin ---- */
  body.page-home .home { padding-top: var(--bar-h); padding-bottom: var(--space-margin); align-items: center; }

  /* ---- About: title, the three lines, the photo (whole) ---- */
  body.page-home .about-grid {                                                                          /* one screen: the title, the lines, then the photo takes ALL the height that is left */
    display: flex; flex-direction: column; align-items: stretch; align-content: normal; box-sizing: border-box; min-height: 100vh; min-height: 100svh;
    padding: calc(var(--bar-h) + 12px) var(--about-margin) var(--about-margin);                         /* right under the bar + a small gap; under the photo: the margin of the phone */
  }
  body.page-home .about-title { margin-top: 0; margin-bottom: 0; }
  body.page-home .about-left { margin-top: 16px; }                                                         /* title -> the lines in mono: 16 px */
  body.page-home .about-defs { display: block; margin: 0; font-size: var(--fs-label); line-height: 1.5; }
  body.page-home .about-defs li { padding: 0; }
  body.page-home .about-line { display: none; }                                                            /* the sentence is in Contact on a phone */
  /* the photo: the full width of the column, the height that is left = 100svh - bar - the space above - the bottom margin (the flex column gives it), never more than 4:5 of the
     width, never less than 160 px; the same box for the three photos, cropped (cover) a little at the top and bottom if needed, the face stays in view */
  body.page-home .portrait { flex: 1 1 0; min-height: 160px; max-height: calc((100vw - 2 * var(--about-margin)) * 1.25); height: auto; aspect-ratio: auto; margin-top: 16px; overflow: hidden; }
  body.page-home .portrait .ab-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }

  /* ---- Contact, from the top: the title (two lines), the email with the arrow at about two thirds of the height of the section, the small caption and the list of the
     contacts on the bottom margin. ---- */
  body.page-home .contact { min-height: max(100vh, 560px); min-height: max(100svh, 560px);  min-height: max(100lvh, 560px); }
  body.page-home .contact-mail {
    position: absolute; left: var(--space-margin); right: var(--space-margin); top: 66.6%; width: auto; margin: 0; padding: 0;
    grid-template-columns: var(--lead-w) minmax(0, max-content);                                                       /* the line ends with the text (before: the whole width of the column, longer than the email) */
    font-size: var(--fs-email);
  }
  body.page-home .contact-links {
    display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0;
    margin: 0; padding: 0; font-size: 14px; line-height: 1.7;
  }
  body.page-home .contact-note {
    display: block; margin: auto 0 16px; padding: 0; max-width: 100%;
    font-family: var(--font-mono); font-weight: var(--nav-fw); font-size: 12px; line-height: 1.5; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text); opacity: var(--soft-a, 0.6);
  }
  body.page-home .contact-note i { font-style: normal; }
  body.page-home .contact-links li { justify-self: auto; }
  /* the order is that of the page: INSTAGRAM, LINKEDIN, VIMEO, the phone, VAT */
  body.page-home .contact-links li:nth-child(5) { order: 5; }

  /* ---- "+" ---- */
  body.page-home .cap2 { font-size: var(--fs-label); line-height: 1.3; }

  /* ---- the project pages: the same scale ---- */
  body.page-project .iv, body.page-project .idesc { font-size: var(--fs-body); line-height: var(--lh-body); }
  body.page-project .ik { font-size: var(--fs-label); line-height: 1.5; }
}

/* ---- the old entrance (fade + 16 px, enter.js / site.js) and the letters: no effect of the mouse on a phone or a touch screen. On a phone the elements that carry data-m are moved by the
   motion module (below); every other element is at full opacity and does not move. Also when the motion is off (reduced motion, a failure): everything is visible. ---- */
@media (max-width: 700px) {
  html.js [data-enter]:not([data-m]), html.js [data-reveal]:not([data-m]) { opacity: 1 !important; transform: none !important; transition: none !important; will-change: auto !important; }
  html.js:not(.m-anim) [data-m][data-enter], html.js:not(.m-anim) [data-m][data-reveal] { opacity: 1 !important; transform: none !important; transition: none !important; will-change: auto !important; }
}
@media (min-width: 701px) and (hover: none) and (pointer: coarse) {
  html.js [data-enter], html.js [data-reveal], html.js [data-enter].is-entered, html.js [data-reveal].is-in {
    opacity: 1 !important; transform: none !important; transition: none !important; will-change: auto !important;
  }
}
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
  .pw, .pl { transform: none !important; will-change: auto !important; opacity: 1 !important; }
}

/* ==========================================================================
   MOTION (every screen, with motion.js; hidden states exist only while html.m-anim is on). Restrained: one idea at a time. Only transform, opacity and clip-path change.
   data-m = text | rise | stagger | img | line | fade | hero. will-change only while an element runs (.m-run). .m-now: shown at once (passed over by a fast scroll).
   ========================================================================== */
@media screen {
  html.js.m-anim {
    --m-ease: cubic-bezier(0.16, 1, 0.3, 1); --m-dist: 28px; --m-t-text: 900ms; --m-t-img: 1200ms; --m-stagger: 70ms;
    --m-t-title: 1000ms; --m-t-line: 800ms; --m-t-fade: 400ms; --m-t-hero: 700ms;
  }
  /* the bar and Close: a fade */
  html.js.m-anim .site-nav:not(.m-in) { opacity: 0; }
  html.js.m-anim .site-nav.m-in { opacity: 1; transition: opacity var(--m-t-fade) var(--m-ease) var(--m-d, 0ms), background-color 150ms linear; }
  /* the opening video of a project: it fades in (nothing black before it: the page behind is blue, the poster is its background) */
  html.js.m-anim [data-m="hero"]:not(.m-in) { opacity: 0; }
  html.js.m-anim [data-m="hero"].m-in { opacity: 1; transition: opacity var(--m-t-hero) ease-out var(--m-d, 0ms); }
  /* a block of text: 28 px up + fade */
  html.js.m-anim [data-m="rise"]:not(.m-in) { opacity: 0; transform: translate3d(0, var(--m-dist), 0); }
  html.js.m-anim [data-m="rise"].m-in { opacity: 1; transform: none; transition: opacity var(--m-t-text) var(--m-ease) var(--m-d, 0ms), transform var(--m-t-text) var(--m-ease) var(--m-d, 0ms); }
  html.js.m-anim [data-m="rise"].m-run { will-change: opacity, transform; }
  /* a list: the children one after the other (the delay of each is written by the module) */
  html.js.m-anim [data-m="stagger"] > *:not(.m-never) { opacity: 0; transform: translate3d(0, var(--m-dist), 0); }
  html.js.m-anim [data-m="stagger"].m-in > * { opacity: 1; transform: none; transition: opacity var(--m-t-text) var(--m-ease) var(--m-d, 0ms), transform var(--m-t-text) var(--m-ease) var(--m-d, 0ms); }
  html.js.m-anim [data-m="stagger"].m-run > * { will-change: opacity, transform; }
  /* a big title: every line rises from under its own mask (the line); the italic word is in its line */
  html.js.m-anim [data-m="text"]:not(.m-ready) { visibility: hidden; }
  html.js.m-anim [data-m="text"] > span { display: block; overflow: hidden; padding: 0.14em 0.1em 0.26em 0; margin: -0.14em -0.1em -0.26em 0; }
  html.js.m-anim [data-m="text"] .m-ln { display: block; transform: translate3d(0, 140%, 0); }
  html.js.m-anim [data-m="text"].m-in .m-ln { transform: none; transition: transform var(--m-t-title) var(--m-ease) var(--m-d, 0ms); }
  html.js.m-anim [data-m="text"].m-run .m-ln { will-change: transform; }
  html.js.m-anim [data-m="text"].m-done > span { overflow: visible; }
  /* an image or a video box: a curtain from the top, the picture settles from 1.08 to 1 (its box keeps its size from the start) */
  html.js.m-anim [data-m="img"]:not(.m-in) { opacity: 0; clip-path: inset(10% 0 0 0); }
  html.js.m-anim [data-m="img"]:not(.m-in) img { transform: scale(1.08); }
  html.js.m-anim [data-m="img"].m-in { opacity: 1; clip-path: inset(0); transition: opacity var(--m-t-img) var(--m-ease) var(--m-d, 0ms), clip-path var(--m-t-img) var(--m-ease) var(--m-d, 0ms); }
  html.js.m-anim [data-m="img"].m-in img { transform: none; transition: transform var(--m-t-img) var(--m-ease) var(--m-d, 0ms); }
  html.js.m-anim [data-m="img"].m-run { will-change: opacity, clip-path; }
  html.js.m-anim [data-m="img"].m-run img { will-change: transform; }
  html.js.m-anim [data-m="img"].m-done { clip-path: none; }
  /* a line that draws from the left */
  html.js.m-anim [data-m="line"]:not(.m-in) { transform: scaleX(0); transform-origin: left center; }
  html.js.m-anim [data-m="line"].m-in { transform: scaleX(1); transform-origin: left center; transition: transform var(--m-t-line) var(--m-ease) var(--m-d, 0ms); }
  html.js.m-anim [data-m="line"].m-run { will-change: transform; }
  html.js.m-anim .nx-rule { --m-t-line: 700ms; }
  /* passed over by a fast scroll: at once, nothing moves */
  html.js.m-anim .m-now, html.js.m-anim .m-now *, html.js.m-anim .m-now > * { transition: none !important; }
}
