/* voi — the frame: sidebar/drawer, bars that hide while scrolling, your own photos.
   Works in both looks (calm notebook and candy café); colours come from the tokens. */

:root { --side-w: 248px; }
.side-collapsed { --side-w: 76px; }

/* ── sidebar (wide screens) / drawer (phones) ─────────────────────────────── */
.sidebar {
  position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: min(84vw, 280px);
  display: flex; flex-direction: column; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 14px) 12px calc(env(safe-area-inset-bottom) + 14px);
  background: color-mix(in srgb, var(--raised) 94%, transparent); backdrop-filter: blur(18px) saturate(1.2);
  border-right: 1px solid var(--rule); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-104%); transition: transform .32s cubic-bezier(.2, .8, .2, 1), width .28s ease;
  box-shadow: 8px 0 30px color-mix(in srgb, var(--ink) 10%, transparent);
}
.drawer-open .sidebar { transform: none; }
.drawer-bg { position: fixed; inset: 0; z-index: 69; background: color-mix(in srgb, var(--ink) 26%, transparent); display: none; animation: fade .2s; }
.drawer-open .drawer-bg { display: block; }

.side-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 14px; }
.side-brand { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.side-logo { font-family: var(--display); font-size: 1.45rem; line-height: 1.05; color: var(--me-strong); }
.side-icon { width: 30px; height: 30px; border-radius: 9px; vertical-align: middle; margin-right: 8px; }
.side-title { display: flex; align-items: center; }
.side-collapsed .side-logo { display: none; }
.side-sub { font-size: .78rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-collapse {
  width: 34px; height: 34px; flex: none; border-radius: 10px; border: 1px solid var(--rule); background: var(--raised);
  color: var(--ink-soft); cursor: pointer; font-size: 1.05rem; line-height: 1; display: none;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 14px;
  text-decoration: none; color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem; text-align: left;
  border: 0; background: transparent; cursor: pointer; transition: background .2s, color .2s;
}
.side-link:hover { background: color-mix(in srgb, var(--me) 9%, transparent); }
.side-link.active { background: var(--me-tint); color: var(--me-strong); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--me) 35%, transparent); }
.side-link .i { width: 22px; height: 22px; flex: none; display: block; }
.side-link .i svg { width: 100%; height: 100%; }
.side-link .badge { position: static; margin-left: auto; animation: none; }
.side-sep { height: 1px; background: var(--rule); margin: 10px 8px; }
.side-me {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: .9rem; border: 1px solid var(--rule);
}
.side-me .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar.sm { width: 32px; height: 32px; font-size: .9rem; }

.menu-btn { font-size: 1.15rem; }

/* wide screens: the sidebar is always there, collapsible to an icon rail */
@media (min-width: 900px) {
  #app:has(> .sidebar) { padding-left: var(--side-w); transition: padding-left .28s ease; }
  .sidebar { transform: none; width: var(--side-w); box-shadow: none; }
  .side-collapse { display: grid; place-items: center; }
  .nav, .menu-btn, .drawer-bg { display: none !important; }
  main { padding-bottom: 48px; }
  .chat { height: calc(100dvh - 92px - env(safe-area-inset-top)); }
  .fab { bottom: 28px; }
  .side-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
  .side-collapsed .sidebar .l, .side-collapsed .side-sub { display: none; }
  .side-collapsed .side-head { flex-direction: column; padding-bottom: 10px; }
  .side-collapsed .side-logo { font-size: 1.2rem; }
  .side-collapsed .side-collapse { transform: rotate(180deg); }
  .side-collapsed .side-link { justify-content: center; padding: 8px; }
  .side-collapsed .side-link .badge { position: absolute; top: 2px; right: 4px; }
  .side-collapsed .side-me { justify-content: center; padding: 8px 4px; border: 0; }
}

/* ── bars slide away while scrolling down, come back on scroll up ─────────── */
.topbar, .nav { transition: transform .32s cubic-bezier(.2, .8, .2, 1); }
.bars-hidden .topbar { transform: translateY(-110%); }
.bars-hidden .nav { transform: translateY(calc(100% + 28px + env(safe-area-inset-bottom))); }
@media (prefers-reduced-motion: reduce) {
  .topbar, .nav, .sidebar, #app { transition: none; }
}

/* ── your own photos ──────────────────────────────────────────────────────── */
.avatar .av-img, .map-pin .av-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
button.av-edit { border: 0; padding: 0; cursor: pointer; font: inherit; }
.av-edit .av-cam {
  position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; font-style: normal;
  display: grid; place-items: center; font-size: .7rem; background: var(--raised); border: 1px solid var(--rule);
}
.linkish { border: 0; background: none; padding: 0; margin-top: 2px; color: var(--me-strong); font: inherit; font-size: .82rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* background photo behind everything, softened by a paper-coloured veil */
html.has-wall body { background-image: var(--wall); background-size: cover; background-position: center; background-attachment: fixed; }
html.has-wall body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--paper); opacity: var(--wall-dim, .55);
}
/* over a photo, surfaces turn into frosted paper */
html.has-wall :is(.card, .topbar, .nav, .sidebar) { background: color-mix(in srgb, var(--raised) 84%, transparent); backdrop-filter: blur(14px) saturate(1.15); }

/* ── collapsible sections in the sidebar (Life tools, Play games) ─────────── */
.side-row { display: flex; align-items: center; }
.side-row .side-link { flex: 1; min-width: 0; }
.side-toggle {
  width: 34px; height: 34px; flex: none; border: 0; border-radius: 10px; background: transparent; color: var(--ink-soft);
  cursor: pointer; font-size: .9rem; transition: transform .2s, background .2s;
}
.side-toggle:hover { background: color-mix(in srgb, var(--me) 9%, transparent); }
.side-group:not(.open) .side-toggle { transform: rotate(-90deg); }
.side-sub { display: none; padding: 2px 0 6px 18px; margin-left: 18px; border-left: 1px solid var(--rule); }
.side-group.open .side-sub { display: block; }
.side-sub-h { font-size: .74rem; font-weight: 700; color: var(--ink-soft); margin: 8px 8px 2px; }
.side-sublink {
  display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 5px 10px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-size: .88rem;
}
.side-sublink:hover { background: color-mix(in srgb, var(--me) 8%, transparent); }
.side-sublink.active { background: var(--me-tint); color: var(--me-strong); font-weight: 700; }
.side-sublink .e { width: 20px; text-align: center; flex: none; }
@media (min-width: 900px) {
  .side-collapsed .side-toggle, .side-collapsed .side-sub { display: none !important; }
}
