/* ============================================================
   GOLEX — Base Reset, HTML/Body, Performance Hints, Animations
============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.lucide { display: inline-block; vertical-align: middle; stroke-width: 1.75; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; text-size-adjust: 100%; overscroll-behavior: none; }
html, body {
  width: 100%; height: 100dvh; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  touch-action: pan-y;
}

#main-nav { will-change: transform; }

#toast { will-change: transform, opacity; }

#msgs-wrap, #guild-msgs-wrap, #posts-feed, #user-list-screen,
#rooms-list-wrap, #notif-list, .room-msgs-wrap {
  will-change: scroll-position;
}

img { decoding: async; loading: lazy; }

.msgs-wrap, #chat-area, #posts-feed, #rooms-list-wrap,
.room-msgs-wrap, .notif-list, #saved-panel-body {
  contain: layout style;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#posts-feed, #rooms-list-wrap, #notif-list {
  scroll-behavior: smooth;
}

.msg, .msg-bubble, .room-msg-row { contain: layout style; }

.nav-btn {
  transition: color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease) !important;
}

.post-card { contain: layout style; box-shadow: 0 2px 12px rgba(15, 23, 42, 0.10); }

#posts-feed .post-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 220px; /* estimated card height — prevents layout shift */
}
#rooms-list-wrap .room-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 100px;
}
.notif-item {
  content-visibility: auto;
  contain-intrinsic-size: 0 72px;
}
.user-item {
  content-visibility: auto;
  contain-intrinsic-size: 0 70px;
}

.guild-msg-row {
  content-visibility: auto;
  contain-intrinsic-size: 0 64px;
}
.comm-post-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 160px;
}
.room-msg-row {
  content-visibility: auto;
  contain-intrinsic-size: 0 56px;
}

button, a, [role="button"], label, input[type="checkbox"], input[type="radio"],
input[type="submit"], input[type="button"], input[type="file"],
.nav-btn, .skill-select-pill, .filter-pill, .skill-card, .level-card,
.post-card, .room-card, .rec-card, .user-item, .community-card,
.comm-toggle-btn, .more-drawer-btn, .icon-btn, .back-btn,
.notif-item, .starter, .goal-pill, .avail-pill, .expertise-type-btn,
.proj-task-card, .proj-member-row, .ups-qa-btn {
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {
  .room-member-dot,
  .guild-typing-dots span,
  .typing-dots span,
  .upload-spinner,
  .vault-bubble-spinner,
  .nova-spinner,
  .rec-dot,
  .voice-btn.recording {
    animation: none !important;
  }
  .guild-empty-icon,
  .chat-empty-icon > *,
  .nova-orb {
    animation: none !important;
    transform: none !important;
  }
  .skel, .skeleton-line {
    animation: none !important;
    background: var(--border) !important;
  }
  *, *::before, *::after {
    transition-duration: 50ms !important;
  }
  .screen.active {
    animation-duration: 1ms !important;
  }
}

#shell {
  position: fixed;
  inset: 0;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  z-index: var(--z-shell); display: flex; align-items: stretch; justify-content: stretch; overflow: hidden;
  box-sizing: border-box;
}

body::before {
  content: ''; position: fixed; inset: 0; z-index: var(--z-overlay-bg); pointer-events: none;
  background: radial-gradient(ellipse at 40% 0%, rgba(35, 87, 232, 0.10), transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(5, 150, 105, 0.025), transparent 55%);
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: var(--z-overlay-bg); pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  opacity: 0.35;
}

#app {
  position: relative; width: 100%; height: 100%;
  background: var(--panel-solid);
  border: none; border-radius: 0;
  overflow: hidden; box-shadow: none;
  display: flex; flex-direction: column; transition: box-shadow 0.4s var(--ease); isolation: isolate;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}
@media (min-width: 600px) and (max-width: 767px) {
  #shell { align-items: stretch; justify-content: stretch; }
  #app {
    width: 100%; height: 100dvh;
    border: none; border-radius: 0;
    box-shadow: none;
  }
  .nav-btn .nav-label { display: block; font-size: 8px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  :root { --sidebar-w: 260px; --screen-pb: 0px; }

  #shell { align-items: stretch; justify-content: stretch; }
  #app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .desktop-sidebar {
    display: flex !important;
    flex-direction: column;
    height: 100dvh;
    background: rgba(248, 249, 252, 0.99);
    border-right: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    z-index: var(--z-shell);
  }
  html[data-theme="dev"] .desktop-sidebar {
    background: rgba(21, 32, 43, 0.99);
  }
  .desktop-main {
    display: flex !important;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    background: var(--panel-solid);
    position: relative;
  }
  #main-nav {
    flex-direction: column;
    justify-content: flex-start;
    gap: 3px;
    padding: 10px 6px;
    border-top: 1px solid var(--border);
    border-right: none;
    height: auto;
    order: 99;
    margin-top: auto;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: stretch;
  }
  .nav-btn {
    flex-direction: row;
    gap: 8px;
    justify-content: flex-start;
    width: 100%;
    min-width: unset;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
  }
  .nav-btn .nav-icon { font-size: 17px; }
  .nav-btn .nav-label { display: block; font-size: 11px; text-transform: none; letter-spacing: 0; }
  .nav-btn.active .nav-icon { transform: none; }
  .nav-btn.create-btn { padding: 9px 12px; margin: 4px 0 0 0; justify-content: center; }
  #user-list-screen {
    flex: 1;
    overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding: 14px 12px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.16) transparent;
  }
  .desktop-chrome-only { display: flex !important; }
  #chat-screen, #explore-screen, #create-screen, #downloads-screen,
  #guild-screen, #rooms-screen, #room-chat-screen, #room-create-screen,
  #projects-screen, #project-create-screen, #project-workspace-screen,
  #profile-modal { height: 100%; }
  #toast { bottom: 20px; left: calc(var(--sidebar-w) + 50%); transform: translateX(-50%) translateY(10px); }
  #toast.show { transform: translateX(-50%) translateY(0); }
  #incoming-call-banner { left: calc(var(--sidebar-w) + 12px); right: 12px; }
  #scroll-bottom-btn { right: 16px; }
}

@media (min-width: 1024px) {
  #shell {
    align-items: stretch;
    justify-content: stretch;
  }
  #app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (min-width: 1024px) {
  :root { --sidebar-w: clamp(280px, 22vw, 340px); --screen-pb: 0px; }
}

#app.pre-login .desktop-main {
  display: none !important;
}
#app.pre-login #main-nav {
  display: none !important;
}
#app.pre-login #user-list-screen {
  display: none !important;
}
@media (min-width: 768px) {
  #app.pre-login {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
  }
  #app.pre-login .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    border-right: none;
    background: transparent;
  }
  #app.pre-login .desktop-main {
    display: none !important;
  }
  #app.pre-login #loading-screen,
  #app.pre-login #login-screen,
  #app.pre-login #username-screen {
    flex: 1;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
  }
}
@media (min-width: 1024px) {

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    background: rgba(248, 249, 252, 0.99);
    border-right: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    z-index: var(--z-shell);
    width: var(--sidebar-w);
    flex-shrink: 0;
  }

  .desktop-main {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    background: var(--panel-solid);
    position: relative;
    flex: 1;
    min-width: 0;
    transform: translateZ(0);
    contain: layout;
    isolation: isolate;
  }

  #main-nav {
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    border-right: none;
    height: auto;
    order: 99;
    margin-top: auto;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: stretch;
  }

  .nav-btn {
    flex-direction: row;
    gap: 10px;
    justify-content: flex-start;
    width: 100%;
    min-width: unset;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
  }

  .nav-btn .nav-icon { font-size: 18px; }
  .nav-btn .nav-label { display: block; font-size: 11px; text-transform: none; letter-spacing: 0; }
  .nav-btn.active .nav-icon { transform: none; }

  .nav-btn.create-btn {
    padding: 10px 14px;
    margin: 4px 0 0 0;
    justify-content: center;
  }

  #user-list-screen {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding: 16px 14px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.16) transparent;
  }

#chat-screen,
  #explore-screen,
  #create-screen,
  #downloads-screen,
  #guild-screen,
  #rooms-screen,
  #room-chat-screen,
  #room-create-screen,
  #projects-screen,
  #project-create-screen,
  #project-workspace-screen,
  #profile-modal {
    height: 100%;
  }

  #toast {
    bottom: 24px;
    left: calc(var(--sidebar-w) + 50%);
    transform: translateX(-50%) translateY(10px);
  }
  #toast.show {
    transform: translateX(-50%) translateY(0);
  }

  #incoming-call-banner {
    left: calc(var(--sidebar-w) + 16px);
    right: 16px;
  }

  #scroll-bottom-btn {
    right: 20px;
  }
}
#chat-empty-state {
  display: flex; /* Always flex — hidden via opacity, not display */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 18px;
  text-align: center;
  padding: 40px 32px;
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}
#chat-empty-state.visible {
  opacity: 1;
  pointer-events: auto;
}
.desktop-main .screen.active {
  position: relative;
  z-index: 1;
}
.chat-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(35, 87, 232, 0.09), rgba(5, 150, 105, 0.06));
  border: 1px solid rgba(35, 87, 232, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 0 40px rgba(35, 87, 232, 0.14), inset 0 0 24px rgba(35, 87, 232, 0.03), var(--shadow-md);
  animation: floatSlow 4s ease-in-out infinite;
}
.chat-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.3;
}
.chat-empty-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 260px;
}
.chat-empty-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(35, 87, 232, 0.62);
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 1px solid rgba(35, 87, 232, 0.12);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: rgba(35, 87, 232, 0.10);
}
@media (max-width: 767px) {
  #chat-empty-state { display: none !important; }
}
@media (max-width: 1023px) {
  #chat-empty-state { display: none !important; }
}

@media (min-width: 1280px) {
  :root { --sidebar-w: clamp(300px, 24vw, 380px); }
}

@media (min-width: 1536px) {
  :root { --sidebar-w: clamp(340px, 22vw, 420px); }
  #posts-feed { padding-left: 16px; padding-right: 16px; }
  .post-card { padding: 18px; }
}

@media (max-width: 599px) {
  #app { border-radius: 0; width: 100%; height: 100dvh; border: none; }
  .chrome { border-radius: 0; }
}
@media (max-width: 374px) {
  .screen { padding: 16px 14px; }
  .skill-card-grid { grid-template-columns: repeat(2, 1fr); }
  .onboard-heading { font-size: 22px; }
  .room-card { padding: 12px 14px; margin: 0 6px 6px; }
  .ups-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .btn { padding: 13px 16px; font-size: 13px; }
}

.desktop-chrome-only {
  display: none !important;
}

@media (min-width: 768px) {
  .desktop-chrome-only {
    display: flex !important;
  }
}

.chrome {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94); flex-shrink: 0;
  -webkit-user-select: none;
  position: relative; z-index: 20;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}
html[data-theme="dev"] .chrome {
  background: rgba(21, 32, 43, 0.97);
}
.chrome-logo {
  font-size: 15px; font-weight: 800; letter-spacing: 2px;
  font-family: var(--font-brand); text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-light), var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  display: flex; align-items: center; gap: 6px;
  cursor: default;
}
.chrome-logo::before {
  content: '◆'; font-size: 10px; -webkit-text-fill-color: var(--accent);
  filter: drop-shadow(0 0 5px rgba(35, 87, 232, 0.4));
  font-family: sans-serif;
}
.chrome-dots { display: flex; gap: 5px; }
.chrome-dot {
  width: 9px; height: 9px; border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease);
}
.chrome-dot:nth-child(1) { background: var(--danger); }
.chrome-dot:nth-child(2) { background: var(--warning); }
.chrome-dot:nth-child(3) { background: var(--accent2); }
.chrome-version {
  font-size: 10px; font-family: var(--font-mono);
  color: var(--muted); letter-spacing: 0.5px;
}
.chrome-bell-btn {
  position: relative; background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  width: 32px; height: 32px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease), opacity var(--duration-fast) var(--ease);
}
.chrome-bell-btn:hover { background: var(--border); color: var(--text); }
.chrome-bell-badge {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); display: none;
  border: 1.5px solid var(--surface);
}
.chrome-bell-badge.has-notif { display: block; }

#golex-expand-overlay {
  position: absolute; inset: 0; z-index: 15;
  background: rgba(240, 244, 250, 1.0);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;
}
#golex-expand-overlay.active { opacity: 1; pointer-events: all; }
#golex-expand-overlay .expand-title {
  font-family: var(--font-brand);
  font-size: 52px; font-weight: 400; letter-spacing: 12px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent), var(--accent2));
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  opacity: 0; transform: scale(0.72) translateY(20px);
  transition: none;
  will-change: transform, opacity;
}
#golex-expand-overlay.active .expand-title {
  animation: overlayTitleIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both, shimmer 3s linear 0.8s infinite;
}
#golex-expand-overlay .expand-hex {
  font-size: 28px; opacity: 0; -webkit-text-fill-color: var(--accent);
  filter: drop-shadow(0 0 12px var(--glow-accent));
  transition: none;
  will-change: transform, opacity;
}
#golex-expand-overlay.active .expand-hex {
  animation: overlayHexIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s both;
}
#golex-expand-overlay .expand-tagline {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 3px;
  color: var(--text-secondary); text-transform: uppercase;
  text-align: center; max-width: 320px; line-height: 2;
  opacity: 0; transform: translateY(18px);
  transition: none;
  will-change: transform, opacity;
}
#golex-expand-overlay.active .expand-tagline {
  animation: overlayTaglineIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.48s both;
}
#golex-expand-overlay .expand-tagline span {
  display: inline-block; padding: 3px 10px; margin: 2px;
  border: 1px solid rgba(35, 87, 232, 0.18);
  border-radius: var(--radius-pill);
  background: rgba(35, 87, 232, 0.15);
  transition: color 0.3s var(--ease), background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
#golex-expand-overlay .expand-tagline span:hover { border-color: rgba(35, 87, 232, 0.42); background: rgba(35, 87, 232, 0.10); color: var(--accent); }
#golex-expand-overlay .expand-dismiss {
  font-size: 11px; font-family: var(--font-mono); color: var(--muted);
  letter-spacing: 2px; text-transform: uppercase;
  opacity: 0; transition: opacity 0.25s var(--ease), border-color 0.25s var(--ease);
  cursor: pointer; padding: 6px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  will-change: opacity;
}
#golex-expand-overlay.active .expand-dismiss {
  animation: overlayDismissIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.65s both;
}
#golex-expand-overlay .expand-dismiss:hover { opacity: 1 !important; border-color: var(--border-hover); }

#connection-bar {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px; background: rgba(239, 68, 68, 0.08);
  border-bottom: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 11px; font-family: var(--font-mono); color: var(--danger-light);
  flex-shrink: 0;
  opacity: 0; max-height: 0; overflow: hidden; pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease), max-height var(--duration-normal) var(--ease);
}
#connection-bar.online { background: rgba(16, 185, 129, 0.06); border-color: rgba(16, 185, 129, 0.2); color: var(--success-light); }
#connection-bar.visible { opacity: 1; max-height: 48px; pointer-events: auto; }

.screen { contain: layout style paint; display: none; flex-direction: column; flex: 1; overflow: hidden; padding: var(--content-py) var(--content-px); pointer-events: none; }
.screen.active { display: flex; animation: glx-screenIn 90ms var(--ease-out) both; pointer-events: auto; }
.screen.golex-hidden { display: none !important; }
@keyframes glx-screenIn { from { opacity: 0; } to { opacity: 1; } }
