/* ============================================================
   home.css — styles for the home / create-or-join page only
   ============================================================ */

body {
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* "safe" so that when the cards are taller than the viewport the column
     stops centering instead of overflowing upward -- plain "center" pushed
     the logo up behind the fixed nav, where it could not be scrolled back. */
  justify-content: safe center;
  min-height: 100vh;
  padding: 72px 20px 40px;
}

/* shared.css sets body.has-nav{padding-top:56px}, which outranks the
   shorthand above on specificity and leaves the logo flush against the nav. */
body.has-nav { padding-top: 72px; }

/* ---- Auth action ---- */
.home-auth {
  align-items: center;
  display: flex;
  gap: 8px;
  max-width: calc(100vw - 32px);
  position: fixed;
  right: 20px;
  top: 18px;
  z-index: 20;
}

.home-auth [hidden] {
  display: none !important;
}

.home-auth-user {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12px;
  max-width: min(260px, 42vw);
  overflow: hidden;
  padding: 7px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-auth-login,
.home-auth-logout,
.home-auth-signup {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  padding: 0 14px;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

.home-auth-signup {
  background: transparent;
  color: var(--text);
}

.home-auth-signup:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--text);
}

.home-auth-login {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.home-auth-login:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.home-auth-logout {
  background: transparent;
  color: var(--text-muted);
}

.home-auth-logout:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ---- Logo & tagline ---- */
.home-logo {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 100%;
  text-align: center;
  line-height: 1.15;
}

.home-tagline {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 48px;
  text-align: center;
}

/* ---- Cards ---- */
.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  margin-bottom: 16px;
}

.home-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ---- Form fields ---- */
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border var(--transition);
  margin-bottom: 16px;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text-muted); }

.field-optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.75;
}

/* ---- Toggle switch row ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  margin-bottom: 20px;
}

.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-sub   { font-size: 11px; color: var(--text-muted); }

.toggle-switch {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---- Buttons ---- */
.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover    { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary:hover { background: var(--surface2); }

/* ---- Active rooms ---- */
.active-rooms-panel {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 16px;
}

.active-rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.active-rooms-header h3 {
  font-size: 13px;
  margin-bottom: 0;
}

.refresh-rooms-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  padding: 6px 10px;
}

.refresh-rooms-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.active-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-color: var(--surface2) transparent;
  scrollbar-width: thin;
}

.active-rooms-list::-webkit-scrollbar {
  width: 8px;
}

.active-rooms-list::-webkit-scrollbar-track {
  background: transparent;
}

.active-rooms-list::-webkit-scrollbar-thumb {
  background: var(--surface2);
  border-radius: 999px;
}

.active-rooms-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.24);
}

.active-rooms-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 0;
}

.active-rooms-empty a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.active-rooms-empty a:hover {
  color: var(--accent);
}

.active-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.active-room-info {
  min-width: 0;
}

.active-room-topic {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-room-id {
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-room-meta {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-room-people {
  display: inline-flex;
  flex-direction: column;
  margin-top: 8px;
  max-width: 100%;
  outline: none;
}

.active-room-people.empty {
  color: var(--text-muted);
  font-size: 11px;
}

.active-room-avatars {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding-left: 2px;
}

.active-room-avatar {
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  display: inline-flex;
  font-size: 10px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  line-height: 1;
  margin-left: -6px;
  min-width: 28px;
  width: 28px;
}

.active-room-avatar:first-child {
  margin-left: 0;
}

.active-room-avatar.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(52,168,83,0.16);
}

.active-room-avatar.more {
  color: var(--text-muted);
  font-size: 9px;
}

.active-room-tooltip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 36px rgba(0,0,0,0.28);
  margin-top: 0;
  max-width: min(260px, 80vw);
  max-height: 0;
  min-width: 210px;
  opacity: 0;
  overflow: hidden;
  padding: 10px;
  pointer-events: auto;
  transform: translateY(4px);
  transition: max-height var(--transition), margin-top var(--transition), opacity var(--transition), transform var(--transition);
}

.active-room-people:hover .active-room-tooltip,
.active-room-people:focus-visible .active-room-tooltip {
  margin-top: 8px;
  max-height: 260px;
  opacity: 1;
  transform: translateY(0);
}

.active-room-tooltip-title {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.active-room-person-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  min-height: 28px;
}

.active-room-person-icon {
  align-items: center;
  background: var(--surface2);
  border-radius: 50%;
  color: var(--text);
  display: inline-flex;
  font-size: 9px;
  font-weight: 700;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.active-room-person-name {
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-room-person-role {
  color: var(--text-muted);
  font-size: 10px;
}

.active-room-join {
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  text-decoration: none;
}

.active-room-join:hover {
  background: var(--accent-hover);
}

/* Keep the generated room link available to legacy JS without showing it. */
#createdLink {
  display: none !important;
}

/* ---- Created room link ---- */
.created-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(52,168,83,0.1);
  border: 1px solid rgba(52,168,83,0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--success);
  word-break: break-all;
  cursor: pointer;
}
.created-link:hover { background: rgba(52,168,83,0.15); }

/* ---- Feature grid ---- */
.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.home-logo img {
  display: block;
  width: 40px;
  min-width: 32px;
  height: auto;
  max-width: 22vw;
  flex: 0 0 auto;
  object-fit: contain;
}

@media (max-height: 760px) {
  body {
    justify-content: flex-start;
    padding-top: 72px;
    padding-bottom: 28px;
  }

  .home-tagline {
    margin-bottom: 28px;
  }
}

@media (max-width: 520px) {
  body {
    justify-content: flex-start;
    min-height: 100dvh;
    padding: 74px 14px 28px;
  }

  .home-auth {
    left: 14px;
    max-width: calc(100vw - 28px);
    right: 14px;
    top: 14px;
  }

  .home-auth-user {
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
  }

  .home-auth-login,
  .home-auth-logout,
  .home-auth-signup {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 12px;
  }

  .home-logo {
    font-size: 24px;
    gap: 10px;
  }

  .home-logo img {
    width: 36px;
    max-width: 18vw;
  }

  .home-tagline {
    margin-bottom: 28px;
  }

  .home-card {
    max-width: none;
    padding: 22px;
    border-radius: 14px;
  }

  .toggle-row,
  .active-rooms-header,
  .active-room-row {
    align-items: flex-start;
  }

  .active-room-row {
    flex-direction: column;
  }

  .active-room-info,
  .active-room-join {
    width: 100%;
  }

  .active-room-join {
    text-align: center;
  }
}

@media (max-width: 340px) {
  .home-logo {
    font-size: 22px;
  }

  .home-logo img {
    width: 32px;
  }

  .home-card {
    padding: 18px;
  }
}

/* ---- Desktop-app promo (floating, bottom-left) ---------------------
   Fixed so it stays out of the centered card stack and never pushes the
   logo off-screen. Browser-only: JS hides it inside the desktop app. */
.desktop-promo {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 20;
  width: 232px;
  max-width: calc(100vw - 40px);
  padding: 14px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.desktop-promo[hidden] {
  display: none !important;
}

.desktop-promo-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.desktop-promo-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.desktop-promo-head {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.desktop-promo-head svg {
  flex: none;
  color: var(--accent);
}

.desktop-promo-logo {
  flex: none;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.desktop-promo-sub {
  margin: 6px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.desktop-promo-btn {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: #fff;
  display: flex;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}

.desktop-promo-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.desktop-promo-alts {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 9px;
}

.desktop-promo-alts a {
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
  transition: color var(--transition);
}

.desktop-promo-alts a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* On short/!narrow viewports it could overlap the cards — drop it to a
   slim full-width bar pinned to the bottom edge. */
@media (max-width: 720px) {
  .desktop-promo {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}
