/* ============================================================
   BUREAU OF LOST TIMELINES — IDENTITY DESK SHEET
   Version: 2.0 (Dossier system)

   css/avatar.css owns one thing: the upload sheet js/avatar.js raises over
   the personnel file when an operative presses the pencil on their
   identicon. It is a stamped page from the same stack as the advisory
   dialogs — spine on the left, ink under the fibre, a single red action —
   and it is the only place in the Bureau where a member is allowed to
   alter their own record.

   The modal sits at z-index 10000 on purpose: css/ui.css raises its dialog
   layer to 20000 because a notice can appear from inside this sheet (the
   "Avatar saved" confirmation), and that notice has to land on top.
   ============================================================ */

.avatar-modal {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  /* The ink of the page floor, drawn thin enough that the file behind it
     is still dimly there — the desk does not go blank on you. */
  background: rgba(11, 12, 14, 0.86);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 10000;
}

.avatar-modal.show {
  display: flex;
}

/* ---------- the sheet ---------- */
.avatar-modal-inner {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - (var(--gutter) * 2));
  overflow: auto;
  background: var(--ink-1);
  background-image: var(--fibre);
  border: 1px solid var(--line-strong);
  border-left: var(--spine) solid var(--alert);
  box-shadow: var(--shadow-2);
  padding: var(--s-5) var(--s-4) var(--s-4);
  text-align: center;
  animation: fadeIn var(--dur-3) var(--ease-out);
}

.avatar-modal-inner h3 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-h4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-bright);
  margin-bottom: var(--s-1);
}

.avatar-hint {
  font-family: var(--font-my);
  font-size: var(--fs-label);
  line-height: 1.7;
  color: var(--paper-dim);
  margin-bottom: var(--s-3);
}

/* ---------- the identicon well ---------- */
/* The circle is 100px because that is the size an uploaded face still
   reads at; everything else in it is a token. */
.avatar-preview {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--s-3);
  background: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  box-shadow: var(--shadow-inset);
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 40px;
  line-height: 1;
  color: var(--paper-bright);
}

.avatar-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* js/avatar.js marks a well that holds a picture rather than an initial with
   has-img. Today that only lands on .profile-avatar (css/style.css); the rule is
   kept here so this sheet's own well behaves the same if it ever does. */
.avatar-preview.has-img {
  padding: 0;
}

/* ---------- choosing the file ---------- */
/* The input is hidden and its label is the button. It is hidden by clipping,
   not removed: a display:none control can never take focus, so the picker
   could not be opened from a keyboard at all. Clipped, it stays in the tab
   order ahead of its label, and the ring below says so on the label the eye
   reads — the same treatment css/admin.css and css/backup.css give their file
   inputs. */
.avatar-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.avatar-file-label {
  display: block;
  background: var(--ink-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-1);
  color: var(--paper-dim);
  padding: 11px var(--s-2);
  margin-bottom: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease);
}

.avatar-file-label:hover {
  color: var(--paper-bright);
  border-color: var(--alert);
  border-style: solid;
  background: var(--alert-wash);
}

.avatar-file:focus-visible + .avatar-file-label {
  outline: 2px solid var(--alert-bright);
  outline-offset: 2px;
}

/* ---------- the actions ---------- */
.avatar-actions {
  display: flex;
  gap: var(--s-1);
  justify-content: center;
  margin-top: var(--s-1);
}

/* Saving is the action this sheet exists for, so it takes the stamp:
   solid red, ink type. REMOVE is the same red said quietly — it only
   fills when you point at it, so the two never look equally certain. */
.avatar-btn {
  background: var(--alert);
  border: 1px solid var(--alert);
  border-radius: var(--r-1);
  color: var(--ink-0);
  padding: 10px var(--s-4);
  min-height: 40px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease);
}

.avatar-btn:hover:not(:disabled) {
  background: var(--alert-bright);
  border-color: var(--alert-bright);
  box-shadow: 0 8px 24px var(--alert-glow);
}

.avatar-btn:focus-visible {
  outline: 2px solid var(--alert-bright);
  outline-offset: 2px;
}

/* A button that cannot act yet is not allowed the red: no file chosen
   yet, nothing to stamp. */
.avatar-btn:disabled {
  background: var(--ink-2);
  border-color: var(--line);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}

.avatar-btn.danger {
  background: transparent;
  border-color: var(--line-red);
  color: var(--alert-bright);
}

.avatar-btn.danger:hover:not(:disabled) {
  background: var(--alert-wash-2);
  border-color: var(--alert);
  box-shadow: none;
}

/* ---------- the close plate ---------- */
/* js/avatar.js writes a cross glyph into this button; the plate around it
   is ours, so the close reads as a Bureau control and not a floating
   character. */
.avatar-modal-close {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  color: var(--muted-strong);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease);
}

.avatar-modal-close:hover {
  color: var(--paper-bright);
  border-color: var(--alert);
  background: var(--alert-wash);
}

.avatar-modal-close:focus-visible {
  outline: 2px solid var(--alert-bright);
  outline-offset: 2px;
}

/* ---------- the refusal ---------- */
.avatar-error {
  font-family: var(--font-my);
  font-size: var(--fs-label);
  line-height: 1.7;
  color: var(--alert-bright);
  margin-top: var(--s-2);
  min-height: 18px;
  overflow-wrap: anywhere;
}

/* Only a refusal gets the red well; an empty error line has to stay
   invisible so the sheet does not grow a border for nothing. */
.avatar-error:not(:empty) {
  background: var(--alert-wash);
  border-left: var(--spine) solid var(--alert);
  padding: var(--s-1) var(--s-2);
  text-align: left;
  margin-top: var(--s-3);
}

/* ---------- narrow screens ---------- */
@media (max-width: 420px) {
  .avatar-modal-inner {
    padding: var(--s-4) var(--s-3);
  }

  .avatar-btn {
    flex: 1;
    padding: 10px var(--s-1);
    letter-spacing: 0.08em;
  }
}

/* ---------- a calmer desk ---------- */
@media (prefers-reduced-motion: reduce) {
  .avatar-modal-inner {
    animation: none;
  }

  .avatar-file-label,
  .avatar-btn,
  .avatar-modal-close {
    transition: none;
  }
}
