/* Midway Space — early-Facebook inspired, mobile-first */
:root {
  --blue: #3b5998;
  --blue-dark: #2d4373;
  --blue-light: #6d84b4;
  --bg: #e9ebee;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #606770;
  --border: #dddfe2;
  --danger: #a33;
  --success: #2d7a3e;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.08);
  --nav-h: 52px;
  --max: 960px;
  font-family: "Lucida Grande", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; display: block; }

.topnav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--blue);
  color: #fff;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.topnav a { color: #fff; text-decoration: none; }
.topnav .brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  margin-right: 1rem;
  white-space: nowrap;
  color: #fff;
}
.brand--logo {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}
/* Mobile centered Menu button */
.brand--mobile {
  display: none;
  align-items: center;
  gap: .4rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px;
  padding: .4rem .7rem;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.02em;
  color: #fff;
  margin-right: 0;
  z-index: 2;
}
.brand--mobile:active {
  background: rgba(255,255,255,.2);
}
.brand--mobile .brand-caret {
  font-size: .75rem;
  opacity: .95;
  transition: transform .15s ease;
  line-height: 1;
}
.topnav.is-menu-open .brand--mobile .brand-caret {
  transform: rotate(180deg);
}
.topnav .nav-links {
  display: flex;
  gap: .15rem;
  flex: 1;
  overflow-x: auto;
  align-items: center;
}
.topnav .nav-links a {
  padding: .45rem .55rem;
  border-radius: 4px;
  font-size: .9rem;
  white-space: nowrap;
}
.topnav .nav-links a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.topnav .nav-right { display: flex; align-items: center; gap: .5rem; margin-left: .5rem; }
.badge {
  background: #f02849;
  color: #fff;
  border-radius: 10px;
  padding: 0 .4rem;
  font-size: .7rem;
  font-weight: 700;
  margin-left: .15rem;
}

/* Mobile dropdown */
.nav-menu-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: var(--nav-h);
  z-index: 250;
  background: var(--blue-dark);
  border-top: 1px solid rgba(255,255,255,.12);
  padding: .35rem 0 .55rem;
  box-shadow: 0 10px 24px rgba(0,0,0,.28);
  max-height: min(70vh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.topnav.is-menu-open .nav-menu-panel {
  display: block;
}
.nav-menu-list {
  display: flex;
  flex-direction: column;
  padding: .25rem .5rem .5rem;
}
.nav-menu-list > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem .9rem;
  border-radius: 6px;
  color: #fff;
  font-size: 1.05rem;
  text-decoration: none;
}
.nav-menu-list > a:hover,
.nav-menu-list > a:focus {
  background: rgba(255,255,255,.12);
  text-decoration: none;
}
.nav-menu-user {
  margin-top: .25rem;
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: .85rem !important;
  opacity: .95;
  font-weight: 600;
}

/* Like button: clear active state */
.post-actions .btn.liked,
button.liked[data-like-url] {
  background: var(--blue) !important;
  color: #fff !important;
  border-color: var(--blue-dark) !important;
  font-weight: 700;
}
.post-actions .btn.liked:hover {
  background: var(--blue-dark) !important;
  color: #fff !important;
}
.comment-like.liked {
  color: var(--blue) !important;
  font-weight: 700;
  background: #e7f0ff;
  border-radius: 4px;
  padding: .1rem .35rem;
}

/* Event cards on feed */
.event-feed-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f0f4fb;
  padding: .75rem 1rem;
  margin: .5rem 0;
  display: block;
  color: inherit;
  text-decoration: none;
}
.event-feed-card:hover {
  background: #e4ecf8;
  text-decoration: none;
}
.event-feed-card--cancelled {
  background: #f5f5f5;
  border-color: #ddd;
}
.event-feed-card--cancelled .event-feed-label {
  color: var(--danger);
}
.event-feed-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--blue);
  margin-bottom: .25rem;
}
.event-feed-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 .25rem;
  color: var(--text);
}
.event-feed-meta {
  color: var(--muted);
  font-size: .9rem;
}
.event-cancelled-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #fff;
  background: var(--danger);
  border-radius: 4px;
  padding: .15rem .4rem;
  vertical-align: middle;
  margin-left: .35rem;
}
.event-cancelled-banner {
  background: #fdecea;
  border: 1px solid #f5c2c0;
  border-radius: var(--radius);
  padding: .65rem .85rem;
  margin-bottom: .75rem;
  color: var(--danger);
}
.event-struck {
  text-decoration: line-through;
  opacity: .75;
}
.push-status-ok { color: var(--success); }
.push-status-error { color: var(--danger); }

/* @mentions */
a.mention,
span.mention {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}
a.mention:hover { text-decoration: underline; }
span.mention-everyone {
  display: inline-block;
  background: #e7f0ff;
  color: var(--blue, #3b5998);
  padding: .05rem .4rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: .9em;
}
.comment-author {
  font-weight: 700;
  color: var(--blue);
  margin-right: .35rem;
  text-decoration: none;
}
.comment-author:hover { text-decoration: underline; }
.comment-avatar-link {
  flex-shrink: 0;
  text-decoration: none;
}
.comment-body { word-wrap: break-word; }
.post-tags { margin: .35rem 0; }
.mention-menu {
  position: absolute;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-height: 200px;
  overflow-y: auto;
  min-width: 180px;
  display: none;
}
.mention-menu.open { display: block; }
.mention-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: .5rem .75rem;
  font: inherit;
  cursor: pointer;
}
.mention-menu button:hover,
.mention-menu button.active {
  background: #e7f0ff;
}

/* Mobile: logo left, Menu centered */
@media (max-width: 799px) {
  .nav-links--desktop,
  .nav-right--desktop {
    display: none !important;
  }
  .brand--mobile {
    display: inline-flex;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  .topnav.is-menu-open .brand--mobile {
    /* keep caret rotation without fighting centering */
    transform: translateX(-50%);
  }
  .topnav.is-menu-open .brand--mobile .brand-caret {
    transform: rotate(180deg);
  }
  .topnav {
    position: sticky;
    justify-content: flex-start;
  }
}

/* Desktop: logo + horizontal tabs */
@media (min-width: 800px) {
  .brand--mobile {
    display: none !important;
  }
  .nav-menu-panel {
    display: none !important;
  }
}

.layout {
  max-width: var(--max);
  margin: 0 auto;
  padding: .75rem;
}
.layout-2col {
  display: grid;
  gap: .75rem;
}
@media (min-width: 800px) {
  .layout-2col { grid-template-columns: 1fr 280px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
  overflow: hidden;
}
.card-body { padding: .85rem 1rem; }
.card-header {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: #f5f6f7;
}

.input, select.input, textarea.input {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
textarea.input { resize: vertical; }
label { display: block; font-weight: 600; margin: .5rem 0 .25rem; font-size: .9rem; }
.help { color: var(--muted); font-size: .85rem; }
.form-row { margin-bottom: .65rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: .45rem .9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #e4e6eb; color: var(--text); }
.btn-secondary:hover { background: #d8dadf; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8b2222; color: #fff; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-link { background: none; color: var(--blue); border: none; padding: .2rem; font-weight: 600; cursor: pointer; }

.messages { list-style: none; padding: 0; margin: 0 0 .75rem; }
.messages li {
  padding: .65rem .85rem;
  border-radius: 6px;
  margin-bottom: .4rem;
  background: #e7f3ff;
  border: 1px solid #cce0ff;
}
.messages li.error, .messages .error { background: #fdecea; border-color: #f5c2c0; color: var(--danger); }
.messages li.success { background: #eaf6ec; border-color: #b7dfc0; color: var(--success); }

/* Auth */
.auth-wrap {
  max-width: 420px;
  margin: 2rem auto;
  padding: 0 .75rem;
}
.auth-card { padding: 1.25rem; }
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.4rem; color: var(--blue); }
.auth-card .sub { color: var(--muted); margin-bottom: 1rem; }

/* Feed / posts */
.post-composer textarea { min-height: 72px; }
/* Collapsible extra fields (audience / album / files) */
.post-options {
  margin: .35rem 0 .75rem;
}
.post-options-toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--blue, #3b5998);
  user-select: none;
}
.post-options-toggle::-webkit-details-marker { display: none; }
.post-options-toggle::before {
  content: "▸";
  display: inline-block;
  font-size: .75rem;
  transition: transform .15s ease;
  color: var(--blue, #3b5998);
}
.post-options[open] > .post-options-toggle::before {
  transform: rotate(90deg);
}
.post-options-toggle:hover {
  text-decoration: underline;
}
.post-options-panel {
  margin-top: .65rem;
  padding: .75rem .85rem;
  border: 1px solid var(--border, #dddfe2);
  border-radius: 8px;
  background: #f7f8fa;
}
.post-composer-actions {
  margin-bottom: 0;
}
.post-meta {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .5rem;
}
/* Avatar framing (zoom + pan via CSS variables --ax --ay --az) */
.avatar-wrap {
  border-radius: 50%;
  overflow: hidden;
  background: #ccd0d5;
  flex-shrink: 0;
  position: relative;
}
.avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--ax, 50%) var(--ay, 50%);
  transform: scale(var(--az, 1));
  transform-origin: var(--ax, 50%) var(--ay, 50%);
  display: block;
}
.avatar-wrap--empty { background: #ccd0d5; }
.avatar-wrap--clickable { cursor: zoom-in; }
.avatar-sm, .avatar-wrap.avatar-sm { width: 32px; height: 32px; }
.avatar-md, .avatar-wrap.avatar-md, .avatar {
  width: 40px;
  height: 40px;
}
.avatar-lg, .avatar-wrap.avatar-lg, .profile-avatar {
  width: 120px;
  height: 120px;
  border: 4px solid #fff;
  box-shadow: var(--shadow);
}
/* legacy bare img.avatar still used nowhere after partial, keep safe */
img.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #ccd0d5;
  flex-shrink: 0;
}
.avatar-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}
.avatar-sliders { min-width: 200px; }

/* Display name color / font on profile edit */
.name-style-preview {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 100px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue-dark));
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
}
.name-style-preview-inner {
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(2px);
  border-radius: 8px;
  padding: .5rem .75rem;
}
.name-style-preview .profile-name {
  margin: 0;
  font-size: 1.35rem;
}
.color-input {
  width: 4rem;
  height: 2.4rem;
  padding: .15rem;
  cursor: pointer;
}
.post-author { font-weight: 700; }
.post-time { color: var(--muted); font-size: .85rem; }
.post-audience {
  display: inline-block;
  font-size: .75rem;
  background: #f0f2f5;
  color: var(--muted);
  padding: .1rem .4rem;
  border-radius: 4px;
  margin-left: .25rem;
}
.post-body { white-space: pre-wrap; word-wrap: break-word; margin: .4rem 0; }
.post-media {
  display: grid;
  gap: 2px;
  margin: .5rem 0;
  background: #000;
}
.post-media.grid-2 { grid-template-columns: 1fr 1fr; }
.post-media img, .post-media video {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  background: #000;
  cursor: zoom-in;
}
.media-pending {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: 1.25rem;
  background: linear-gradient(145deg, #1c1e21 0%, #3a3b3c 100%);
  color: #e4e6eb;
  text-align: center;
}
.media-pending-text { font-size: .95rem; line-height: 1.35; max-width: 16rem; }
.media-pending-text .help { color: #b0b3b8; margin-top: .35rem; }
.media-pending-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #8ab4f8;
  border-radius: 50%;
  animation: ms-spin .8s linear infinite;
}
@keyframes ms-spin {
  to { transform: rotate(360deg); }
}
.media-failed {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3a3b3c;
  color: #f28b82;
  padding: 1rem;
}
.upload-progress {
  margin-top: .35rem;
  font-weight: 600;
  color: var(--blue, #3b5998);
}
.post-composer-form.is-uploading .js-composer-submit {
  opacity: .75;
  pointer-events: none;
}
.link-preview {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: .5rem 0;
  display: grid;
  grid-template-columns: 100px 1fr;
}
.link-preview img { width: 100px; height: 100px; object-fit: cover; }
.link-preview .lp-body { padding: .5rem .65rem; }
.link-preview .lp-title { font-weight: 700; font-size: .9rem; }
.link-preview .lp-desc { color: var(--muted); font-size: .8rem; }
.post-actions {
  display: flex;
  gap: .25rem;
  border-top: 1px solid var(--border);
  padding-top: .4rem;
  margin-top: .5rem;
}
.post-actions form { display: inline; }
.comments { margin-top: .5rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.comment {
  display: flex;
  gap: .5rem;
  margin-bottom: .45rem;
  font-size: .92rem;
}
.comment-bubble {
  background: #f0f2f5;
  border-radius: 12px;
  padding: .35rem .65rem;
  flex: 1;
}
.comment-author { font-weight: 700; margin-right: .25rem; }
.comment-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .2rem;
}
.comment-like {
  font-size: .8rem;
  color: var(--muted);
  padding: 0;
}
.comment-like.liked {
  color: var(--blue);
  font-weight: 700;
}
.comment-like:hover { color: var(--blue); }

/* People directory */
.people-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.people-row:hover {
  background: #f5f6f7;
  text-decoration: none;
}
.people-row:last-child { border-bottom: none; }
.people-meta { flex: 1; min-width: 0; }
.people-bio { margin-top: .15rem; }
.people-chevron {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

/* Profile */
.profile-banner {
  height: 200px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue-dark));
  background-size: cover;
  background-position: center center;
  position: relative;
}
.profile-banner--has-image {
  cursor: zoom-in;
}
.profile-banner--has-image:focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
.banner-preview {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
}
.banner-position-slider {
  flex: 1;
  min-width: 120px;
  accent-color: var(--blue);
}
.banner-reframe .profile-banner {
  max-height: 200px;
}
.profile-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: -48px;
  padding: 0 1rem 1rem;
  position: relative;
}
/* profile header uses .avatar-wrap.avatar-lg */
.profile-header .avatar-wrap.avatar-lg {
  width: 120px;
  height: 120px;
  border: 4px solid #fff;
  box-shadow: var(--shadow);
}
.profile-name { font-size: 1.5rem; font-weight: 700; margin: 0; }
.profile-bio { color: var(--muted); margin: .25rem 0 0; }
.pinned-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.92);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.lightbox.open { display: flex; }
.lightbox img, .lightbox video {
  max-width: min(100%, 1100px);
  max-height: 90vh;
  object-fit: contain;
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: .75rem;
  right: 1rem;
  color: #fff;
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

/* Chat */
.chat-layout {
  display: grid;
  gap: .75rem;
  height: calc(100vh - var(--nav-h) - 1.5rem);
}
@media (min-width: 800px) {
  .chat-layout { grid-template-columns: 260px 1fr; }
}
.chat-list a {
  display: block;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.chat-list a:hover { background: #f5f6f7; }
.chat-room {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 360px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.bubble {
  max-width: 80%;
  padding: .5rem .75rem;
  border-radius: 12px;
  background: #f0f2f5;
  align-self: flex-start;
  word-wrap: break-word;
}
.bubble.mine {
  background: #dce6f8;
  align-self: flex-end;
}
.bubble .meta { font-size: .75rem; color: var(--muted); margin-top: .2rem; }
.chat-compose {
  display: flex;
  gap: .4rem;
  padding: .65rem;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-compose input[type="text"] { flex: 1; }
.typing-indicator {
  font-size: .8rem;
  color: var(--muted);
  padding: 0 .75rem .35rem;
  min-height: 1.2rem;
}
.read-receipt { font-size: .7rem; color: var(--muted); }

/* Family tree */
.tree-board {
  min-height: 280px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: #fafbfc;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-start;
}
.tree-node {
  background: #fff;
  border: 2px solid var(--blue);
  border-radius: 10px;
  padding: .65rem .85rem;
  text-align: center;
  min-width: 100px;
  box-shadow: var(--shadow);
}
.tree-node.focus { background: var(--blue); color: #fff; border-color: var(--blue-dark); }
.tree-node.focus a { color: #fff; }
.tree-edge-label { font-size: .75rem; color: var(--muted); width: 100%; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Toast notifications */
#toast-root {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.toast {
  background: #1c1e21;
  color: #fff;
  padding: .65rem .9rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  max-width: 320px;
  font-size: .9rem;
  animation: slideIn .2s ease;
}
@keyframes slideIn {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (max-width: 600px) {
  .profile-banner { height: 140px; }
  .profile-header .avatar-wrap.avatar-lg,
  .avatar-wrap.avatar-lg { width: 88px; height: 88px; }
  .link-preview { grid-template-columns: 1fr; }
  .link-preview img { width: 100%; height: 140px; }
}
