/* A phone in the hand, an iPhone above all (web/js/phone.js is the other half).
   - The app is fitted to the screen that's really there: under the status bar and round the notch (safe areas), and above
     the keyboard when it's up (--vv-top and --kb, kept by phone.js), the tabs out of the way while you type.
   - iOS paints a Home Screen app's status bar from whatever is fixed at the top edge. So on a phone the app's own bar
     comes first, in the desk's colour, and the classification banner sits directly under it: the status bar never turns
     oxblood and stays that way.
   - Thumbs, not a mouse: bigger targets, menus and dialogs that rise from the foot of the screen, nothing that needs hover. */

/* --- any touch screen ---------------------------------------------------------------------------------------------- */
html[data-touch] { -webkit-tap-highlight-color: transparent; }
html[data-touch] * { scrollbar-width: none; }
html[data-touch] ::-webkit-scrollbar { display: none; width: 0; height: 0; }
html[data-touch] button, html[data-touch] a, html[data-touch] .row, html[data-touch] .card { touch-action: manipulation; }
html[data-touch] :is(.bar, .tabs, .side, .scene-strip, .subnav, .banner, .btn, .chip, .label, .plate, .composer .context, .composer .foot, .menu, .msg) {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html[data-touch] :is(.log, .scroll, .sheet-scroll, .pane, .menu, .dialog > .body) { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
html[data-touch] .cover .hold { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* iOS 26's Home Screen app is told the screen is a status bar shorter than it is, so a page sized by 100% or 100dvh stops short */
@media (display-mode: standalone) { html { height: 100vh; height: 100lvh; } }
html[data-standalone] { height: 100vh; height: 100lvh; }
@media (hover: none) {
  .msg:hover { background: none; }
  .msg:hover .tools, .msg .tools { display: none; }           /* hold the message instead */
  .card:hover { transform: none; }
  .row:hover { background: none; } .row:active { background: color-mix(in srgb, var(--raise) 60%, transparent); }
  .btn:active, .chip:active, .tabs button:active { opacity: .7; }
}
/* what's over the app sits in the same fitted box, so a dialog is never under the keyboard */
html[data-touch] #over, html[data-touch] #gate { top: var(--vv-top, 0px); bottom: var(--kb, 0px); height: auto; }
html[data-touch] #gate { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }

/* menus rise from the foot of the screen */
.rise-wrap { background: rgba(12, 14, 16, .58); animation: fade 160ms; }
.menu.rise { left: 0; right: 0; bottom: 0; top: auto; min-width: 0; max-width: none; max-height: min(78%, 620px); border-width: 1px 0 0;
  padding: 6px 0 calc(10px + env(safe-area-inset-bottom, 0px)); animation: rise 240ms var(--ease); box-shadow: 0 -18px 40px rgba(0, 0, 0, .35); }
html.keyboard .menu.rise { padding-bottom: 10px; }
.menu.rise::before { content: ""; display: block; width: 38px; height: 3px; background: var(--line); margin: 4px auto 8px; }
.menu.rise button { min-height: 50px; padding: 0 20px; font-size: 1rem; }
.menu.rise .head { padding: 12px 20px 6px; }
.menu.rise button small { font-size: var(--fs-micro); }
.menu .quick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px 14px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.menu .quick button { justify-content: center; min-height: 52px; padding: 0; font-size: 1.5rem; border: 1px solid var(--line-soft); }
@keyframes rise { from { transform: translateY(100%); } }

/* --- a phone ------------------------------------------------------------------------------------------------------- */
@media (max-width: 760px) {
  :root { --pad: 14px; --bar-h: 50px; }
  #app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); bottom: var(--kb, 0px); height: auto; background: var(--desk);
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    grid-template-rows: var(--bar-h) auto minmax(0, 1fr) auto; }
  .bar { order: -1; gap: 8px; padding: 0 10px 0 12px; }
  .banner { font-size: var(--fs-micro); padding: 3px 10px; letter-spacing: var(--track); }
  .brand b { font-size: 1.3rem; } .brand img { width: 28px; height: 28px; }
  .me-chip { flex: 0 1 auto; min-width: 0; padding: 5px 10px 5px 5px; }
  .iconbtn { width: 40px; height: 40px; }

  /* the tabs: a strip across the foot, flush to the edges and down over the home bar */
  .tabs { padding: 0 4px max(0px, calc(env(safe-area-inset-bottom, 0px) - 14px)); }
  .tabs button { position: relative; height: 52px; padding: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: var(--fs-micro); }
  .tabs button[aria-current="true"]::before { content: ""; position: absolute; top: -1px; left: 24%; right: 24%; height: 2px; background: var(--brass); }
  html.keyboard .tabs { display: none; }

  /* thumbs */
  .row { padding: 11px 16px; min-height: 54px; }
  .field { height: 46px; padding: 0 14px; }
  textarea.field { height: auto; padding: 12px 14px; }
  .btn { height: 44px; } .btn.sm { height: 36px; padding: 0 13px; font-size: var(--fs-micro); }
  .chip { height: 32px; padding: 0 11px; font-size: var(--fs-micro); }
  .side h3 { padding: 20px 16px 6px; } .side h3 button { width: 40px; height: 32px; }
  .side .scroll { padding-bottom: 28px; }
  .subnav button { min-height: 44px; }
  .finder { height: 48px; }

  /* a place, and its scene: with the keyboard up the picture gives its room to the words */
  .plate { height: 24vh; min-height: 148px; }
  .plate h1 { font-size: clamp(2rem, 11vw, 3rem); }
  .plate .tools { top: 10px; right: 10px; left: 10px; justify-content: flex-end; }
  .plate .tools .phone-back { margin-right: auto; width: 36px; padding: 0; justify-content: center; }
  .plate .tod { top: 56px; }
  .place:not(.poster) .plate .tod { display: none; }            /* the picture's light says it; the poster keeps the words */
  html.keyboard .place:not(.poster) .plate { height: 0; min-height: 0; }
  .poster-body { bottom: 22px; gap: 14px; }
  .poster-body p { font-size: 1.06rem; }
  .poster-body .btn { width: 100%; height: 48px; }
  .poster-body .areas { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); }
  .poster-body .areas .chip { flex: none; }
  .scene-strip { padding: 7px var(--pad); }

  /* the conversation */
  .log { padding: 12px var(--pad) 6px; }
  .composer { padding: 4px 8px 8px; }
  .composer textarea { min-height: 46px; max-height: 32vh; padding: 11px 12px; }
  .composer .context { flex-wrap: nowrap; overflow-x: auto; padding: 8px 8px 0; }
  .composer .context > * { flex: none; }
  .composer .hint { font-size: 0; }
  .composer .foot { padding: 0 4px 4px 8px; }
  .composer .foot .iconbtn { width: 44px; height: 40px; }
  .typing { min-height: 0; }

  /* dialogs rise too, and their buttons share the width */
  .dialog, .dialog.wide { left: 0; right: 0; bottom: 0; top: auto; transform: none; width: 100%; max-height: calc(100% - 10px - env(safe-area-inset-top, 0px));
    border-width: 1px 0 0; animation: rise 240ms var(--ease); }
  .dialog > .body { padding: 16px; }
  .dialog > footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  html.keyboard .dialog > footer { padding-bottom: 12px; }
  .dialog > footer .btn { flex: 1; padding: 0 8px; }
  #toasts { left: 12px; right: 12px; bottom: calc(var(--kb, 0px) + 66px + env(safe-area-inset-bottom, 0px)); }
  html.keyboard #toasts { bottom: calc(var(--kb, 0px) + 12px); }

  /* the cover sheet */
  .cover { width: calc(100vw - 44px); gap: 14px; }
  .cover .pair { grid-template-columns: minmax(0, 1fr); }      /* two buttons don't fit side by side in a phone's width: one above the other */
  .cover .crest { width: 112px; height: 112px; }
  html.keyboard .cover .crest { width: 64px; height: 64px; }
  .cover .hold { height: 54px !important; }

  /* documents */
  .sheet-scroll { padding: 14px 10px calc(70px + env(safe-area-inset-bottom, 0px)); }
}

/* a phone on its side: every line of height counts */
@media (max-height: 480px) and (pointer: coarse) {
  .banner, .copyline { display: none; }
  #app { grid-template-rows: var(--bar-h) minmax(0, 1fr) auto; }       /* the bar, the view, the tabs where there are any */
  .composer .hint { font-size: 0; }
  .composer textarea { min-height: 40px; }
  .scene-strip { padding-top: 5px; padding-bottom: 5px; }
  :root { --bar-h: 42px; }
  .tabs button { height: 40px; }
  .place:not(.poster) .plate { height: 48px; min-height: 48px; }        /* just its buttons: the way back, the sound, the scene */
  .place:not(.poster) .plate .title, .place:not(.poster) .plate .credit { display: none; }
  .plate .tools { top: 6px; }
  .globe-wrap { display: none; }
}

@media (max-width: 760px) {
  .settings .phone-back { justify-self: start; }
  .settings h2 { font-size: 2rem; }
  .settings .pane { padding: 16px var(--pad) calc(40px + env(safe-area-inset-bottom, 0px)); }
  .panel .line { flex-wrap: wrap; row-gap: 8px; }
}

@media (max-width: 760px) {
  /* a person: their card, then their file, one page that scrolls as a whole */
  .reader { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .reader .person { overflow: visible; padding: 16px var(--pad); }
  .reader .sheet-scroll { overflow: visible; }
  .archive .back { min-height: 44px; }
  .docrow { padding-top: 12px; padding-bottom: 12px; }
}

/* a touch screen wider than a phone (an iPad, a phone on its side): the same fitted box, round the notch and above the keyboard */
@media (min-width: 761px) {
  html[data-touch] #app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); bottom: var(--kb, 0px); height: auto; background: var(--desk);
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
  html[data-touch].keyboard #app { padding-bottom: 0; }
  html[data-touch].keyboard .copyline { display: none; }
}

/* reading it on a phone: the same scale a size up (settings.js makes 16px the phone's default), and a log without a gutter */
@media (max-width: 760px) {
  .msg .at, .msg .at.shown { display: none; }
  .msg { padding: 1px 4px 1px 10px; }
  .msg.narration { padding-left: 12px; }
  .slug { margin-top: 22px; }
  .banner { font-size: .68rem; padding: 4px 10px; }
  .tabs button { font-size: .7rem; letter-spacing: .1em; }
  .plate .where { margin-bottom: 6px; }
  .place:not(.poster) .plate h1 { font-size: clamp(1.9rem, 9.5vw, 2.6rem); }
  .plate .credit { right: 10px; bottom: 5px; }
  .place:not(.poster) .plate .credit { top: auto; max-width: 46%; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .scene-strip .cast .face { width: 30px; height: 30px; }
  .composer .context .chip, .voice-chip { height: 30px; }
}
@media (max-width: 760px) {
  .me-chip { padding: 3px 10px 3px 4px; gap: 8px; }
  .me-chip .face { width: 30px; height: 30px; }
  .me-chip .who b { line-height: 1.2; } .me-chip .who span { line-height: 1.25; }
  .plate .tools .btn.sm, .plate .tools .chip { height: 34px; }
}
@media (max-width: 760px) {
  /* one column that never grows past the screen, however long a line in it is (1fr alone lets a long preview widen it) */
  .traffic, .theatre, .settings { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .globe-wrap { aspect-ratio: auto; height: min(30vh, 240px); }
  .find-row .finder { height: 48px; }
}
@media (max-width: 760px) {
  .org-bus { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 0; }
  .org-bus::before, .org-bus .node::before { display: none; }
  .org-bus .node:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .node { padding: 14px 8px 12px; } .node b { font-size: 1.25rem; }
  .org-row { grid-template-columns: minmax(0, 1fr); gap: 6px; } .org-row > .label { padding-top: 0; }
  .org-detail { padding: 16px 14px 18px; } .org-head h2 { font-size: 1.5rem; }
  .org-people .who { width: 100%; }
  .above { flex-direction: column; align-items: flex-start; gap: 10px; } .above .bars { max-width: 100%; }
}

/* the clean frame on a phone: the bar with the way back, the picture, the caption. Typing gives the picture's room to the words */
@media (max-width: 760px) {
  .place .plate { height: auto; min-height: 0; }
  .place:not(.poster) .plate .frame { height: 24vh; min-height: 140px; }
  html.keyboard .place:not(.poster) .plate, .place .plate { height: auto; min-height: 0; }
  html.keyboard .place:not(.poster) .plate .frame { height: 0; min-height: 0; }
  html.keyboard .place:not(.poster) .plate .credit { display: none; }
  .plate-bar { padding: 5px 10px; gap: 8px; min-height: 48px; }
  .plate-bar .phone-back { width: 36px; height: 36px; padding: 0; justify-content: center; flex: none; }
  .plate-bar .here { gap: 10px; flex: 1; }
  .place .plate-bar h1 { font-size: 1.25rem; }
  .place .plate-bar .slate, .place:not(.poster) .plate-bar .tod { display: none; }
  .plate-bar > span[style] { display: none; }
  .place .plate-bar .btn.sm, .place .plate-bar .chip { height: 34px; flex: none; }
  .place .plate .credit { padding: 3px 10px 0; max-width: none; text-align: right; }
  .place .poster-body { padding: 14px var(--pad) 18px; }
  .place .poster-body h1 { font-size: clamp(1.9rem, 9vw, 2.6rem); }
  .place .poster-body p { font-size: 1rem; }
  .place.poster .plate { grid-template-rows: auto minmax(120px, 1fr) auto; }
  .place.poster { overflow-y: auto; }
}
@media (max-height: 480px) and (pointer: coarse) {
  .place:not(.poster) .plate .frame { height: 0; min-height: 0; }
  .place:not(.poster) .plate, .place .plate { height: auto; min-height: 0; }
  .place .plate .credit { display: none; }
}
@media (max-width: 760px) {
  .place.poster .plate { grid-template-rows: auto minmax(26vh, 1fr) auto auto; }
  .place .poster-body { max-height: none; overflow: visible; }
  .rooms-row { grid-template-columns: minmax(0, 1fr); gap: 4px; } .rooms-row > .label { padding-top: 4px; }
  .rooms .areas { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad) 2px; } .rooms .areas .chip { flex: none; }
  .room-pick { max-width: 60vw; }
}
@media (max-width: 760px) {
  /* the bar on a phone: the way back, the place and the room under it, then what you can do, small */
  .plate-bar .here { flex-direction: column; align-items: flex-start; gap: 2px; }
  .place .plate-bar .area-now { font-size: .66rem; letter-spacing: .08em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .place .plate-bar .btn.sm { padding: 0 9px; letter-spacing: .06em; }
  .place .plate-bar .btn.sm::before, .place .plate-bar .btn.sm::after { content: none !important; }
}
@media (max-width: 760px) {
  .op-row { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; } .op-row .tag { grid-column: 2; justify-self: start; }
  .op-row .op-no { font-size: 1.5rem; } .op-main b { font-size: 1.15rem; }
  .op-voices div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .op-actions .btn { flex: 1 1 100%; } .op-host { padding: 2px 12px 8px; } .op-book h2 { font-size: 1.4rem; }
}
@media (max-width: 760px) { .jargon-list { grid-template-columns: minmax(0, 1fr); } .composer .phrases { height: 32px; } }
