/* Taxi OS under a finger — one place for the rules touch needs.
 *
 * Linked from every page AFTER its own <style>, so these settle a tie.
 *
 * Jenn, 2026-11-13: "i every time when click something using my hand, it show's a shadow.
 * i dont want a shadow. remove all of them." Two different things paint it:
 *
 *   1. iOS draws a translucent grey square over whatever a finger lands on. That is
 *      `-webkit-tap-highlight-color`, and it is on by default on every tappable thing.
 *   2. A tap also leaves `:hover` applied until the next tap somewhere else, so a card
 *      that lifts and shadows under a mouse stays lifted. Those rules are gated at their
 *      source with `@media (hover: hover)` — a lift belongs to a pointer that can hover.
 *
 * Both are fixed; this file does the first, everywhere at once.
 */

html, body, *, *::before, *::after { -webkit-tap-highlight-color: transparent; }

/* No wait after a tap. iOS ignores a page's "no zoom" (maximum-scale, user-scalable), so every
 * page can still be zoomed with a double tap, and Safari may hold a single tap back to see
 * whether a second is coming (Jenn, 2026-11-13: "the respond is slow when click anything").
 * `manipulation` keeps scrolling and pinch-zoom and drops only the double tap, so a tap is
 * answered at once. It goes on the things a finger taps, NOT on html/body: the Calendar sets
 * its own pan-only there so it never zooms (Jenn, 2026-11-04), and a later html rule would
 * overwrite that. On a control, touch actions narrow from ancestor to child and never widen,
 * so inside the Calendar a button still cannot zoom.
 */
a, button, input, select, textarea, label, summary, [onclick], [role="button"] {
  touch-action: manipulation;
}

/* Safari also paints its own callout menu on a long press over a link or a button, which
 * is a second grey flash on a slow tap. Text stays selectable: only controls are excluded.
 */
button, a, [role="button"], [onclick], label, summary {
  -webkit-touch-callout: none;
}

/* ── A target a finger can hit ──────────────────────────────────────────────────────────
 * 44px is the smallest target a finger hits reliably (Apple's own figure). On an iPad the top
 * bars' links were 23px tall, the ways back 16, most of the pages' own buttons 24 to 34, and
 * the WhatsApp operator's dot 8: a finger that lands a little off lands on nothing, which
 * feels exactly like a tap that was ignored (Jenn, 2026-11-13: "feels like i did not click
 * anything").
 *
 * The first pass wrote `.topnav a { padding: 13px }` here and it never took: topnav.js appends
 * its own `.topnav a{padding:5px 11px}` to <head> at run time, after this file, and won on
 * order — hence `.topnav.topnav`. tests/ipad_browser.mjs now measures it the way a finger
 * meets it, asking the page what each point around a control would land on.
 */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 600px) {
  /* The links: 44px tall to a finger, 30 drawn (the pill under the page you are on). A
     transparent border is part of what a finger hits but not of what is painted. */
  .topnav.topnav a {
    padding: 8px 11px; line-height: 14px;
    border-top: 7px solid transparent; border-bottom: 7px solid transparent;
  }
  /* topnav.js colours the page you are on (and a hovered link) with the `background`
     shorthand, which puts the clip back to the border: said again for those, or the pill
     paints the whole 44px. */
  .topnav.topnav a, .topnav.topnav a.active, .topnav.topnav a:hover { background-clip: padding-box; }
  /* The ways back carry no background, so they simply stand 44px tall. The Pipeline's way Home
     is the classless button in its .brand; its .back-btn is the chat's way back to the list,
     which the Pipeline hides with !important when both panes show. .pl-back is the pay sheet's
     way back to the person (/team/<id>/pay), which has no bar of its own. A way back that sits
     straight in a .topbar (Insights, Brain Memory) gets its 44 from the reach below. */
  .topbar .back-btn, .top .back-btn, .brain-topbar .back2, .topbar .brand > button, .chat-head .back-btn,
  .pl-back {
    min-height: 44px; display: inline-flex; align-items: center;
  }
  /* The square icon buttons on Home's bar (team, bell). */
  .notif-bell, .tb-icon { width: 44px; height: 44px; }
  /* Everything else in a bar keeps its look, and the area a finger can land on grows to 44px
     around it, invisibly — what `.add-btn::after` already did on Tasks, here for each of them.
     Measured from the middle, so a button already 44px gains nothing and one drawn 27px tall
     reaches 8.5px past each edge. It is measured from inside the border, so a bordered button
     reaches the full 44 where an inset of 7px stopped at 42 (the Calendar's layers button). */
  .topbar > button, .topbar > a, .topbar-right > button, .topbar-right > a,
  .topbar .chip, .topbar .view-seg-btn, .topbar .btn-new, .topbar .today-btn, .topbar .add-btn,
  .topbar .layer-btn, .or-bar-right > a, .or-bar-right > button, .topbar .tb-ico, .brain-topbar .top-btn,
  #brainLogWrap > button, #userMenuBtn, .top .r > button, .top .r > a {
    position: relative;
  }
  .topbar > button::before, .topbar > a::before, .topbar-right > button::before, .topbar-right > a::before,
  .topbar .chip::before, .topbar .view-seg-btn::before, .topbar .btn-new::before, .topbar .today-btn::before,
  .topbar .add-btn::before, .topbar .layer-btn::before, .or-bar-right > a::before, .or-bar-right > button::before, .topbar .tb-ico::before, .brain-topbar .top-btn::before,
  #brainLogWrap > button::before, #userMenuBtn::before, .top .r > button::before, .top .r > a::before {
    content: ''; position: absolute;
    top: min(0px, calc(50% - 22px)); bottom: min(0px, calc(50% - 22px));
    left: min(0px, calc(50% - 22px)); right: min(0px, calc(50% - 22px));
  }
  /* Tasks' filter chips and the Calendar's Day / Week / Month sit a few px apart in one group.
     Drawn at least a finger wide, they reach only up and down, so a tap between two never
     lands on the wrong one. */
  .topbar .chip, .topbar .view-seg-btn { min-width: 44px; }
  /* Outreach's two square buttons were 8px apart, so each reached into the other's 44. */
  .or-bar-right { gap: 12px; }
  /* The × that closes a form or a panel (new task, a task's panel, a job, an event, Account)
     is drawn 24 to 28px; it reaches 44 the same way. Only these: a × in a list (Home's "Cancel
     this leave", a job's date blocks) keeps its size, so a finger can't land on the row above. */
  .tm-head .tm-x, .detail-close, .modal-x, .modal-close { position: relative; }
  .tm-head .tm-x::before, .detail-close::before, .modal-x::before, .modal-close::before {
    content: ''; position: absolute;
    top: min(0px, calc(50% - 22px)); bottom: min(0px, calc(50% - 22px));
    left: min(0px, calc(50% - 22px)); right: min(0px, calc(50% - 22px));
  }
  /* The WhatsApp operator's dot on Home and the Pipeline (owner and admin) was 8px to tap. */
  #op-nav-indicator { min-width: 44px; min-height: 44px; justify-content: center; }
  #op-nav-widget { top: 44px !important; }
}

/* The shared top bar hides itself at 768px and under, which is where an iPad mini (744)
   and a 9.7" iPad (768) sit in portrait. A tablet has room for it, standing or lying
   (Jenn, 2026-11-13: "why some top bar has navigation some are not? make all them the
   same and has top bar navigation"). */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 600px) {
  /* Written twice over so it outranks the hide topnav.js injects: that <style> is appended
     to <head> at run time, after this file, so an equally specific rule would win on order
     and an iPad mini (768 wide) would lose its navigation. */
  .topnav.topnav { display: flex !important; }
  .divider-v.divider-v { display: block !important; }
}

/* ── Nothing passes above the top bar ───────────────────────────────────────────────────
 * Added to the Home Screen, Taxi OS runs full screen with a TRANSLUCENT status bar
 * (apple-mobile-web-app-status-bar-style: black-translucent), so the page begins behind the
 * clock. Three pages left room for it and seventeen did not: on an iPad the Jobs page drew
 * its title straight through the time (Jenn, 2026-11-13: "nothing should pass above the top
 * bar").
 *
 * One figure does it, and the pages' own offsets are already written on top of it:
 * --topbar-h is the bar's whole height, the status bar included.
 */
:root {
  --topbar-safe: env(safe-area-inset-top, 0px);
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --topbar-h: calc(52px + var(--topbar-safe));
}
.topbar, .brain-topbar {
  height: var(--topbar-h);
  padding-top: var(--topbar-safe);
  box-sizing: border-box;
}

/* The nav is the widest thing in the bar and an iPad standing up is not wide. It scrolls
   inside the bar rather than pushing the page's own buttons off the edge.
   A grid or flex child refuses to shrink below its content unless it is told to, so a bar
   too wide for the screen stretched its whole column: the Calendar drew a 833px month inside
   an 820px screen, which is the cut-off again by another road. */
@media (pointer: coarse) {
  .app > *, .main, .topbar { min-width: 0; }
  /* The nav is the one thing in the bar that may give way. Letting the bar shrink made the
     buttons beside it fold their words onto two lines ("← Home", "+ New"). */
  .topbar button, .topbar > a, .topbar .back-btn, .topbar .back, .topbar .btn-new,
  .topbar .page-title, .topbar .title, .topbar-right a,
  .brain-topbar button, .brain-topbar > a, .brain-topbar .back2, .top .back-btn {
    flex: none; white-space: nowrap;
  }
  /* The group of buttons on the right is the page's own: it keeps its width, and the nav
     beside it is what scrolls. Outreach's let its Gmail button be squeezed to an empty box. */
  .topbar-right, .or-bar-right { flex: none; }
  /* A name beside the way back keeps to one line ("Internal Hub", "Website Insights" and
     "Reply Lessons" folded). */
  .topbar .brand, .topbar .brand-sub, .topbar > strong, .topbar .topbar-title { flex: none; white-space: nowrap; }
  /* A strip that scrolls has to look like one: its far edge fades out, so "Out…" reads as
     "more this way" and not as a bar that has been cut off. */
  .topnav {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    padding-right: 24px;
  }
  /* ...and once it has been scrolled (layout.js marks it), the near edge fades as well, so a
     word cut by the left edge reads the same way instead of as "os". */
  .topnav.topnav-scrolled {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  }
  .topnav {
    flex: 1 1 auto; min-width: 0;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topnav::-webkit-scrollbar { display: none; }
  /* Accounting's bar keeps its nav to one 27px row and drops whatever doesn't fit, which on an
     iPad standing up dropped "My profile" and, on the narrowest, "Accounting" itself — the page
     you are on. Under a finger it scrolls like every other page's. */
  .topbar .topnav.topnav {
    flex-wrap: nowrap; height: auto; padding: 0 24px 0 0;
    overflow-x: auto; overflow-y: hidden;
  }
}

/* My profile and the pay pages draw their bar as two groups that may wrap, so on an iPad mini
   standing up the nav fell to a row of its own and pushed Edit profile and Sign out to a third.
   On a tablet the left group stays one row and its nav scrolls, as everywhere else. */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 600px) {
  .top { flex-wrap: nowrap; }
  .top .l { flex-wrap: nowrap; flex: 1 1 auto; min-width: 0; }
  .top .r { flex: none; flex-wrap: nowrap; }
}

/* ── A tap you can see ──────────────────────────────────────────────────────────────────
 * Jenn, 2026-11-13, once the shadow had gone: "when i click those feature card feels like i
 * did not click anything. just felt like something wrong." Taking away the grey square and
 * the stuck lift took away the only sign a tap had landed, and a page that then takes a third
 * of a second to come from the server reads as a tap that was ignored.
 *
 * What a finger is on now dims the instant it lands, the way iPadOS's own buttons do, and a
 * tool card sinks a little. Not a shadow. layout.js puts .is-pressed on the ONE thing under
 * the finger: CSS :active would light every ancestor as well, the dim page behind a sheet
 * included, and on iOS it does not fire at all without a touch listener.
 */
.is-pressed { opacity: .5 !important; transition: none !important; }
.entry-card.is-pressed, .team-card.is-pressed {
  opacity: .78 !important; transform: scale(.975) !important;
}
/* ...and lets go gently, whatever the element's own transition says. */
.is-releasing { transition: opacity .2s ease, transform .2s ease !important; }
/* A finger that turned out to be scrolling: the dim goes at once, nothing fades in view. */
.is-dropped { transition: none !important; }

/* ── A page on its way ─────────────────────────────────────────────────────────────────
 * A thin line under the status bar from the moment a link is tapped until the next page
 * paints: the wait for the server reads as work rather than as nothing happening.
 */
#navProgress {
  position: fixed; top: var(--topbar-safe, 0px); left: 0; height: 3px; width: 0;
  background: #0071e3; z-index: 2147483000; pointer-events: none; opacity: 0;
  border-radius: 0 2px 2px 0;
}
#navProgress.on {
  width: 85%; opacity: 1;
  transition: width 2.4s cubic-bezier(.08, .8, .2, 1), opacity .15s;
}
/* ...and what was tapped stays pressed until its page comes, a tool card with a turning ring in
   its corner, where the finger and the eye are (layout.js going(): the press used to fade a tenth
   of a second after the tap, half a second before the page, and was tapped again). */
.is-going { opacity: .5 !important; }
.entry-card.is-going { opacity: .78 !important; transform: scale(.975) !important; position: relative; }
.entry-card.is-going::after {
  content: ""; position: absolute; top: 12px; right: 12px; width: 18px; height: 18px;
  box-sizing: border-box; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .12); border-top-color: #0071e3;
  animation: taxi-going .7s linear infinite;
}
@keyframes taxi-going { to { transform: rotate(360deg); } }

/* ── Nothing waits for a hover ─────────────────────────────────────────────────────────
 * A tablet has no hover, so a control drawn invisible until the pointer was over its row was
 * there to be tapped and never seen: a job's ··· menu on Jobs, a chat's delete and a reply's
 * copy in Taxi Brain. On a screen that cannot hover they are simply shown. (The Pipeline's own
 * hover controls already sit behind (hover: hover) and use a long press on touch.)
 */
@media (hover: none) {
  .row-menu-btn, .chat-del, .copy-btn { opacity: 1 !important; }
  .row-menu-btn { min-width: 44px; min-height: 44px; }
}
