/* ========================================================================
   meta.css — cross-cutting overlays for run-level events.
   Currently holds the Bankruptcy game-over modal. Future home for the
   Prestige "Sell the Garage" overlay (Phase 6 of economy-and-meta).
   ======================================================================== */

/* ---- Bankruptcy game-over overlay ---- */
.bankruptcy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 20, 0.86);
  backdrop-filter: blur(4px);
  animation: bankruptcy-fade-in 0.25s var(--ease, ease-out);
}
/* The HTML `hidden` attribute resolves to display:none via the user-agent
   stylesheet, but the `.bankruptcy-overlay { display: flex }` rule above
   overrides it (author wins). Re-apply display:none for hidden so the
   modal is actually hidden when state.gameOver is null. */
.bankruptcy-overlay[hidden] { display: none; }
@keyframes bankruptcy-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.bankruptcy-panel {
  width: min(420px, 92vw);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  background: var(--bg-panel);
  border: 1px solid rgba(232, 80, 58, 0.55);
  border-radius: var(--r-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65),
              0 0 0 1px rgba(232, 80, 58, 0.18) inset;
  text-align: center;
}

.bankruptcy-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: var(--sp-2);
}
.bankruptcy-title {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xxl, 28px);
  color: #f0b4a8;
  letter-spacing: 0.02em;
}
.bankruptcy-blurb {
  margin: 0 0 var(--sp-3);
  color: var(--text-dim);
  line-height: 1.45;
}
.bankruptcy-stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  margin: 0 0 var(--sp-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-align: left;
  font-size: var(--fs-sm);
}
.bankruptcy-stats .stat-label { color: var(--text-dim); }
.bankruptcy-stats .stat-value { color: var(--text); font-weight: var(--fw-semi); }

.bankruptcy-restart {
  min-width: 140px;
}

/* ---- Prestige "Sell the Garage" overlay ---- */
.prestige-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 20, 0.86);
  backdrop-filter: blur(4px);
  animation: bankruptcy-fade-in 0.25s var(--ease, ease-out);
}
/* Same hidden-attribute override as the bankruptcy overlay above. */
.prestige-overlay[hidden] { display: none; }
.prestige-panel {
  width: min(520px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  background: var(--bg-panel);
  border: 1px solid rgba(255, 200, 80, 0.55);
  border-radius: var(--r-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65),
              0 0 0 1px rgba(255, 200, 80, 0.16) inset;
  text-align: center;
}
.prestige-icon  { font-size: 44px; line-height: 1; margin-bottom: var(--sp-2); }
.prestige-title { margin: 0 0 var(--sp-2); font-size: var(--fs-xxl, 26px); color: #ffe0a3; }
.prestige-blurb { margin: 0 0 var(--sp-3); color: var(--text-dim); line-height: 1.45; font-size: var(--fs-sm); }

.prestige-perks {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.prestige-perk {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.prestige-perk:hover {
  border-color: rgba(255, 200, 80, 0.55);
  background: var(--bg-card-hover);
}
.prestige-perk-icon { font-size: 22px; line-height: 1; }
.prestige-perk-info { flex: 1; min-width: 0; }
.prestige-perk-name { font-weight: var(--fw-semi); margin-bottom: 2px; }
.prestige-perk-desc { color: var(--text-dim); font-size: var(--fs-sm); line-height: 1.35; }

.prestige-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.prestige-cancel:hover { color: var(--text); border-color: var(--border-strong); }

/* ---- Prestige HUD button (topbar) — only shown when player is eligible ---- */
.hud-prestige {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px var(--sp-2);
  background: rgba(255, 200, 80, 0.18);
  border: 1px solid rgba(255, 200, 80, 0.65);
  border-radius: var(--r-sm);
  color: #ffe0a3;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.hud-prestige:hover {
  background: rgba(255, 200, 80, 0.28);
  border-color: rgba(255, 200, 80, 0.9);
}
.hud-prestige[hidden] { display: none; }
.hud-prestige-icon { font-size: 14px; line-height: 1; }
.hud-prestige-text { font-weight: var(--fw-semi); }

/* ---- Start-menu active-perk banner ---- */
.sm-prestige-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin: var(--sp-3) 0;
  background: rgba(255, 200, 80, 0.12);
  border: 1px solid rgba(255, 200, 80, 0.55);
  border-radius: var(--r-sm);
  color: #ffe0a3;
}
.sm-prestige-icon { font-size: 24px; line-height: 1; }
.sm-prestige-text { flex: 1; min-width: 0; }
.sm-prestige-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 224, 163, 0.7);
}
.sm-prestige-name { font-weight: var(--fw-semi); }
.sm-prestige-clear {
  background: transparent;
  border: 1px solid rgba(255, 200, 80, 0.5);
  color: #ffe0a3;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.sm-prestige-clear:hover { background: rgba(255, 200, 80, 0.18); }

/* ---- Onboarding popover ---- */
.onboarding-popover {
  position: fixed;
  z-index: 8500;
  width: 280px;
  padding: var(--sp-3);
  background: var(--bg-panel);
  border: 1px solid var(--accent, #4fc3f7);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55),
              0 0 0 1px rgba(79, 195, 247, 0.18) inset;
  animation: onboarding-pop-in 0.18s var(--ease, ease-out);
}
@keyframes onboarding-pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.onboarding-step {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.onboarding-title {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--accent, #4fc3f7);
}
.onboarding-body {
  margin: 0 0 var(--sp-3);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.onboarding-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
}
.onboarding-skip {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: underline;
}
.onboarding-skip:hover { color: var(--text); }
.onboarding-next {
  min-width: 88px;
}

/* Anchor highlight — pulsing accent ring on the targeted UI element. */
.onboarding-anchor {
  position: relative;
  z-index: 10;
  box-shadow: 0 0 0 2px var(--accent, #4fc3f7),
              0 0 14px rgba(79, 195, 247, 0.55);
  animation: onboarding-pulse 1.4s ease-in-out infinite;
}
@keyframes onboarding-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent, #4fc3f7),
                         0 0 12px rgba(79, 195, 247, 0.45); }
  50%      { box-shadow: 0 0 0 3px var(--accent, #4fc3f7),
                         0 0 22px rgba(79, 195, 247, 0.85); }
}

/* ---------- About overlay ---------- */
/* Scrim + centered panel pattern (cf. .prestige-overlay above), but
   dressed up with: animated conic-gradient ring around the icon,
   gradient-text title, sweeping shimmer line under the title,
   ambient floating sparkles, animated panel border, and a button
   with a shine sweep on hover. All driven by @keyframes — no JS. */
.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(79, 195, 247, 0.10) 0%, rgba(0, 0, 0, 0) 60%),
    rgba(8, 12, 20, 0.88);
  backdrop-filter: blur(6px);
  animation: aboutOverlayIn 0.32s var(--ease, ease-out);
}
.about-overlay[hidden] { display: none; }
@keyframes aboutOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.about-panel {
  position: relative;
  width: min(480px, 92vw);
  padding: var(--sp-5) var(--sp-5) var(--sp-5);
  background:
    radial-gradient(circle at 50% -10%, rgba(79, 195, 247, 0.10), transparent 60%),
    var(--bg-panel);
  border: 1px solid rgba(79, 195, 247, 0.55);
  border-radius: var(--r-md);
  box-shadow:
    0 20px 56px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(79, 195, 247, 0.18) inset,
    0 0 36px rgba(79, 195, 247, 0.18);
  text-align: center;
  overflow: hidden;
  animation: aboutPanelIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.18);
}
@keyframes aboutPanelIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Soft pulsing border-glow — slow, never grabby. */
.about-panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 24px rgba(79, 195, 247, 0.20);
  animation: aboutPanelGlow 4.2s ease-in-out infinite;
}
@keyframes aboutPanelGlow {
  0%, 100% { box-shadow: 0 0 18px rgba(79, 195, 247, 0.15); }
  50%      { box-shadow: 0 0 38px rgba(79, 195, 247, 0.42); }
}

/* Icon wrap = positioning context for the two rotating rings. */
.about-icon-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.about-icon-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    rgba(79, 195, 247, 0.85) 0deg,
    rgba(79, 195, 247, 0) 70deg,
    rgba(79, 195, 247, 0) 290deg,
    rgba(79, 195, 247, 0.85) 360deg
  );
  /* Mask leaves only an annular ring visible. */
  -webkit-mask: radial-gradient(circle at center, transparent 38px, #000 40px, #000 47px, transparent 49px);
          mask: radial-gradient(circle at center, transparent 38px, #000 40px, #000 47px, transparent 49px);
  animation: aboutRingSpin 6s linear infinite;
}
.about-icon-ring-2 {
  background: conic-gradient(
    from 180deg,
    rgba(255, 200, 80, 0.55) 0deg,
    rgba(255, 200, 80, 0) 80deg,
    rgba(255, 200, 80, 0) 280deg,
    rgba(255, 200, 80, 0.55) 360deg
  );
  -webkit-mask: radial-gradient(circle at center, transparent 30px, #000 32px, #000 37px, transparent 39px);
          mask: radial-gradient(circle at center, transparent 30px, #000 32px, #000 37px, transparent 39px);
  animation: aboutRingSpin 9s linear infinite reverse;
}
@keyframes aboutRingSpin {
  to { transform: rotate(360deg); }
}
.about-icon {
  position: relative;
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(79, 195, 247, 0.55));
  animation: aboutIconBob 3.6s ease-in-out infinite;
}
@keyframes aboutIconBob {
  0%, 100% { transform: translateY(0)    rotate(-3deg); }
  50%      { transform: translateY(-4px) rotate( 3deg); }
}

.about-title {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xxl, 28px);
  font-weight: var(--fw-bold);
  letter-spacing: 0.5px;
  /* Animated gradient sweep across the text. */
  background: linear-gradient(
    100deg,
    #ffffff 0%,
    var(--accent, #4fc3f7) 40%,
    #c8e6ff 60%,
    var(--accent, #4fc3f7) 80%,
    #ffffff 100%
  );
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: aboutTitleSweep 6s linear infinite;
}
@keyframes aboutTitleSweep {
  0%   { background-position: 0% center; }
  100% { background-position: 220% center; }
}

/* Thin shimmer line under the title — drawn via a 2px-tall element
   with a moving gradient highlight. */
.about-shimmer {
  position: relative;
  width: 60%;
  height: 2px;
  margin: 0 auto var(--sp-3);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(79, 195, 247, 0.0)  20%,
    rgba(79, 195, 247, 0.95) 50%,
    rgba(79, 195, 247, 0.0)  80%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: aboutShimmer 3.4s linear infinite;
}
@keyframes aboutShimmer {
  0%   { background-position: -100% 0; }
  100% { background-position:  100% 0; }
}

.about-blurb {
  position: relative;
  margin: 0 0 var(--sp-2);
  color: var(--text, #e6edf5);
  line-height: 1.55;
  font-size: var(--fs-sm);
}
.about-author {
  /* Subtle gradient on the author name too. */
  background: linear-gradient(90deg, #fff, var(--accent, #4fc3f7), #fff);
  background-size: 200% auto;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: aboutTitleSweep 4.8s linear infinite;
  font-weight: var(--fw-bold);
}
.about-link {
  color: var(--accent, #4fc3f7);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(79, 195, 247, 0.5);
  transition: text-decoration-color var(--dur-fast) var(--ease),
              filter var(--dur-fast) var(--ease);
}
.about-link:hover {
  text-decoration-color: var(--accent, #4fc3f7);
  filter: drop-shadow(0 0 8px rgba(79, 195, 247, 0.65));
}

.about-close {
  position: relative;
  margin-top: var(--sp-4);
  padding: 10px 28px;
  background: linear-gradient(180deg, rgba(79, 195, 247, 0.14), rgba(79, 195, 247, 0.04));
  color: var(--text);
  border: 1px solid rgba(79, 195, 247, 0.50);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  letter-spacing: 0.5px;
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.about-close:hover {
  background: linear-gradient(180deg, rgba(79, 195, 247, 0.28), rgba(79, 195, 247, 0.10));
  border-color: rgba(79, 195, 247, 0.90);
  box-shadow: 0 0 18px rgba(79, 195, 247, 0.45);
  transform: translateY(-1px);
}
/* Diagonal shine sweeps across on hover. */
.about-close::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -40%;
  width: 30%;
  background: linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s var(--ease);
  pointer-events: none;
}
.about-close:hover::after { left: 130%; }

/* Floating sparkles — four positioned absolutely, each with its own
   keyframe phase so they drift independently. Pure decoration. */
.about-spark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent, #4fc3f7);
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.85);
  pointer-events: none;
  opacity: 0;
}
.about-spark-1 { top: 12%; left: 14%; animation: aboutSpark 5.2s ease-in-out 0.2s infinite; }
.about-spark-2 { top: 22%; right: 16%; animation: aboutSpark 6.4s ease-in-out 1.1s infinite; }
.about-spark-3 { bottom: 28%; left: 22%; animation: aboutSpark 4.8s ease-in-out 2.0s infinite; }
.about-spark-4 { bottom: 18%; right: 20%; animation: aboutSpark 5.6s ease-in-out 0.8s infinite; }
@keyframes aboutSpark {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.6); }
  20%      { opacity: 0.9; }
  50%      { opacity: 1; transform: translateY(-10px) scale(1); }
  80%      { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .about-panel,
  .about-icon,
  .about-icon-ring,
  .about-title,
  .about-author,
  .about-shimmer,
  .about-spark,
  .about-panel::before {
    animation: none !important;
  }
  /* Static fallback: still keep the gradient text colour by snapping to a fixed background-position. */
  .about-title,
  .about-author {
    background-position: 50% center;
  }
}
