/* ── Starosphere flow-UI skin — star-editorial v1 (DESIGN-LOCK-V1, W-D0) ───────
 * The stranger's-first-60s surfaces: sign-in · onboarding · empty-state · OS
 * picker · custom-app composer. GOVERNING IDEA: a warm printed almanac made
 * operational — bond-cream plaza ground, press-umber ink, ONE cadmium act per
 * surface, elevation drawn as an ENGRAVED HAIRLINE (a 1px printed rule + faint
 * warm cast), never a drop shadow. Editorial calm, not console dark.
 *
 * IDENTITY SOURCE OF TRUTH: packages/theme/src/design/languages/star-editorial.ts
 * (operator-ratified 2026-07-07). Every value below mirrors that language verbatim:
 *   • surface ramp  ground #F5EEDD → card #EFE7D3 → raised #FBF5E6 → sunk #E4D8BC
 *   • ink           #2C2118 / #5A4A38 / faint umber (never #000)
 *   • the ONE act   cadmium #DD5A2A (<40% area), deep #B8461E on press
 *   • engraved line #CBB799 rest / #B9A886 strong
 *   • ZERO-RADIUS   v3 ratified 2026-07-07 — sharp, carved-block corners
 *                   (architectural instrument precision, not soft app-chrome)
 *   • VOICE         Space Grotesk UI + IBM Plex Mono data; serif display awaits
 *                   Fraunces self-hosting (Georgia fallback — matches the live
 *                   chrome, which is NOT yet self-hosting either)
 *   • MOTION        Cold Press Settle — calm easeOut, printed, confident
 *
 * SCOPING: the star-editorial `--star-*` values are declared on `.sph` (NOT global
 * :root) so these overlays carry the ratified identity WITHOUT reskinning the
 * booted OS underneath. Provenance mirror: src/starosphere-tokens.css.
 * Law: NO Inter · NO purple/blue AI gradient · NO pure black · NO glassmorphism.
 * GPU-safe motion only (transform/opacity). Every control: hover/active/focus.
 * ──────────────────────────────────────────────────────────────────────────── */

.sph {
  /* — Surface ramp (bond-cream editorial ground → card → raised → sunk) — */
  --star-paper:        #F5EEDD;  /* page ground — the world's light (never #fff) */
  --star-paper-2:      #EFE7D3;  /* travertine card body / surface */
  --star-paper-raised: #FBF5E6;  /* raised cards, modals, controls — warm paper lift */
  --star-paper-3:      #E4D8BC;  /* data wells / inputs — sunk panel */
  /* — Ink (press-umber, never #000) — */
  --star-ink:          #2C2118;
  --star-ink-soft:     #5A4A38;
  --star-ink-faint:    #8A785E;
  /* — Engraved hairlines — */
  --star-line:         #CBB799;  /* resting engraved rule */
  --star-line-strong:  #B9A886;  /* stronger frame edge */
  /* — The ONE cadmium act — */
  --star-cadmium:      #DD5A2A;
  --star-cadmium-ink:  #FBF3E6;
  --star-cadmium-deep: #B8461E;
  --star-stamp:        #A62A1D;  /* stamp red — destructive only */
  /* — Almanac craft duo (muted, never a second saturated shout) — */
  --star-teal:         #2E6E68;
  --star-teal-soft:    #6FA39C;
  --star-rust:         #9A5330;
  --star-seaglass:     #9FBDAF;
  --star-warn:         #C98A2E;
  /* — Type (voice) — */
  --star-font-display: "Fraunces", "Spectral", Georgia, "Times New Roman", serif;
  --star-font-ui:      "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --star-font-mono:    "IBM Plex Mono", "Cascadia Code", ui-monospace, "SF Mono", Menlo, monospace;
  --star-size-hero:    clamp(2.2rem, 4.4vw, 3.4rem);
  --star-size-h2:      clamp(1.4rem, 2.4vw, 1.9rem);
  --star-size-lede:    clamp(1.02rem, 1.4vw, 1.22rem);
  /* — ZERO-RADIUS: sharp carved-block corners (v3 ratified 2026-07-07) — */
  --star-radius:       0px;
  --star-radius-lg:    0px;
  /* — Elevation: engraved LINE + faint warm press-umber cast (NOT a drop shadow) — */
  --star-lift:         0 1px 0 rgba(185, 168, 134, 0.7), 0 8px 24px rgba(44, 33, 24, 0.10);
  --star-lift-modal:   0 1px 0 rgba(185, 168, 134, 0.85), 0 24px 56px rgba(44, 33, 24, 0.16);
  /* — Motion: Cold Press Settle — */
  --star-ease:         cubic-bezier(0.22, 0.61, 0.36, 1);
  --star-dur:          180ms;

  font-family: var(--star-font-ui);
  color: var(--star-ink);
}

/* Almanac diamond-dither — a motif accent (dialog headers). NEVER a smooth AI
 * gradient: a repeating cadmium-on-paper hatch, low opacity. */
.sph-dither {
  background-image:
    repeating-linear-gradient(45deg,  color-mix(in oklab, var(--star-cadmium) 20%, transparent) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, color-mix(in oklab, var(--star-cadmium) 20%, transparent) 0 1px, transparent 1px 6px);
  background-size: 8px 8px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.sph-cta {
  font: 700 1rem var(--star-font-ui);
  color: var(--star-cadmium-ink);
  background: var(--star-cadmium);
  border: 1px solid var(--star-cadmium-deep);
  border-radius: var(--star-radius);
  padding: 11px 22px;
  cursor: pointer;
  transition: transform var(--star-dur) var(--star-ease), background var(--star-dur) var(--star-ease);
}
.sph-cta:hover  { transform: translateY(-1px); background: var(--star-cadmium-deep); }
.sph-cta:active { transform: translateY(0); }
.sph-cta:focus-visible { outline: 2px solid var(--star-ink); outline-offset: 2px; }
.sph-cta:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.sph-ghost {
  font: 600 1rem var(--star-font-ui);
  color: var(--star-ink);
  background: transparent;
  border: 1px solid var(--star-line-strong);
  border-radius: var(--star-radius);
  padding: 11px 20px;
  cursor: pointer;
  transition: transform var(--star-dur) var(--star-ease), border-color var(--star-dur) var(--star-ease);
}
.sph-ghost:hover  { transform: translateY(-1px); border-color: var(--star-ink); }
.sph-ghost:active { transform: translateY(0); }
.sph-ghost:focus-visible { outline: 2px solid var(--star-ink); outline-offset: 2px; }
.sph-ghost:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Account pill (top-right, seated BELOW the OS menu bar) ────────────────── */
.sph-pill {
  position: fixed;
  /* top-RIGHT, below the OS menu bar (matches this block's stated intent + the
     dock's flex-end) — was left:12px, which collided with the top-left window
     cascade origin (boot Agent titlebar). */
  top: 44px; right: 12px; left: auto;
  z-index: 6000;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--star-paper-2);
  border: 1px solid var(--star-line);
  border-radius: 0;
  box-shadow: var(--star-lift);
  font-size: 0.82rem; color: var(--star-ink-soft);
  max-width: min(46vw, 360px);
}
.sph-pill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--star-teal); flex: 0 0 auto; }
.sph-pill__email { font-weight: 600; color: var(--star-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sph-pill__btn {
  font: 600 0.8rem var(--star-font-ui);
  color: var(--star-ink); background: var(--star-paper);
  border: 1px solid var(--star-line); border-radius: 0;
  padding: 5px 12px; cursor: pointer;
  transition: transform var(--star-dur) var(--star-ease), border-color var(--star-dur) var(--star-ease);
}
.sph-pill__btn:hover { transform: translateY(-1px); border-color: var(--star-ink); }
.sph-pill__btn:active { transform: translateY(0); }
.sph-pill__btn:focus-visible { outline: 2px solid var(--star-ink); outline-offset: 2px; }
.sph-pill__btn--accent { color: var(--star-cadmium-ink); background: var(--star-cadmium); border-color: var(--star-cadmium-deep); }
.sph-pill__btn--accent:hover { background: var(--star-cadmium-deep); }

/* ── Action dock (top-right, stacked under the account pill) ───────────────── */
.sph-dock {
  position: fixed; top: 92px; right: 12px; left: auto; z-index: 6000;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}

/* ── Scrim + dialog ───────────────────────────────────────────────────────── */
.sph-scrim {
  position: fixed; inset: 0; z-index: 1000000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: color-mix(in oklab, var(--star-ink) 40%, transparent);
  animation: sph-fade var(--star-dur) var(--star-ease);
}
@keyframes sph-fade { from { opacity: 0; } to { opacity: 1; } }

.sph-dialog {
  width: 100%;
  background: var(--star-paper-raised);
  border: 1px solid var(--star-line-strong);
  border-radius: var(--star-radius-lg);
  box-shadow: var(--star-lift-modal);
  overflow: hidden;
  animation: sph-rise var(--star-dur) var(--star-ease);
}
@keyframes sph-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.sph-dialog--sm { max-width: 440px; }
.sph-dialog--md { max-width: 560px; }
.sph-dialog--lg { max-width: 860px; }

.sph-dialog__head {
  position: relative;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--star-line);
}
.sph-dialog__head::after {
  content: ""; position: absolute; inset: 0; opacity: 0.5; pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg,  color-mix(in oklab, var(--star-cadmium) 16%, transparent) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, color-mix(in oklab, var(--star-cadmium) 16%, transparent) 0 1px, transparent 1px 7px);
  background-size: 9px 9px;
  -webkit-mask-image: linear-gradient(to right, #000, transparent 62%);
          mask-image: linear-gradient(to right, #000, transparent 62%);
}
.sph-dialog__eyebrow {
  font: 700 0.7rem var(--star-font-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--star-teal); margin: 0 0 6px;
}
.sph-dialog__title {
  font: 600 var(--star-size-h2)/1.08 var(--star-font-display);
  letter-spacing: -0.01em; color: var(--star-ink); margin: 0;
}
.sph-dialog__sub { margin: 6px 0 0; color: var(--star-ink-soft); font-size: 0.92rem; max-width: 46ch; }
.sph-dialog__x {
  position: relative; z-index: 1;
  flex: 0 0 auto;
  width: 32px; height: 32px; line-height: 1;
  font-size: 1.1rem; color: var(--star-ink-soft);
  background: var(--star-paper-2); border: 1px solid var(--star-line);
  border-radius: 0; cursor: pointer;
  transition: transform var(--star-dur) var(--star-ease), border-color var(--star-dur) var(--star-ease);
}
.sph-dialog__x:hover { transform: translateY(-1px); border-color: var(--star-ink); }
.sph-dialog__x:focus-visible { outline: 2px solid var(--star-ink); outline-offset: 2px; }
.sph-dialog__body { padding: 22px 24px; }
.sph-dialog__foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 16px 24px 20px; border-top: 1px solid var(--star-line);
  background: var(--star-paper-2);
}
.sph-dialog__foot--split { justify-content: space-between; }

/* ── Field ────────────────────────────────────────────────────────────────── */
.sph-field { display: flex; flex-direction: column; gap: 7px; }
.sph-label { font: 600 0.82rem var(--star-font-ui); color: var(--star-ink-soft); }
.sph-input, .sph-textarea {
  font: 400 1rem var(--star-font-ui);
  color: var(--star-ink); background: var(--star-paper-3);
  border: 1px solid var(--star-line-strong); border-radius: var(--star-radius);
  padding: 11px 13px; width: 100%; box-sizing: border-box;
  transition: border-color var(--star-dur) var(--star-ease), box-shadow var(--star-dur) var(--star-ease);
}
.sph-input::placeholder, .sph-textarea::placeholder { color: var(--star-ink-faint); }
.sph-input:hover, .sph-textarea:hover { border-color: var(--star-ink-faint); }
.sph-input:focus-visible, .sph-textarea:focus-visible {
  outline: none; border-color: var(--star-cadmium);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--star-cadmium) 22%, transparent);
}
.sph-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

/* honest status line */
.sph-note {
  margin: 14px 0 0; padding: 12px 14px;
  border: 1px solid var(--star-line); border-left: 3px solid var(--star-teal);
  border-radius: var(--star-radius); background: var(--star-paper-2);
  color: var(--star-ink-soft); font-size: 0.9rem; line-height: 1.5;
}
.sph-note code { font-family: var(--star-font-mono); color: var(--star-ink); font-size: 0.85em; }
.sph-note--warn { border-left-color: var(--star-warn); }
.sph-note--err  { border-left-color: var(--star-stamp); color: var(--star-stamp); }

/* ── Onboarding (calm 3 beats) ────────────────────────────────────────────── */
.sph-onb {
  position: fixed; inset: 0; z-index: 1000100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  background: var(--star-paper);
  animation: sph-fade 240ms var(--star-ease);
}
.sph-onb__inner { max-width: 540px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.sph-onb__mark { position: relative; width: 84px; height: 84px; }
.sph-onb__mark svg { display: block; width: 100%; height: 100%; }
.sph-onb__beat { animation: sph-rise 320ms var(--star-ease); }
.sph-onb__eyebrow {
  font: 700 0.72rem var(--star-font-mono); letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--star-teal); margin: 0 0 12px;
}
.sph-onb__title {
  font: 600 var(--star-size-hero)/1.05 var(--star-font-display);
  letter-spacing: -0.015em; color: var(--star-ink); margin: 0;
}
.sph-onb__body { margin: 14px 0 0; color: var(--star-ink-soft); font-size: var(--star-size-lede); line-height: 1.55; max-width: 40ch; }
.sph-onb__dots { display: flex; gap: 8px; margin-top: 6px; }
/* carved square progress ticks (zero-radius identity) */
.sph-onb__dot { width: 8px; height: 8px; border-radius: 0; background: var(--star-line-strong); transition: background var(--star-dur) var(--star-ease), transform var(--star-dur) var(--star-ease); }
.sph-onb__dot[data-on="true"] { background: var(--star-cadmium); transform: scale(1.35); }
.sph-onb__actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.sph-onb__skip {
  font: 600 0.86rem var(--star-font-ui); color: var(--star-ink-faint);
  background: transparent; border: none; cursor: pointer; padding: 8px 6px;
  text-decoration: underline; text-underline-offset: 3px;
}
.sph-onb__skip:hover { color: var(--star-ink); }
.sph-onb__skip:focus-visible { outline: 2px solid var(--star-ink); outline-offset: 2px; border-radius: 0; }

/* ── Empty state (warm plaza) ─────────────────────────────────────────────── */
.sph-empty {
  position: fixed; z-index: 5200;
  left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: min(88vw, 460px);
  padding: 30px 30px 28px; text-align: center;
  background: var(--star-paper-raised);
  border: 1px solid var(--star-line-strong); border-radius: var(--star-radius-lg);
  box-shadow: var(--star-lift-modal);
  animation: sph-rise 260ms var(--star-ease);
}
.sph-empty__mark { width: 72px; height: 72px; margin: 0 auto 16px; }
.sph-empty__title { font: 600 var(--star-size-h2)/1.1 var(--star-font-display); letter-spacing: -0.01em; margin: 0; color: var(--star-ink); }
.sph-empty__body { margin: 10px auto 22px; color: var(--star-ink-soft); font-size: 0.98rem; line-height: 1.5; max-width: 34ch; }

/* ── OS picker (Almanac grid) ─────────────────────────────────────────────── */
.sph-picker__meta {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 0.86rem; color: var(--star-ink-soft);
}
.sph-picker__count { font-family: var(--star-font-mono); font-weight: 700; color: var(--star-ink); }
.sph-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px; max-height: 52vh; overflow-y: auto; padding: 2px;
}
.sph-appcard {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 12px; text-align: left;
  background: var(--star-paper-2);
  border: 1px solid var(--star-line); border-radius: var(--star-radius);
  cursor: pointer; width: 100%;
  transition: transform var(--star-dur) var(--star-ease), border-color var(--star-dur) var(--star-ease);
}
.sph-appcard:hover { transform: translateY(-1px); border-color: var(--star-ink-faint); }
.sph-appcard:active { transform: translateY(0); }
.sph-appcard:focus-visible { outline: 2px solid var(--star-ink); outline-offset: 2px; }
.sph-appcard[data-on="true"] { border-color: var(--star-teal); background: color-mix(in oklab, var(--star-teal) 8%, var(--star-paper-2)); }
.sph-appcard__icon {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--star-paper); border: 1px solid var(--star-line); border-radius: 0;
  overflow: hidden;
}
.sph-appcard__icon svg, .sph-appcard__icon img { width: 26px; height: 26px; image-rendering: crisp-edges; }
.sph-appcard__text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sph-appcard__name { font-weight: 600; font-size: 0.92rem; color: var(--star-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sph-appcard__cat { font: 500 0.72rem var(--star-font-mono); letter-spacing: 0.04em; color: var(--star-ink-faint); text-transform: uppercase; }
.sph-appcard__tick {
  margin-left: auto; flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 0;
  display: grid; place-items: center;
  border: 1px solid var(--star-line); background: var(--star-paper); color: transparent;
  font-size: 0.8rem; font-weight: 700;
  transition: background var(--star-dur) var(--star-ease), color var(--star-dur) var(--star-ease);
}
.sph-appcard[data-on="true"] .sph-appcard__tick { background: var(--star-teal); border-color: var(--star-teal); color: var(--star-cadmium-ink); }

/* ── Composer result ──────────────────────────────────────────────────────── */
.sph-result {
  margin-top: 16px; padding: 16px; border: 1px solid var(--star-line);
  border-radius: var(--star-radius); background: var(--star-paper-2);
  animation: sph-rise var(--star-dur) var(--star-ease);
}
.sph-result__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sph-result__title { font: 600 1.05rem var(--star-font-display); color: var(--star-ink); margin: 0; }
.sph-badge {
  font: 700 0.68rem var(--star-font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 0; white-space: nowrap;
}
.sph-badge--live { color: var(--star-teal); background: color-mix(in oklab, var(--star-teal) 14%, var(--star-paper)); border: 1px solid var(--star-teal-soft); }
.sph-badge--tmpl { color: var(--star-rust); background: color-mix(in oklab, var(--star-rust) 12%, var(--star-paper)); border: 1px solid var(--star-rust); }
.sph-result__hint { margin: 10px 0 14px; color: var(--star-ink-soft); font-size: 0.88rem; line-height: 1.5; }
.sph-result__id { font-family: var(--star-font-mono); font-size: 0.82em; color: var(--star-ink-faint); }

/* Spinner (GPU-safe rotate on transform). */
.sph-spin {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
  border: 2px solid color-mix(in oklab, var(--star-cadmium-ink) 45%, transparent);
  border-top-color: var(--star-cadmium-ink); border-radius: 50%;
  animation: sph-rotate 0.7s linear infinite;
}
.sph-spin--ink { border-color: color-mix(in oklab, var(--star-ink) 30%, transparent); border-top-color: var(--star-ink); }
@keyframes sph-rotate { to { transform: rotate(360deg); } }

/* The sphere mark is static at idle; live motion belongs to explicit loading states. */
.sph-sphere-spin { transform-box: fill-box; transform-origin: center; }

@media (max-width: 560px) {
  .sph-pill { top: 40px; right: 10px; left: 10px; max-width: none; justify-content: flex-end; }
  .sph-dock { top: 84px; left: 10px; }
  .sph-dialog__foot--split { flex-direction: column; align-items: stretch; gap: 10px; }
  .sph-grid { grid-template-columns: 1fr; max-height: 48vh; }
}

@media (prefers-reduced-motion: reduce) {
  .sph *, .sph-scrim, .sph-dialog, .sph-onb, .sph-empty, .sph-result, .sph-onb__beat { animation: none !important; }
  .sph-cta, .sph-ghost, .sph-appcard, .sph-pill__btn, .sph-dialog__x { transition: none; }
  .sph-cta:hover, .sph-ghost:hover, .sph-appcard:hover, .sph-pill__btn:hover, .sph-dialog__x:hover { transform: none; }
  .sph-spin, .sph-sphere-spin { animation: none; }
}
