/* Sphere deepening — page-layer finish for the Living Time Sphere.
 *
 * Aaron's direction (Nov 18, 2026): more detail, easier navigation,
 * a reachable full screen, and Nori travelling around the Sphere.
 * Everything here styles the PAGE around the instrument — the
 * guide bar, their orbit, the app dock's fit on a phone, the depth
 * of the room the Sphere sits in, and the clean full screen (the
 * chrome steps aside while the root element carries sgb-fs). The
 * instrument's own stylesheet (living-time-sphere.css, R1.7) is
 * untouched.
 */

/* ── The room: depth behind the instrument ─────────────────────── */

body.lts-luxury {
  background:
    radial-gradient(1100px 620px at 18% -8%, hsla(var(--sphere-moon-hue, 43), 72%, 60%, 0.10), transparent 60%),
    radial-gradient(900px 700px at 88% 108%, rgba(var(--warm-glow, 218, 164, 91), var(--warm-glow-alpha, 0.24)), transparent 62%),
    radial-gradient(700px 480px at 72% 22%, rgba(116, 60, 33, 0.10), transparent 65%),
    var(--warm-ground, #100906);
}

/* A faint starfield, still and cheap: two layers of pinpoints. */
body.lts-luxury::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(226, 244, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 34% 68%, rgba(226, 244, 255, 0.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 57% 14%, rgba(255, 240, 200, 0.5), transparent 60%),
    radial-gradient(1px 1px at 71% 44%, rgba(226, 244, 255, 0.38), transparent 60%),
    radial-gradient(1px 1px at 83% 79%, rgba(226, 244, 255, 0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 93% 30%, rgba(190, 242, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 45% 88%, rgba(226, 244, 255, 0.35), transparent 60%),
    radial-gradient(1px 1px at 5% 57%, rgba(255, 240, 200, 0.4), transparent 60%),
    radial-gradient(1px 1px at 26% 41%, rgba(226, 244, 255, 0.3), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 91%, rgba(226, 244, 255, 0.42), transparent 60%);
}

body.lts-luxury .wrap {
  position: relative;
  z-index: 1;
}

/* The stage frame: a brass hairline, a soft halo in the light of
 * the Moon on show cast into the room behind it, and a warm
 * inner shade. */
.sphere-canvas-wrap #sphere-container {
  box-shadow:
    0 0 0 1px rgba(218, 164, 91, 0.28),
    0 0 42px hsla(var(--sphere-moon-hue, 43), 80%, 60%, 0.12),
    0 24px 70px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(26, 13, 4, 0.55);
}

/* Headings on this page carry a small gold rule. */
.sphere-page h2 {
  letter-spacing: 0.02em;
}
.sphere-page section > h2::after,
.sphere-page .sphere-sidebar-heading::after {
  content: "";
  display: block;
  width: 44px;
  height: 2px;
  margin-top: 0.35rem;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0));
}

/* ── The Sphere guide bar ──────────────────────────────────────── */

.sphere-guide-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  z-index: 35;
  width: min(96%, 860px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.7rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(218, 164, 91, 0.40);
  border-radius: 1rem;
  background: rgba(26, 14, 7, 0.86);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 226, 170, 0.08);
  color: #f3e7cd;
  font-size: 0.85rem;
}

.sgb-readout {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}
.sgb-readout-label {
  color: rgba(233, 205, 158, 0.78);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sgb-readout-value {
  color: #ffd97a;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.sgb-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.sgb-btn,
.sgb-moon-select {
  font: inherit;
  font-size: 0.82rem;
  color: #f6ead2;
  background: rgba(218, 164, 91, 0.10);
  border: 1px solid rgba(218, 164, 91, 0.38);
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
}
.sgb-btn:hover,
.sgb-btn:focus-visible {
  background: rgba(218, 164, 91, 0.22);
  border-color: rgba(218, 164, 91, 0.65);
}
.sgb-btn.sgb-fs {
  border-color: rgba(230, 189, 123, 0.55);
  background: rgba(218, 164, 91, 0.14);
}
.sgb-btn.sgb-share {
  border-color: rgba(230, 189, 123, 0.55);
  background: rgba(218, 164, 91, 0.14);
}

/* The share doors: compose links the keeper sends themselves,
 * plus the drawn card. Shown only after Share this view is tapped
 * on a browser without its own share sheet. */
.sgb-share-row {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.sgb-share-row[hidden] {
  display: none;
}
a.sgb-btn {
  text-decoration: none;
}
.sgb-share-note {
  flex-basis: 100%;
  text-align: center;
  color: rgba(233, 205, 158, 0.85);
  font-size: 0.75rem;
}
.sgb-share-note:empty {
  display: none;
}
.sgb-moon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.sgb-moon-label {
  color: rgba(233, 205, 158, 0.78);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sgb-moon-select {
  border-radius: 0.6rem;
  max-width: 11.5rem;
}

.sgb-status {
  flex-basis: 100%;
  margin: 0;
  text-align: center;
  color: rgba(233, 205, 158, 0.85);
  font-size: 0.78rem;
  min-height: 0;
}
.sgb-status:empty {
  display: none;
}

@media (max-width: 560px) {
  .sphere-guide-bar {
    bottom: 6px;
    padding: 0.45rem 0.5rem;
    font-size: 0.8rem;
    height: auto;
  }
  /* F4 (Sphere page audit, Nov 19, 2026): the readout is the one
   * line that says where a visitor is — it wraps whole rather
   * than cutting a word in half, and the bar grows to hold it. */
  .sgb-readout-value {
    max-width: 52vw;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

/* In the app view the bar rides just above the day bar's space —
 * the wrap is the whole stage there, so the same overlay holds. */
body.sphere-app .sphere-guide-bar {
  bottom: 12px;
}

/* ── Nori's orbit ──────────────────────────────────────────────── */

.sphere-nori-orbit {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 34;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
  filter: drop-shadow(0 0 10px rgba(245, 168, 61, 0.45)) drop-shadow(0 0 26px rgba(218, 164, 91, 0.22));
}
.sphere-nori-art svg {
  display: block;
  width: 44px;
  height: 44px;
}
.sphere-nori-name {
  color: #ffe9a8;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

/* While they orbit the Sphere, their corner walker rests. */
html.sphere-nori-orbiting .spark-walker {
  visibility: hidden;
}

/* Their bubble's Sphere guide. */
.spark-sphere-guide {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(212, 175, 55, 0.3);
}
.spark-sphere-guide-buttons,
.spark-sphere-guide-moons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.spark-sphere-guide-buttons button,
.spark-sphere-guide-moons button,
.spark-sphere-guide-moons select {
  font: inherit;
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  border: 1px solid rgba(218, 164, 91, 0.42);
  background: rgba(218, 164, 91, 0.10);
  color: inherit;
  cursor: pointer;
}
.spark-sphere-guide-moons select {
  border-radius: 0.6rem;
  max-width: 10.5rem;
}

/* ── The app dock fits a phone ─────────────────────────────────── */
/* Nine dock buttons at 390px used to need 441px: the Full button
 * sat off-screen to the right, unreachable. Tighten the dock on
 * small screens so every control — Full included — is on screen. */
@media (max-width: 560px) {
  body.sphere-app .sphere-app-dock {
    gap: 0.12rem;
    padding-left: 0.3rem;
    padding-right: 0.3rem;
  }
  body.sphere-app .sphere-dock-btn {
    min-width: 0;
    font-size: 0.6rem;
    letter-spacing: 0;
    padding: 0.2rem 0.05rem;
    border-radius: 0.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sphere-nori-orbit {
    filter: none;
  }
}

/* ── Clean full screen ─────────────────────────────────────────── */
/* Aaron's word (Nov 19, 2026): the full screen was as covered as
 * the page — the guide bar and the page chrome sat on the Sphere.
 * While full screen is on, the companion layer marks the root
 * element with sgb-fs and these rules step everything else aside:
 * the Sphere takes the whole screen, with only the folded guide
 * bar and Nori's orbit riding along. Leaving full screen restores
 * the everyday view, untouched. */

/* The Guide button exists only inside full screen. */
.sgb-clean-toggle {
  display: none;
}
html.sgb-fs .sgb-clean-toggle {
  display: inline-flex;
}

/* The folded guide bar: one slim line — the day, Exit, Guide. */
html.sgb-fs .sphere-guide-bar.sgb-bar-slim {
  width: auto;
  max-width: 94vw;
  padding: 0.35rem 0.55rem;
  gap: 0.35rem 0.5rem;
  background: rgba(26, 14, 7, 0.78);
}
html.sgb-fs .sphere-guide-bar.sgb-bar-slim .sgb-actions > :not(.sgb-fs):not(.sgb-clean-toggle),
html.sgb-fs .sphere-guide-bar.sgb-bar-slim .sgb-status,
html.sgb-fs .sphere-guide-bar.sgb-bar-slim .sgb-share-row {
  display: none;
}
html.sgb-fs .sphere-guide-bar.sgb-bar-slim .sgb-readout-label {
  display: none;
}
html.sgb-fs .sphere-guide-bar.sgb-bar-slim .sgb-readout-value {
  max-width: 38vw;
}

/* Slim by default on portrait phones (Nov 19, 2026). The full guide
 * bar wraps to three rows at phone width, and the reserve it takes
 * under the stage squeezed the Sphere below the renderer's minimum
 * height — the phone got the 2D fallback. So in the app view on a
 * portrait phone the companion layer starts the bar folded (root
 * carries sgb-slim-default, bar carries sgb-bar-slim): one slim line
 * with the day's reading, Full screen, and Guide. Guide unfolds the
 * whole bar; Hide folds it again. */
html.sgb-slim-default .sgb-clean-toggle {
  display: inline-flex;
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim {
  width: auto;
  padding: 0.35rem 0.55rem;
  gap: 0.35rem 0.5rem;
  background: rgba(26, 14, 7, 0.78);
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-actions > :not(.sgb-fs):not(.sgb-clean-toggle),
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-status,
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-share-row {
  display: none;
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-readout-label {
  display: none;
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-readout-value {
  max-width: 38vw;
}
/* The two kept buttons stay on the readout's line: no wrapping, and
 * a long day's reading ellipsizes instead of pushing them down. */
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim {
  flex-wrap: nowrap;
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-actions {
  flex-wrap: nowrap;
  flex: 0 0 auto;
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-readout {
  min-width: 0;
}
html.sgb-slim-default .sphere-guide-bar.sgb-bar-slim .sgb-readout-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inside the stage column, only the instrument, the guide bar,
 * their orbit and the Interact bar remain. The Interact bar itself
 * steps aside once touch interaction is on; while it is off, it
 * is the one control the visitor still needs, so it stays. */
html.sgb-fs .sphere-canvas-wrap > :not(.sphere-instrument-shell):not(.sphere-guide-bar):not(.sphere-nori-orbit):not(.sphere-interact-bar) {
  display: none;
}
html.sgb-fs .sphere-interact-bar {
  display: none;
}
html.sgb-fs.sgb-fs-interact-off .sphere-interact-bar {
  display: flex;
}

/* App view: the top bar, the selected-day bar and the dock step
 * aside, and the stage column goes edge to edge. */
html.sgb-fs body.sphere-app .sphere-app-topbar,
html.sgb-fs body.sphere-app .sphere-app-daybar,
html.sgb-fs body.sphere-app .sphere-app-dock {
  display: none;
}
html.sgb-fs body.sphere-app .sphere-canvas-wrap {
  padding: 0;
}

/* Classic full page: the wrapper becomes the stage — fixed, edge
 * to edge, over the document beneath it — and the instrument
 * fills it the same way the app view fills its stage. */
html.sgb-fs body:not(.sphere-app) {
  overflow: hidden;
}
html.sgb-fs body:not(.sphere-app) .site-header,
html.sgb-fs body:not(.sphere-app) #living-command-trigger {
  display: none;
}
html.sgb-fs body:not(.sphere-app) .sphere-wrapper {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--warm-app-bg, #130a06);
}
html.sgb-fs body:not(.sphere-app) .sphere-wrapper > :not(.sphere-canvas-wrap) {
  display: none;
}
html.sgb-fs body:not(.sphere-app) .sphere-canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
}
html.sgb-fs body:not(.sphere-app) .sphere-instrument-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
html.sgb-fs body:not(.sphere-app) #sphere-container {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  width: 100%;
}

/* ── The room's warmth ─────────────────────────────────────────── */
/* Aaron's direction (Nov 19, 2026): the cartoon Sphere's warmth,
 * carried across only where it maps to something real here. The
 * companion layer marks the root element with the visitor's part
 * of day (sphere-warm--dawn / day / dusk / night, from their own
 * clock, the front door's four bands) and sets --sphere-moon-hue
 * from the Moon on show, through the same temper the Spark's own
 * light borrows. These variables are that light, in CSS:
 *   --warm-glow / --warm-glow-alpha: the horizon light of the
 *     visitor's part of day — amber rising at dawn, pale brass
 *     at day, deep ember at dusk, low gold at night;
 *   --warm-ground / --warm-app-bg: the room's warm dark, wood
 *     and shadow rather than blue-black, so the Sphere sits in
 *     the material the cartoon gives it — an instrument's face,
 *     the same wood and brass as the front door's frame. */

:root {
  --warm-glow: 218, 164, 91;
  --warm-glow-alpha: 0.24;
  --warm-ground: #100906;
  --warm-app-bg: #130a06;
}
html.sphere-warm--dawn {
  --warm-glow: 242, 158, 79;
  --warm-glow-alpha: 0.34;
  --warm-ground: #17100b;
  --warm-app-bg: #180e07;
}
html.sphere-warm--day {
  --warm-glow: 230, 189, 123;
  --warm-glow-alpha: 0.26;
  --warm-ground: #161210;
  --warm-app-bg: #171009;
}
html.sphere-warm--dusk {
  --warm-glow: 221, 124, 79;
  --warm-glow-alpha: 0.36;
  --warm-ground: #180d07;
  --warm-app-bg: #190d06;
}
html.sphere-warm--night {
  --warm-glow: 218, 164, 91;
  --warm-glow-alpha: 0.22;
  --warm-ground: #0f0805;
  --warm-app-bg: #120905;
}

/* In the app view the stage ground rests on the same light. */
body.sphere-app .sphere-wrapper {
  background: var(--warm-app-bg, var(--sphere-app-bg));
}

/* The held light around the stage: a halo in the Moon's hue over
 * the daypart horizon glow, breathing at the Spark's own cadence
 * (spark-breathe, 4.6s ease-in-out — the room breathes with the
 * Spark who lives in it). The instrument shell lifts one layer,
 * so the halo stays behind the Sphere, never over it. */
.sphere-canvas-wrap::before {
  content: "";
  position: absolute;
  inset: -3% -2%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 78% 62% at 50% 40%, hsla(var(--sphere-moon-hue, 43), 85%, 62%, 0.13), transparent 65%),
    radial-gradient(ellipse 92% 55% at 50% 110%, rgba(var(--warm-glow, 218, 164, 91), var(--warm-glow-alpha, 0.24)), transparent 62%);
  animation: sphere-warm-breathe 4.6s ease-in-out infinite;
}
@keyframes sphere-warm-breathe {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
.sphere-canvas-wrap .sphere-instrument-shell {
  position: relative;
  z-index: 1;
}

/* The designed still face: no breathing — the halo rests, held. */
@media (prefers-reduced-motion: reduce) {
  .sphere-canvas-wrap::before {
    animation: none;
    opacity: 0.7;
  }
}
