/* Mobile-first: base rules target phone widths; min-width queries add
   larger-screen refinements only, never the reverse. */

body {
  min-height: 100vh;
}

/* A class rule setting its own `display` (e.g. .roster-edit-form { display:
   flex }) otherwise wins over the browser's default `[hidden]{display:none}`
   UA rule at equal specificity, silently breaking `el.hidden = true`
   anywhere that pattern is used. One global override avoids that trap for
   every current and future use of the hidden attribute in this app. */
[hidden] {
  display: none !important;
}

.centered-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-height: 100vh;
}

.status-card {
  width: 100%;
  max-width: 26rem;
  text-align: center;
}

.error-text {
  color: #ff8a8a;
  font-size: 0.9rem;
}

.hint-text {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.btn-danger {
  color: #ff8a8a;
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.35);
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
}

.btn-danger:hover {
  background: rgba(255, 90, 90, 0.2);
}

.legal-footer {
  margin: 1.5rem auto 0.75rem;
  padding: 0 1rem;
  max-width: 40rem;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.legal-footer a {
  color: var(--color-accent-blue-text);
}

body.room-page .legal-footer {
  display: none; /* fixed 100vh room layout has no scroll room for a footer — see .room-header link instead */
}

.empty-state {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-coach {
  background: var(--color-accent-yellow);
  color: var(--color-accent-yellow-text);
}

.badge-open {
  background: rgba(59, 130, 246, 0.25);
  color: var(--color-accent-blue-text);
}

.badge-closed {
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text-secondary);
}

/* Forms */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.stack-form label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-align: left;
}

.stack-form input,
.stack-form textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-size: 1rem;
  font-family: var(--font-body);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.inline-form input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
}

/* Identity picker */
.identity-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.identity-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 1.05rem;
}

.identity-option input {
  width: auto;
}

/* Admin pages */
.page-wrap {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.channel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.channel-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.channel-row-meta {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.channel-row-date {
  color: var(--color-accent-blue-text);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.15rem 0 0;
}

.date-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
}

.date-search-form label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.date-search-form input[type='date'] {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  color-scheme: dark;
}

.date-range-field input[type='date'] {
  color-scheme: dark;
}

.channel-row-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.channel-row-links label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.channel-row-links input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-size: 0.8rem;
}

.channel-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.roster-list-plain {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.roster-list-plain .roster-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.sheets-pull-panel {
  margin-bottom: 1rem;
}

.participant-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--glass-border);
}

.participant-row:last-child {
  border-bottom: none;
}

/* Chat room — the whole screen is pinned to the viewport (no page-level
   scroll): header/roster/poll/input all stay put, only .message-list below
   scrolls, like a real chat app. */
body.room-page {
  height: 100vh;
  overflow: hidden;
}

.room-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  flex-shrink: 0;
  z-index: 5;
  border-radius: 0;
}

.room-header h1 {
  font-size: 1.05rem;
  margin: 0;
}

.room-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.room-privacy-link {
  padding: 0.4rem 0.55rem;
}

.room-privacy-link-label {
  display: none;
}

@media (min-width: 640px) {
  .room-privacy-link-label {
    display: inline;
    margin-left: 0.3rem;
  }
}

.roster-panel {
  margin: 0.75rem 1rem;
  flex-shrink: 0;
}

.roster-panel ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.roster-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
}

.roster-item-view {
  flex: 1;
}

.roster-edit-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.3rem;
}

.roster-edit-form input {
  flex: 1;
  min-width: 6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-size: 0.85rem;
}

.roster-edit-actions {
  display: flex;
  gap: 0.4rem;
  width: 100%;
}

.roster-add-panel {
  margin: 0.75rem 0;
}

.roster-add-panel summary {
  cursor: pointer;
  color: var(--color-accent-blue-text);
  font-weight: 600;
  font-size: 0.9rem;
}

.roster-add-panel form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.roster-add-panel input {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-size: 0.9rem;
}

.poll-section {
  padding: 0.85rem 1rem 0.5rem;
  flex-shrink: 0;
}

.poll-widget h3 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--glass-border);
}

.poll-options-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.poll-option label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.poll-count {
  margin-left: auto;
  font-weight: 600;
  color: var(--color-accent-blue-text);
}

.poll-voters {
  margin: 0.2rem 0 0 1.6rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.poll-create-panel {
  margin-top: 0.6rem;
}

.poll-create-panel summary {
  cursor: pointer;
  color: var(--color-accent-blue-text);
  font-weight: 600;
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 1rem 1rem;
  overflow: hidden;
}

.message-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  /* column-reverse (DOM holds newest-first, see channel.client.js) instead
     of column + justify-content:flex-end: the flex-end approach hits a real
     Chromium bug where scrollHeight stops reflecting actual overflowing
     content once justify-content pushes items to the end, so the list
     silently stops being scrollable instead of scrolling. column-reverse's
     default (flex-start in the reversed axis) sticks content to the visual
     bottom without that bug, and — as a bonus — a scroll container defaults
     to scrollTop:0 which in reverse means "already showing the newest
     message", so no JS scroll-to-bottom call is needed on load either. */
  flex-direction: column-reverse;
  gap: 0.4rem;
}

/* Chat bubbles: mine = right-aligned accent bubble, other = left-aligned
   neutral glass bubble, tail corner gets a smaller radius (a standard
   chat-app cue), coach gets its own tint regardless of alignment. */
.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.message-mine {
  align-self: flex-end;
  align-items: flex-end;
}

.message-other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  border-radius: 16px;
  padding: 0.5rem 0.75rem 0.35rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

.message-mine .message-bubble {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.4);
  border-bottom-right-radius: 4px;
}

.message-other .message-bubble {
  border-bottom-left-radius: 4px;
}

.message-coach .message-bubble {
  background: rgba(255, 214, 10, 0.12);
  border-color: rgba(255, 214, 10, 0.35);
}

.message-author {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.15rem;
  padding: 0 0.2rem;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.message-body {
  word-wrap: break-word;
  display: block;
}

.message-time {
  display: block;
  font-size: 0.65rem;
  color: var(--color-text-secondary);
  opacity: 0.75;
  text-align: right;
  margin-top: 0.1rem;
}

.message-form {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.5rem;
  flex-shrink: 0;
}

.message-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-size: 1rem;
}

/* Larger screens: give the room a two-column layout (roster/poll sidebar +
   chat), and admin forms a bit more breathing room. Base (above) already
   works standalone on a phone. */
@media (min-width: 760px) {
  .room-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      'header header'
      'poll chat'
      'roster chat';
    height: 100vh;
  }

  .room-header {
    grid-area: header;
  }

  .poll-section {
    grid-area: poll;
    overflow-y: auto;
  }

  .roster-panel {
    grid-area: roster;
    overflow-y: auto;
  }

  #toggle-roster-btn {
    display: none;
  }

  .roster-panel[hidden] {
    display: block !important;
  }

  .chat-section {
    grid-area: chat;
    height: 100%;
  }

  .participant-row {
    grid-template-columns: 1fr 1fr 1fr auto;
    align-items: center;
  }
}

/* Ambient halo — ported verbatim (same keyframes/timings) from the academy
   site's AmbientHalo.astro, so this app carries the same brand identity.
   position: fixed + pointer-events: none: stays put while scrolling and
   never blocks clicks on whatever it sits over. */
.ambient-halo-orbit {
  position: fixed;
  top: 3rem;
  left: 50%;
  width: clamp(22rem, 85vw, 52rem);
  margin-left: calc(clamp(22rem, 85vw, 52rem) / -2);
  z-index: -1;
  pointer-events: none;
  animation: halo-drift-x 15s ease-in-out infinite;
}

.ambient-halo-drift {
  animation: halo-drift-y 22s ease-in-out infinite;
}

.ambient-halo {
  width: 100%;
  height: clamp(24rem, 50vw, 34rem);
  background: radial-gradient(ellipse at center, rgba(59, 130, 246, 0.28), rgba(255, 214, 10, 0.14) 45%, transparent 70%);
  filter: blur(10px);
  animation: halo-heartbeat 4.5s ease-in-out infinite;
}

@keyframes halo-drift-x {
  0% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(4.2rem);
  }
  55% {
    transform: translateX(-1.8rem);
  }
  80% {
    transform: translateX(-3.6rem);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes halo-drift-y {
  0% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-4.8rem);
  }
  60% {
    transform: translateY(1.8rem);
  }
  85% {
    transform: translateY(-2.4rem);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes halo-heartbeat {
  0% {
    transform: scale(1);
    opacity: 0.84;
  }
  15% {
    transform: scale(1.05);
    opacity: 1;
  }
  30% {
    transform: scale(1.01);
    opacity: 0.92;
  }
  45% {
    transform: scale(1.05);
    opacity: 1;
  }
  60%,
  100% {
    transform: scale(1);
    opacity: 0.84;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-halo-orbit,
  .ambient-halo-drift,
  .ambient-halo {
    animation: none;
  }
}
