/* Clout Web UI Styles - layout layer
   App shell grid, left/right rails, bottom nav, mobile more sheet,
   sidebar widgets, and the responsive grid media queries. */

@layer layout {
.container {
  margin: 0 auto;
  padding: 1rem;
}

/* =========================================================================
   APP SHELL LAYOUT (DESKTOP + MOBILE NAV)
   ========================================================================= */

.container {
  max-width: 1440px;
  padding: 1rem 1.5rem;
}


#main-app {
  min-height: 80vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 240px;
  gap: 1rem;
  align-items: start;
  max-width: 1100px;
  margin: 0 auto;
}

.app-rail-left {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: calc(100vh - 2rem);
}

.rail-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
}

.rail-brand {
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: center;
}

.rail-logo {
  display: none;
}

.app-nav-tabs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border: none;
  background: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 0;
}

.app-nav-tabs .tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
  text-align: center;
  font-size: 0;
}

.app-nav-tabs .tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.app-nav-tabs .tab-btn.active {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary);
}

.app-nav-tabs .tab-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.app-nav-tabs .tab-btn .tab-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  font-size: 0.65rem;
  background: var(--error);
  color: white;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.rail-spacer { flex: 1; }

.compose-fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  /* Hidden on desktop: the inline-compose at the top of the feed and the
     Create Post tab cover composing. The .mobile-compose-fab handles mobile.
     Keeping the rest of the styling intact so the .visitor-mode rule and any
     future re-enablement still get the right look. */
  display: none;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  transition: background 0.15s;
}

.compose-fab:hover { background: var(--primary-hover); }

.rail-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.rail-status-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.2;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-main {
  min-width: 0;
}

.app-rail-right {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
}

.sidebar-widget h4 {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.sidebar-search-input {
  display: flex;
  position: relative;
}

.sidebar-search-input .input {
  width: 100%;
  padding-right: 2rem;
  font-size: 0.85rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.sidebar-search-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}

.legend-levels {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.legend-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.legend-color {
  flex-shrink: 0;
  width: 4px;
  min-height: 28px;
  border-radius: 2px;
  align-self: stretch;
}

.legend-text {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  line-height: 1.3;
}

.legend-text strong { color: var(--text); }

.legend-desc {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.sidebar-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.sidebar-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem;
}

.sidebar-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* "People You Trust" widget — surfaces the top trusted users with
   generative identicon avatars (see js/utils/identicon.js). Mirrors
   hypermind-swarm's always-visible "Following" list. */
.sidebar-trusted-people {
  /* Compact rows; the widget shows up to 8 people. */
}

.trusted-people-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.trusted-people-header h4 {
  margin: 0;
}

.manage-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.manage-link:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-hover);
}

.trusted-people-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.trusted-people-loading,
.trusted-people-empty {
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 0.5rem 0.25rem;
  line-height: 1.4;
}

.trusted-person-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.trusted-person-item:hover {
  background: var(--bg-hover);
}

.trusted-person-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-hover);
  flex-shrink: 0;
}

/* Identicon fills the avatar container (see .avatar-identicon in feed.css) */
.trusted-person-avatar .avatar-identicon {
  border-radius: 50%;
}

.trusted-person-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.trusted-person-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trusted-person-key {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trusted-person-weight {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  flex-shrink: 0;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

.trusted-person-weight.weight-full {
  background: rgba(34, 197, 94, 0.15);
  color: var(--hop-1, #22c55e);
}

.trusted-person-weight.weight-medium {
  background: rgba(234, 179, 8, 0.15);
  color: var(--hop-2, #eab308);
}

.trusted-person-weight.weight-low {
  background: rgba(249, 115, 22, 0.15);
  color: var(--hop-3, #f97316);
}

.daypass-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.daypass-countdown {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.daypass-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.sidebar-status-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.app-main .tab-content .section {
  margin-bottom: 1rem;
}

.mobile-compose-fab {
  display: none;
}

.mobile-more-trigger {
  display: none;
}

.mobile-more-sheet {
  display: none;
}


@media (max-width: 1200px) and (min-width: 769px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-rail-right {
    display: none;
  }

  /* .visitor-banner no longer needs margin overrides here: it now uses
     max-width + auto margins (see pwa.css) and self-centers at every size. */

  .inline-search-fallback-container {
    display: flex !important;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
  }

  .inline-search-fallback-container .input {
    flex: 1;
    font-size: 0.85rem;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
  }
}

@media (max-width: 768px) {
  .app-rail-right {
    display: none;
  }

  /* .visitor-banner margins are no longer set here; the banner self-centers
     via max-width + auto margins in pwa.css. */

  .inline-compose {
    display: none;
  }

  .compose-fab {
    display: none; /* mobile uses existing mobile-compose-fab */
  }

  .feed-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .feed-sort-row {
    flex-wrap: wrap;
  }

  .inline-search-fallback-container {
    display: none !important;
  }

  #main-app {
    padding-bottom: 132px;
  }

  .app-shell {
    display: block;
  }

  .app-rail-left {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    width: 100%;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(8px);
    padding: 0.45rem 0.4rem calc(0.45rem + env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: center;
  }

  .rail-brand {
    display: none;
  }

  .rail-spacer,
  .rail-status,
  .compose-fab {
    display: none;
  }

  .app-nav-tabs {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 0;
    gap: 0.35rem;
  }

  .app-nav-tabs .tab-btn {
    width: auto;
    min-width: 0;
    flex: 1;
    text-align: center;
    font-size: 0.82rem;
    padding: 0.7rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    flex-shrink: 0;
  }

  .app-nav-tabs .tab-btn[data-tab="thread"] {
    display: none !important;
  }

  .app-nav-tabs .tab-btn[data-tab="owner"],
  .app-nav-tabs .tab-btn[data-tab="settings"] {
    display: none !important;
  }

  .mobile-more-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 84px;
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.82rem;
    flex-shrink: 0;
    cursor: pointer;
  }

  .mobile-compose-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 1rem;
    bottom: calc(90px + env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    z-index: 1001;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  body.nav-scroll-down .mobile-compose-fab {
    transform: translateY(80px);
    opacity: 0;
    pointer-events: none;
  }

  .mobile-more-sheet {
    position: fixed;
    inset: 0;
    z-index: 1100;
  }

  .mobile-more-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
  }

  .mobile-more-panel {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(76px + env(safe-area-inset-bottom));
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
  }

  .mobile-more-action,
  .mobile-more-close {
    flex: 1;
    min-height: 42px;
  }
}
} /* end @layer layout */
