/* ==========================================================================
   v015 — Mobile and touch presentation (iPhone / iOS Safari first).
   Loaded last on every page. EVERY rule below sits inside a media query that a desktop browser
   window (mouse or trackpad, wider than 40rem / 640 CSS px) does not match:
     · (max-width: 40rem)                         phones in portrait (and very narrow windows)
     · (max-width: 52rem)                         only where the collapsed navigation already applies
     · (hover: none) and (pointer: coarse)        touch-first devices (phones, tablets) at any width
     · (orientation: landscape) and (max-height: 30rem)   phones in landscape
   The approved desktop presentation is therefore untouched (verified by full-page pixel comparison,
   see ZETA-v015-MOBILE-COMPATIBILITY-REPORT.md). No content is added, removed or reworded here:
   these rules only change size, spacing, order and other visual presentation.
   ========================================================================== */

/* ---------- 1. Touch devices: tap feedback, comfortable targets (≥ 44 × 44 CSS px) ---------- */
@media (hover: none) and (pointer: coarse), (max-width: 40rem) {
  html { -webkit-tap-highlight-color: rgba(168, 134, 63, 0.18); }

  /* running text never below 16 px; small print stays legible (labels never below 12 px) */
  .prom-msg__text { font-size: 1rem; }
  .omega-exp__note { font-size: 0.875rem; }
  .osx__inset-tag { font-size: 0.8125rem; }
  .omega-arch__qual, .omega-exp__lang { font-size: 0.75rem; }
  input, select, textarea { font-size: max(16px, 1em); } /* iOS zooms into form fields below 16 px */

  /* header */
  .brand { min-height: 44px; }
  .site-nav a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; } /* full navigation (landscape phones, tablets) */
  .js .nav-toggle { min-height: 44px; min-width: 44px; }

  /* footer: each link becomes a full-height row */
  .site-footer li { margin-bottom: 0; }
  .site-footer li a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }

  /* stand-alone text links (not links inside running text) */
  .simple-page__back a, .osx__source a, .prom-app__alt a, .resume-links a, .contact-head__links a,
  .resume-viewer__back, .resume-viewer__download { display: inline-flex; align-items: center; min-height: 44px; }
  .prom-back-btn { min-height: 44px; }

  /* code / file toolbars (PROMETHEUS and OMEGA archives, OMEGA experiments) */
  .js .prom-copy, .js .prom-src-btn, .prom-src-dl, .js .omega-exp__copy {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px;
  }
  .omega-exp__copy { font-size: 0.82rem; padding-inline: 0.85rem; }
  .prom-modal__close, .prom-modal__tab { display: inline-flex; align-items: center; min-height: 44px; }
  .prom-notes__btn { min-width: 44px; min-height: 44px; }
  .resume-viewer__zoom button { min-width: 44px; min-height: 44px; }

  /* disclosure rows */
  .prom-index__list a { min-height: 44px; align-items: center; }
  .omega-exp__summary { min-height: 44px; }
  .prom-rec__more > summary { padding-block: 0.75rem; } /* keeps the native disclosure triangle (display unchanged) */

  /* scroll containers: momentum scrolling, no scroll chaining to the page */
  .prom-code__scroll, .omega-exp__scroll, .omega-exp__tablewrap, .prom-rec__scroll, .prom-fig__scroll, .prom-modal__body {
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  .prom-modal__body { overscroll-behavior: contain; }
  .prom-modal__backdrop { touch-action: none; }
}

/* Touch devices have no hover: stop hover effects from "sticking" after a tap */
@media (hover: none) {
  .prom-launch:hover { box-shadow: 0 2px 4px rgba(16, 29, 56, 0.08), 0 18px 48px rgba(16, 29, 56, 0.18); }
  .prom-launch:hover .prom-launch__img { transform: none; }
  .prom-launch:hover .prom-launch__cta { background: var(--navy-900); }
  .project-panel:hover { border-top-color: var(--navy-900); box-shadow: var(--shadow); }
  .prom-notes__link:hover { border-color: var(--gold-500); box-shadow: 0 1px 2px rgba(16, 29, 56, .06), 0 6px 18px rgba(16, 29, 56, .07); }
  .resume-preview:hover { border-color: var(--rule); box-shadow: 0 1px 2px rgba(16,29,56,.06), 0 8px 24px rgba(16,29,56,.08); }
  .prom-arch__summary:hover, .tl-item summary:hover { background: transparent; }
  .prom-arch[open] > .prom-arch__summary:hover { background: transparent; }
  .tl-item details[open] summary:hover { background: var(--surface); }
}

/* ---------- 2. Collapsed navigation (phones and narrow windows, JavaScript on) ---------- */
@media (max-width: 52rem) {
  .js .nav-toggle {
    display: inline-flex; align-items: center; gap: 0.55rem; padding: 0 0.9rem;
    font-weight: 600; letter-spacing: 0.04em; border-radius: 4px;
  }
  /* three-line / close glyph drawn in CSS (decorative; the button keeps its text label "Menu") */
  .js .nav-toggle::before {
    content: ""; width: 1rem; height: 0.75rem; flex: none;
    background: linear-gradient(currentColor, currentColor) 0 0 / 100% 1.5px no-repeat,
                linear-gradient(currentColor, currentColor) 0 50% / 100% 1.5px no-repeat,
                linear-gradient(currentColor, currentColor) 0 100% / 100% 1.5px no-repeat;
  }
  .js .nav-toggle[aria-expanded="true"] { background: var(--navy-900); color: var(--ivory-50); border-color: var(--navy-900); }
  .js .nav-toggle[aria-expanded="true"]::before {
    height: 1rem;
    background: linear-gradient(45deg, transparent calc(50% - 0.75px), currentColor calc(50% - 0.75px), currentColor calc(50% + 0.75px), transparent calc(50% + 0.75px)),
                linear-gradient(-45deg, transparent calc(50% - 0.75px), currentColor calc(50% - 0.75px), currentColor calc(50% + 0.75px), transparent calc(50% + 0.75px));
  }
  .js .site-nav.is-open { padding-top: var(--space-2); }
  .js .site-nav a { display: flex; align-items: center; min-height: 48px; padding: 0.25rem 0; font-size: 1rem; }
  .js .site-nav a[aria-current="page"], .js .site-nav a[data-section-current] { padding-left: var(--space-3); }
}

/* ---------- 3. Phones (portrait): typography and reading comfort ---------- */
@media (max-width: 40rem) {

  /* footer: a little more air between the stacked groups */
  .site-footer__base { padding-bottom: max(var(--space-4), env(safe-area-inset-bottom)); }

  /* horizontal-scroll affordance: soft edge shadows appear only where more content lies beyond the edge */
  .prom-code__scroll {
    background:
      linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center / 2.5rem 100% no-repeat local,
      linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center / 2.5rem 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(16, 29, 56, 0.2), rgba(16, 29, 56, 0)) left center / 0.85rem 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(16, 29, 56, 0.2), rgba(16, 29, 56, 0)) right center / 0.85rem 100% no-repeat scroll,
      #fff;
  }
  .prom-code__scroll > pre { background: transparent; }
  .omega-exp__scroll {
    background:
      linear-gradient(to right, #f7f2e7 30%, rgba(247, 242, 231, 0)) left center / 2.5rem 100% no-repeat local,
      linear-gradient(to left, #f7f2e7 30%, rgba(247, 242, 231, 0)) right center / 2.5rem 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(16, 29, 56, 0.2), rgba(16, 29, 56, 0)) left center / 0.85rem 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(16, 29, 56, 0.2), rgba(16, 29, 56, 0)) right center / 0.85rem 100% no-repeat scroll;
  }
  .prom-rec__scroll, .omega-exp__tablewrap {
    background:
      linear-gradient(to right, #fdfbf6 30%, rgba(253, 251, 246, 0)) left center / 2.5rem 100% no-repeat local,
      linear-gradient(to left, #fdfbf6 30%, rgba(253, 251, 246, 0)) right center / 2.5rem 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(16, 29, 56, 0.2), rgba(16, 29, 56, 0)) left center / 0.85rem 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(16, 29, 56, 0.2), rgba(16, 29, 56, 0)) right center / 0.85rem 100% no-repeat scroll,
      #fdfbf6;
  }
  .prom-rec__scroll > .prom-rec__table { background: transparent; }

  /* PROMETHEUS: application preview — a taller window onto the application (sidebar and first exchange) */
  .prom-launch__frame { aspect-ratio: 4 / 3; max-height: 78svh; }
  .prom-launch__img { object-position: 0 0; }

  /* enlarged viewers: full screen, dynamic viewport height, clear of the home indicator */
  .prom-modal__panel { height: 100vh; height: 100dvh; }
  .prom-modal__bar { padding-top: max(0.55rem, env(safe-area-inset-top)); padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
  .prom-modal__body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- 4. OMEGA "Experimental Set Up" on phones ----------
   One vertical composition: the photograph as wide as the screen with clear lettered markers, then the
   six annotations as an ordered legend that is also the connection schematic. The legend runs down the
   physical chain — A Surface → B adapter → C Cat6A cable → F HP EliteBook — joined by a gold line; D (the
   USB drive in the HP) and E (the 9260 card inside the HP, dashed as on the desktop figure) branch from F.
   Only the visual order changes: the DOM, reading order for assistive technology, every name and every
   description are exactly as on the desktop figure, and the 9260 reference photograph stays with E. */
@media (max-width: 40rem) {
  .osx__photo { width: calc(100vw - 0.75rem); max-width: none; margin-inline: calc(50% - 50vw + 0.375rem); }
  .osx__marker {
    width: 1.75rem; height: 1.75rem; font-size: 0.85rem; border-width: 1.5px;
    box-shadow: 0 1px 3px rgba(16, 29, 56, 0.28); font-variant-numeric: lining-nums;
  }
  .osx__notes { display: flex; flex-direction: column; gap: 0; margin-top: var(--space-5); }
  .osx__note { position: relative; grid-template-columns: 2.25rem minmax(0, 1fr); column-gap: 0.85rem; padding-bottom: var(--space-5); }
  .osx__note--a { order: 1; } .osx__note--b { order: 2; } .osx__note--c { order: 3; }
  .osx__note--f { order: 4; } .osx__note--d { order: 5; } .osx__note--e { order: 6; padding-bottom: 0; }
  .osx__letter {
    position: relative; z-index: 1; justify-self: center; width: 2rem; height: 2rem;
    font-size: 0.9rem; border-width: 1.5px; background: var(--ivory-50);
  }
  .osx__name { font-size: 1.25rem; padding-top: 0.2rem; font-variant-numeric: lining-nums; }
  .osx__desc { font-size: 1rem; margin-top: 0.3rem; }
  /* the chain A → B → C → F */
  .osx__note--a::before, .osx__note--b::before, .osx__note--c::before, .osx__note--f::before {
    content: ""; position: absolute; left: calc(1.125rem - 0.75px); top: 2rem; bottom: 0;
    border-left: 1.5px solid var(--gold-500);
  }
  /* D and E: components of F, indented beneath it */
  .osx__note--d, .osx__note--e { margin-left: 1.75rem; }
  .osx__note--d::before, .osx__note--e::before {
    content: ""; position: absolute; left: calc(-0.625rem - 0.75px); top: 0; width: 0.8rem; height: 1rem;
    border-left: 1.5px solid var(--gold-500); border-bottom: 1.5px solid var(--gold-500);
  }
  .osx__note--d::after {
    content: ""; position: absolute; left: calc(-0.625rem - 0.75px); top: 1rem; bottom: 0;
    border-left: 1.5px solid var(--gold-500);
  }
  .osx__note--e::before { border-left-style: dashed; border-bottom-style: dashed; }
  .osx__inset { width: min(17rem, 100%); margin-top: var(--space-4); }
  .osx__source { margin-top: var(--space-6); }
}

/* ---------- 5. Phones in landscape ---------- */
@media (orientation: landscape) and (max-height: 30rem) {
  /* the whole photograph fits in the visible height */
  .osx__photo { max-width: min(936px, calc(86svh * 936 / 682)); }
  .osx__marker { width: 1.75rem; height: 1.75rem; font-size: 0.85rem; border-width: 1.5px; box-shadow: 0 1px 3px rgba(16, 29, 56, 0.28); }
  .osx__name { font-variant-numeric: lining-nums; }
  /* enlarged viewers use the full screen; the short height goes to the content, not the frame */
  .prom-modal__panel { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .prom-modal__bar { padding-top: 0.35rem; padding-bottom: 0.35rem; padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
  .prom-launch__frame { max-height: 70svh; }
}
