/* TorBula · top bar icons, shared by every page with the top bar (the
   portfolio, both hubs, every tool). See CLAUDE.md, "one top bar everywhere".
   Also the band behind the clock in the home-screen app (end of the file).

   Theme button: sun ⇄ moon. Both glyphs sit stacked in .tbi-theme and the
   one that doesn't apply is turned a quarter away and scaled to nothing
   (transform only, never opacity: the button is glass). On a switch the old
   glyph turns away and shrinks, accelerating (.2s), and the new one turns in
   and grows a touch past full size before settling (.38s after .12s), like
   SF Symbols' replace: .5s in all, the timing of the Settings panel and of
   the language globe (nav-icons.js). One wheel: into dark everything turns
   clockwise, out of it back. The transition that runs is the one of the
   state an icon goes TO, so each rule carries its own.

   Markup (sizes/colours come from the page's own icon class):
     <button …><span class="tbi-theme" aria-hidden="true">
       <img src="…/main-svg/sol.svg" class="nav-ic-img tbi-sun" alt="">
       <img src="…/main-svg/luna.svg?v=2" class="nav-ic-img tbi-moon" alt="">
     </span></button>
   The page's inline pre-paint script puts .dark on <html> (hubs) or <body>
   (portfolio, tools); either works here. */
.tbi-theme { display: grid; place-items: center; }
.tbi-theme > * {
  grid-area: 1 / 1; display: block;
  transition: transform .38s .12s cubic-bezier(.34, 1.5, .64, 1);   /* arriving */
}
/* Ink: the pages colour these icons with filter: invert(1) in dark, which
   flips at once, while the glass behind may still be fading. Into dark the
   button stays light until the page behind darkens, so the leaving sun keeps
   its dark ink until it has shrunk away. Out of dark the portfolio's and the
   tools' buttons turn light at once (the moon takes the new ink straight
   away), but the hubs' capsules fade their background over .25s: they set
   --tbi-ink-wait (.12s, halfway) so the moon doesn't turn black on dark. */
.tbi-theme > .tbi-moon {   /* leaving */
  transition: transform .2s cubic-bezier(.4, 0, 1, 1), filter 0s var(--tbi-ink-wait, 0s);
}
.dark .tbi-theme > .tbi-sun { transition: transform .2s cubic-bezier(.4, 0, 1, 1), filter 0s .2s; }
.tbi-theme > .tbi-moon { transform: rotate(-90deg) scale(0); }
.dark .tbi-theme > .tbi-sun { transform: rotate(90deg) scale(0); }
.dark .tbi-theme > .tbi-moon {
  transform: none;
  transition: transform .38s .12s cubic-bezier(.34, 1.5, .64, 1);
}
@media (prefers-reduced-motion: reduce) {
  .tbi-theme > * { transition: none !important; }
}

/* Legibility on bright content (user, 2026-11-24). In dark mode the glass
   is nearly clear and the type and glyphs on it are white, so over a white
   tile, photo or page they vanished. As iOS 26 does with clear glass over
   media: the glass dims a little (each page's dark .liquidGlass-tint /
   .nav-ic, rgba(0,0,0,.14) where it was 5 % white) and the type and glyphs
   get a soft shadow that hugs them, not the whole button. Over the usual
   dark background the shadow can't be seen. The hubs' capsules are opaque
   and don't need it (their classes don't match). */
body.dark :is(.nav-wrap :is(.nav-link, .nav-logo-txt, .nav-title), .btn-glass .btn-label) {
  text-shadow: 0 0 1px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .35), 0 0 10px rgba(0, 0, 0, .35);
}
/* The bar's section links are all in the PRIMARY colour, the pill alone
   marks the current one: like iOS 26 tab bars, whose unselected items are
   the label colour and the selected one sits in the glass lens. The old
   secondary grey (--t2) only read on the background it was picked for: on
   glass over a bright tile in dark mode, or a dark one in light mode, it
   all but vanished (user, 2026-11-24). Only in the top bar (.nav-wrap): the
   tools use .nav-link for tabs and segmented controls on solid panels too. */
.nav-wrap .nav-link {
  color: var(--t1);
  transition: color .25s var(--ease), font-weight .25s var(--ease);
}
/* …and the current one also in semibold, as iOS's segmented control does,
   so it stands out even where the pill is faint (light mode). Each link
   keeps its SEMIBOLD width at all times (an invisible bold copy of its
   label, data-label, which nav-icons.js keeps in step with the text), so
   nothing shifts and the pill doesn't jump when the current one changes. */
.nav-wrap .nav-link.active { font-weight: 600; }
.nav-wrap .nav-link::after {
  content: attr(data-label);
  content: attr(data-label) / "";   /* not read aloud where supported */
  display: block; height: 0; overflow: hidden; visibility: hidden;
  font-weight: 600;
}
body.dark .nav-wrap .nav-ic-img {   /* the pages already invert these in dark */
  filter: invert(1) drop-shadow(0 0 1px rgba(0, 0, 0, .4)) drop-shadow(0 1px 3px rgba(0, 0, 0, .4));
}
body.dark .nav-wrap :is(.nav-logo-mark, .nav-promo, .nav-back-ic) {
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, .4)) drop-shadow(0 1px 3px rgba(0, 0, 0, .4));
}
body.dark .nav-burger span { box-shadow: 0 0 1px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .35); }

/* Home-screen app (user report 2026-11-25: "opened from the home screen, the
   top bar's buttons blur"). Opened from its icon, iOS 26+ may draw the site
   under the clock, and then iOS 27 blurs the top of the screen down to about
   110pt, past the clock: our bar sat right in it. Three layers, since iOS
   documents none of this (community reports, iOS 27.0-27.2):
   1. <meta name="apple-mobile-web-app-status-bar-style" content="default"> on
      every page with the bar: the page starts BELOW the clock, which iOS
      tints with theme-color, and there is no blur at all. iOS reads it only
      when the app is added: an icon added before it keeps the old behaviour
      until it is removed and added again from Safari. Without the meta, iOS
      27.2 drew our page under the clock (user's screenshot, 2026-11-26).
   2. if the page still runs under the clock, every top bar (and what is
      laid out from it) starts env(safe-area-inset-top) lower: the clock's
      band, 0 below the clock, in a Safari tab and on a computer.
   3. this band covers that zone. A pinned, full-width element with a plain
      colour at the top edge makes iOS paint the status bar solid in that
      colour. A real element right after <body> on every page with the bar
      (<div class="tb-sbar" aria-hidden="true"></div>), plain
      background-color, no gradient and no transition on it (iOS reads it,
      and a gradient's sample goes stale). It takes taps and sits above
      EVERY layer: iOS finds it by hitting the top edge, and the first try
      ignores pointer-events, so an invisible full-screen layer above it (the
      portfolio's closed referral overlay, opacity 0) won and the status bar
      stayed blurred (kleis #98 found the same). Its height is the inset, so
      without one it is 0 px and nothing at all. The fade under it lets
      content scrolling up dissolve into it instead of being cut. Pages that
      lay out with JS read the inset from this band's height (Lector PDF). */
.tb-sbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2147483647;
  height: env(safe-area-inset-top, 0px);
  background-color: var(--bg);
}
.tb-sbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%;
  height: min(12px, env(safe-area-inset-top, 0px));
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}

/* ═══════ Sin zoom con doble toque / doble clic (user, 2026-11-27: "no debe ampliarse en ningún lado") ═══════
   iOS Safari ignora user-scalable=no; lo que lo evita es touch-action: manipulation. Va aquí porque esta hoja la
   cargan el portfolio, los dos hubs y todas las herramientas, y con :where(): especificidad 0, así que lo que una
   página ya fije para sus superficies de arrastre (touch-action: none / pan-x pan-y…) sigue mandando. */
:where(*) { touch-action: manipulation; }
