/*
 * Mail accessibility, loading and pane layout (gap items 22-25). Linked last from mail.html and app.html.
 * Only what the older layers cannot express is here; each block says which item it belongs to.
 */

/* ---- 22: contrast ------------------------------------------------------------------------------------------
 * (The category tab preview line was #80868b, 3.7:1; it is #5f6368 in gmail-parity-final.css and
 * communications-mail-embedded.css, where it was set.) */
/* The compose dock's "New message" button is white on #1a73e8, 4.33:1; the same blue one step darker is 5.3:1. */
html body.mail-body #mail-compose-new-session {
  background-color: #1967d2;
}

/* ---- 24: loading is shown in the list only ----------------------------------------------------------------
 * The workspace shell covers the Mail stage with a skeleton until the frame has loaded, and Mail shows its own
 * skeleton rows while the first slice of conversations is on its way. Both are list-shaped, neither dims or
 * covers anything outside the list, and neither takes pointer events, so the top bar, the rail and the sidebar
 * stay usable the whole time. */
.tenant-mail-loading {
  display: block;
  padding: 0;
  background: #fff;
  pointer-events: none;
}

.tenant-mail-loading-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tenant-mail-loading-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.tenant-mail-loading-toolbar span,
.tenant-mail-loading-row span,
.tenant-mail-loading-row b,
.tenant-mail-loading-row i,
.tenant-mail-loading-row u {
  display: block;
  border-radius: 999px;
  text-decoration: none;
  background: linear-gradient(90deg, rgba(226, 232, 240, 0.82), rgba(248, 250, 252, 0.96), rgba(226, 232, 240, 0.82));
  background-size: 220% 100%;
  animation: mailSkeletonSweep 1.1s ease-in-out infinite;
}

.tenant-mail-loading-toolbar span {
  width: 20px;
  height: 20px;
}

.tenant-mail-loading-rows {
  padding: 0 20px;
}

.tenant-mail-loading-row {
  display: grid;
  grid-template-columns: 22px 150px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.82);
}

.tenant-mail-loading-row span { width: 22px; height: 22px; }
.tenant-mail-loading-row b { height: 9px; width: 78%; }
.tenant-mail-loading-row i { height: 8px; width: 88%; }
.tenant-mail-loading-row u { height: 8px; width: 100%; }
.tenant-mail-loading-row:nth-child(3n) i { width: 64%; }
.tenant-mail-loading-row:nth-child(4n) i { width: 74%; }

/* Inside Mail the skeleton fills the list panel instead of leaving the lower half of the pane empty. */
body.mail-body .mail-thread-panel:has(> #mail-threads > .mail-list-skeleton) {
  min-height: 100%;
}

#mail-threads[aria-busy="true"] > .mail-list-skeleton .mail-skeleton-row {
  min-height: 44px;
}

@media (prefers-reduced-motion: reduce) {
  .tenant-mail-loading-toolbar span,
  .tenant-mail-loading-row span,
  .tenant-mail-loading-row b,
  .tenant-mail-loading-row i,
  .tenant-mail-loading-row u,
  .mail-skeleton-row span,
  .mail-skeleton-row b,
  .mail-skeleton-row i {
    animation: none;
  }
}

/* ---- 25: reading pane --------------------------------------------------------------------------------------
 * mail-panes.js publishes body[data-mail-pane-fit]: "split" when this document is wide enough for the list and the
 * reader side by side (900px in the workspace frame, 1161px standalone), "single" when Mail shows one pane at a
 * time. Settings publish data-mail-reading-pane (split also for "below") and data-mail-reading-layout. */

/* Standalone, 901px to 1160px: styles.css stacks the page there (the sidebar `order: 2`, the list `order: 1`)
 * and a later rule keeps two columns (sidebar 256px, list 1fr), so the swapped order put the list in the 256px
 * column and the sidebar in the wide one. The sidebar goes first, as the columns say. */
@media (min-width: 901px) and (max-width: 1160px) {
  html body.mail-body:not(.mail-embedded) .mail-shell.mail-pane.is-active > .mail-sidebar {
    order: 0;
  }

  html body.mail-body:not(.mail-embedded) .mail-shell.mail-pane.is-active > .mail-thread-list {
    order: 1;
  }
}

/* The options in quick settings and in the full settings page. */
.mail-pane-options {
  display: grid;
  gap: 8px;
}

.mail-pane-option {
  display: grid;
  grid-template-columns: auto 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #dce3ec;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.mail-pane-option:has(input:checked) {
  border-color: #0b57d0;
  background: #f2f6fd;
}

.mail-pane-option:has(input:focus-visible) {
  outline: 2px solid #0b57d0;
  outline-offset: 2px;
}

.mail-pane-option-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mail-pane-option-text strong {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.mail-pane-option-text small {
  font-size: 12px;
  line-height: 1.35;
  color: #596579;
}

/* A drawing of the layout: the list is the light block, the reader the tinted one. */
.mail-pane-glyph {
  display: flex;
  width: 44px;
  height: 32px;
  overflow: hidden;
  border: 1.5px solid #b4bfce;
  border-radius: 5px;
  background: #fff;
}

.mail-pane-glyph i {
  display: block;
  flex: 1 1 0;
  background: #e8eef7;
}

.mail-pane-glyph i + i {
  background: #cfdcf2;
}

.mail-pane-glyph.is-none i + i {
  display: none;
}

.mail-pane-glyph.is-right i:first-child {
  flex-grow: 1.35;
  border-right: 1.5px solid #b4bfce;
}

.mail-pane-glyph.is-below {
  flex-direction: column;
}

.mail-pane-glyph.is-below i:first-child {
  border-bottom: 1.5px solid #b4bfce;
}

.mail-pane-option:has(input:checked) .mail-pane-glyph {
  border-color: #0b57d0;
}

.mail-pane-hint {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #596579;
}

/* Inside the workspace frame (body.mail-embedded) the list and the reader share the pane stack. mail-triage.css
 * places them for the standalone page only, so here the stack becomes a two-cell grid when the frame is wide
 * enough: columns for "Right of list", rows for "Below list". Narrower, the stack stays a block and the reader is
 * a pane of its own. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack {
  height: 100%;
  min-height: 0;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-shell.mail-pane {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-reader-shell.is-split-companion {
  min-width: 0;
  min-height: 0;
  height: auto;
  max-width: none;
  margin: 0;
  overflow: auto;
  background: #fff;
  box-shadow: none;
}

/* styles.css hides the reader (`.mail-embedded[data-mail-pane="inbox"] .mail-view`) because the frame used to be
 * one pane at a time; in a split the reader is the companion cell and shows its conversation. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion .mail-view {
  display: flex;
}

/* Right of list. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="side"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 42%);
  grid-template-rows: minmax(0, 1fr);
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="side"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-shell.mail-pane {
  grid-area: 1 / 1;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="side"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-reader-shell.is-split-companion {
  grid-area: 1 / 2;
  align-self: stretch;
  border-left: 1px solid #dadce0;
  border-top: 0;
}

/* Below list. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="below"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(180px, 1fr) minmax(240px, 52%);
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="below"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-shell.mail-pane {
  grid-area: 1 / 1;
  height: 100%;
  max-height: 100%;
}

/* The older layers pin the list panel to the frame's full height; here it fills only its row. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="below"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-shell.mail-pane .mail-thread-panel {
  height: 100% !important;
  max-height: 100%;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="below"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-pane-stack > .mail-reader-shell.is-split-companion {
  grid-area: 2 / 1;
  align-self: stretch;
  z-index: auto;
  border-top: 1px solid #dadce0;
  border-left: 0;
}

/* A reader of 340px to 600px, the same fitting mail-triage.css gives the standalone split: one-line subject with
 * an ellipsis (the toolbar above it has a fixed height), no "1 of 888" pager, and the message header wrapping
 * the sender onto its own line instead of breaking the name after every word. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion :is(.mail-panel-header > div:first-child, .mail-view-title-row) {
  min-width: 0;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion #mail-view-subject {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion .mail-reader-position {
  display: none;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion .mail-message-head {
  flex-wrap: wrap;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion .mail-message-persona {
  flex: 1 1 100%;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-reader-shell.is-split-companion .mail-message-status {
  margin-left: 56px;
}

/* Right of list leaves the list about 520px to 660px. The inbox category tabs (All mail, Primary, ...) drop their
 * preview line and scroll sideways instead of overlapping each other. */
body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="side"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-smart-category-strip {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="side"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-smart-category-strip > button {
  flex: 0 0 auto;
}

body.mail-embedded[data-mail-pane-fit="split"][data-mail-reading-layout="side"][data-mail-reading-pane="split"][data-mail-pane="inbox"] .mail-smart-category-strip .mail-category-copy small {
  display: none;
}

/* Rows in a list of 520px to 660px. The embedded row template reserves 220px for the subject and 88px for the
 * time, which a list this narrow cannot give both, so the status chips overlapped the time. The subject takes what
 * is left, the chips shrink to their content and the time keeps a fixed column. */
html body.mail-body.mail-embedded.mail-simple-mode[data-mail-view="gmail"][data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-reading-layout="side"][data-mail-pane="inbox"] #mail-threads .mail-gmail-row-open {
  grid-template-columns: minmax(96px, 0.6fr) minmax(0, 1.8fr) minmax(0, auto) 76px !important;
}

html body.mail-body.mail-embedded.mail-simple-mode[data-mail-view="gmail"][data-mail-pane-fit="split"][data-mail-reading-pane="split"][data-mail-reading-layout="side"][data-mail-pane="inbox"] #mail-threads .mail-gmail-row-chips {
  min-width: 0;
  overflow: hidden;
}

/* The standalone "below" layout reserves scroll room under the list for a reader that overlays it; here the
 * reader has its own row, so the list needs none. */
body.mail-embedded[data-mail-reading-layout="below"][data-mail-pane="inbox"] #mail-threads::after {
  content: none;
  height: 0;
}
