/* v2: phone polish (portal-mobile, Nov 14, 2026), from the mobile-native skill.
   Loaded by dev.html right after app.css. Overrides only: app.css (Aayan's) is not edited.
   Each block says which phone problem it fixes and why. */

/* ---------- 1. Tap flash, font inflation ----------
   iOS Safari and Android Chrome paint a gray box over anything tappable. It fights the :active feedback
   below and is the loudest "this is a website" tell. text-size-adjust stops Safari inflating text in landscape. */
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---------- 2. Inputs zoom the page ----------
   The root size is 14.5px and inputs inherit it (app.css: button,input,select,textarea{font:inherit}).
   iOS zooms into any focused field under 16px and does not zoom back out. 16px on touch screens only,
   so the desktop look is unchanged. Larger sizes (the essay editor's 16.5px) win by specificity. */
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px; }
}

/* ---------- 3. Wrong height (100vh) ----------
   On a phone 100vh is the height with the URL bar hidden, so a 100vh shell starts taller than the screen and
   the sidebar drawer's footer (your name, sign out) sits under the browser toolbar.
   dvh tracks the visible area (app shell, drawer, chat, modal); svh is the smallest size and never shifts
   while scrolling (the sign-in screen, a first screen). Browsers without the units keep app.css's vh. */
@supports (height: 100dvh) {
  .shell { min-height: 100dvh; }
  .side { height: 100dvh; }
  .auth { min-height: 100svh; }
  .chat { height: calc(100dvh - 170px); }
  .modal { max-height: 90dvh; }
}

/* ---------- 4. Laggy taps, long-press selecting labels ----------
   touch-action: manipulation tells the browser these never double-tap-zoom, so the tap fires at once.
   Controls are not text: a long press on a button or a menu link should not select its label or open the
   link callout. Content (body text, names, emails, meeting details) stays selectable. */
button, a, [role="button"], label, select, .slot, .day, .choice, .check, .li.click, .table tr.click, .chat-li, .np {
  touch-action: manipulation;
}
button, .btn, .seg button, .slot, .day, .check, .nav a, .tabs a, .demo-grid button, .gbtn, .bell, #mnav {
  -webkit-user-select: none;
  user-select: none;
}
.nav a, .tabs a, .btn, .me { -webkit-touch-callout: none; }

/* ---------- 5. Press feedback on every input type ----------
   With the tap flash gone (1) and hover gated (6), elements that only had a hover state need an :active one,
   or a tap shows nothing until the next screen draws. 100ms, ease-out, like app.css's .btn:active. */
.li.click:active, .chat-li:active, .np:active, .table tr.click:active td { background: var(--line2); }
.slot:not(.on):active, .demo-grid button:active { border-color: var(--green); }
.choice:not(.pick):not(.ok):not(.no):active, .gbtn:active { border-color: #bdbcb4; }
.nav a:active, .me:active { background: var(--side2); }
.day:active, .slot:active, .choice:active, .demo-grid button:active, .gbtn:active { transform: scale(.98); }
.day, .slot, .demo-grid button, .gbtn { transition: transform .1s ease-out, border-color .15s, background .15s; }

/* ---------- 6. Hover stuck after a tap ----------
   Touch has no hover; the browser fakes one on tap and leaves it on until the next tap elsewhere (a slot stays
   green-bordered, a list row stays gray). app.css's hover rules are not gated, so on devices whose main pointer
   cannot hover precisely they are set back to the resting look here. Mice and trackpads (an iPad with a
   trackpad included) keep every hover. Each line mirrors one app.css :hover rule; state classes (.on, .pick,
   .unread) are excluded so their own look stays. */
@media not all and (hover: hover) and (pointer: fine) {
  .nav a:not(.on):hover { background: transparent; color: #c9c9cf; }
  .me:hover { background: transparent; }
  .crumb a:hover { color: inherit; }
  .btn:hover { border-color: var(--line); }
  .btn.pri:hover { background: var(--ink); border-color: var(--ink); }
  :root[data-theme="dark"] .btn.pri:hover { background: var(--green); border-color: var(--green); }
  .btn.green:hover { filter: none; border-color: var(--green); }
  .btn.ghost:hover { background: transparent; border-color: transparent; }
  .ai-btn:hover { border-color: transparent; }
  .hero .btn:hover { border-color: rgba(255,255,255,.14); }
  .hero .btn.green:hover { border-color: var(--green); }
  .li.click:hover { background: transparent; }
  .table tr.click:hover td { background: transparent; }
  .tabs a:not(.on):hover { color: var(--muted); }
  .essay-card:hover { border-color: var(--line); transform: none; }
  .slot:not(.on):hover { border-color: var(--line); }
  .choice:not(.pick):not(.ok):not(.no):hover { border-color: var(--line); }
  .gbtn:hover { border-color: var(--line); }
  .demo-grid button:hover { border-color: var(--line); }
  .bell:hover { border-color: var(--line); }
  .np:not(.unread):hover { background: transparent; }
  .chat-li:not(.on):hover { background: transparent; }
  .modc:hover .mplay { transform: translate(-50%,-50%); background: rgba(13,13,15,.7); color: #fff; }
}

/* ---------- 7. Scroll chaining ----------
   The page itself keeps its normal scroll and pull-to-refresh (it is a scrolling document; a reload is a
   harmless way to refresh). Inner scrollers stop at their own end instead of dragging the page behind them:
   the sidebar drawer, modals, the chat panes, the bell list, the reading passage. */
.side, .modal, .chat-list, .chat-body, .np-list, .passage { overscroll-behavior: contain; }
.tabs, .days, .tablewrap { overscroll-behavior-x: contain; }

/* ---------- 8. Notch, home indicator, landscape sides ----------
   dev.html sets viewport-fit=cover, so the page paints edge to edge and env(safe-area-inset-*) has values.
   Pad the edges that touch them: the phone top bar, the drawer, the toasts, the main column in landscape,
   the sign-in art panel and the modal backdrop. All are 0px on desktop and on phones without insets. */
@media (max-width: 820px) {
  .mobilebar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .side {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
  }
  .main {
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .auth-art {
    padding-top: calc(28px + env(safe-area-inset-top, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
  }
  .auth-form { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
  .bellbar { right: calc(16px + env(safe-area-inset-right, 0px)); }
}
#toasts { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.modal-bg {
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
           max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

/* portal-p16: the parent home's 52 week heatmap scrolls inside its card instead of widening the phone page
   (found by the phone pass for the parent home; the scroll box still counted its full width when the column sized itself). */
@media (max-width: 820px) {
  [data-v2-heatmap] { max-width: calc(100vw - 72px); }
}

/* ---------- 9. portal-mobile-fix1: Shinwoo's iPhone test (Nov 14, 3:35 PM) ----------
   Stack instead of squish. Aayan's student home (a student's Overview for staff, and his live home) puts the North
   Star and the counselor box side by side and four stat cards two to a row; on a phone the statement was squeezed
   into a narrow left column and the credits ring stuck out of its card. Every rule below is phone only. */
@media (max-width: 820px) {
  /* North Star hero: one column, the counselor box full width under the statement, smaller type, buttons share a row. */
  .hero { padding: 22px 18px; border-radius: 16px; }
  .hero::after { width: 260px; height: 260px; right: -110px; top: -120px; }
  .hero h2 { font-size: 23px; line-height: 1.2; max-width: none; overflow-wrap: anywhere; }
  .hero > .row.between { flex-direction: column; align-items: stretch; gap: 14px; }
  .hero > .row.between > * { width: 100%; min-width: 0; }
  .hero .meta { gap: 6px 14px; margin-top: 12px; }
  .hero > .row.wrap:not(.between) { margin-top: 16px !important; gap: 8px; }
  .hero > .row.wrap:not(.between) > .btn { flex: 1 1 auto; }

  /* Cards never grow wider than their column; a stat card's text gives way to the ring, not the other way round. */
  .card, .grid > * { min-width: 0; }
  .stat .row.between { gap: 12px; }
  .stat .row.between > :first-child { min-width: 0; }

  /* Calmer top of page: smaller headings, tighter gaps, card headers wrap under a long title. */
  .top { gap: 8px; margin-bottom: 14px; }
  .top h1 { font-size: 26px; }
  [data-v2-home-heading] { font-size: 26px !important; }
  .top .sub { font-size: 13.5px; line-height: 1.45; }
  .grid { gap: 12px; }
  .card { padding: 16px; }
  .card-h { flex-wrap: wrap; row-gap: 6px; }
  .card-h h3 { min-width: 0; }
  .v2-home { gap: 14px !important; }
}
/* Four stat cards: one per row on a phone (two per row left the credits ring outside its card at 320 to 430px). */
@media (max-width: 600px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
  /* College list stat tiles stay two by two on a phone (client-colleges-batch F22). */
  .g4.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4.two-up .stat { padding: 12px 14px; }
  .g4.two-up .stat .v { font-size: 18px !important; overflow-wrap: anywhere; }
}

/* ---------- 10. portal-mobile-fix1: side menu drawer ----------
   v2/mobile.js adds the backdrop and sets html.v2-drawer-open while the menu is open. The backdrop sits over the page
   and the top bar (under the drawer), so a tap outside the menu only closes it. The page cannot scroll while the menu
   is open; the menu scrolls on its own. */
.v2-drawer-bg {
  position: fixed; inset: 0; z-index: 35; background: rgba(8, 8, 10, .45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease-out; touch-action: none;
}
html.v2-drawer-open .v2-drawer-bg { opacity: 1; pointer-events: auto; }
html.v2-drawer-open, html.v2-drawer-open body { overflow: hidden; }
@media (max-width: 820px) {
  .side { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
}
@media (min-width: 821px) {
  .v2-drawer-bg { display: none; }
}

/* ---------- client-home-batch: shorter Home ---------- */
/* F07: the rating prompt is one slim card */
.v2-fb-slim { padding: 12px 14px; }
.v2-fb-slim #v2-fb-stars .btn.sm { min-width: 34px; padding-left: 0; padding-right: 0; justify-content: center; }
.v2-fb-slim #v2-fb-stars .btn.sm[data-fb-dismiss] { padding: 0 10px; }
/* F08: North Star band, smaller; the empty placeholder is a single quiet line */
.hero[data-ns] { padding: 16px 22px; border-radius: 14px; }
.hero[data-ns] h2 { font-size: 24px; margin-top: 4px; }
.hero[data-ns] .meta { margin-top: 8px; }
.hero[data-ns="empty"] { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.hero[data-ns] .ns-line { font-size: 14px; color: #b8b8bf; margin: 0; flex: 1 1 260px; }
.hero[data-ns="empty"] .meta { margin-top: 0; }
/* F09: the "More" fold on the phone student home */
.v2-home-more > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card, #fff); list-style: none; }
.v2-home-more > summary::-webkit-details-marker { display: none; }
.v2-home-more[open] > summary { margin-bottom: 14px; }
/* F10: "Show N more" inside the overdue action lists */
.v2-action-more > summary { cursor: pointer; font-size: 13px; padding: 9px 0; color: var(--muted); border-top: 1px solid var(--line); }
/* F11: staff stat tiles stay two per row on a phone (the one-column rule above is for pages with the credits ring) */
@media (max-width: 600px) {
  .v2-home[data-v2-home="owner"] .grid.g4, .v2-home[data-v2-home="counselor"] .grid.g4, .v2-home[data-v2-home="ssc"] .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .v2-home .grid.g4 .stat { padding: 12px; }
  .v2-home .grid.g4 .stat .v { font-size: 24px; }
  .v2-home .grid.g4 .stat .d { font-size: 11.5px; }
  .hero[data-ns] { padding: 14px 16px; }
  .hero[data-ns] h2 { font-size: 20px; }
}
.v2-fb-slim > .row > .grow { flex: 1 1 220px; min-width: 200px; }
@media (max-width: 600px) { .v2-fb-slim > .row { flex-direction: column; align-items: stretch; } .v2-fb-slim > .row > .grow { flex: none; min-width: 0; } .v2-fb-slim #v2-fb-stars { flex-wrap: wrap; } }
/* client-nav-shell-batch F03: the bell lives in the phone top bar (v2/phone-bell.js moves it), next to the help button. */
@media (max-width: 820px) {
  .mobilebar > span:last-child { display: inline-flex; align-items: center; gap: 4px; }
  .mobilebar .v2-help-wrap { float: none; }
  .v2-phone-bell { display: inline-flex; position: static; }
  .mobilebar .bell { width: 40px; height: 40px; background: transparent; border-color: transparent; color: var(--side-ink, #fff); box-shadow: none; }
  .mobilebar .bell i { border-color: var(--side); }
  .mobilebar .bellp { position: fixed; right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(58px + env(safe-area-inset-top, 0px)); width: min(360px, calc(100vw - 24px)); z-index: 60; color: var(--ink); text-align: left; }
  .mobilebar .bellp.hide { display: none; }
}

/* client-nav-shell-batch F04: on a phone a wide table scrolls inside its own box instead of widening the whole page
   (owner Home, Follow-ups, Call audits, Team and access were 420 to 610 px wide on a 390 px screen). The .tablewrap box
   already scrolls; "contain: paint" also stops its content from adding to the page's scroll width. Inputs may shrink to the
   column, and a row that holds an input wraps. */
@media (max-width: 820px) {
  .tablewrap { max-width: 100%; contain: paint; }
  .input { min-width: 0; max-width: 100%; box-sizing: border-box; }
  label.f, .grid > * { min-width: 0; }
  .row:has(> input.input) { flex-wrap: wrap; }
  .seg { max-width: 100%; flex-wrap: wrap; }
  .pill { max-width: 100%; white-space: normal; }
}

/* client-parent-home-batch: the parent rating card uses the same slim layout */
.v2-fb-slim #v2-pr-stars .btn.sm { min-width: 34px; padding-left: 0; padding-right: 0; justify-content: center; }
.v2-fb-slim #v2-pr-stars .btn.sm[data-pr-dismiss] { padding: 0 10px; }
@media (max-width: 600px) { .v2-fb-slim #v2-pr-stars { flex-wrap: wrap; } }
