/* ---------- App header additions ---------- */

.pitch-site--app .stage__header > .stage-brand {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.pitch-site--app .stage__header > .stage-actions {
  align-items: center;
  display: flex;
  flex: 1;
  gap: 8px;
  justify-content: flex-end;
}

.stage-org-switcher {
  position: relative;
  width: fit-content;
}

.stage-org-switcher > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.stage-org-switcher > summary::-webkit-details-marker {
  display: none;
}

.stage-org-switcher__label {
  align-items: center;
  color: var(--ps-cream-soft);
  display: flex;
  font-family: var(--font-mono);
  font-size: 11px;
  gap: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-org-switcher__crest {
  filter: drop-shadow(0 1px 3px rgba(6, 20, 11, 0.6));
  flex: none;
}

.stage-org-switcher__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-org-switcher > summary.stage-org-switcher__label::after {
  color: var(--ps-yellow);
  content: " ▾";
}

.stage-org-switcher[open] > summary.stage-org-switcher__label::after {
  content: " ▴";
}

.stage-org-switcher > summary:hover {
  color: var(--ps-cream);
}

.stage-org-switcher .stage-menu-card {
  left: 0;
  right: auto;
}

/* ---------- Chips ---------- */

.stage-chip {
  align-items: center;
  backdrop-filter: blur(10px);
  background: var(--ps-chrome);
  border: 2px solid var(--ps-ink);
  border-radius: 100px;
  box-shadow: var(--ps-chrome-shadow);
  color: var(--ps-cream);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 9px 14px;
  text-decoration: none;
  white-space: nowrap;
}

a.stage-chip:hover {
  color: var(--ps-yellow);
}

details.stage-chip {
  padding: 0;
  position: relative;
}

details.stage-chip > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 14px;
  user-select: none;
}

details.stage-chip > summary::-webkit-details-marker {
  display: none;
}

details.stage-chip > summary::after {
  color: var(--ps-yellow);
  content: " ▾";
}

details.stage-chip[open] > summary::after {
  content: " ▴";
}

.stage-chip--live {
  color: var(--ps-live);
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.stage-chip__dot {
  animation: stage-chip-pulse 1.6s ease-in-out infinite;
  background: var(--ps-live);
  border-radius: 50%;
  height: 8px;
  width: 8px;
}

.stage-chip--warning {
  color: var(--ps-yellow);
  font-family: var(--font-mono);
  text-transform: uppercase;
}

@keyframes stage-chip-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* ---------- Paper menu card (chips, switcher, user menu) ---------- */

.stage-menu-card {
  background: var(--ps-paper-raised);
  border: 2px solid var(--ps-ink);
  border-radius: 10px;
  box-shadow: 6px 6px 0 rgba(6, 20, 11, 0.6);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(70vh, 480px);
  min-width: 14rem;
  overflow-y: auto;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 6;
}

.stage-menu-card form {
  margin: 0;
}

.stage-menu-card__item {
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--ps-ink);
  cursor: pointer;
  display: block;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  width: 100%;
}

.stage-menu-card__item:hover {
  background: var(--ps-paper-shade);
  color: var(--ps-ink);
}

.stage-menu-card__item.is-active {
  background: var(--ps-yellow);
}

.stage-menu-card__item--muted {
  color: var(--ps-ink-soft);
}

.stage-menu-card__item--signout,
.stage-menu-card__item--danger {
  color: var(--ps-red-deep);
}

.stage-menu-card__hint {
  color: var(--ps-ink-soft);
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stage-menu-card__heading {
  color: var(--ps-red-deep);
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 8px 10px 2px;
  text-transform: uppercase;
}

.stage-menu-card__group {
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding-top: 4px;
}

.stage-menu-card__group--compact {
  display: none;
}

/* ---------- Row actions: a three-dot menu of what a page can do ---------- */

.stage-actions {
  position: relative;
}

.stage-actions__trigger {
  align-items: center;
  border: 2px solid var(--color-ink);
  border-radius: 8px;
  color: var(--color-ink);
  cursor: pointer;
  display: flex;
  height: 2.25rem;
  justify-content: center;
  list-style: none;
  user-select: none;
  width: 2.25rem;
}

.stage-actions__trigger::-webkit-details-marker {
  display: none;
}

.stage-actions__trigger:hover,
.stage-actions[open] .stage-actions__trigger {
  background: var(--color-shade);
}

.stage-actions__trigger svg {
  height: 1.125rem;
  width: 1.125rem;
}

.stage-actions__card {
  background: var(--color-surface);
  border: 2px solid var(--color-ink);
  border-radius: 10px;
  box-shadow: 6px 6px 0 rgba(6, 20, 11, 0.25);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 12rem;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 8;
}

.stage-actions__card form {
  margin: 0;
}

.stage-actions__card .folder-picker {
  position: static;
}

.stage-actions__card .folder-picker__dropdown {
  background: none;
  border: none;
  box-shadow: none;
  margin: 0;
  min-width: 0;
  padding: 0 0 4px;
  position: static;
}

.stage-actions__card .folder-picker__title {
  display: none;
}

/* ---------- User menu ---------- */

.stage-user {
  position: relative;
}

.stage-user__summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 10px;
  list-style: none;
  user-select: none;
}

.stage-user__summary::-webkit-details-marker {
  display: none;
}

.stage-user__avatar {
  align-items: center;
  background: var(--ps-yellow);
  border: 2px solid var(--ps-ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 rgba(6, 20, 11, 0.7);
  color: var(--ps-ink);
  display: flex;
  flex: none;
  font-size: 12px;
  font-weight: 700;
  height: 36px;
  justify-content: center;
  letter-spacing: 0.02em;
  width: 36px;
}

.stage-user__avatar--large {
  font-size: 1rem;
  height: 3rem;
  width: 3rem;
}

.stage-user__summary:hover .stage-user__avatar {
  background: var(--ps-cream);
}

.stage-user__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stage-user__name {
  color: var(--ps-cream);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.stage-user__role {
  color: var(--ps-cream-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- Landing: greeting, recent activity and module glyphs ---------- */

.stage-landing {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 12px 0 24px;
  width: 100%;
}

.stage-greeting {
  color: var(--ps-yellow);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin: 0;
  text-align: center;
  text-shadow: 0 1px 10px rgba(6, 20, 11, 0.7);
  text-transform: uppercase;
}

.stage-recent {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-recent__title {
  color: var(--ps-cream);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  text-shadow: 0 1px 8px rgba(6, 20, 11, 0.8);
}

.stage-recent__groups {
  align-content: start;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.stage-recent__group {
  backdrop-filter: blur(6px);
  background: var(--ps-chrome);
  border: 2px solid var(--ps-ink);
  border-radius: 12px;
  box-shadow: var(--ps-chrome-shadow);
  color: var(--ps-cream);
  min-width: 0;
  padding: 12px 16px;
}

.stage-recent__heading {
  color: var(--ps-yellow);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.stage-recent__list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stage-recent__link {
  color: var(--ps-cream);
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-recent__link:hover {
  color: var(--ps-yellow);
}

.stage-recent__empty {
  backdrop-filter: blur(6px);
  background: var(--ps-chrome);
  border: 2px solid var(--ps-ink);
  border-radius: 12px;
  box-shadow: var(--ps-chrome-shadow);
  color: var(--ps-cream-soft);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin: 0;
  text-transform: uppercase;
}

.stage-modules {
  display: grid;
  gap: 28px 12px;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.stage-module {
  align-items: center;
  animation: stage-module-bob 6s ease-in-out infinite;
  display: flex;
  justify-content: center;
  margin: 0;
}

.stage-module__link {
  align-items: center;
  color: var(--ps-cream);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 1px 8px rgba(6, 20, 11, 0.7);
}

.stage-module__art {
  aspect-ratio: 1;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(6, 20, 11, 0.55));
  transition: filter 160ms, transform 160ms;
  width: clamp(64px, 6vw, 92px);
}

.stage-module__art svg {
  display: block;
  height: 100%;
  width: 100%;
}

.stage-module__label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: color 160ms;
}

.stage-module__status {
  color: var(--ps-cream-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  min-height: 1.2em;
  text-transform: uppercase;
}

.stage-module--hero .stage-module__art {
  color: var(--ps-yellow);
}

.stage-module__link:hover .stage-module__art {
  filter: brightness(1.25) drop-shadow(0 2px 10px rgba(6, 20, 11, 0.6));
  transform: translateY(-2px);
}

.stage-module__link:hover .stage-module__label {
  color: var(--ps-yellow);
}

.stage-module__link:focus-visible {
  border-radius: 14px;
  outline: 3px solid var(--ps-yellow);
  outline-offset: 4px;
}

.stage-module--slot-1 { animation-delay: 0s; }
.stage-module--slot-2 { animation-delay: -0.9s; }
.stage-module--slot-3 { animation-delay: -1.8s; }
.stage-module--slot-4 { animation-delay: -2.7s; }
.stage-module--slot-5 { animation-delay: -3.6s; }
.stage-module--slot-6 { animation-delay: -4.5s; }
.stage-module--slot-7 { animation-delay: -5.4s; }

@keyframes stage-module-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -9px; }
}

@media (min-width: 75rem) {
  .stage-landing {
    align-items: center;
    column-gap: clamp(24px, 4vw, 72px);
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
    grid-template-rows: auto minmax(0, 1fr);
    inset: 0;
    padding: 4px clamp(16px, 3vw, 48px) 16px;
    position: absolute;
    row-gap: 8px;
  }

  .stage-landing .stage-greeting {
    grid-column: 1 / 3;
  }

  .stage-landing .stage-recent {
    align-self: center;
  }

  .stage-landing .stage-recent__groups {
    gap: clamp(10px, 1.6vh, 18px) 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-landing .stage-modules {
    align-content: center;
    gap: clamp(16px, 3vh, 40px) 4px;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    height: 100%;
  }

  .stage-module--slot-1 { grid-area: 1 / 1 / 2 / 3; }
  .stage-module--slot-2 { grid-area: 1 / 3 / 2 / 5; }
  .stage-module--slot-3 { grid-area: 1 / 5 / 2 / 7; }
  .stage-module--slot-4 { grid-area: 1 / 7 / 2 / 9; }
  .stage-module--slot-5 { grid-area: 2 / 2 / 3 / 4; }
  .stage-module--slot-6 { grid-area: 2 / 4 / 3 / 6; }
  .stage-module--slot-7 { grid-area: 2 / 6 / 3 / 8; }
}

@media (max-width: 49.999rem) {
  .stage-modules {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Hockey: coming soon ---------- */

.stage-coming-soon {
  align-items: center;
  color: var(--ps-cream);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  text-shadow: 0 1px 10px rgba(6, 20, 11, 0.7);
}

.stage-coming-soon__kicker {
  color: var(--ps-yellow);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  margin: 0;
  text-transform: uppercase;
}

.stage-coming-soon__line {
  color: var(--ps-cream);
  font-size: clamp(34px, 5vw, 72px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
}

/* ---------- View frame: switching view swaps the stage in place ---------- */

.pitch-site--app #stage_view {
  display: contents;
}

.pitch-site--app #stage_view[busy] .stage__overlay,
.pitch-site--app #stage_view[busy] .stage-statpanel,
.pitch-site--app #stage_view[busy] .stage-bench,
.pitch-site--app #stage_view[busy] .pitch-window {
  opacity: 0.5;
  transition: opacity 0.15s ease 0.15s;
}

/* ---------- Window variants ---------- */

.pitch-site--app .pitch-window__title {
  color: var(--ps-ink);
  flex: 0 1 auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pitch-site--app .pitch-window--wide {
  max-width: 80rem;
}

.pitch-site--app .pitch-window--stretch {
  flex: 1 1 auto;
}

.pitch-site--app .pitch-window--stretch .pitch-window__body {
  display: flex;
  flex-direction: column;
}

.pitch-site--app .pitch-window--stretch .pitch-window__body > * {
  flex: 1 1 auto;
}

.pitch-site--app .pitch-window--full {
  align-self: stretch;
  flex: 1 1 auto;
  max-width: none;
  min-height: 60dvh;
}

.pitch-site--app .pitch-window--full .pitch-window__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 0;
}

.pitch-site--app .pitch-window__body > .auth-flash {
  margin-inline: clamp(16px, 3vw, 32px);
}

.pitch-site--app .pitch-window:not(.pitch-window--full) .pitch-window__body > :not(.container, .container-large, .container-small, .auth-flash, .stage-auth-card) {
  padding-inline: clamp(16px, 3vw, 32px);
}

/* ---------- Auth tabs (sign in / create account) ---------- */

.stage-auth-tabs {
  background: var(--ps-paper-shade);
  border: 2px solid var(--ps-ink);
  border-radius: 99rem;
  display: flex;
  gap: 4px;
  margin-inline: auto;
  padding: 4px;
  width: fit-content;
}

.stage-auth-tabs__link {
  border-radius: 99rem;
  color: var(--ps-ink);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 18px;
  text-decoration: none;
}

.stage-auth-tabs__link.is-active {
  background: var(--ps-red);
  color: var(--ps-cream);
}

.stage-auth-card__title {
  font-size: 1.75rem;
  letter-spacing: -0.025em;
  margin: 0;
  text-align: center;
}

/* ---------- Locked CTA on paper ---------- */

.pitch-site--app .locked-section__card {
  background: var(--ps-paper-raised);
  border: 2px solid var(--ps-ink);
  border-radius: 10px;
  box-shadow: var(--ps-hard-shadow);
}

.pitch-site--app .locked-section__title {
  color: var(--ps-ink);
}

/* ---------- Responsive header ---------- */

@media (min-width: 50rem) and (max-width: 74.999rem) {
  .stage-chip {
    font-size: 12px;
  }

  .stage-user__name {
    display: none;
  }
}

@media (max-width: 49.999rem) {
  .stage-org-switcher,
  .stage-org-switcher__label,
  .stage-actions > .stage-chip,
  .stage-user__text {
    display: none;
  }

  .stage-menu-card__group--compact {
    display: flex;
  }

  .stage-menu-card {
    max-width: calc(100vw - 32px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-module,
  .stage-chip__dot {
    animation: none;
  }
}
