/* =========================================================================
   Case-study navigation for tablet + mobile (below 1024px), shared by the three case studies.
   Both pieces appear once the reader starts scrolling (js/case-nav.js adds .is-shown):
     - top:    Previous / Next case study. Left button sits on the left padding, right button
               on the right padding.
     - bottom: the landing page's floating dock: same markup, same look, same mobile "Menu".
   On desktop (1024+) neither is shown: the side panel carries Previous / Next there.

   The dock rules are copied from css/style.css ("10. FLOATING DOCK" and its responsive part)
   because the case studies don't load that stylesheet. Landing-page tokens are scoped to
   .dock so the case studies' own colours are untouched.
   Breakpoints: mobile ≤767, tablet 768–1023.
   ========================================================================= */

.fn-topbar, .dock { display: none; }

@media (max-width: 1023px) {

  /* ---------- top: Previous / Next ---------- */
  .fn-topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    position: fixed; top: 0; left: 0; right: 0; z-index: 40;
    /* same inset as the page title: 8px page edge + the panel's own left padding */
    padding: max(0.75rem, env(safe-area-inset-top)) calc(8px + clamp(1rem, 2vw, 2rem)) 0.5rem;
    pointer-events: none;                 /* only the two buttons take taps */
    opacity: 0; transform: translateY(-100%);
    transition: opacity .35s cubic-bezier(0.22, 1, 0.36, 1), transform .35s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .fn-topbar.is-shown { opacity: 1; transform: none; }
  .fn-topbar a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 2.75rem; padding: 0.6rem 1.25rem; border-radius: 100px;
    /* same glass as the dock below: lighter tint, soft blur, cream text */
    background: rgba(20, 20, 24, 0.40); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 0;
    font-size: 0.75rem; font-weight: 500; line-height: 1.2; letter-spacing: 0.12em; text-transform: uppercase;
    color: #f4f1ea; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35); white-space: nowrap;
    pointer-events: none;
    transition: color .3s, border-color .3s, background-color .3s;
  }
  .fn-topbar.is-shown a { pointer-events: auto; }
  .fn-topbar a:hover, .fn-topbar a:focus-visible {
    color: #fff; background: rgba(20, 20, 24, 0.55);
  }

  /* ---------- bottom: the landing page's dock ---------- */
  .dock {
    --ink: #f4f1ea; --ink-2: #cfcabf; --muted: #948d80; --accent: #c6c2b9;
    --display: "Tokyo Dreams", "Libre Baskerville", Georgia, serif;
    --sans: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    position: fixed; z-index: 300;
    left: 50%; bottom: clamp(16px, 2.6vh, 30px);
    display: flex; align-items: center; gap: clamp(1.4rem, 3.2vw, 2.75rem);
    padding: 0.5rem 0.5rem 0.5rem 0.75rem;
    border-radius: 100px;
    background: rgba(20, 20, 24, 0.40);   /* same light glass as the landing page */
    border: none;
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    box-shadow: 0 24px 60px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.12);
    max-width: calc(100vw - 16px);
    font-family: var(--sans); line-height: 1.6;
    /* hidden until the reader starts scrolling */
    opacity: 0; transform: translateX(-50%) translateY(24px); pointer-events: none;
    transition: opacity .4s var(--ease), transform .5s var(--ease);
  }
  .dock.is-shown { opacity: 1; transform: translateX(-50%); pointer-events: auto; }

  .dock__bar { display: contents; }   /* transparent on tablet */
  .dock__brand { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; flex: none; background: rgba(255,255,255,0.06); display: grid; place-items: center; transition: opacity .35s var(--ease), transform .4s var(--ease); }
  .dock__brand img { display: block; width: 60%; height: 60%; object-fit: contain; }
  .dock__links { display: flex; gap: clamp(0.95rem, 2vw, 1.6rem); padding: 0 0.4rem; }
  .dock__links a {
    position: relative; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
    padding: 0.3em 0; white-space: nowrap; transition: color .4s var(--ease);
  }
  .dock__links a:hover { color: #fff; }

  /* NB: :where() keeps these selectors at the landing page's specificity (a bare .pill),
     so the later .dock__bigCta / .pill--menu rules win exactly as they do there. */
  :where(.dock) .pill {
    display: inline-flex; align-items: center; gap: 0.7em;
    font-family: var(--sans); font-size: 0.75rem; font-weight: 500;
    letter-spacing: 0.14em; text-transform: uppercase;
    white-space: nowrap;
    padding: 0.85em 1.4em; border-radius: 100px;
    border: none;
    background: rgba(0,0,0,0.28); color: var(--ink);   /* no blur of its own: it sits on the dock's glass */
    transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease), transform .45s var(--ease);
  }
  :where(.dock) .pill:hover { background: var(--ink); color: #111; border-color: var(--ink); }
  :where(.dock) .pill__plus { font-size: 1.15em; line-height: 0; transition: transform .45s var(--ease); }
  :where(.dock) .pill:hover .pill__plus { transform: rotate(90deg); }
  :where(.dock) .pill--contact { background: var(--ink); color: #111; border-color: var(--ink); }
  :where(.dock) .pill--contact:hover { background: rgba(244, 241, 234, 0.14); color: var(--ink); }
  :where(.dock) .pill--contact .pill__plus { font-size: 1em; }
  :where(.dock) .pill--contact:hover .pill__plus { transform: translate(2px, -2px); }

  /* Mobile "Menu" button: shown at the mobile breakpoint only (see below) */
  :where(.dock) .pill--menu { display: none; background: var(--ink); color: #111; border: none; cursor: pointer; transition: background-color .45s var(--ease), color .45s var(--ease), opacity .35s var(--ease), transform .4s var(--ease); }
  :where(.dock) .pill--menu:hover { background: rgba(244, 241, 234, 0.14); color: var(--ink); }
  /* mobile-expanded-panel only: must come AFTER the .pill rules above (same specificity, as on the landing page) */
  .dock__bigLinks, .dock__bigCta, .dock__close { display: none; }
  .dock__close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; fill: none; }
  html.menu-open body { overflow: hidden; }
}

/* Mobile: the dock IS the menu: same pill, same width, always.
   "Menu" only grows it TALLER (not wider): the logo + Menu bar fades out, a close (X) fades in at
   the top, the big stacked links fade into the middle and a full-width "Preview CV" pins to the bottom. */
@media (max-width: 767px) {
  :where(.dock) .pill--menu { display: inline-flex; padding: 0.95rem 1.5rem; }
  .dock__links { display: none; }   /* the small inline row is for tablet */
  .dock .pill--contact { display: none; }   /* replaced by .dock__bigCta on mobile */

  .dock {
    width: min(88vw, 420px);
    height: 57px;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    padding: 0.4rem;
    border-radius: 100px;
    overflow: hidden;
    bottom: calc(clamp(16px, 2.6vh, 30px) + env(safe-area-inset-bottom, 0px));
    transition: opacity .4s var(--ease), transform .5s var(--ease), height .5s var(--ease), border-radius .5s var(--ease), background-color .45s var(--ease);
  }
  .dock.is-open {
    height: min(64vh, 540px);   /* tall enough for the larger links below */
    border-radius: 32px;
    padding-bottom: 0.6rem;
  }

  /* logo + Menu bar: the closed-state content, fades out as a whole */
  .dock__bar {
    display: flex; align-items: center; justify-content: space-between;
    flex: none; width: 100%;
    opacity: 1; transition: opacity .3s var(--ease);
  }
  .dock.is-open .dock__bar { opacity: 0; pointer-events: none; }

  /* close (X): centred at the very top, independent of the bar */
  .dock__close {
    display: grid; place-items: center; position: absolute;
    top: 0.4rem; left: 50%; transform: translateX(-50%) scale(0.5);
    width: 40px; height: 40px; border-radius: 50%;
    background: transparent; border: none; color: var(--ink); cursor: pointer;
    opacity: 0; pointer-events: none; z-index: 2;
    transition: opacity .35s var(--ease), transform .4s var(--ease);
  }
  .dock.is-open .dock__close { opacity: 1; transform: translateX(-50%) scale(1); pointer-events: auto; }

  /* big stacked links: fade into the tall middle area once the pill has grown */
  .dock__bigLinks {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; gap: clamp(0.8rem, 2.6vh, 1.4rem); text-align: center;
    opacity: 0; pointer-events: none;
    transition: opacity .3s var(--ease);
  }
  .dock.is-open .dock__bigLinks { opacity: 1; pointer-events: auto; }
  .dock__bigLinks a {
    font-family: var(--display); font-weight: 400; color: var(--ink);
    font-size: clamp(1.7rem, 7.6vw, 2.1rem); line-height: 1; letter-spacing: 0.01em;
    transition: color .35s var(--ease), transform .45s var(--ease);
  }
  .dock__bigLinks a:hover { color: var(--accent); transform: translateY(-2px); }

  /* Preview CV: full width, pinned at the very bottom */
  .dock__bigCta {
    display: flex; flex: none; width: 100%; justify-content: center;
    padding: 0.95rem 1.5rem; line-height: normal;   /* the same height as the Menu button (a <button>, so line-height: normal) */
    background: var(--ink); color: #111;
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .35s var(--ease), transform .4s var(--ease), background-color .45s var(--ease), color .45s var(--ease);
  }
  .dock__bigCta:hover { background: rgba(244, 241, 234, 0.14); color: var(--ink); }
  .dock.is-open .dock__bigCta { opacity: 1; transform: translateY(0); pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .fn-topbar, .dock { transition-duration: 0.001ms !important; }
}

/* =========================================================================
   Image viewer (tablet / mobile): tap a diagram marked [data-zoom] to open it enlarged.
   js/case-nav.js builds the overlay on first use. The picture is shown far wider than the
   screen and can be dragged around (and pinch-zoomed further), on the case study's light blue.
   ========================================================================= */
.zoom { display: none; }

@media (max-width: 1023px) {
  .zoom {
    position: fixed; inset: 0; z-index: 1000;   /* above the dock (300) and the top bar (40) */
    background: #A2CBE6;
  }
  .zoom.is-open { display: block; animation: zoom-fade .25s ease both; }

  .zoom__scroller {
    position: absolute; inset: 0; overflow: auto;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    touch-action: pan-x pan-y pinch-zoom;
  }
  .zoom__stage { width: max-content; padding: 4.5rem 1.25rem 2.5rem; }
  .zoom__img { display: block; width: clamp(1300px, 200vw, 2600px); max-width: none; height: auto; }

  .zoom__close {
    position: fixed; top: max(0.75rem, env(safe-area-inset-top)); right: 0.9rem; z-index: 2;
    display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border-radius: 50%; border: 1px solid rgba(27, 37, 64, 0.22);
    background: rgba(255, 255, 255, 0.55); color: #1b2540; cursor: pointer;
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .zoom__close:hover, .zoom__close:focus-visible { background: rgba(255, 255, 255, 0.85); }
  .zoom__close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; fill: none; }

  html.zoom-open body { overflow: hidden; }
}
@keyframes zoom-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .zoom.is-open { animation: none; } }

/* =========================================================================
   Custom cursor (devices with a mouse): the same small dot as on the landing page.
   js/case-nav.js creates the element and moves it; the system cursor is hidden while it is on.
   ========================================================================= */
.cursor { position: fixed; top: 0; left: 0; z-index: 9999; pointer-events: none; display: none; }
html.has-cursor .cursor { display: block; }
html.has-cursor, html.has-cursor a, html.has-cursor button,
html.has-cursor [role="button"], html.has-cursor img[data-zoom] { cursor: none; }
.cursor__dot {
  position: fixed; top: 0; left: 0; width: 12px; height: 12px; border-radius: 50%;
  background: #f4f1ea; transform: translate(-50%, -50%); mix-blend-mode: difference;
  transition: width .3s cubic-bezier(0.22, 1, 0.36, 1), height .3s cubic-bezier(0.22, 1, 0.36, 1);
}
html.cursor-active .cursor__dot { width: 26px; height: 26px; }
