/* phototracker's own rules, loaded after trackerui's shared sheet.
 *
 * Only what the shared sheet does not already give: the sign-in page, the
 * token table, and the account menu. Anything here that the family shares
 * belongs upstream in trackerui instead -- this file is for what is
 * particular to picking photos.
 *
 * Adapted from tangotracker's app.css, which carries the same pages. The
 * column widths are not: its token table borrows a roster sized for teacher
 * numbers, and these four columns are a different shape.
 */

/* ---- Sign-in ----------------------------------------------------------- */

.signin { max-width: 26rem; margin: 12vh auto 0; text-align: center; }

.signin h1 { font-size: 2.2rem; margin-bottom: var(--s2); }

.signin .btn { margin-top: var(--s6); }

.signin-error {
  margin-top: var(--s4);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

/* Google's brand guidelines require its button stay white with dark text,
 * so this is the one control that opts out of the dark palette. */
.btn-google {
  background: #fff;
  color: #1f1f1f;
  border-color: #dadce0;
  text-transform: none;
  font-family: var(--font-body);
  letter-spacing: normal;
}

.btn-google:hover { background: #f8f9fa; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }

/* ---- Headings and messages --------------------------------------------- */

/* The count beside a page's name: part of the heading's text, but not the
 * name, so it carries the muted weight rather than the display face. */
.head-count {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--muted);
}

.form-error {
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---- The revealed token ------------------------------------------------ */

/* The callout the secret arrives in. Bordered rather than tinted: this is the
 * one thing on the page that cannot be recovered by reloading, and it has to
 * read as different from the table below it. */
.reveal-note {
  margin: var(--s3) 0;
  padding: var(--s3);
  border: 1px solid var(--violet);
  border-radius: var(--radius);
  background: var(--surface);
}

.reveal-note h2 { margin-top: 0; }

.reveal-row { display: flex; align-items: flex-start; gap: var(--s2); }

/* The secret is a monospaced block that wraps, because a token running off the
 * edge of its box is one a reader cannot check they have selected in full.
 * user-select: all makes one click take the whole value. */
.token-reveal {
  display: block;
  margin: 0;
  padding: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
  white-space: pre-wrap;
  min-width: 0;
  user-select: all;
  flex: 1;
}

/* On a phone the value and Copy cannot share a row: the token is the wider
 * of the two and Copy would be pushed off-screen, on the one page that shows
 * the secret once. */
@media (max-width: 480px) {
  .reveal-row { flex-direction: column; align-items: stretch; }
  .reveal-row .btn-copy { width: 100%; min-height: 44px; }
}

/* Sits beside the value shown once, so it must not wrap or shrink away from
 * it. */
.btn-copy { flex: 0 0 auto; }

/* ---- Forms ------------------------------------------------------------- */

/* A one-column stack. Without this the label and input lay out as an inline
 * run at their intrinsic width, which reads as merely cramped on a desktop
 * and pushes past the viewport on a phone. */
.edit-form { display: flex; flex-direction: column; gap: var(--s1); }

.edit-form label {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--faint);
}

/* An input must not exceed the column, or its longest content sets its own
 * width and widens the whole page. */
.edit-form input { width: 100%; max-width: 100%; }

.edit-form .btn { margin-top: var(--s4); align-self: flex-start; }

.btn-accent { background: var(--violet); border-color: var(--violet); color: #fff; }

.btn-accent:hover { background: var(--violet-dark); }

/* Destructive, and it looks it. Outlined rather than filled so a table of
 * tokens is not a wall of red -- the colour is the warning, the fill is
 * reserved for the hover that means the pointer is on it.
 *
 * The class is doubled to outweigh the shared sheet's .btn, which sets its own
 * background. At equal specificity that background wins on source order, and
 * the result is danger-coloured text on a danger-coloured fill: a button whose
 * label cannot be read at all. No Go test can catch that. */
.btn.btn-danger.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn.btn-danger.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---- The token table --------------------------------------------------- */

/* Four columns: label, created, last used, and the revoke button. Sized here
 * rather than borrowed from tangotracker's roster, which pins its first column
 * to the width of a two-digit teacher number.
 *
 * table-layout: fixed so the widths below are honoured; without it the browser
 * sizes from content and a long label starves the rest. */
.tokentable { table-layout: fixed; width: 100%; }

.tokentable th, .tokentable td { padding: var(--s2) var(--s1); }

/* The widths go on the header row, because that is the row a fixed layout
 * reads them from. The label takes whatever the three fixed columns leave. */
.tokentable th:nth-child(2) { width: 7rem; }
.tokentable th:nth-child(3) { width: 7rem; }
.tokentable th:nth-child(4) { width: 7rem; }

.tokentable th:nth-child(4), .tokentable td:nth-child(4) { text-align: right; }

/* A label may be several words and is the only cell that wraps. */
.tokentable td:nth-child(1) { word-break: break-word; }

/* A wrapped table still carries trackerui's 520px floor, which would move the
 * sideways scroll inside the box rather than removing it. Four short cells do
 * not need it. */
.tablewrap .tokentable { min-width: 0; }

/* ---- Account menu ------------------------------------------------------ */

/* Account things live here rather than in the nav: the nav is about what is in
 * the library, and a token is about who you are. details/summary so the menu
 * opens with no script running at all. */
.usermenu { position: relative; }

.usermenu summary,
.usermenu .user-email {
  list-style: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usermenu summary::-webkit-details-marker { display: none; }

.usermenu summary:hover { color: var(--text); }

.usermenu-items {
  position: absolute;
  right: 0;
  top: calc(100% + var(--s2));
  z-index: 20;
  min-width: 11rem;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.usermenu-items a,
.usermenu-items button {
  display: block;
  width: 100%;
  padding: var(--s1) var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.usermenu-items a:hover,
.usermenu-items button:hover { background: var(--surface-3); }

/* ---- Utilities --------------------------------------------------------- */

/* Available to a screen reader, absent from the page. Used for a table header
 * whose column holds buttons that name themselves. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- The photo grid ---------------------------------------------------- */

/* Filter chips. Counts live inside them, because "liked" without a number
 * does not answer the question a person opens this page with. */
.filters { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s3) 0; }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s1);
  padding: var(--s1) var(--s3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.chip:hover { border-color: var(--violet); }

.chip.current { border-color: var(--violet); background: var(--surface-3); }

.chip-count { color: var(--muted); font-size: 0.8rem; }

.chip-liked.current { border-color: var(--danger); }

/* The action bar. Sticky, because the selection is made by scrolling and the
 * buttons that act on it must not be left at the top of the page. */
.gridbar {
  position: sticky;
  top: 4.5rem; /* clears trackerui's sticky top bar */
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s2);
  margin-bottom: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.selcount { color: var(--muted); font-size: 0.9rem; min-width: 7rem; }

/* A selection that is not empty is the one thing on this bar worth noticing. */
.selcount.any { color: var(--violet-bright); font-weight: 600; }

.gridbar-hint { margin-left: auto; }

/* auto-fill rather than auto-fit: a page with three photos should show three
 * tiles at their proper size, not three stretched across the whole width. */
.grid-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s3);
}

/* Narrower tiles on a phone (about two per row): one photo per row makes
 * triage a long scroll. */
@media (max-width: 640px) {
  .grid-photos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.tile {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  position: relative;
}

/* The cursor the keyboard moves. Outlined rather than filled so it reads over
 * any photograph. */
.tile.cursor { border-color: var(--violet); box-shadow: 0 0 0 2px var(--violet-soft); }

.tile.liked { border-color: var(--danger); }

/* A failed like must not look like a successful one. */
.tile.failed { border-color: var(--warn); }

/* The ratio comes from the source image, so the space is reserved before the
 * picture loads and the grid does not jump as tiles arrive. */
.tile-open, .tile-pending {
  display: block;
  aspect-ratio: var(--ratio, 1.5);
  background: var(--surface-2);
}

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

/* Not an error: the deriver runs every thirty seconds, and a photo that has
 * just landed has no picture yet. */
.tile-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 1.5rem;
}

.tile-select {
  position: absolute;
  top: var(--s2);
  left: var(--s2);
  z-index: 2;
  /* 44px square: the checkbox is the touch route to batch actions (Delete, and
   * Like or Unlike on several photos at once). */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(11, 11, 18, 0.65);
  cursor: pointer;
}

.tile-select input { cursor: pointer; margin: 0; width: 24px; height: 24px; }

/* Touch route to Like, one tap per photo. */
.tile-like {
  position: absolute;
  top: var(--s2);
  right: var(--s2);
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(11, 11, 18, 0.65);
  color: var(--faint);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.tile-like[aria-pressed="true"] { color: var(--danger); }

/* j/k/l need a keyboard, so the hint is noise on a touch screen. */
@media (pointer: coarse) {
  .gridbar-hint { display: none; }
}

.tile figcaption {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  padding: var(--s2);
  font-size: 0.8rem;
}

/* The filename is the only part that can run long; it takes the slack and
 * truncates rather than pushing the date off the tile. */
.tile-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-when { flex: 0 0 auto; }

.tile-flag { flex: 0 0 auto; color: var(--danger); }

.tile-flag.imported { color: var(--ok); }

.more { margin-top: var(--s4); text-align: center; }
