/*
 * OneHLP (ADR-023): phone navigation for the staff panels and the portal.
 * Five slots (two places, the centre action button, two places or one + More),
 * the action sheet and the More page. Phones: 860 px and narrower here (the portal's
 * top menu folds at 860); the staff skin hides it again from 761 px (staff phones: 760).
 * Colours are ADR-002 roles only.
 */
.oh-pbar, .oh-sheet, .oh-more { display: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }   /* iOS: no text inflation */

/* Installed app (ADR-023 amendment 2): opened from the home screen, it feels like an app */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }        /* no rubber-band bounce of the whole page */
}

@media (max-width: 860px) {
  :root { --oh-pbar-h: 64px; }
  body { padding-bottom: calc(var(--oh-pbar-h) + env(safe-area-inset-bottom, 0px)); }

  .oh-pbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 320;
    height: calc(var(--oh-pbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    background: var(--oh-surface); border-top: 1px solid var(--oh-border);
    box-shadow: 0 -2px 12px rgba(var(--oh-shadow-rgb), .06);
    font-family: var(--oh-font, inherit);
  }
  .oh-pbar, .oh-sheet, .oh-more { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
  .oh-pbar-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 0; min-height: 44px; padding: 6px 2px; border: 0; background: none; cursor: pointer;
    color: var(--oh-text-muted); text-decoration: none; font: 500 .75rem/1.1 var(--oh-font, inherit);
  }
  button.oh-pbar-item { height: auto !important; line-height: 1.1 !important; margin: 0; border: 0 !important;
    border-radius: 0; background: none !important; box-shadow: none !important; }
  .oh-pbar-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .oh-pbar-item svg { width: 26px; height: 26px; }
  .oh-pbar-item:hover, .oh-pbar-item:focus-visible { color: var(--oh-text); text-decoration: none; }
  .oh-pbar-item.active, .oh-pbar-item[aria-expanded="true"] { color: var(--oh-primary-text); font-weight: 700; }
  .oh-pbar-item.active svg { stroke-width: 2.1; }
  .oh-pbar-centre { display: flex; justify-content: center; }
  .oh-pbar-act {
    width: 60px; height: 60px; margin-top: -20px; padding: 0; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: var(--oh-primary); color: var(--oh-on-primary); border: 0;
    box-shadow: 0 0 0 6px var(--oh-surface), 0 4px 12px rgba(var(--oh-primary-rgb), .35);
    transition: transform .15s ease, background .15s ease;
  }
  .oh-pbar-act svg { width: 30px; height: 30px; stroke-width: 2.4; transition: transform .2s ease; }
  .oh-pbar-act:active { transform: scale(.96); }
  .oh-pbar-act[aria-expanded="true"] { background: var(--oh-chrome); color: var(--oh-on-chrome);
    box-shadow: 0 0 0 6px var(--oh-surface), 0 4px 12px rgba(var(--oh-shadow-rgb), .3); }
  .oh-pbar-act[aria-expanded="true"] svg { transform: rotate(180deg); }
  .oh-pbar-gap { display: block; }

  /* The action sheet: above the bar, under the backdrop */
  .oh-sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 315; }
  .oh-sheet-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .5); }
  .oh-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: calc(var(--oh-pbar-h) + env(safe-area-inset-bottom, 0px));
    max-height: calc(100% - var(--oh-pbar-h) - env(safe-area-inset-bottom, 0px) - 48px);
    display: flex; flex-direction: column;
    background: var(--oh-surface); color: var(--oh-text); border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 24px rgba(var(--oh-shadow-rgb), .18);
    padding-top: 8px; animation: oh-sheet-up .2s ease-out; font-family: var(--oh-font, inherit);
  }
  @keyframes oh-sheet-up { from { translate: 0 40px; opacity: .4; } to { translate: 0 0; opacity: 1; } }
  .oh-sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--oh-border-strong); margin: 0 auto 8px; flex: none; }
  .oh-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 8px; flex: none; }
  /* the popup "?" (onehlp-help.js) sits beside the title; its help opens under it */
  .oh-sheet-head > div { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; min-width: 0; }
  .oh-sheet-head > div > h2 { flex: 0 1 auto; min-width: 0; }
  .oh-sheet-head .oh-help-inline { flex-basis: 100%; max-height: 40vh; overflow-y: auto; }
  .oh-sheet-kicker { flex-basis: 100%; }
  .oh-sheet-kicker { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--oh-text-muted); }
  .oh-sheet-head h2 { margin: 0; font-size: 1.125rem; font-weight: 700; line-height: 1.3; color: var(--oh-text);
    overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .oh-sheet-x {
    flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--oh-border-strong);
    background: var(--oh-surface); color: var(--oh-text); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0;
  }
  .oh-sheet-body { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
  .oh-sheet-row {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 16px;
    border: 0; border-top: 1px solid var(--oh-divider); background: none; box-sizing: border-box;
    color: var(--oh-text); text-align: left; text-decoration: none; cursor: pointer; font: 400 1rem/1.3 var(--oh-font, inherit);
  }
  .oh-sheet-row:first-child, .oh-sheet-group + .oh-sheet-row, .oh-sheet-primary + .oh-sheet-row { border-top: 0; }
  .oh-sheet-row svg { flex: none; color: var(--oh-text-muted); }
  .oh-sheet-row:hover, .oh-sheet-row:focus-visible { background: var(--oh-subtle); text-decoration: none; color: var(--oh-text); }
  .oh-sheet-row small { margin-left: auto; font-size: .8125rem; color: var(--oh-text-muted); }
  .oh-sheet-row.oh-sheet-primary {
    margin: 0 16px 6px; width: calc(100% - 32px); border-radius: 12px; border: 0;
    background: var(--oh-primary); color: var(--oh-on-primary); font-weight: 600;
  }
  .oh-sheet-row.oh-sheet-primary svg, .oh-sheet-row.oh-sheet-primary small { color: var(--oh-on-primary); }
  .oh-sheet-row.oh-sheet-primary:hover { background: var(--oh-primary-hover); color: var(--oh-on-primary); }
  .oh-sheet-row.oh-sheet-sub { padding-left: 54px; font-size: .9375rem; }
  .oh-sheet-group {
    margin-top: 4px; padding: 10px 16px 6px; background: var(--oh-subtle);
    font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--oh-text-muted);
  }
  .oh-sheet-group.oh-danger { background: var(--oh-danger-faint); color: var(--oh-danger-text); }
  .oh-sheet-row.oh-danger, .oh-sheet-row.oh-danger svg { color: var(--oh-danger-text); font-weight: 600; }
  .oh-sheet-empty { padding: 4px 16px 12px; color: var(--oh-text-muted); font-size: .9375rem; }

  /* The More page: a full page over the content, above the bar */
  .oh-more:not([hidden]) {
    display: block; position: fixed; left: 0; right: 0; top: 0; z-index: 318;
    bottom: calc(var(--oh-pbar-h) + env(safe-area-inset-bottom, 0px));
    background: var(--oh-bg); color: var(--oh-text); font-family: var(--oh-font, inherit);
  }
  .oh-more-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 16px; box-sizing: border-box; }
  .oh-more-top { background: var(--oh-surface); padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 0; border-bottom: 1px solid var(--oh-border); }
  .oh-more-titlebar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .oh-more-titlebar h2 { margin-right: auto !important; }
  .oh-more-titlebar .oh-help-inline { flex-basis: 100%; }
  .oh-more-titlebar h2 { margin: 0; font-size: 1.75rem; font-weight: 700; color: var(--oh-text); }
  .oh-more-person { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
  .oh-more-person b { display: block; font-size: 1rem; }
  .oh-more-person small { display: block; font-size: .875rem; color: var(--oh-text-muted); }
  .oh-more-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--oh-chrome); color: var(--oh-on-chrome); font-weight: 600; flex: none; }
  .oh-more-round { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
  .oh-more-round a, .oh-more-round button {
    display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 44px;
    background: none; border: 0; padding: 0; cursor: pointer; color: var(--oh-text); text-decoration: none; font: 400 .9375rem var(--oh-font, inherit);
  }
  .oh-more-round span { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--oh-primary);
    display: flex; align-items: center; justify-content: center; color: var(--oh-primary-text); }
  .oh-more-round svg { width: 28px; height: 28px; }
  .oh-more-logout { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; margin-top: 14px;
    border-top: 1px solid var(--oh-border); color: var(--oh-primary-text); text-decoration: none; font-size: 1.0625rem; font-weight: 600; }
  .oh-more-group { margin: 0; padding: 16px 16px 6px; font-size: .8125rem; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--oh-text-muted); }
  .oh-more-list { background: var(--oh-surface); border-top: 1px solid var(--oh-border); border-bottom: 1px solid var(--oh-border); }
  .oh-more-list a { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px;
    color: var(--oh-text); text-decoration: none; font-size: 1rem; }
  .oh-more-list a + a { border-top: 1px solid var(--oh-divider); }
  .oh-more-list a > svg:first-child { color: var(--oh-primary-text); flex: none; }
  .oh-more-list a > svg:last-child { margin-left: auto; color: var(--oh-text-placeholder); flex: none; }
  .oh-more-list small { margin-left: auto; font-size: .8125rem; color: var(--oh-text-muted); }
  .oh-more-list small + svg { margin-left: 4px !important; }
  /* "Choose what is in the bar" (ADR-023 amendment) */
  .oh-more-edit { margin-top: 16px; }
  .oh-more-edit-open {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 16px; box-sizing: border-box;
    background: var(--oh-surface) !important; border: 0 !important; border-top: 1px solid var(--oh-border) !important;
    border-bottom: 1px solid var(--oh-border) !important; border-radius: 0 !important; box-shadow: none !important;
    height: auto !important; line-height: 1.3 !important; color: var(--oh-primary-text); font: 600 1rem var(--oh-font, inherit); cursor: pointer;
  }
  .oh-more-edit-open[aria-expanded="true"] { color: var(--oh-text); }
  .oh-bar-editor { background: var(--oh-surface); padding: 4px 16px 16px; border-bottom: 1px solid var(--oh-border); }
  .oh-bar-editor h3 { display: inline-block; margin: 10px 8px 4px 0; font-size: 1.0625rem; font-weight: 700; color: var(--oh-text); vertical-align: middle; }
  .oh-bar-editor > .oh-help-pop-btn { vertical-align: middle; margin-top: 6px; }
  .oh-bar-editor > p { margin: 0 0 10px; font-size: .9375rem; color: var(--oh-text-muted); }
  .oh-bar-picks { display: grid; gap: 8px; }
  .oh-bar-pick {
    display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; box-sizing: border-box;
    height: auto !important; line-height: 1.3 !important; box-shadow: none !important;
    border: 1px solid var(--oh-border-strong) !important; border-radius: 12px !important;
    background: var(--oh-surface) !important; color: var(--oh-text); text-align: left; font: 400 1rem var(--oh-font, inherit); cursor: pointer;
  }
  .oh-bar-pick.on { border-color: var(--oh-primary) !important; background: var(--oh-primary-faint) !important; font-weight: 600; }
  .oh-bar-num {
    flex: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--oh-border-strong); font-weight: 700; font-size: .875rem;
  }
  .oh-bar-pick.on .oh-bar-num { background: var(--oh-primary); border-color: var(--oh-primary); color: var(--oh-on-primary); }
  .oh-bar-msg { min-height: 1.3em; margin: 8px 0 0; font-size: .9375rem; color: var(--oh-text-muted); }
  .oh-bar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
  html.oh-pnav-open, html.oh-pnav-open body { overflow: hidden; }
  .oh-to-top { bottom: calc(var(--oh-pbar-h) + 16px + env(safe-area-inset-bottom, 0px)) !important; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .oh-sheet-panel { animation: none; }
  .oh-pbar-act, .oh-pbar-act svg { transition: none; }
}
