/* mobile.css
   Mobile layout (<= 900px): feed of projects (carousel, name under it, caption), profile-style info page,
   fullscreen project viewer. Desktop is untouched.
   Link it AFTER styles.css, without a media attribute (the rules below are wrapped in the media query).
   Needs:    mobile-feed.js (builds .m-feed and .m-toast); page-swap.js for the + info / - info link
   Provides: nothing */

/* desktop: the mobile-only pieces never show */
.m-feed, .m-toast { display: none; }

@media (max-width: 900px) {

  /* ---------- base ---------- */
  html { -webkit-text-size-adjust: 100%; }
  body {
    cursor: auto;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top, 0px) 0 calc(48px + env(safe-area-inset-bottom, 0px)) 0;   /* room for the bottom "+ info" link */
  }
  .container { display: flex; flex-direction: column; flex-wrap: nowrap; height: auto; min-width: 0; width: 100%; }
  /* the same "+ info / - info" link, moved from the left side to the bottom (page-swap.js still drives it) */
  .menu-toggle-vertical {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; transform: none;
    box-sizing: border-box; height: calc(48px + env(safe-area-inset-bottom, 0px));
    padding: 0 0 env(safe-area-inset-bottom, 0px); font-size: 14px;
    background: #fff;                                   /* no separator line */
  }
  .menu-toggle-vertical a { display: flex; align-items: center; justify-content: center; height: 48px; padding: 0 48px; }

  /* ---------- home: feed replaces the desktop columns ---------- */
  .C1-Home, .C2-Home { display: none !important; }
  .C3-Home { min-width: 0; max-width: none; width: 100%; margin: 0; padding: 0; }
  /* the original gallery stays in the page (its modals and click handlers live in it) but takes no space */
  .C3-Home .thing { height: 0; overflow: hidden; margin: 0; padding: 0; }
  .m-feed { display: block; }

  /* one project = one card: carousel (dots inside), project name, description, "+" */
  .m-card { padding-bottom: 34px; }
  .m-media { position: relative; }
  .m-slides {
    display: flex; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .m-slides::-webkit-scrollbar { display: none; }
  .m-slides:not(.is-fit) { min-height: 60vw; }          /* placeholder until the first image has loaded */
  .m-slide { position: relative; flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; }
  .m-slide img { display: block; max-width: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
  /* FIRST image: in the normal flow, width = screen width, height follows from its own proportions (never cropped).
     It also sets the height of the whole carousel. */
  .m-slide.is-main img { position: static; width: 100%; height: auto; }
  /* every other image: shown whole inside that box, centred (a shorter one gets space above and below, a taller one is scaled down) */
  .m-slide:not(.is-main) img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

  /* slider dots: round, inside the image, at the bottom */
  .m-dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
  .m-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .55); box-shadow: 0 0 3px rgba(0, 0, 0, .35); }
  .m-dots i.is-on { background: #fff; }

  /* project name: same style as the desktop list (h3, 14px, bold, #333) */
  .m-label { padding: 0 16px; }
  .m-label .m-title { margin: 10px 0 0; font-size: 14px; font-weight: bold; line-height: normal; color: #333; }

  .m-caption { margin: 5px 16px 0; font-size: 13px; line-height: 1.45; color: #333; }
  .m-caption.is-clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  /* project info (copied from the desktop panel built by project-info.js), shown when "+" is tapped */
  .m-card .m-info { display: none; width: auto; max-width: none; margin: 12px 16px 0; }   /* width:auto: the desktop panel is width:100%, which plus the margins overflowed the screen */
  .m-card.is-open .m-info { display: block; }
  .m-info .project-extra__content { padding: 0; }
  .m-info h4 { font-size: 12px; font-weight: bold; line-height: normal; }
  .m-info h5 { font-size: 11px; font-weight: lighter; line-height: 1.6; }

  /* "+" / "-": same style as the project name */
  .m-expand {
    display: block; background: none; border: 0; margin: 0; padding: 8px 16px 8px 16px;
    font: inherit; font-size: 14px; font-weight: bold; line-height: 1.2; color: #333; outline: none; -webkit-tap-highlight-color: transparent;
  }

  /* ---------- info: profile style ---------- */
  .C1-Bio, .C2-Bio, .C3-Bio { min-width: 0; max-width: none; width: 100%; margin: 0; box-sizing: border-box; padding-left: 16px; padding-right: 16px; }
  .C1-Bio { display: none !important; }                 /* no portrait on the mobile info page */
  .C2-Bio { padding-top: 28px; padding-bottom: 8px; }
  .C3-Bio { padding-top: 14px; padding-bottom: 28px; }

  /* info text: the original desktop sizes, spacing and proportions (styles.css rewrites them smaller at <= 900px) */
  .C2-Bio h2.C2-title, .C3-Bio h2.grid-header { font-size: 18px; font-weight: bold; }
  .C2-Bio .C2-title { margin: 0.83em 0 0; }
  .C2-Bio h3.C2-subtitle { font-size: 14px; font-weight: bold; margin: 10px 0 0; }
  .C2-Bio p.C2-body { font-size: 12px; font-weight: lighter; line-height: 1.6; margin: 5px 0 10px; text-align: justify; }
  .C3-Bio .grid-header { margin: 0.83em 0 0; }
  .C3-Bio .grid-layout { grid-template-columns: 1fr 1fr; row-gap: 15px; column-gap: 40px; padding: 0; }   /* 2 columns instead of 3: only the width differs */
  .C3-Bio h3.box-subtitle { font-size: 14px; font-weight: bold; margin: 10px 0 0; line-height: 19px; }
  .C3-Bio p.box-body { font-size: 12px; font-weight: lighter; margin: 5px 0 0; line-height: 18px; }

  /* ---------- project viewer: fullscreen, black, swipe ---------- */
  .modal { background: #000; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .modal-content { width: 100%; height: auto; max-width: 100%; max-height: calc(100% - 130px); object-fit: contain; }
  .modal-text {
    height: auto; min-height: 50px; padding: 0 16px calc(12px + env(safe-area-inset-bottom, 0px));
    color: #fff; font-size: 12px; font-weight: normal; line-height: 1.35;
  }
  .modal .prev, .modal .next { display: none !important; }      /* swipe instead */
  .modal .close {
    color: #fff; font-size: 28px; line-height: 1;
    top: calc(6px + env(safe-area-inset-top, 0px)); right: 4px; padding: 12px 18px 24px 24px;
  }

  /* ---------- toast (replaces the cursor hint's "copied") ---------- */
  .m-toast {
    display: block; position: fixed; left: 50%; z-index: 300; pointer-events: none;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
    padding: 5px 9px; background: #111; color: #fff; font-size: 11px; opacity: 0; transition: opacity .15s ease;
  }
  .m-toast.is-on { opacity: 1; }
}
