/* Cyphra brand override (Phase 7). Unlayered, so it beats Twenty's @layer rdg, twenty-ui rules.
   Logical properties only (RTL). No colour except the inherited tertiary text token (D-04) and the 09 + New button,
   which uses Twenty's own accent token like every Cyphra primary action. */
[data-cyphra-hidden] {
  display: none !important;
}

/* S-2 Powered-by mark: not interactive, below Twenty's menus and modals. */
#cyphra-powered {
  position: fixed;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 400 12px/1.4 var(--t-font-family);
  color: var(--t-font-color-tertiary);
  pointer-events: none;
  white-space: nowrap;
}

/* Sidebar side in both LTR and RTL. */
#cyphra-powered.cyphra-auth {
  inset-block-end: 8px;
  inset-inline-start: 16px;
}

/* S-2 fallback, shipped: in flow at the end of the sidebar nav, so it can never cover a nav control.
   The collapsed sidebar is a 48px icon rail; the mark has no room there and is hidden. */
:has(> [id^="scroll-wrapper-"][id$="navigation-drawer"]) {
  container-type: inline-size;
}

#cyphra-powered.cyphra-nav {
  position: static;
  padding-block: 8px;
  padding-inline: 16px;
}

@container (max-width: 159px) {
  #cyphra-powered.cyphra-nav {
    display: none;
  }
}

/* Login pages: the slot of the hidden legal footer (D-20). */
#cyphra-powered.cyphra-login {
  inset-block-end: 24px;
  inset-inline: 0;
  justify-content: center;
}

/* The Privacy and Terms links are the mark's only interactive part. */
#cyphra-powered a {
  color: inherit;
  pointer-events: auto;
}

@media (max-width: 767px) {
  #cyphra-powered.cyphra-auth,
  #cyphra-powered.cyphra-nav {
    display: none;
  }
}

@media (max-height: 639px) {
  #cyphra-powered.cyphra-login {
    display: none;
  }
}

/* H7: no links to Twenty's site or repositories. */
a[href*="twenty.com"],
a[href*="twentyhq"] {
  display: none !important;
}

/* Phase 6 M-2: F1 view a customer — record link chips (the contact on a company page) are about 22px tall, under the
   24px tap floor (UI-SPEC G4) — upstream to file. The chip is content-box with block padding, so the content minimum
   is 24px less that padding. Hook: the chip's data-clickable attribute (mobile-smoke asserts it). 09-09 X1: the phone
   chip (Call, an a[href^="tel:"] chip, 21px) gets the same floor. */
@media (max-width: 768px) {
  a[href^="/object/"][data-clickable],
  a[href^="tel:"][data-clickable] {
    min-block-size: calc(24px - 2 * var(--t-spacing-1));
  }
}

/* 09-01 UI-SPEC S-1: the + New floating button at the inline end (left edge in RTL). 261110-fml supersedes S-1
   "Desktop: Never rendered": on desktop it shows as a labelled pill (+ New / + جديد). On phones it sits 16px above
   the stock bottom bar. z-index 24, measured in Edge on v2.52.0: the phone bottom bar's box is z 23 and spans the full width, so the
   button must sit above it to take taps; the side panel (z 21), dropdowns (z 38) and modals are above or equal only while
   open, and cyphra.js hides the button whenever one is open. */
#cyphra-fab {
  position: fixed;
  z-index: 24;
  inset-inline-end: 16px;
  inset-block-end: calc(var(--cyphra-bottom-bar) + 16px + env(safe-area-inset-bottom));
  inline-size: 56px;
  block-size: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--t-border-radius-pill);
  /* Stock sets corner-shape: squircle globally; its own pills opt back like this. */
  corner-shape: round;
  background: var(--t-color-blue);
  color: var(--t-font-color-on-accent);
  box-shadow: var(--t-box-shadow-strong);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#cyphra-fab:focus-visible {
  outline: 2px solid var(--t-color-blue);
  outline-offset: 2px;
}

/* 261110-fml, measured in Edge on v2.52.0 (Pixel 7 and iPhone 15 alike): the bottom bar's pill
   (nav:has(svg.tabler-icon-home)) is 49.8px tall with a 12px bottom inset in its wrapper, so its top is 62px above
   the viewport bottom. */
:root {
  --cyphra-bottom-bar: 62px;
}

/* Quick 261113: one + New per screen. Phones use the tab bar's centre tab (below), desktop the floating pill, so the
   floating button is desktop only. The header's own + New stays clickable for both (they click it) but is visually
   hidden everywhere: it duplicated the pill beside the stock create button. */
@media (max-width: 768px) {
  #cyphra-fab {
    display: none !important;
  }
}
[data-click-outside-id="page-action-container"] button[aria-label="جديد / New"] {
  position: absolute !important;
  inline-size: 1px !important;
  min-inline-size: 0 !important;
  block-size: 1px !important;
  min-block-size: 0 !important;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}
/* Desktop: the stock header actions are 26px; 32px is easier to hit and still fits the 44px header row. */
@media (min-width: 769px) {
  [data-click-outside-id="page-action-container"] button {
    min-block-size: 32px;
    min-inline-size: 32px;
  }
}

/* Desktop: an extended pill in the bottom inline-end corner. Nothing interactive sits there on the people list or a
   record page (measured at 1440x900); the stock snackbar does, so cyphra.js hides the pill while one shows. */
@media (min-width: 769px) {
  #cyphra-fab {
    inline-size: auto;
    block-size: 48px;
    gap: 8px;
    padding-inline: 16px 20px;
    inset-inline-end: 24px;
    inset-block-end: 24px;
    font: 600 14px/1 var(--t-font-family);
  }
  #cyphra-fab svg {
    inline-size: 20px;
    block-size: 20px;
  }
}

/* 09-08 UI-SPEC S-6: the one-time install banner and iOS hint, phone only, non-modal, above the bottom bar (z 24 like
   the FAB, which cyphra.js hides while the banner shows). Logical properties only (RTL mirrors itself). */
#cyphra-install {
  position: fixed;
  z-index: 24;
  inset-inline: 16px;
  inset-block-end: calc(var(--cyphra-bottom-bar) + 16px + env(safe-area-inset-bottom));
  background: var(--t-background-primary);
  border: 1px solid var(--t-border-color-medium);
  border-radius: var(--t-border-radius-md);
  box-shadow: var(--t-box-shadow-strong);
  padding: 16px;
  font-family: var(--t-font-family);
  font-size: 13px;
  color: var(--t-font-color-primary);
}
#cyphra-install .cyphra-install-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
#cyphra-install .cyphra-install-title {
  font-weight: 600;
}
#cyphra-install .cyphra-install-body {
  margin-block-start: 8px;
  color: var(--t-font-color-secondary);
}
#cyphra-install .cyphra-install-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-block-start: 16px;
}
#cyphra-install button {
  min-block-size: 44px;
  padding-inline: 16px;
  border: 0;
  border-radius: var(--t-border-radius-sm);
  background: transparent;
  color: var(--t-font-color-secondary);
  font: inherit;
  cursor: pointer;
}
#cyphra-install .cyphra-install-primary {
  color: var(--t-font-color-primary);
}
#cyphra-install .cyphra-install-accent {
  background: var(--t-color-blue);
  color: var(--t-font-color-on-accent);
}

@media (min-width: 769px) {
  #cyphra-install {
    display: none !important;
  }
}

/* 10-04 D-10: the phone page-header logo link to Zone Home (cyphra.js renderHomeLogo), a 44x44 tap box at the inline
   start of the stock title row. Phone only. */
#cyphra-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-inline-size: 44px;
  min-block-size: 44px;
  margin-inline-end: 4px;
  text-decoration: none;
}

#cyphra-home:focus-visible {
  outline: 2px solid var(--t-color-blue);
  outline-offset: 2px;
}

@media (min-width: 769px) {
  #cyphra-home {
    display: none;
  }
}

/* Quick 261113: readability. Stock sets html to 13px and sizes text and spacing in rem, so one root bump scales text,
   gaps and tap rows together. Phones get 16px and 52px drawer rows. */
html {
  font-size: 15px;
}

@media (max-width: 768px) {
  html {
    font-size: 16px;
  }
  .navigation-drawer-item {
    min-block-size: 52px;
    font-size: 17px;
  }
  /* The icon box (17px, sometimes a glyph plus a badge glyph): zoom scales the whole box, so composites stay intact. */
  .navigation-drawer-item > div:first-child > div:first-child {
    zoom: 1.35;
    margin-inline-end: 4px;
  }
  /* The floating bottom bar covers the last rows otherwise. Stock lets the drawer's flex column shrink below its rows
     (they overflow visibly, outside the scroll range); unshrinkable sections plus a trailing spacer fix both. */
  [id^="scroll-wrapper-"][id$="navigation-drawer"] > div > div {
    flex-shrink: 0;
  }
  [id^="scroll-wrapper-"][id$="navigation-drawer"] > div::after {
    content: "";
    display: block;
    flex: none;
    block-size: calc(var(--cyphra-bottom-bar) + 24px + env(safe-area-inset-bottom));
  }
  /* Page header actions (+ New, create, Ask AI, command menu) are 26px icon buttons in stock: lift to 40px, the most the
     52px header row takes. */
  [data-click-outside-id="page-action-container"] button {
    min-inline-size: 40px;
    min-block-size: 40px;
  }
}

/* Quick 261113: the phone tab bar (cyphra.js renderTabs): Home, the role's main list, + New raised in the centre,
   WhatsApp, Menu. Full width, flush to the bottom edge, safe-area aware; the stock floating bar is hidden while it
   shows (html.cyphra-tabs-on) and stays mounted for Menu and search to click. Logical properties only (RTL). */
@media (max-width: 768px) {
  html.cyphra-tabs-on {
    --cyphra-bottom-bar: 64px;
  }
  html.cyphra-tabs-on nav:has(svg.tabler-icon-home) {
    display: none !important;
  }
  #cyphra-tabs {
    position: fixed;
    z-index: 24;
    inset-inline: 0;
    inset-block-end: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    align-items: end;
    block-size: calc(64px + env(safe-area-inset-bottom));
    padding-block-end: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--t-background-primary) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-block-start: 1px solid var(--t-border-color-light);
    font-family: var(--t-font-family);
  }
  .cyphra-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    block-size: 64px;
    min-inline-size: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--t-font-color-tertiary);
    font: 500 11px/1.2 var(--t-font-family);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .cyphra-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 56px;
    block-size: 30px;
    border-radius: var(--t-border-radius-pill);
    corner-shape: round;
    transition: background-color 0.15s;
  }
  .cyphra-tab-label {
    max-inline-size: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cyphra-tab[aria-current="page"] {
    color: var(--t-color-blue);
    font-weight: 600;
  }
  .cyphra-tab[aria-current="page"] .cyphra-tab-icon {
    background: color-mix(in srgb, var(--t-color-blue) 14%, transparent);
  }
  .cyphra-tab:active .cyphra-tab-icon {
    transform: scale(0.92);
  }
  .cyphra-tab:focus-visible {
    outline: 2px solid var(--t-color-blue);
    outline-offset: -4px;
  }
  /* + New: a raised accent circle that breaks the bar's top edge. */
  .cyphra-tab-new {
    color: var(--t-font-color-secondary);
  }
  .cyphra-tab-new .cyphra-tab-icon {
    inline-size: 52px;
    block-size: 52px;
    margin-block-start: -22px;
    background: var(--t-color-blue);
    color: var(--t-font-color-on-accent);
    box-shadow: var(--t-box-shadow-strong);
  }
  .cyphra-tab-new svg {
    inline-size: 28px;
    block-size: 28px;
  }
  /* Search, moved from the stock bar to the page header (cyphra.js renderSearch). */
  #cyphra-search {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 40px;
    min-block-size: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--t-border-radius-sm);
    background: transparent;
    color: var(--t-font-color-secondary);
    cursor: pointer;
  }
  #cyphra-search svg {
    inline-size: 22px;
    block-size: 22px;
  }
}

@media (min-width: 769px) {
  #cyphra-tabs,
  #cyphra-search {
    display: none !important;
  }
}
