/* teacher/tablet.css — the desktop app on an iPad held upright.
 *
 * Every rule here sits under html.fv-tablet (set by shared/device.js on an
 * iPad or Android tablet only) and inside max-width: 1099px (an iPad held
 * upright is 744 to 1024 points wide; on its side it is 1133 or more). A
 * computer never matches, so the desktop app is unchanged on it, even in a
 * narrow window or with a touch screen. Loaded last in teacher/app.html, so
 * these rules win over the page's own.
 *
 * What it fixes: layouts made for a 1280-point screen, squeezed into 800.
 * Toolbars scroll sideways instead of wrapping into each other, the grader
 * fills the screen with the work above the scoring, and fixed-width
 * columns stack. e2e/ipad-portrait.spec.js checks each screen for text
 * that overlaps, runs off the side or is cut off. */

@media (max-width: 1099px) {
  /* ── The top bar ────────────────────────────────────────────────── */

  /* Dashboard to Reporting all in view: tighter tabs, nothing cut off.
     Six tabs since Bulletins (B1g): a size smaller, with 6 px sides, they
     fit an iPad Air (820 wide, about 560 points) in the wide stand-in for
     CI's fonts (e2e/wide-font.js). */
  html.fv-tablet .tb-seg .tb-seg-link {
    padding-left: 6px;
    padding-right: 6px;
    font-size: var(--text-sm);
  }
  /* An iPad mini (744 wide) has about 508 points for the six tabs: 12 px
     words with 5 px sides fit in the wide stand-in too (CI's Linux font cut
     Reporting off with 10 px sides when there were five). */
  @media (max-width: 799px) {
    html.fv-tablet .tb-seg .tb-seg-link {
      padding-left: 5px;
      padding-right: 5px;
      font-size: var(--text-xs);
    }
  }

  /* ── Help ───────────────────────────────────────────────────────── */

  /* The panel opens over the page, as it does on a narrow screen, so the
     page keeps its width instead of squeezing into 400 points beside it. */
  html.fv-tablet .help-panel {
    position: fixed;
    top: var(--dock-h);
    right: 0;
    bottom: 0;
    width: min(400px, 100vw);
    height: auto;
    z-index: var(--z-modal);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  }

  /* ── The grader ─────────────────────────────────────────────────── */

  /* The whole screen, edge to edge. */
  html.fv-tablet .grader-overlay {
    padding: 0;
    align-items: stretch;
  }
  html.fv-tablet .grader-dialog {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  /* The top bar in two rows: the assignment's title and Done, then the
     student's name with ← → and Show and ⋯. */
  html.fv-tablet .grader-toolbar {
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'title end'
      'name end';
    row-gap: 8px;
    padding: 8px 16px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  html.fv-tablet .grader-title-wrap {
    display: flex;
    grid-area: title;
    max-width: none;
    align-items: flex-start;
  }
  html.fv-tablet .grader-student-row {
    grid-area: name;
  }
  html.fv-tablet .grader-toolbar-end {
    grid-area: end;
    align-self: end;
  }
  html.fv-tablet .grader-show-btn,
  html.fv-tablet .grader-status-btn {
    white-space: nowrap;
  }

  /* The work above, the rubric below, each scrolling on its own, so the
     page stays in view while the rubric is ticked. Narrowing the rubric
     gives the page more of the height. */
  html.fv-tablet .grader-dialog.has-work .grader-split {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 46fr) minmax(0, 54fr);
  }
  html.fv-tablet .grader-dialog.has-work.is-focus .grader-split {
    grid-template-rows: minmax(0, 64fr) minmax(0, 36fr);
  }
  html.fv-tablet .grader-dialog.has-work .grader-panel-col,
  html.fv-tablet .grader-dialog.has-work.is-over .grader-panel-col {
    position: static;
    width: auto;
    border-radius: 0;
    box-shadow: inset 0 1px 0 var(--divider-strong);
  }
  /* Upright, the work is above the rubric: Over and the drag have nothing to do. */
  html.fv-tablet .grader-place-item {
    display: none;
  }
  html.fv-tablet .grader-dialog.has-work.is-over .grader-split {
    grid-template-columns: minmax(0, 1fr);
  }
  html.fv-tablet .grader-dialog.has-work.is-over .grader-work-bar,
  html.fv-tablet .grader-dialog.has-work.is-over .grader-markup-tray {
    left: 50%;
    max-width: calc(100% - var(--space-6));
  }
  html.fv-tablet .grader-handle {
    display: flex;
    top: 0;
    left: 50%;
    width: 48px;
    height: 20px;
    margin: -10px 0 0 -24px;
  }
  html.fv-tablet .grader-handle svg {
    transform: rotate(90deg);
  }

  /* The foot clears the home bar. */
  html.fv-tablet .grader-foot {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  /* ── The student dashboard ──────────────────────────────────────── */

  /* All six tabs in view, each name and count on one line. */
  html.fv-tablet .stu-tab {
    flex: 1 1 auto;
    padding: 8px 10px 9px;
  }
  html.fv-tablet .stu-tab-label {
    font-size: var(--text-md);
    white-space: nowrap;
  }
  html.fv-tablet .stu-tab-stat {
    font-size: var(--text-xs, 12px);
    white-space: nowrap;
  }

  /* Learner Profile: each section the width of the panel, no wider; the
     student's card and the Private Note side by side only when both fit. */
  html.fv-tablet .lp2 > * {
    min-width: 0;
    max-width: 100%;
  }
  html.fv-tablet .lp2-card {
    flex-basis: 320px;
  }

  /* ── Assignments: a piece's score rows ──────────────────────────── */

  /* Name, mark and Missing · Excused · Late on one line, the comment on
     its own line below, instead of squeezed to nothing past the edge. */
  html.fv-tablet .ldg-grid,
  html.fv-tablet .ldg-grid.pts-grid {
    --ldg-cols: minmax(120px, 1fr) max-content max-content;
  }
  html.fv-tablet .ldg-row .ldg-overall {
    grid-column: 1 / -1;
  }
  html.fv-tablet .ldg-head > :nth-child(4) {
    display: none;
  }

  /* ── Class Settings ─────────────────────────────────────────────── */

  /* Competencies: the hint, then Select · Import / Export · Add Folder ·
     Add Competency, wrapping onto a second line when they must. */
  html.fv-tablet .cm-comp-main {
    align-self: stretch;
    max-width: 100%;
  }
  html.fv-tablet .cm-comp-toolbar,
  html.fv-tablet .cm-comp-buttons {
    flex-wrap: wrap;
  }
  html.fv-tablet .cm-comp-buttons {
    flex-shrink: 1;
    min-width: 0;
  }

  /* A folder's name in full; its count and Counts as One go to a second
     line when the name needs the room. */
  html.fv-tablet .cm-comp-list .mod-folder-header {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  html.fv-tablet .cm-comp-list .mod-folder-name-input {
    flex: 1 1 calc(100% - 90px);
    min-width: 160px;
  }
  html.fv-tablet .cm-comp-list .mod-folder-meta {
    margin-left: auto;
  }

  /* ── Add From Another Class ─────────────────────────────────────── */

  /* Rows and controls a finger can hit, and Scoring gives its room to the
     titles (teacher/add-from-class.js). */
  html.fv-tablet .afrom-card {
    --afrom-cols: 20px minmax(0, 1fr) 150px 92px;
    max-height: 100%;
  }
  html.fv-tablet .afrom-scoring {
    display: none;
  }
  html.fv-tablet .afrom-row {
    min-height: 44px;
  }
  html.fv-tablet .afrom-box {
    width: 20px;
    height: 20px;
  }
  html.fv-tablet .afrom-class,
  html.fv-tablet .afrom-select,
  html.fv-tablet .afrom-search .assess-search-input {
    height: 40px;
  }

  /* ── Class Settings: the class list, class header and Students bar ── */

  /* Buttons, the ⋯ and the search field a finger can hit; the header and
     the bar wrap rather than squeeze (e2e/class-settings-bars.spec.js). */
  html.fv-tablet .cm-bar .tb-action-btn,
  html.fv-tablet .cm-bar .atb-icon-btn {
    min-width: 44px;
  }
  html.fv-tablet .cm-bar .tb-action-btn,
  html.fv-tablet .cm-bar .atb-icon-btn,
  html.fv-tablet .cm-bar .atb-search {
    min-height: 44px;
  }
  html.fv-tablet .cm-bar .atb-search {
    height: 44px;
  }
  html.fv-tablet .cm-bar .atb-field > input {
    height: 42px;
  }

  /* ── Class Settings › Student Page: Students ───────────────────── */

  /* A finger-sized box to tick, name to open, and panel and bar buttons
     (teacher/student-page-students.js). The panel takes the full width of
     an iPad mini. */
  html.fv-tablet .sps-pick-box {
    min-width: 44px;
    min-height: 44px;
  }
  html.fv-tablet .sps-check {
    width: 20px;
    height: 20px;
  }
  html.fv-tablet .sps-name {
    min-height: 44px;
  }
  html.fv-tablet .sps-bar .sps-bar-btn,
  html.fv-tablet .sps-panel .cm-action-btn,
  html.fv-tablet .sps-panel .btn,
  html.fv-tablet .sps-panel .seg-btn,
  html.fv-tablet .sp-row .sps-except {
    min-height: 44px;
  }
  /* ── The Dashboard's middle row ─────────────────────────────────── */

  /* The row stacks at every upright width, not only under 900 px: Inbox 450,
     Bulletins 300, then Competencies 520, as on the board (an iPad is far
     too tall for the row's window-height rule). */
  html.fv-tablet .dash-row {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
  html.fv-tablet .dash-row-left,
  html.fv-tablet .dash-row-left.has-bulletins {
    grid-template-rows: none;
  }
  html.fv-tablet .dash-row-inbox {
    height: 450px;
  }
  html.fv-tablet .dash-row-bulletins {
    height: 300px;
  }
  html.fv-tablet .dash-row-comp {
    height: 520px;
  }
  /* Every control in the row is a finger's size, 44 px (board F): the period
     pills, Curricular | Core, the piece switch, the buttons, and the links
     in the tiles' heads. A link keeps its look; only the place it answers a
     tap grows. */
  html.fv-tablet .dash-row .dash-comp-seg .seg-btn,
  html.fv-tablet .dash-row .dash-comp-span .seg-btn,
  html.fv-tablet .dash-row button.dash-comp-it-name,
  html.fv-tablet .dash-row .dash-comp-quiet,
  html.fv-tablet .dash-row .dash-inbox-switch .seg-btn,
  html.fv-tablet .dash-row .dash-inbox-action,
  html.fv-tablet .dash-row .dash-inbox-stack-title,
  html.fv-tablet .dash-row .dash-inbox-return-btn,
  html.fv-tablet .dash-row .dash-inbox-rc-nav,
  html.fv-tablet .dash-row .dash-inbox-rc-title,
  html.fv-tablet .dash-row .dash-inbox-rc-key,
  html.fv-tablet .dash-row .dash-inbox-rc-st {
    min-height: 44px;
  }
  html.fv-tablet .dash-row .dash-inbox-rc-nav {
    min-width: 44px;
  }
  /* Roll Call's rows are a finger's size too; the grid scrolls when the class is longer. */
  html.fv-tablet .dash-row .dash-inbox-rc-grid {
    grid-template-rows: repeat(var(--dash-inbox-rc-rows, 7), 44px);
  }
  html.fv-tablet .dash-row .dash-comp-sub-link,
  html.fv-tablet .dash-row .dash-inbox-head a,
  html.fv-tablet .dash-row .dash-recent-head a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  /* The Bulletins tile (on since B1g): its head's two links and each row's
     words and Seen By answer a tap 44 px high. Rows grow to 48 px; the head
     and three rows still fit the 300 px tile. */
  html.fv-tablet .dash-row .dash-bulletins-head {
    height: 44px;
    align-items: center;
  }
  html.fv-tablet .dash-row .dash-bulletins-actions {
    align-items: center;
  }
  html.fv-tablet .dash-row .dash-bulletins-write,
  html.fv-tablet .dash-row .dash-bulletins-open,
  html.fv-tablet .dash-row .dash-bulletins-seen {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 44px;
  }
  html.fv-tablet .dash-row .dash-bulletins-words {
    display: block;
    line-height: 44px;
  }
  html.fv-tablet .dash-row .dash-bulletins-rows {
    grid-auto-rows: 48px;
  }
  html.fv-tablet .dash-row .dash-bulletins-row {
    height: 48px;
  }

  /* ── Bulletins: the write bar and the box ───────────────────────── */

  /* Every button, field and the switch's row a finger can hit; the rows
     wrap rather than squeeze (e2e/bulletins-bar.spec.js). */
  html.fv-tablet .bulletin-bar-open,
  html.fv-tablet .bulletin-field,
  html.fv-tablet .bulletin-page .tb-action-btn,
  html.fv-tablet .bulletin-kinds .seg-btn {
    min-height: 44px;
  }
  html.fv-tablet .bulletin-react-row {
    min-height: 44px;
  }
  html.fv-tablet textarea.bulletin-field {
    min-height: 84px;
  }

  @media (max-width: 799px) {
    html.fv-tablet .sps-panel {
      width: 100%;
    }
  }
}
