/* profile.css — the traveller's own page (js/profile.js).
   The quiet button lives bottom-left where the demo controls used to sit; the
   page it opens wears the Lexiverse's dark shell and periwinkle glow, but it
   sits still — no sweeping scanline. */

/* ---------- The button (bottom-left) ---------- */

#profile-btn {
  position: fixed;
  bottom: max(3vh, env(safe-area-inset-bottom, 0px) + 14px);
  left: 4vw;
  z-index: 40; /* above the overlays: reachable from the galaxy map and menus, like the portal and counter */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  background: none;
  border: 1px solid rgba(154, 147, 184, 0.35);
  border-radius: 50%;
  color: var(--lavender);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
#profile-btn:hover {
  opacity: 1;
  border-color: rgba(185, 180, 232, 0.9);
  box-shadow: 0 0 16px rgba(140, 135, 220, 0.28);
}
#profile-btn svg { width: 19px; height: 19px; display: block; }
#profile-btn .pf-head,
#profile-btn .pf-body {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

/* ---------- The page ---------- */

#profile {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(11, 10, 31, 0.84);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center;
  padding: 5vh 5vw;
  opacity: 0;
  transition: opacity 0.35s ease;
  cursor: pointer;
}
#profile.show { opacity: 1; }

.pf-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.3em;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  cursor: auto;
  padding: 1.6em 1.7em 1.5em;
  border: 1px solid rgba(150, 148, 220, 0.5);
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(74, 60, 140, 0.18), transparent 60%),
    rgba(16, 14, 40, 0.94);
  box-shadow: 0 0 34px rgba(116, 112, 200, 0.22), inset 0 0 24px rgba(116, 112, 200, 0.07);
}

.pf-close {
  position: absolute;
  top: 1.1em; right: 1.1em;
  z-index: 2;
  background: none;
  border: 1px solid rgba(150, 148, 220, 0.4);
  border-radius: 50%;
  width: 2em; height: 2em;
  color: var(--lavender);
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease;
}
.pf-close:hover { border-color: #B9B4E8; color: var(--cream); }

/* ---------- Header: identity on the left, avatar on the right ---------- */

.pf-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.4em;
}
.pf-id {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  min-width: 0;
  padding-top: 0.1em;
}
.pf-name-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  max-width: 100%;
}
.pf-name {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--cream);
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-name.empty { color: var(--lavender); opacity: 0.6; font-style: italic; }
.pf-name-input {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--gold);
  background: none;
  border: none;
  border-bottom: 1px solid var(--gold);
  padding: 0 0 0.1em;
  outline: none;
  max-width: 12em;
}
.pf-edit {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7em; height: 1.7em;
  padding: 0;
  background: none;
  border: 1px solid rgba(150, 148, 220, 0.3);
  border-radius: 50%;
  color: var(--lavender);
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease;
}
.pf-edit:hover { border-color: var(--gold); color: var(--gold); }
.pf-edit svg { width: 0.95em; height: 0.95em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.pf-email {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--lavender);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-class {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  align-self: flex-start;
  margin-top: 0.15em;
  padding: 0.3em 0.85em;
  border: 1px solid rgba(232, 193, 106, 0.4);
  border-radius: 999px;
  background: rgba(232, 193, 106, 0.06);
}
.pf-class-mark {
  width: 7px; height: 7px;
  transform: rotate(45deg);
  background: var(--gold);
  box-shadow: 0 0 8px rgba(232, 193, 106, 0.7);
}
.pf-class-name {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ---------- Avatar: a Lexi device, tinted ---------- */

.pf-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7em;
  flex-shrink: 0;
  margin-top: 1.6em; /* clear of the close button in the corner */
}
/* Reuses .dv-lexi (the awake, living face). Bigger here, with a soft halo in
   Lexi's chosen color. The eyes and LED follow the global --lexi-eye from
   .dv-eye / .dv-led, so this avatar is exactly the Lexi on the counter. */
.pf-avatar .dv-device {
  box-shadow: 0 0 20px color-mix(in srgb, var(--lexi-eye, #74B0FF) 34%, transparent);
}
.pf-avatar .dv-screen {
  width: 3em;
  height: 2em;
  font-size: 1.5rem;
  background: rgba(20, 17, 46, 0.95);
}
.pf-avatar .dv-eye { box-shadow: 0 0 6px color-mix(in srgb, var(--lexi-eye, #74B0FF) 60%, transparent); }

.pf-swatches {
  display: flex;
  gap: 0.4em;
}
.pf-swatch {
  --sc: #E8C16A;
  width: 16px; height: 16px;
  padding: 0;
  border-radius: 50%;
  background: var(--sc);
  border: 1px solid rgba(11, 10, 31, 0.5);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.pf-swatch:hover { opacity: 0.85; transform: scale(1.12); }
.pf-swatch.active {
  opacity: 1;
  transform: scale(1.12);
  box-shadow: 0 0 0 2px rgba(16, 14, 40, 0.94), 0 0 0 3px var(--sc), 0 0 10px color-mix(in srgb, var(--sc) 60%, transparent);
}

/* ---------- Stats: a small band ---------- */

.pf-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  padding: 0.3em 0.1em;
}
.pf-stat {
  flex: 1 1 0;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45em;
  text-align: center;
}
/* Each number sits on a little scanner screen (the .dv-device look): mint,
   glowing, a scanline sweeping across, exactly like the word count. */
.pf-stat .dv-device { display: flex; width: 100%; }
.pf-stat .dv-screen {
  width: 100%;
  min-width: 0;
  padding: 0.3em 0.4em;
}
.pf-stat-num {
  font-family: var(--sans);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.15;
  /* color and glow inherit from .dv-screen — the same mint as the count */
}
.pf-stat-label {
  font-family: var(--sans);
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  color: var(--lavender);
}

/* ---------- Restoration bar: how much of the universe is at peace ---------- */

.pf-progress {
  display: flex;
  flex-direction: column;
  gap: 0.45em;
}
.pf-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7em;
}
.pf-progress-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--lavender);
  opacity: 0.85;
}
.pf-progress-pct {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(232, 193, 106, 0.3);
}
.pf-progress-track {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: rgba(28, 24, 64, 0.85);
  border: 1px solid rgba(150, 148, 220, 0.3);
  overflow: hidden;
}
.pf-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 70%, #B98A3A), var(--gold));
  box-shadow: 0 0 12px rgba(232, 193, 106, 0.55);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
/* A faint sheen slides along the filled part, the same restrained motion as
   the scanner screens. */
.pf-progress-fill::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 246, 224, 0.5), transparent);
  animation: pf-sheen 3.4s ease-in-out infinite;
}
@keyframes pf-sheen {
  0% { left: -40%; }
  60%, 100% { left: 110%; }
}
.pf-progress-hint {
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.7rem;
  color: var(--lavender);
  opacity: 0.7;
}
@media (prefers-reduced-motion: reduce) {
  .pf-progress-fill::after { animation: none; display: none; }
}

/* ---------- Rosettes: the gifts of rescued planets, full width ---------- */

.pf-boxes { display: flex; }
.pf-box {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  width: 100%;
  min-height: 96px;
  padding: 0.9em 1em;
  border: 1px solid rgba(150, 148, 220, 0.22);
  border-radius: 14px;
  background: rgba(28, 24, 64, 0.35);
}
.pf-box-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--lavender);
  opacity: 0.85;
}
.pf-box-rosettes.empty { justify-content: center; align-items: center; }
.pf-rosette-tray {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.7em;
  max-height: 132px;
  overflow-y: auto;
  padding-top: 0.1em;
}
/* The tray's rosettes are the small ones; hover names the planet (title). */
.pf-rosette-tray .rosette { --rs: 30px; cursor: help; }
.pf-rosette-empty {
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--lavender);
  opacity: 0.6;
  text-align: center;
}
.pf-rosette-hint {
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.66rem;
  color: var(--lavender);
  opacity: 0.6;
  margin-top: 0.1em;
}
/* The rosette's hover name: floated above the medal, never clipped. */
.pf-tip {
  position: fixed;
  z-index: 60;
  transform: translate(-50%, -100%);
  padding: 0.35em 0.7em;
  border: 1px solid rgba(150, 148, 220, 0.5);
  border-radius: 8px;
  background: rgba(16, 14, 40, 0.96);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 12px rgba(116, 112, 200, 0.2);
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--cream);
  white-space: nowrap;
  pointer-events: none;
}
/* A small pointer down to the rosette. */
.pf-tip::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(16, 14, 40, 0.96);
}

/* ---------- Start over: a small door, gated behind a warning ---------- */

.pf-danger {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.8em;
}
.pf-start-btn {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 0.4em 0.9em;
  color: var(--lavender);
  background: none;
  border: 1px solid rgba(154, 147, 184, 0.3);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.75;
  transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease, opacity 0.25s ease;
}
.pf-start-btn:hover {
  opacity: 1;
  border-color: rgba(232, 118, 106, 0.6);
  color: #E8776A;
  background: rgba(232, 118, 106, 0.06);
}
.pf-danger.armed .pf-start-btn { display: none; }

.pf-warn {
  display: none;
  flex-direction: column;
  gap: 0.7em;
  width: 100%;
  padding: 1.1em 1.2em;
  border: 1px solid rgba(232, 118, 106, 0.4);
  border-radius: 14px;
  background: rgba(46, 20, 26, 0.5);
  animation: menu-word-in 0.35s ease;
}
.pf-danger.armed .pf-warn { display: flex; }
.pf-warn-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--cream);
}
.pf-warn-body {
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--lavender);
}
.pf-warn-row {
  display: flex;
  gap: 0.7em;
  margin-top: 0.2em;
}
.pf-warn-cancel,
.pf-warn-confirm {
  flex: 1;
  font-family: var(--sans);
  font-size: 0.78rem;
  padding: 0.6em 1em;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}
.pf-warn-cancel {
  color: var(--cream);
  background: none;
  border: 1px solid rgba(154, 147, 184, 0.45);
}
.pf-warn-cancel:hover { border-color: var(--cream); }
.pf-warn-confirm {
  color: #E8776A;
  background: rgba(232, 118, 106, 0.08);
  border: 1px solid rgba(232, 118, 106, 0.55);
}
.pf-warn-confirm:hover { background: rgba(232, 118, 106, 0.18); border-color: #E8776A; }

@media (max-width: 520px) {
  .pf-shell { padding: 1.3em 1.1em 1.3em; gap: 1.1em; }
  .pf-top { flex-direction: column-reverse; align-items: center; gap: 1em; }
  .pf-id { align-items: center; text-align: center; }
  .pf-class { align-self: center; }
  .pf-avatar-wrap { margin-top: 0; }
  .pf-name { font-size: 1.5rem; white-space: normal; }
  .pf-danger { align-items: stretch; }
  .pf-start-btn { align-self: center; }
}
