/* One screen for signing in and for waiting: the scene, the panel and their type.
   The sign-in screen (auth-gate.tsx) and the loading screen (entry-screen.js) are both drawn
   with these rules. The loading screen is also shown by the dashboard and by the workspace
   page before its script has loaded, so the dashboard serves a copy of this folder
   (public/entry-screen/, kept identical by scripts/sync-entry-screen.mjs and its test). */

.oc-login {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 448px);
  place-items: center;
  min-height: 100svh;
  padding: 96px clamp(32px, 6vw, 120px) 100px;
  color: #f4f1eb;
  background: #080808;
}

.oc-login-atmosphere {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse at 30% 50%, #33251b 0%, #080808 70%);
  animation: oc-login-reveal 1.6s ease-out both;
}

/* The still, the loop's first frame, remains visible until the loop has a frame to show. */
.oc-login-artwork {
  position: absolute;
  inset: -2%;
  /* --oc-login-artwork: a page that already has the image cached under another address names it. */
  background: var(--oc-login-artwork, url("./login-black-hole-still.png")) center / cover no-repeat;
}

.oc-login-loop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 400ms ease;
}

.oc-login-loop[data-ready="true"] {
  opacity: 1;
}

.oc-login-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 40%, #08080840 66%, #08080885),
    linear-gradient(0deg, #08080880, transparent 18%, transparent 85%, #08080860);
}

.oc-login-content {
  grid-column: 2;
  width: min(100%, 448px);
  min-width: 0;
  animation: oc-login-enter 800ms 120ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.oc-login-card {
  padding: 40px;
  border: 1px solid #ffffff14;
  border-top-color: #ffffff26;
  border-radius: 24px;
  background: linear-gradient(145deg, #242320eb, #141413f5 70%);
  box-shadow: 0 24px 80px #00000040, 0 4px 20px #0000001a, inset 0 1px 0 #ffffff05;
}

.oc-login-brand {
  margin-bottom: 38px;
}

.oc-login-brand > span {
  color: #f4f1eb;
}

.oc-login-heading {
  max-width: 12ch;
  margin: 0;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.oc-login-description {
  max-width: 34ch;
  margin: 16px 0 0;
  color: #aaa7a0;
  font-size: 14px;
  line-height: 1.7;
}

.oc-login-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 50px;
  margin-top: 30px;
  padding: 13px 18px;
  border: 1px solid #ffffff59;
  border-radius: 12px;
  color: #211d17;
  background: #f1ede5;
  box-shadow: inset 0 1px 0 #ffffffb3, 0 2px 5px #0000001a;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.oc-login-primary > svg {
  flex-shrink: 0;
}

.oc-login-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.oc-login-arrow {
  transition: transform 200ms ease;
}

.oc-login-divider {
  height: 1px;
  margin: 24px 0 12px;
  background: linear-gradient(90deg, #ffffff12, #ffffff08);
}

.oc-login-alternative {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  color: #b1ada5;
  font-size: 13px;
  line-height: 1.6;
  cursor: pointer;
  transition: color 180ms ease;
}

.oc-login-alternative:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.oc-login-motion {
  position: absolute;
  right: max(32px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 0;
  color: #a59c91;
  font-size: 12px;
  cursor: pointer;
}

.oc-login :is(button, input):focus-visible {
  outline: 2px solid #d9b38a;
  outline-offset: 4px;
}

@media (hover: hover) {
  .oc-login-primary:hover:not(:disabled) {
    background: #fffaf1;
    box-shadow: inset 0 1px 0 #fff, 0 2px 12px #f4c89114;
  }

  .oc-login-primary:hover:not(:disabled) .oc-login-arrow {
    transform: translateX(3px);
  }

  .oc-login-alternative:hover:not(:disabled),
  .oc-login-motion:hover {
    color: #f1ede5;
  }
}

@keyframes oc-login-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes oc-login-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 960px) {
  .oc-login {
    grid-template-columns: minmax(0, 1fr);
    padding: 380px 24px 88px;
  }

  .oc-login-content {
    grid-column: 1;
  }

  .oc-login-artwork {
    inset: auto;
    width: 1120px;
    height: 630px;
    top: -80px;
    left: calc(50% - 347px);
    background-size: contain;
    mask-image: linear-gradient(#000 75%, transparent);
  }

  .oc-login-atmosphere {
    background: #080808;
  }

  .oc-login-atmosphere::after {
    background: linear-gradient(0deg, #080808 0%, transparent 55%);
  }
}

@media (max-width: 520px) {
  .oc-login {
    padding: 290px 20px 80px;
  }

  .oc-login-card {
    padding: 30px 26px 24px;
    border-radius: 20px;
  }

  .oc-login-heading {
    font-size: clamp(28px, 8vw, 34px);
  }

  .oc-login-brand {
    margin-bottom: 24px;
  }

  .oc-login-artwork {
    width: 760px;
    height: 428px;
    top: -30px;
    left: calc(50% - 236px);
  }

  .oc-login-motion {
    right: max(20px, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  .oc-login *,
  .oc-login *::before,
  .oc-login *::after {
    animation: none !important;
    transition: none !important;
  }

  .oc-login-motion {
    display: none;
  }
}

/* ---- The loading screen -----------------------------------------------------------------
   Same scene and panel; the sign-in controls give way to one status row. It is drawn where no
   app stylesheet or reset exists (the dashboard, a page whose script has not run), so it
   states its own base. :where() keeps that base below every rule above. */

.oc-login[data-entry-screen] {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.4px;
  text-align: left;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:where(.oc-login[data-entry-screen]),
:where(.oc-login[data-entry-screen]) :where(*, ::before, ::after) {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0 solid;
}

:where(.oc-login[data-entry-screen]) :where(button) {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  border-radius: 0;
  background-color: transparent;
  text-rendering: auto;
}

.oc-login[data-entry-screen] [hidden] {
  display: none !important;
}

/* A screen that continues the one before it (the next page of the same wait) does not fade
   in again. */
.oc-login[data-entry-continued] .oc-login-atmosphere,
.oc-login[data-entry-continued] .oc-login-content {
  animation: none;
}

.oc-login-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f4f1eb;
}

.oc-login-mark > svg {
  flex-shrink: 0;
}

.oc-login-mark > span {
  font-size: 26.24px;
  letter-spacing: -0.025em;
}

/* The status row sits where the sign-in button sits and has its shape, but is not a control. */
.oc-login-status {
  cursor: default;
}

.oc-login-status > span:first-child {
  min-width: 0;
  flex: 1;
}

.oc-login-status-meta {
  flex-shrink: 0;
  color: #6f685d;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.oc-login-spinner {
  flex-shrink: 0;
  animation: oc-login-spin 1s linear infinite;
}

/* Under the panel, in the place of the sign-in screen's note. */
.oc-login-below {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  padding: 0 4px;
  color: #b9afa3;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
  cursor: pointer;
  transition: color 180ms ease;
}

.oc-login-below[data-entry-empty] {
  visibility: hidden;
}

@media (hover: hover) {
  .oc-login-below:hover {
    color: #f1ede5;
  }
}

/* Debug: the corner opposite "pause animation". The button looks like that one; the panel
   opens above it, over the artwork, and never over the sign-in panel's column on a wide screen. */
.oc-login-debug {
  position: absolute;
  left: max(32px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 0;
  color: #a59c91;
  font-size: 12px;
  cursor: pointer;
}

.oc-login-debug > svg {
  flex-shrink: 0;
}

.oc-login-debug[aria-expanded="true"] {
  color: #f1ede5;
}

.oc-login-debug-panel {
  position: absolute;
  left: max(32px, env(safe-area-inset-left));
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 48px);
  width: min(400px, calc(100% - 64px));
  max-height: min(60%, 440px);
  overflow-y: auto;
  padding: 12px 16px 14px;
  border: 1px solid #ffffff14;
  border-top-color: #ffffff26;
  border-radius: 12px;
  color: #e8e4dc;
  /* opaque: on a phone it lies over the panel, whose text must not show through */
  background: #141413;
  box-shadow: 0 16px 48px #00000059;
  font-size: 12px;
  line-height: 1.5;
}

.oc-login-debug-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #b1ada5;
}

.oc-login-debug-copy {
  min-height: 28px;
  color: #a59c91;
  font-size: 12px;
  cursor: pointer;
}

.oc-login-debug-panel > dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 14px;
}

.oc-login-debug-panel > dl > div {
  display: contents;
}

.oc-login-debug-panel dt {
  color: #8f897f;
}

.oc-login-debug-panel dd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

@media (hover: hover) {
  .oc-login-debug:hover,
  .oc-login-debug-copy:hover {
    color: #f1ede5;
  }
}

@media (max-width: 520px) {
  .oc-login-debug,
  .oc-login-debug-panel {
    left: max(20px, env(safe-area-inset-left));
  }

  .oc-login-debug-panel {
    width: calc(100% - 40px);
  }
}

.oc-login-error {
  max-height: 30svh;
  overflow: auto;
  overflow-wrap: anywhere;
  margin-top: 20px;
  padding: 10px 12px;
  border: 1px solid #663c3c;
  border-radius: 8px;
  color: #f1a6a6;
  background: #251a1a;
  font-size: 13px;
  line-height: 20px;
}

.oc-login[data-entry-screen] .oc-login-motion > svg {
  flex-shrink: 0;
}

@keyframes oc-login-spin {
  to { transform: rotate(360deg); }
}

/* A long wait offers the way out under its status row: the two read as one group. */
.oc-login-status:not([hidden]) + .oc-login-primary {
  margin-top: 10px;
}

/* The screen as a layer over the page. The page's first paint (index.html) is held in the
   document until React has drawn in its place, and is visible only once these rules apply,
   never as bare markup. The app's own layer (wait-screen.tsx) sits under the desktop window's
   drag strip and controls; over a mounted app it sits above the app's menus and dialogs. */
#oc-entry-prepaint,
.oc-entry-layer {
  position: fixed;
  inset: 0;
  overflow-y: auto;
}

#oc-entry-prepaint {
  visibility: visible !important;
}

/* Until the page's own script has said which still to use (prepaint.js), the first paint
   names none: a browser may start fetching the one this stylesheet names the moment the
   markup exists, and a workspace page already has the dashboard's copy of it. */
#oc-entry-prepaint:not([data-entry-settled]) .oc-login-artwork {
  background-image: none;
}

.oc-entry-layer {
  z-index: 89;
}

.oc-entry-layer[data-entry-over-app] {
  z-index: 2000;
}
