/* ===========================================================================
   Cloud surfaces — sign-in, activity drawer, version history, enrollment.

   Loaded after cv-styles.css and reuses its custom properties (--glass-*,
   --accent, --stroke, radii, easings) rather than redefining a second design
   language. Only genuinely new components live here; nothing overrides the
   editor or the .cv-page document surface, which must stay ink-on-white.
   =========================================================================== */

/* Hidden until boot decides the app is in cloud mode. */
.cloud-only[hidden] {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────── sign in */

/* .gate in cv-styles.css is opacity:0/visibility:hidden unless the body is in
   the "gate" view. The sign-in screen is a fourth view, so it needs its own
   rules — without these it is in the DOM, not [hidden], and still invisible. */
body[data-view="signin"] .gate.signin {
  opacity: 1;
  visibility: visible;
}

body[data-view="signin"] .gate.signin .gate-inner {
  transform: none;
}

/* The profile gate sits at the same z-index and would swallow clicks meant for
   the sign-in form. */
body[data-view="signin"] #profileGate {
  pointer-events: none;
  visibility: hidden;
}

.gate-inner.narrow {
  max-width: 26rem;
}

.signin-form {
  display: grid;
  gap: 0.9rem;
  padding: 1.4rem;
  border-radius: var(--radius-lg, 1.25rem);
  text-align: left;
}

.signin-step {
  display: grid;
  gap: 0.75rem;
}

.button.block,
.text-button.block {
  width: 100%;
  justify-content: center;
}

.hint {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-dim, rgba(231, 233, 243, 0.6));
}

.hint b {
  color: var(--text, #e7e9f3);
  font-weight: 600;
}

/* Wide tracking so a 6-digit code is read as digits, not a word. */
.code-input {
  font-size: 1.5rem !important;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.form-error {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.7rem;
  background: color-mix(in srgb, #f87171 14%, transparent);
  border: 1px solid color-mix(in srgb, #f87171 34%, transparent);
  color: #fecaca;
  font-size: 0.86rem;
  line-height: 1.5;
}

.signin-foot {
  margin: 1.1rem 0 0;
  font-size: 0.82rem;
  color: var(--text-dim, rgba(231, 233, 243, 0.55));
}

/* ─────────────────────────────────────────────────────────── drawers */

.drawer {
  position: fixed;
  z-index: 60;
  inset-block: 0.75rem;
  inset-inline-end: 0.75rem;
  width: min(24rem, calc(100vw - 1.5rem));
  padding: 1.1rem 1.2rem 1.4rem;
  border-radius: var(--radius-lg, 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: drawer-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(1.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drawer {
    animation: none;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.drawer-sub,
.drawer-empty {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-dim, rgba(231, 233, 243, 0.58));
}

.drawer-empty {
  padding: 1.5rem 0;
  text-align: center;
}

/* ───────────────────────────────────────────────────── activity list */

.job-list,
.revision-list,
.enroll-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.job,
.revision {
  display: grid;
  gap: 0.45rem;
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.09));
}

.job-head,
.revision-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.job-name {
  font-weight: 600;
  font-size: 0.88rem;
  /* Filenames are long and must not push the timestamp off the row. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-when,
.revision-when {
  flex: none;
  font-size: 0.74rem;
  color: var(--text-dim, rgba(231, 233, 243, 0.5));
  font-variant-numeric: tabular-nums;
}

.job-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.job-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--accent, #4338ca),
    color-mix(in srgb, var(--accent, #4338ca) 55%, #fff)
  );
  transition: width 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* Indeterminate shimmer while a phase is active, so a slow render still looks
   alive rather than stalled. */
.job-running .job-fill {
  background-size: 200% 100%;
  animation: job-shimmer 1.4s linear infinite;
}

@keyframes job-shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .job-running .job-fill {
    animation: none;
  }
}

.job-succeeded .job-fill {
  background: linear-gradient(90deg, #34d399, #6ee7b7);
}

.job-failed .job-fill {
  background: linear-gradient(90deg, #f87171, #fca5a5);
}

.job-meta {
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-dim, rgba(231, 233, 243, 0.58));
}

.job-phase {
  text-transform: capitalize;
}

.job-failed .job-phase {
  color: #fca5a5;
  text-transform: none;
}

.job-mail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Count of in-flight jobs on the toolbar button. */
.badge {
  position: absolute;
  top: -0.2rem;
  inset-inline-end: -0.2rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--accent, #4338ca);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(7, 8, 15, 0.85);
}

#jobsButton {
  position: relative;
}

/* ─────────────────────────────────────────────────── version history */

.revision-number {
  font-weight: 700;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.revision-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-dim, rgba(231, 233, 243, 0.55));
}

.revision-tag {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #4338ca) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #4338ca) 38%, transparent);
  color: color-mix(in srgb, var(--accent, #4338ca) 30%, #fff);
}

.revision-actions {
  display: flex;
  justify-content: flex-end;
}

/* ───────────────────────────────────────────────────────── enrollment */

.sheet-note {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.09));
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-dim, rgba(231, 233, 243, 0.68));
}

.enroll-list-wrap h3 {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim, rgba(231, 233, 243, 0.55));
}

.enroll-list-wrap .muted {
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.enroll-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
  font-size: 0.84rem;
}

.enroll-number {
  flex: 1;
  font-variant-numeric: tabular-nums;
}

.enroll-status {
  flex: none;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.enroll-verified .enroll-status {
  background: color-mix(in srgb, #34d399 18%, transparent);
  border: 1px solid color-mix(in srgb, #34d399 40%, transparent);
  color: #6ee7b7;
}

.enroll-pending .enroll-status {
  background: color-mix(in srgb, #fbbf24 18%, transparent);
  border: 1px solid color-mix(in srgb, #fbbf24 40%, transparent);
  color: #fcd34d;
}

/* ────────────────────────────────────────────────────────── demo mode */

/* Unmistakable, but out of the way of the UI being reviewed. */
.demo-banner {
  position: fixed;
  z-index: 90;
  inset-block-end: 0.75rem;
  inset-inline-start: 0.75rem;
  max-width: min(30rem, calc(100vw - 1.5rem));
  padding: 0.7rem 0.9rem;
  border-radius: 0.8rem;
  background: color-mix(in srgb, #fbbf24 16%, rgba(10, 11, 20, 0.86));
  border: 1px solid color-mix(in srgb, #fbbf24 42%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  color: #fde68a;
  font-size: 0.78rem;
  line-height: 1.55;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.demo-banner b {
  color: #fff;
  font-weight: 700;
}

.demo-banner code {
  padding: 0.05rem 0.3rem;
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95em;
  color: #fff;
}

/* ────────────────────────────────────────────── responsive / print */

@media (max-width: 640px) {
  .drawer {
    inset: auto 0.5rem 0.5rem;
    width: auto;
    max-height: 78vh;
  }
}

/* None of this belongs in a printed CV. */
@media print {
  .drawer,
  .gate.signin,
  #enrollSheet,
  .badge {
    display: none !important;
  }
}

/* Invite sheet: an admin badge and a non-actionable "you" marker. The current
   user has no Remove or Make-member button at all, because removing your own
   admin rights can lock the last administrator out of the deployment. */
.enroll-admin .enroll-status {
  background: color-mix(in srgb, var(--accent, #4338ca) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #4338ca) 42%, transparent);
  color: color-mix(in srgb, var(--accent, #4338ca) 30%, #fff);
}

.enroll-self {
  flex: none;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.1));
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, rgba(231, 233, 243, 0.6));
}

/* Addresses are longer than phone numbers and must not stretch the sheet. */
.enroll-item .enroll-number {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: normal;
}

/* ═══════════════════════════════════════════════ Naidoo Space launcher */

/* The launcher reuses .gate, which cv-styles.css keeps hidden unless the body is
   in the matching view — so it needs its own view rule, exactly like the sign-in
   screen. Without this the section is in the DOM, not [hidden], and invisible. */
body[data-view="launcher"] .gate.launcher {
  opacity: 1;
  visibility: visible;
}

body[data-view="launcher"] .gate.launcher .gate-inner {
  transform: none;
}

/* The CV profile gate shares this z-index and would swallow clicks. */
body[data-view="launcher"] #profileGate,
body[data-view="launcher"] #signIn {
  pointer-events: none;
  visibility: hidden;
}

.app-grid {
  list-style: none;
  margin: 2rem auto 1.5rem;
  padding: 0;
  display: grid;
  /* auto-fit rather than a fixed column count: four tools sit in a row on a
     desktop and reflow to one on a phone with no breakpoint to maintain. */
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  max-width: 62rem;
  text-align: left;
}

.app-card {
  display: flex;
}

.app-hit {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: var(--radius-lg, 1.15rem);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.1));
  background:
    linear-gradient(
      160deg,
      color-mix(in srgb, var(--app-accent, #4338ca) 18%, transparent),
      transparent 60%
    ),
    rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px) saturate(140%);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition:
    transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1),
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

.app-hit:hover:not(:disabled),
.app-hit:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--app-accent, #4338ca) 55%, transparent);
  box-shadow:
    0 18px 40px -18px rgba(0, 0, 0, 0.7),
    0 0 0 1px color-mix(in srgb, var(--app-accent, #4338ca) 40%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .app-hit {
    transition: none;
  }
  .app-hit:hover:not(:disabled) {
    transform: none;
  }
}

.app-icon {
  display: grid;
  place-items: center;
  /* min-, not fixed: a glyph must never be clipped by its own tile. */
  min-width: 2.6rem;
  min-height: 2.6rem;
  border-radius: 0.8rem;
  background: color-mix(in srgb, var(--app-accent, #4338ca) 30%, transparent);
  border: 1px solid color-mix(in srgb, var(--app-accent, #4338ca) 50%, transparent);
  font-size: 1.1rem;
  line-height: 1.1;
  color: #fff;
}

.app-copy {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.app-name {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.app-tagline {
  font-size: 0.82rem;
  color: color-mix(in srgb, var(--app-accent, #4338ca) 25%, #fff);
}

.app-desc {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-dim, rgba(231, 233, 243, 0.6));
  /* Descriptions vary in length; wrapping is correct, truncation is not. */
  overflow-wrap: anywhere;
}

/* Unbuilt tools are shown deliberately rather than hidden: an empty launcher
   invites "is it broken?", a greyed card answers the question before it is asked. */
.app-soon .app-hit {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-badge {
  position: absolute;
  top: 0.7rem;
  inset-inline-end: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.12));
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, rgba(231, 233, 243, 0.65));
}

.launcher-who {
  font-size: 0.8rem;
  color: var(--text-dim, rgba(231, 233, 243, 0.55));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24ch;
}
