/* =============================================================================
   Wagoe Chat shell (ZZP-292)

   The panes of wagoe-chat.ui.core.layout at three widths, on the
   chat-theme.css tokens. Under .chat-app, like the components, to outrank
   the pilot styles that load after it.

     wide    from 1280px   sidebar | main | panel
     medium  768-1279px    sidebar | main, the panel over the main
     narrow  below 768px   one pane; data-pane="list" shows the sidebar;
                           the panel takes the screen; a bottom bar
   ============================================================================= */

/* The pilot's main wrapper and page reset give way to the shell. */
/* A column the height of the screen: a view-as bar above takes its share. */
/* As high as what is visible: chat.js sets --wc-viewport-height from the
   visual viewport, which iOS shrinks for its keyboard where it leaves the
   page as it is. Clear of the notch and the rounded corners (viewport-fit=cover). */
.chat-app.wc-shell-page {
  display: flex; flex-direction: column; box-sizing: border-box;
  height: var(--wc-viewport-height, 100dvh); min-height: 0; margin: 0; overflow: hidden;
}
.chat-app:is(.wc-shell-page, .wc-plain-page) {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.chat-app:is(.wc-shell-page, .wc-plain-page) .main-content { max-width: none; }
.chat-app.wc-shell-page .main-content,
.chat-app .wc-live { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-app.wc-shell-page .main-content { margin: 0; padding: 0; }

.chat-app .wc-app {
  display: grid;
  grid-template-columns: var(--wc-sidebar-width) minmax(0, 1fr);
  flex: 1; min-height: 0;
}
.chat-app .wc-app.has-panel {
  grid-template-columns: var(--wc-sidebar-width) minmax(0, 1fr) var(--wc-panel-width);
}

/* --- Sidebar ---------------------------------------------------------------- */

.chat-app .wc-sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--wc-paper-2); border-right: 1px solid var(--wc-rule);
  font-size: var(--wc-text-sm);
}
.chat-app .wc-workspace {
  display: flex; align-items: center; gap: var(--wc-space-3);
  min-height: var(--wc-header-height); padding: var(--wc-space-2) var(--wc-space-4);
  border-bottom: 1px solid var(--wc-rule);
}
.chat-app .wc-workspace-mark {
  display: grid; place-items: center; flex: none;
  width: var(--wc-size-control); height: var(--wc-size-control);
  border-radius: var(--wc-radius-md);
  background: var(--wc-ink); color: var(--wc-paper);
  font-family: var(--wc-font-serif); font-size: var(--wc-text-md); line-height: 1;
}
.chat-app .wc-workspace-name {
  font-family: var(--wc-font-serif); font-size: var(--wc-text-md);
  letter-spacing: var(--wc-tracking-display); line-height: var(--wc-leading-tight);
  color: var(--wc-ink);
}

.chat-app .wc-nav { list-style: none; margin: 0; padding: var(--wc-space-3) var(--wc-space-2) 0; }
.chat-app .wc-sidebar-body { flex: 1; overflow-y: auto; padding: 0 var(--wc-space-2) var(--wc-space-6); }
.chat-app .wc-sidebar-section { margin-top: var(--wc-space-5); }
.chat-app .wc-sidebar-label {
  margin: 0; padding: 0 var(--wc-space-3) var(--wc-space-1);
  font-family: var(--wc-font-sans); font-size: var(--wc-text-2xs); font-weight: 600;
  letter-spacing: var(--wc-tracking-label); text-transform: uppercase; color: var(--wc-ink-3);
}

/* Nav entries and Me are .wc-conv rows (chat-components.css). */
.chat-app .wc-nav .wc-icon { color: var(--wc-ink-3); }
.chat-app .wc-conv.wc-me {
  height: auto; min-height: var(--wc-header-height);
  padding: var(--wc-space-2) var(--wc-space-4);
  border-radius: 0; border-top: 1px solid var(--wc-rule);
}
.chat-app .wc-me-name { font-weight: 600; color: var(--wc-ink); }
.chat-app .wc-bottom-item:focus-visible { outline: 2px solid var(--wc-focus); outline-offset: -2px; }

/* --- Main ------------------------------------------------------------------- */

.chat-app .wc-main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  overflow-y: auto; background: var(--wc-surface);
}
/* Stays at the top as the pane scrolls under it. */
.chat-app .wc-pane-header {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: var(--wc-space-4); flex: none;
  min-height: var(--wc-header-height); padding: var(--wc-space-2) var(--wc-space-6);
  border-bottom: 1px solid var(--wc-rule);
  background: var(--wc-surface);
}
.chat-app .wc-pane-title-block { flex: 1; min-width: 0; }
/* Display titles: the pane's, the panel's, a plain page's. */
.chat-app :is(.wc-pane-title, .wc-panel-title, .wc-plain h1) {
  margin: 0; color: var(--wc-ink);
  font-family: var(--wc-font-serif); font-weight: 450;
  line-height: var(--wc-leading-tight); letter-spacing: var(--wc-tracking-display);
}
.chat-app .wc-pane-title {
  font-size: var(--wc-text-lg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Wraps: a long member list stays readable. */
.chat-app .wc-pane-sub { margin: var(--wc-space-half) 0 0; color: var(--wc-ink-2); font-size: var(--wc-text-sm); }
.chat-app .wc-pane-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--wc-space-2); }
.chat-app .wc-pane-actions form { margin: 0; }
.chat-app .wc-pane-body { padding: var(--wc-space-4) var(--wc-space-6) var(--wc-space-6); }
.chat-app .wc-back { display: none; }

/* The Me screen's list of places and settings. */
.chat-app .wc-me-list { list-style: none; margin: 0; padding: 0; max-width: var(--wc-card-width); }
.chat-app .wc-me-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--wc-space-3);
  min-height: var(--wc-size-touch); border-bottom: 1px solid var(--wc-rule);
}
.chat-app .wc-me-list a { flex: 1; color: var(--wc-ink); text-decoration: none; padding: var(--wc-space-2) 0; }
.chat-app .wc-me-list a:hover { color: var(--wc-accent); }
.chat-app .wc-me-list form { margin: var(--wc-space-3) 0; }

/* --- Side panel ------------------------------------------------------------- */

.chat-app .wc-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--wc-paper); border-left: 1px solid var(--wc-rule);
}
.chat-app .wc-panel-header {
  display: flex; align-items: center; gap: var(--wc-space-3); flex: none;
  min-height: var(--wc-header-height);
  padding: var(--wc-space-2) var(--wc-space-3) var(--wc-space-2) var(--wc-space-5);
  border-bottom: 1px solid var(--wc-rule);
}
.chat-app .wc-panel-title-block { flex: 1; min-width: 0; }
.chat-app .wc-panel-title { font-size: var(--wc-text-md); }
.chat-app .wc-panel-back { display: none; }
.chat-app .wc-panel-body { flex: 1; overflow-y: auto; padding: var(--wc-space-2) var(--wc-space-5) var(--wc-space-4); }

/* --- Bottom navigation (narrow only) ---------------------------------------- */

.chat-app .wc-bottom-nav { display: none; }

/* --- A page without navigation ---------------------------------------------- */

.chat-app .wc-plain {
  max-width: 36rem; margin: var(--wc-space-10) auto; padding: var(--wc-space-6);
  background: var(--wc-surface); border: 1px solid var(--wc-rule); border-radius: var(--wc-radius-lg);
}
.chat-app .wc-plain h1 { margin-bottom: var(--wc-space-4); font-size: var(--wc-text-xl); }
/* Sign-in and profile: the user module's own cards, so no frame of ours. */
.chat-app .wc-plain:is(.wc-auth, .wc-profile) { border: 0; background: none; padding: 0 var(--wc-space-4); }
.chat-app .wc-plain.wc-auth { max-width: var(--wc-card-width); }
.chat-app .wc-plain.wc-profile { max-width: 50rem; }
.chat-app .wc-profile-back { margin-bottom: var(--wc-space-4); }
/* The app's name above the sign-in forms. */
.chat-app .wc-auth-theme { margin-left: auto; }
.chat-app .wc-auth-brand {
  display: flex; align-items: center; gap: var(--wc-space-3); margin: 0 0 var(--wc-space-5);
  font-family: var(--wc-font-serif); font-size: var(--wc-text-md); color: var(--wc-ink);
}

/* --- Medium: the panel slides over the main ---------------------------------- */

@media (max-width: 1279px) {
  .chat-app .wc-app.has-panel { grid-template-columns: var(--wc-sidebar-width) minmax(0, 1fr); }
  .chat-app .wc-panel {
    /* As high as the page: over iOS's keyboard, bottom: 0 hides the reply box. */
    position: fixed; top: 0; right: 0; z-index: 20;
    box-sizing: border-box; height: var(--wc-viewport-height, 100dvh);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
    width: min(var(--wc-panel-width), 90vw);
    box-shadow: var(--wc-shadow-3);
  }
}

/* --- Narrow: one pane at a time ---------------------------------------------- */

@media (max-width: 767px) {
  .chat-app .wc-app,
  .chat-app .wc-app.has-panel { grid-template-columns: minmax(0, 1fr); }
  /* Room for the bottom bar, fixed over the foot of the screen; it takes the
     safe area too. */
  .chat-app.wc-shell-page { padding-bottom: 0; }
  .chat-app.wc-shell-page .main-content {
    padding-bottom: calc(var(--wc-bottom-nav-height) + env(safe-area-inset-bottom));
  }
  /* Typing (chat.js): the keyboard takes the foot, the bar steps aside so the
     composer sits right above the keys. */
  .wc-typing .chat-app .wc-bottom-nav { display: none; }
  .wc-typing .chat-app.wc-shell-page .main-content { padding-bottom: 0; }
  .chat-app .wc-sidebar { display: none; }
  .chat-app .wc-app[data-pane="list"] .wc-sidebar { display: flex; border-right: 0; }
  .chat-app .wc-app[data-pane="list"] .wc-main { display: none; }
  /* The list screen has the bottom bar: no Home, Saved or Me twice. */
  .chat-app .wc-app[data-pane="list"] :is(.wc-nav, .wc-me) { display: none; }

  .chat-app .wc-panel { position: static; width: auto; height: auto; padding: 0; box-shadow: none; border-left: 0; }
  .chat-app .wc-app.has-panel .wc-main { display: none; }
  .chat-app .wc-panel-back { display: inline-flex; }
  .chat-app .wc-panel-close { display: none; }

  .chat-app .wc-back { display: inline-flex; }
  .chat-app .wc-pane-header { padding: var(--wc-space-1) var(--wc-space-2) var(--wc-space-1) var(--wc-space-4); gap: var(--wc-space-1); }
  .chat-app .wc-pane-header:has(> .wc-back) { padding-left: var(--wc-space-1); }
  .chat-app .wc-pane-title { font-size: var(--wc-text-md); }
  /* One line under the title here: the header stays a header. */
  .chat-app .wc-pane-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-app .wc-pane-body { padding: var(--wc-space-3) var(--wc-space-4) var(--wc-space-4); }
  .chat-app :is(.wc-back, .wc-panel-back) { min-width: var(--wc-size-touch); height: var(--wc-size-touch); }

  .chat-app .wc-bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    height: calc(var(--wc-bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--wc-paper-2); border-top: 1px solid var(--wc-rule);
  }
  .chat-app .wc-bottom-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--wc-space-half);
    color: var(--wc-ink-3); font-size: var(--wc-text-2xs); font-weight: 600; text-decoration: none;
  }
  .chat-app .wc-bottom-item[aria-current="page"] { color: var(--wc-accent); }
}

/* --- Touch: targets of at least 44px, nothing only on hover ------------------ */

@media (pointer: coarse) {
  .chat-app :is(.wc-btn, .wc-icon-btn, .wc-toggle, .wc-conv, .wc-bottom-item, .thread-summary) {
    min-height: var(--wc-size-touch);
  }
  .chat-app .wc-icon-btn { min-width: var(--wc-size-touch); }
  .chat-app .wc-composer-bar { gap: var(--wc-space-2); }
}

