/* ==========================================================================
   BMT (British Messaging Thingyimajig) — layout.css
   Purpose: structural layout only — window chrome, grids, positioning.
   No colors, fonts, or "skin" decisions here. Those live in
   theme-aol.css / theme-pesterchum.css so themes can be swapped freely
   without touching structure.
   ========================================================================== */

/* --------------------------------------------------------------------
   Site header — logo + top nav, shared across every page. Sits in
   normal document flow ABOVE .desktop (not fixed/overlapping), so it
   pushes window positioning down naturally rather than covering it.
   -------------------------------------------------------------------- */

.site-header {
  width: 100%;
  flex-shrink: 0;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 14px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.site-nav__signed-in {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}

/* --------------------------------------------------------------------
   Desktop — the full-page backdrop that windows sit on top of
   -------------------------------------------------------------------- */

.desktop {
  position: relative;
  width: 100%;
  flex: 1;
  overflow: hidden;
}

/* --------------------------------------------------------------------
   Window — the base draggable panel used for login, buddy list,
   chat, and profile. Each page wraps its content in one or more
   .window elements.
   -------------------------------------------------------------------- */

.window {
  position: absolute;
  top: 80px;
  left: 80px;
  display: flex;
  flex-direction: column;
  width: 320px;
  min-width: 220px;
  min-height: 160px;
  resize: both;
  overflow: hidden;
}

.window.is-minimized {
  height: auto !important;
  min-height: 0;
  resize: none;
}

.window.is-minimized .window__body {
  display: none;
}

/* Title bar — drag handle + window controls */
.window__titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 4px 6px;
  cursor: move;
  user-select: none;
}

.window__title {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.window__controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.window__control-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Scrollable body area beneath the title bar */
.window__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}

/* --------------------------------------------------------------------
   Sign-on screen (index.html)
   -------------------------------------------------------------------- */

.signon {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.signon__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.signon__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* --------------------------------------------------------------------
   Two-pane chat layout (chat.html) — overrides the default floating
   .window positioning so the buddy list and chat window sit side by
   side as flex items instead of both stacking at the same 80px/80px
   spot (which is what .window uses by default for single free-floating
   windows like the sign-on screen).
   -------------------------------------------------------------------- */

#bmt-layout {
  align-items: flex-start;
  padding: 40px;
}

#bmt-layout .window {
  position: relative;
  top: auto;
  left: auto;
}

#buddylist-window {
  width: 220px;
  height: 480px;
  flex-shrink: 0;
}

#chat-window {
  width: 480px;
  height: 480px;
  flex: 1;
}

/* --------------------------------------------------------------------
   Buddy list (buddylist.html)
   -------------------------------------------------------------------- */

.buddylist {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.buddylist__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 4px 8px;
}

.buddylist__groups {
  flex: 1;
  overflow-y: auto;
}

.buddy-group {
  display: flex;
  flex-direction: column;
}

.buddy-group__header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
}

.buddy-group__list {
  display: flex;
  flex-direction: column;
}

.buddy-group__list.is-collapsed {
  display: none;
}

.buddy {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  cursor: pointer;
}

.buddy__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.buddy__name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.buddy__status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
}

/* --------------------------------------------------------------------
   Chat window (chat.html)
   -------------------------------------------------------------------- */

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat__log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  min-height: 0;
}

.chat__message {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat__message-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.chat__typing-indicator {
  flex-shrink: 0;
  padding: 2px 8px;
  min-height: 1.2em;
}

.chat__composer {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px 8px;
}

.chat__composer-input {
  flex: 1;
  resize: none;
}

/* --------------------------------------------------------------------
   Profile screen (profile.html)
   -------------------------------------------------------------------- */

.profile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.profile__icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --------------------------------------------------------------------
   Utility classes
   -------------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.flex-row {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-sm { gap: 4px; }
.gap-md { gap: 8px; }
.gap-lg { gap: 16px; }