/*
 * The app's frame (components/shell.js): the sticky top bar, the three columns (left menu,
 * page, right rail), the phone tab bar, page headings, and how it all rearranges on smaller
 * screens. Loaded on every page by index.html.
 */

/* ---------- Top bar ---------- */

/* The top bar and the feed row under it stay at the top together. */
.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar {
  /* Above the feed row under it, so the account menu opens over the row, not behind it. */
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--topbar-row);
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
}

.topbar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar__bell {
  position: relative;
}

.topbar__avatar {
  display: flex;
  border-radius: 50%;
  transition: box-shadow 0.15s;
}

.topbar__avatar:hover {
  box-shadow: 0 0 0 3px var(--surface-sunken);
}

/* ---------- Three-column shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, var(--content-width)) 300px;
  justify-content: center;
  gap: 28px;
  padding: 24px 20px 48px;
}

.shell__left,
.shell__right {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-height) - 48px);
  overflow-y: auto;
}

.shell__main {
  min-width: 0;
}

/* The left menu on computers. */
.side-nav {
  display: grid;
  gap: 2px;
}

.side-nav__link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.side-nav__link:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.side-nav__link.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Quieter links under the main nav: back to the public home page and the roadmap. */
.side-nav__extra {
  display: grid;
  gap: 2px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.side-nav__extra a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-faint);
  font-size: 0.88rem;
  font-weight: 500;
}

.side-nav__extra a:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.side-nav__link.is-active .side-nav__icon {
  color: var(--accent);
}

.side-nav__icon,
.tab-bar__icon {
  position: relative;
  display: flex;
}

/* The bottom tab bar on phones (hidden on wider screens, see Responsive below). */
.tab-bar {
  display: none;
}

/* ---------- Right rail ---------- */

/* The footer always shows at the bottom of the right column, never at the end
   of an endless feed: when the cards are taller than the screen, they scroll
   on their own and the footer stays put. */
.shell__right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.rail-card {
  padding: 14px 16px 6px;
}

.rail-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.rail-card__header h2 {
  font-size: 0.95rem;
}

.rail-card__header a {
  color: var(--accent-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.rail__footer {
  flex: none;
  display: grid;
  gap: 4px;
  padding: 0 4px;
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.rail__footer a:hover {
  text-decoration: underline;
}

/* The "Legal" group: a small heading, then its links on one wrapping line. */
.rail__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  align-items: baseline;
}

.rail__legal strong {
  color: var(--ink-soft);
  font-weight: 700;
}

/* ---------- Pages ---------- */

.page {
  display: grid;
  gap: 16px;
}

.page--centered {
  min-height: 60vh;
  place-items: center;
}

.page__title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

/* A page title with an action or badge on the right. */
.page__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}


.page__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 220px minmax(0, var(--content-width));
  }
  .shell__right {
    display: none;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: calc(var(--content-width) + 32px);
    margin: 0 auto;
    padding: 16px 16px calc(var(--tabbar-height) + 24px);
  }

  .shell__left {
    display: none;
  }

  .topbar {
    gap: 12px;
    padding: 0 16px;
  }

  .topbar__bell {
    display: none;
  }

  .topbar__actions {
    margin-left: auto;
  }

  .tab-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    display: flex;
    height: var(--tabbar-height);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
  }

  .tab-bar__link {
    display: grid;
    flex: 1;
    place-items: center;
    align-content: center;
    gap: 2px;
    color: var(--ink-faint);
    font-size: 0.7rem;
    font-weight: 600;
  }

  .tab-bar__link.is-active {
    color: var(--accent);
  }
}

/* The shortcuts for the space you're in (components/space-menu.js), above the main nav. */
.space-menu {
  display: grid;
  gap: 2px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.space-menu__title {
  padding: 0 14px 6px;
  color: var(--ink-faint);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.space-menu__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
}

.space-menu__link:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.space-menu__link[aria-current] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Rows in the right column that link somewhere (forums, jobs, applications). */
.rail__cards {
  display: grid;
  flex: 0 1 auto;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  /* Room for card shadows inside the scrolling area. */
  padding: 2px;
  margin: -2px;
}

/* One row in a right-column card. */
.rail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  min-width: 0;
}

.rail-row__text {
  display: grid;
  min-width: 0;
}

.rail-row__text strong,
.rail-row__text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-row__text span {
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.rail-row:hover strong {
  text-decoration: underline;
}

.rail-row__emoji {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-sunken);
  font-size: 1rem;
}

.rail-card__empty {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.rail-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  list-style: none;
}

.rail-topics li {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.rail-topics li.is-mine {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

/* "You" at the top of the Pulse and Business panels: followers and following. */
.you-card {
  display: grid;
  gap: 12px;
  padding-bottom: 14px;
}

.you-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.you-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.you-card__stat {
  display: grid;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.you-card__stat strong {
  font-size: 1.15rem;
}

.you-card__stat span {
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.you-card__stat:hover strong {
  text-decoration: underline;
}

/* "Trending now" in the side column (rail.js). */
.rail-trending__label {
  margin: 4px 0 2px;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rail-trending__rule {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 0.75rem;
}

/* You, at the top of the Friends and Photos column (space-menu.js). */
.space-menu__profile {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink);
}

.space-menu__profile:hover {
  background: var(--surface-sunken);
}

.space-menu__profile[aria-current] {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.space-menu__profile-text {
  display: grid;
  min-width: 0;
}

.space-menu__profile-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-menu__profile-text span {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

/* Phones: nothing may push the page wider than the screen. Grid pages let their cards shrink
   to fit instead of growing to their widest row, and anything still too wide is clipped
   (clip, unlike hidden, keeps the sticky top bar working). */
.page {
  grid-template-columns: minmax(0, 1fr);
}

.app {
  overflow-x: clip;
}

/* The feed mode picker under a space's shortcuts (space-menu.js). */
.space-menu__mode {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 0 14px;
}

.space-menu__mode .pill-select {
  width: 100%;
}

/* The page's own menu is now all the left column holds: no dividing line under it. */
.side-nav__wrap > .space-menu {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

/* ---------- Phones: the page's menu slides in from the left (shell.js) ---------- */

.topbar__page-menu,
.page-menu__backdrop {
  display: none;
}

@media (max-width: 820px) {
  .topbar__page-menu:not([hidden]) {
    display: inline-flex;
  }

  .shell .shell__left {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: block;
    width: min(300px, 85vw);
    max-height: none;
    padding: calc(16px + env(safe-area-inset-top)) 12px 24px;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    visibility: hidden;
  }

  .app.is-page-menu-open .shell .shell__left {
    transform: none;
    visibility: visible;
  }

  .page-menu__backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 39;
    display: block;
    background: rgb(0 0 0 / 0.4);
  }
}

@media (max-width: 820px) {
  /* Slide out before hiding, and work on profile pages too (they hide the left column on computers). */
  .shell .shell__left,
  .shell:has(.profile__body) > .shell__left {
    display: block;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }

  .app.is-page-menu-open .shell .shell__left {
    transition: transform 0.25s ease, visibility 0s;
  }
}

/* The right column scrolls with the page: no box with its own scroll bar inside it. */
.shell__right {
  position: static;
  max-height: none;
  overflow: visible;
}

.rail__cards {
  overflow: visible;
  margin: 0;
  padding: 0;
}
