/* ==== Sable app styles (production-shaped) ==============================
   One orb on solid black, rendered once at 180 px. Its places are
   transforms of one wrapper (only transform moves):
     centre 144 · the entrance and Home are the same place
     forward 180 · higher, clear of the iOS passkey sheet, for messages
   Words form beneath it. Motion follows WAYFINDER Connections round 7. */
@font-face {
  font-family: "Schibsted Grotesk";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-400.woff2") format("woff2");
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-500.woff2") format("woff2");
}
:root {
  color-scheme: dark;
  --bg: #000000;
  --text: #dbe5ee;
  --quiet: #8c9dae;
  --hint: #66788a;
  --cyan: #9fd8df;
  --font: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Helvetica Neue", system-ui, sans-serif;
  --curve: cubic-bezier(0.2, 0.8, 0.2, 1);
  --travel: 760ms;
  background-color: var(--bg);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.app {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
/* The safe box. JS writes --fy (forward centre) and --cy (centre place). */
.stage {
  position: absolute;
  top: var(--sat);
  bottom: var(--sab);
  left: var(--sal);
  right: var(--sar);
  --fy: 241px;
  --cy: 50%;
}

/* ---- The orb ------------------------------------------------------ */
/* Resting box = the forward place; JS sets the transform for every place. */
.orbwrap {
  position: absolute;
  left: calc(50% - 90px);
  top: calc(var(--fy) - 90px);
  width: 180px;
  height: 180px;
  transform-origin: 50% 50%;
  transition: transform var(--travel) var(--curve);
  z-index: 5;
}
.orbwrap.travel { will-change: transform; }
.orbwrap.instant { transition: none; }

.halo {
  position: absolute;
  inset: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(159, 216, 223, 0.22), rgba(159, 216, 223, 0) 62%);
  opacity: 0;
  transition: opacity 700ms ease;
  pointer-events: none;
}
.app.forward .halo { opacity: 1; }

/* Arc: only while the server checks the passkey (2 px, one turn per 1.2 s). */
.arc {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(159, 216, 223, 0.75);
  border-right-color: rgba(159, 216, 223, 0.18);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}
.app.checking .arc { opacity: 1; animation: spin 1.2s linear infinite; }

/* CSS orb: the fallback when the canvas renderer can't run. */
.orb {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: none; /* the orb owns its gestures: no scroll, zoom or pull */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  background:
    radial-gradient(circle at 35% 27%, rgba(219, 229, 238, 0.5), rgba(219, 229, 238, 0) 21%),
    radial-gradient(circle at 52% 62%, rgba(159, 216, 223, 0.45), rgba(159, 216, 223, 0.06) 46%, rgba(159, 216, 223, 0) 64%),
    radial-gradient(circle at 40% 32%, #1e3449 0%, #0c1621 58%, #05080c 100%);
  box-shadow: inset -14px -18px 42px rgba(0, 0, 0, 0.55), 0 0 60px rgba(159, 216, 223, 0.12);
}
.orb.sable-orb-rendered { background: transparent; box-shadow: none; }
.orb:focus-visible { outline: 3px solid var(--cyan); outline-offset: 10px; }
.orb[inert] { cursor: default; }

/* ---- Home: the greeting beneath the centred orb -------------------- */
.greet {
  position: absolute;
  left: 24px;
  right: 24px;
  top: calc(var(--cy) + 72px + 30px);
  margin: 0;
  text-align: center;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.015em;
  text-wrap: balance;
  opacity: 0;
  visibility: hidden;
  transition: opacity 400ms ease, visibility 0s linear 400ms;
}
.greet:focus { outline: none; }
.app.at-home .greet {
  opacity: 1;
  visibility: visible;
  transition: opacity 700ms ease 260ms, visibility 0s;
}
.app.at-home.forward .greet { opacity: 0.18; transition: opacity 520ms var(--curve); }

/* ---- What forms beneath the forward orb --------------------------- */
.form {
  position: absolute;
  left: 36px;
  right: 36px;
  top: calc(var(--fy) + 110px);
  text-align: center;
}
.form h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.form h2:focus { outline: none; }
.form p {
  margin: 8px auto 0;
  max-width: 300px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--quiet);
  text-wrap: balance;
}
.hint {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 92px;
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
  color: var(--cyan);
}
.hint.pulse { animation: pulse 420ms ease; }
.quiet {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  font-size: 15px;
}
.quiet span { color: var(--text); opacity: 0.6; padding: 0 8px; }
.quiet button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  opacity: 0.6;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.quiet button:active { opacity: 1; }
.quiet button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; opacity: 1; }

.form, .hint, .quiet { opacity: 0; transition: opacity 200ms ease; }
.form.in { animation: rise 520ms var(--curve) var(--delay, 260ms) both; }
.hint.in, .quiet.in { animation: fade 400ms ease var(--delay2, 520ms) both; }
.form.in, .hint.in, .quiet.in { opacity: 1; }

.app.arriving .orb { animation: arrive 900ms var(--curve) both; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes arrive { from { opacity: 0; filter: blur(8px); } to { opacity: 1; filter: blur(0); } }
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 45% { opacity: 0.35; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Reduced motion: no travel or spin; the orb changes place, the rest cross-fades. */
@media (prefers-reduced-motion: reduce) {
  .app .orbwrap, .app .arc { transition: none; animation: none; }
  .app .form.in, .app .hint.in, .app .quiet.in { animation: fade 300ms ease both; }
  .app.arriving .orb, .app .hint.pulse { animation: none; }
}

@media (forced-colors: active) {
  .orb { border: 2px solid ButtonText; }
}

/* The keyboard action is visible when focused; touch keeps the quiet orb UI. */
.sr-only:focus-visible { position: relative; width: auto; height: auto; margin: 12px 0; clip-path: none; overflow: visible; padding: 10px 14px; min-height: 44px; background: #000; border: 1px solid var(--cyan); }
.greet[inert] { pointer-events: none; }
/* Compact landscape/large text: let messages scroll inside the safe area. */
@media (max-height: 600px) {
  .form { top: calc(var(--fy) + 100px); }
  .hint { bottom: 72px; }
}

@media (max-height: 500px) {
  .app { overflow-y: auto; }
  .stage {
    position: relative; inset: auto;
    margin: var(--sat) var(--sar) var(--sab) var(--sal);
    height: calc(100dvh - var(--sat) - var(--sab));
    min-height: 568px;
  }
}
