/*
 * The app shell on the design tokens: the open-plane sidebar, the view header, the views' canvases,
 * the phone's top bar, menu sheet and bottom tabs. Behaviour lives in js/shell.js.
 * Loads after deck.css, so equal-specificity rules here win over the deck's legacy ones.
 */
:root {
  --view-head-h: 72px;
  --tabbar-h: 56px;
  --orbit-topbar-h: var(--view-head-h);
}

.icon { flex: none; }
.orbit-mark { width: 24px; height: 24px; flex: none; }

.shell { display: flex; height: calc(100vh - var(--orbit-player-h, 0px)); height: calc(100dvh - var(--orbit-player-h, 0px)); }
.shell a, .shell button, .shell select { font-family: inherit; }
.shell :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.phone-only { display: none; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width); flex: none; display: flex; flex-direction: column;
  padding: 16px 12px 12px; overflow-y: auto; font-size: var(--fs-small); color: var(--text);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px;
  font-size: var(--fs-body); font-weight: 600; color: var(--text); text-decoration: none;
}
.sheet-close { display: none; }
.group-switch { position: relative; margin: 8px 0 20px; }
.group-switch select {
  appearance: none; -webkit-appearance: none; width: 100%; min-height: var(--control-height);
  padding: 0 36px 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text); font-size: var(--fs-small); font-weight: 500;
  text-overflow: ellipsis; cursor: pointer;
}
.group-switch .icon { position: absolute; right: 12px; top: 50%; margin-top: -8px; pointer-events: none; color: var(--muted); }

.nav { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-list a, .nav-list button {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 12px; margin: 0;
  border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: var(--fs-small);
  font-weight: 400; text-align: left; text-decoration: none; cursor: pointer;
}
.nav-list a:hover, .nav-list button:hover { background: color-mix(in srgb, var(--active) 55%, transparent); color: var(--text); }
.nav-list a[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.nav-count, .mobile-tabs .nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-chip);
  background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 600;
  line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
}
.nav-count[hidden] { display: none; }

/* ---- Account row and menu ---- */
.me { position: relative; margin-top: 12px; }
.me-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px;
  border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; cursor: pointer;
}
.me-btn:hover { background: color-mix(in srgb, var(--active) 55%, transparent); }
.me-btn .icon { color: var(--muted); }
.me-avatar .avatar-dot { width: 32px; height: 32px; font-size: 14px; display: inline-flex; border-radius: 50%; }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-name { font-size: var(--fs-small); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-status { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 20; padding: 6px;
  background: var(--surface); border-radius: 12px; box-shadow: 0 8px 24px rgba(27, 29, 31, 0.14); /* taste-skill-ignore: a floating menu */
}
.menu[hidden] { display: none; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; background: none; color: var(--text); font-size: var(--fs-small); text-align: left; cursor: pointer;
}
.menu button:hover { background: var(--active); }
.menu .icon { color: var(--muted); }

/* ---- Main column and view header ---- */
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view-head { height: var(--view-head-h); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 var(--pad); }
.view-head h1 {
  margin: 0; font-size: var(--fs-title); line-height: 1.2; font-weight: 600; letter-spacing: -0.01em;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.view-head h1:focus { outline: none; }
.menu-btn { display: none; }
.view-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.act-quiet {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface);
  color: var(--text); font-size: var(--fs-small); font-weight: 500; cursor: pointer;
}
.act-quiet:hover { background: var(--active); }
.act-post {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 16px; border: 0; border-radius: var(--radius-control);
  background: var(--primary); color: var(--surface); font-size: var(--fs-small); font-weight: 600; cursor: pointer; white-space: nowrap;
}
body:not([data-view="group"]) .group-only { display: none; }

.views { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--pad) var(--pad); }
.view[hidden] { display: none; }
.view[data-view="group"], .view[data-view="read"] { padding: 0; overflow: hidden; }
.deck-container { padding: 0 var(--pad) var(--pad); gap: var(--gap); }
.view[data-view="read"] #orbit-reader {
  height: calc(100vh - var(--view-head-h) - var(--pad) - var(--orbit-player-h, 0px));
  height: calc(100dvh - var(--view-head-h) - var(--pad) - var(--orbit-player-h, 0px));
  margin: 0 var(--pad) var(--pad); border: 0; border-radius: var(--radius-card);
}
.column-tabs { display: none; }
/* Columns share the canvas: two default columns fill it instead of leaving a dead strip. */
.deck-col { max-width: none; }
.view[data-view="read"] .reader-heading { display: none; }

/* Views that mount inline: width of a reading column, old modal furniture removed.
   Events, Activity, and Photos own their width below, so they are excluded here. */
.view:not([data-view="group"]):not([data-view="read"]):not([data-view="settings"]):not([data-view="events"]):not([data-view="activity"]):not([data-view="photos"]) > * { max-width: 760px; }
.view .modal-head { display: none !important; }
.view .modal { max-width: none; width: 100%; max-height: none; overflow: visible; border: 0; border-radius: var(--radius-card); padding: 24px; background: var(--surface); }

/* ---- Activity ---- */
.activity-bar { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 12px; color: var(--muted); font-size: var(--fs-small); }
.activity-list { list-style: none; margin: 0; padding: 8px; background: var(--surface); border-radius: var(--radius-card); }
.activity-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px; border-radius: 12px; }
.activity-item + .activity-item { border-top: 1px solid var(--rule); }
.activity-dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; }
.activity-item[data-unread="true"] .activity-dot { background: var(--accent); }
.view[data-view="activity"] > * { max-width: 1100px; }
.activity-line { font-size: var(--fs-body); max-width: 70ch; }
.activity-item[data-unread="false"] .activity-line { color: var(--muted); }
.activity-summary { margin-top: 2px; font-size: var(--fs-small); color: var(--muted); overflow-wrap: anywhere; max-width: 70ch; }
.activity-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-empty { padding: 32px 24px; background: var(--surface); border-radius: var(--radius-card); color: var(--muted); font-size: var(--fs-small); }
.activity-empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: var(--fs-body); font-weight: 600; }

/* ---- Settings (temporary list until the Settings views) ---- */
.settings-bridge h2 { margin: 24px 0 8px; font-size: var(--fs-section); font-weight: 600; }
.settings-bridge h2:first-child { margin-top: 0; }
.settings-list { background: var(--surface); border-radius: var(--radius-card); padding: 8px; }
.settings-row {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 12px; border: 0; border-radius: 12px;
  background: none; color: var(--text); font-size: var(--fs-small); text-align: left; cursor: pointer;
}
.settings-row:hover { background: var(--ground); }
.settings-row-title { font-weight: 500; }
.settings-row-note { color: var(--muted); font-size: 12px; }

/* ---- Edit status dialog ---- */
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: var(--fs-section); font-weight: 600; }
.status-form { display: flex; flex-direction: column; gap: 16px; }
.avatar-change { display: inline-flex; align-items: center; gap: 12px; align-self: flex-start; border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: var(--fs-small); font-weight: 500; cursor: pointer; }
.avatar-change .avatar-dot { width: 40px; height: 40px; font-size: 16px; }
.status-field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-small); font-weight: 500; }
.status-field input { min-height: var(--control-height); padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); font: inherit; font-weight: 400; }

/* ---- Phone: top bar, menu sheet, bottom tabs ---- */
.mobile-tabs { display: none; }
@media (max-width: 980px) {
  :root { --orbit-topbar-h: calc(48px + var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .shell { display: block; height: auto; }
  .wide-only { display: none; }
  .phone-only { display: inline-flex; align-items: center; }
  .view-head {
    position: sticky; top: 0; z-index: 30; height: 48px; padding: 0 16px 0 8px; gap: 4px; background: var(--ground);
  }
  .view-head h1 { font-size: var(--fs-section); }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
    border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer;
  }
  .menu-btn .icon { width: 20px; height: 20px; }
  .views { display: block; }
  .view { overflow: visible; padding: 0 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
  .view[data-view="group"], .view[data-view="read"] { overflow: visible; padding: 0; }
  .deck-container { padding: 8px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); gap: 16px; min-height: 0; }
  .view[data-view="read"] #orbit-reader {
    height: calc(100dvh - 48px - var(--tabbar-h) - env(safe-area-inset-bottom) - var(--orbit-player-h, 0px));
    margin: 0; border-radius: 0;
  }
  .column-tabs {
    display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 0; scrollbar-width: none;
    position: sticky; top: 48px; z-index: 20; background: var(--ground);
  }
  .column-tabs:empty { display: none; }
  .column-tabs::after { content: ""; flex: 0 0 8px; }
  .column-tabs button {
    flex: 0 0 auto; min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--pill-neutral-bg);
    color: var(--pill-neutral-ink); font: inherit; font-size: var(--fs-small); font-weight: 500; cursor: pointer;
  }
  .column-tabs button.active { background: var(--primary); color: var(--surface); }
  /* The tabs already name the column; its header would say it twice. */
  .column-tabs:not(:empty) ~ .deck-container .col-header { display: none; }

  .sidebar { display: none; }
  body.menu-open .sidebar {
    display: flex; position: fixed; inset: 0; z-index: 200; width: auto; background: var(--ground);
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .sheet-close { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; }
  .nav-list a, .nav-list button { min-height: 44px; }
  .me-btn { min-height: 56px; }

  .mobile-tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--surface);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-top: 1px solid var(--border);
  }
  .mobile-tabs a {
    position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: 12px; font-weight: 500; text-decoration: none;
  }
  .mobile-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; }
  .mobile-tabs .nav-count { position: absolute; top: 6px; left: calc(50% + 6px); margin: 0; }
  html body.orbit-shell #orbit-player { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: 6px; }
}
