/* IAL Maths Lab — v057
 *
 * Phone handoff (scan → photograph → it lands on the tablet) and the paper
 * archive. Same rules as the rest of the chain: nothing here is a media query,
 * because the interface can be zoomed to 150% and a media query would still be
 * reading the unzoomed width. Grids use auto-fill so they reflow on their own.
 */

/* ---------- the phone dialog ---------- */

#phoneSendDialog,
#archiveNewDialog {
  position: fixed;
  inset: 0;
  z-index: 260;                 /* above the workspace (120) and the toast (100) */
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 22, 40, .46);
  padding: 18px;
  overflow-y: auto;
}

#phoneSendDialog.show,
#archiveNewDialog.show { display: flex; }

.phoneCard,
.archiveNewCard {
  position: relative;
  width: min(520px, calc(100vw / var(--ial-ui-zoom, 1) - 36px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 26px 60px rgba(8, 20, 40, .32);
  padding: 24px 22px 20px;
  text-align: center;
}

.phoneClose {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #6d7684;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.phoneClose:hover { background: #f1f5fb; color: var(--ink, #16181d); }

.phoneCard h3,
.archiveNewCard h3 {
  margin: 6px 0 8px;
  font-size: 19px;
  letter-spacing: -.2px;
}

.phoneLead {
  margin: 0 auto 16px;
  max-width: 42ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: #5b6169;
}

.phoneQr {
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  width: min(260px, calc(100vw / var(--ial-ui-zoom, 1) - 90px));
  aspect-ratio: 1;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line, #e2e6ee);
  border-radius: 16px;
}

.phoneQr svg { width: 100%; height: 100%; display: block; }

.phoneUrl {
  margin: 0 0 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: #7a8290;
  word-break: break-all;
  line-height: 1.5;
}

.phoneSendStatus {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eef1f6;
  color: #5b6169;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 14px;
}

.phoneSendStatus.ok { background: #e8f7ee; color: #1e8e3e; }
.phoneSendStatus.warn { background: #fdf3e3; color: #b26a00; }

.phoneSteps {
  display: grid;
  gap: 4px;
  text-align: left;
  font-size: 12px;
  color: #6d7684;
  margin: 0 auto 14px;
  max-width: 34ch;
}

.phoneMore {
  text-align: left;
  font-size: 12px;
  color: #6d7684;
  max-width: 40ch;
  margin: 0 auto 14px;
}

.phoneMore summary { cursor: pointer; }

.phoneMore p { margin: 6px 0 0; line-height: 1.6; }

.phoneActions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- the archive page ---------- */

.archiveBody { display: grid; gap: 18px; }

.archiveHead {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.archiveHead h1 { margin: 4px 0 6px; font-size: 26px; letter-spacing: -.4px; }

.archiveHead p { margin: 0; max-width: 62ch; color: #5b6169; line-height: 1.6; font-size: 13.5px; }

.archiveEmpty {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 26px 24px;
  border: 1px dashed var(--line, #dde3ec);
  border-radius: 16px;
  background: #fafbfd;
}

.archiveEmpty b { font-size: 16px; }

.archiveEmpty span { color: #5b6169; line-height: 1.6; font-size: 13.5px; max-width: 62ch; }

.archiveList {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.archiveCard {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line, #e2e6ee);
  border-radius: 16px;
  background: #fff;
}

.archiveCard.open { border-color: var(--blue, #315efb); box-shadow: 0 0 0 3px rgba(49, 94, 251, .12); }

.archiveCardTop { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }

.archiveCardTop b { display: block; font-size: 14.5px; }

.archiveCardTop span { font-size: 11.5px; color: #7a8290; }

.archiveCount { text-align: center; white-space: nowrap; }

.archiveCount b { display: block; font-size: 19px; line-height: 1.1; color: var(--navy, #0d2443); }

.archiveCount em { font-style: normal; font-size: 11px; color: #7a8290; }

.archiveThumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
  align-items: center;
}

.archiveThumb {
  margin: 0;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f4f9;
  border: 1px solid var(--line, #e2e6ee);
}

.archiveThumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.archiveMore,
.archiveNoPages { font-size: 11.5px; color: #7a8290; }

.archiveActions { display: flex; gap: 8px; flex-wrap: wrap; }

/* the sheet that appears while pages are being added */

.archiveSheet {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line, #e2e6ee);
  border-radius: 18px;
  background: #f7f9fc;
}

.archiveSheet h3 { margin: 4px 0 2px; font-size: 18px; }

.archiveSheet header small { color: #7a8290; font-size: 12px; }

.archiveSheetGrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.archiveTap {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line, #e2e6ee);
  border-radius: 14px;
}

.archiveTap small { color: #7a8290; font-size: 12px; line-height: 1.5; }

.archiveSheetPages {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.archivePage { margin: 0; display: grid; gap: 5px; }

.archivePage img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line, #e2e6ee);
  background: #eef1f6;
}

.archivePage figcaption { font-size: 11.5px; color: #7a8290; text-align: center; }

.archiveSelectLabel {
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: #5b6169;
  margin: 0 0 16px;
}

.archiveSelectLabel select {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border: 1px solid var(--line, #e2e6ee);
  border-radius: 12px;
  background: #fff;
}

/* ---------- the toolbar button ---------- */

.workspacePhoneBtn { white-space: nowrap; }
