/* The officer hub: the Officers tab signed out (public roster, sign in) and signed in (the hub
   shell), plus the shared pieces in /js/hub/ui.js: badges, avatars, dialogs, toasts, empty and
   error states. Colors come from the tokens in app.css, so light and dark both work. */

:root {
  /* Avatar tones: a tinted circle with readable initials in either theme. */
  --tone-0-bg: #0e4f5c; --tone-0-fg: #cffafe;
  --tone-1-bg: #3a5313; --tone-1-fg: #ecfccb;
  --tone-2-bg: #46307a; --tone-2-fg: #ede9fe;
  --tone-3-bg: #6b4410; --tone-3-fg: #fef3c7;
  --tone-4-bg: #6d2239; --tone-4-fg: #ffe4e6;
  --tone-5-bg: #1e3a8a; --tone-5-fg: #dbeafe;
  --scrim: rgba(2, 6, 16, 0.66);
}

@media (prefers-color-scheme: light) {
  :root {
    --tone-0-bg: #cffafe; --tone-0-fg: #155e75;
    --tone-1-bg: #e4f7c5; --tone-1-fg: #3f6212;
    --tone-2-bg: #ede9fe; --tone-2-fg: #5b21b6;
    --tone-3-bg: #fef3c7; --tone-3-fg: #92400e;
    --tone-4-bg: #ffe4e6; --tone-4-fg: #9f1239;
    --tone-5-bg: #dbeafe; --tone-5-fg: #1e40af;
    --scrim: rgba(15, 23, 42, 0.45);
  }
}

/* ---------- avatars ---------- */

.hub-avatar {
  flex: none;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  font-weight: 800; font-size: 15px; letter-spacing: 0.02em;
  background: var(--surface-2); color: var(--text);
  user-select: none; -webkit-user-select: none;
}
.hub-avatar.size-sm { width: 28px; height: 28px; font-size: 12px; }
.hub-avatar.size-lg { width: 52px; height: 52px; font-size: 19px; }
.hub-avatar.tone-0 { background: var(--tone-0-bg); color: var(--tone-0-fg); }
.hub-avatar.tone-1 { background: var(--tone-1-bg); color: var(--tone-1-fg); }
.hub-avatar.tone-2 { background: var(--tone-2-bg); color: var(--tone-2-fg); }
.hub-avatar.tone-3 { background: var(--tone-3-bg); color: var(--tone-3-fg); }
.hub-avatar.tone-4 { background: var(--tone-4-bg); color: var(--tone-4-fg); }
.hub-avatar.tone-5 { background: var(--tone-5-bg); color: var(--tone-5-fg); }
.hub-avatar.is-open { background: transparent; color: var(--muted); border: 1.5px dashed var(--line-strong); font-size: 20px; font-weight: 500; }
.hub-avatar.is-system { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-strong); }

/* ---------- signed out: public roster and sign in ---------- */

.hub-public { margin-top: 12px; }
.hub-public-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin: 18px 0 24px; }
.hub-public-head h1 { margin-bottom: 6px; }
.hub-public-head h1:focus { outline: none; } /* focused by script after signing out, not a control */
.hub-public-head .lede { margin: 0; max-width: 620px; }
.hub-jump { display: none; flex: none; }

.hub-public-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.hub-roster { min-width: 0; }

.hub-group + .hub-group { margin-top: 26px; }
.hub-group h2 { font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.hub-seats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.hub-seat {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 14px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.hub-seat-text { display: grid; gap: 1px; min-width: 0; }
.hub-seat-name { font-weight: 750; font-size: 16px; overflow-wrap: anywhere; }
.hub-seat-role { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.hub-seat.is-open { background: transparent; border-style: dashed; border-color: var(--line-strong); }
.hub-seat-link { font-size: 14px; font-weight: 650; margin-top: 4px; }

.hub-signin { position: sticky; top: 16px; }
.hub-signin h2 { font-size: 20px; margin-bottom: 4px; }
.hub-signin > .hint { margin-bottom: 16px; }
.hub-signin .notice { margin: 0 0 14px; }
.hub-deep-note { border-left-color: var(--accent); }
.hub-signin-form label { margin-bottom: 8px; }
input[type="text"].hub-code {
  min-height: 56px; margin-bottom: 10px;
  font: 700 22px/1 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.16em; text-align: center; text-transform: uppercase;
}
input[type="text"].hub-code::placeholder { letter-spacing: 0.16em; opacity: 0.45; }
.hub-signin .form-error { margin: 0 0 10px; }
.hub-signin-ready { margin: 0 0 10px; color: var(--ok); font-weight: 600; }
/* Messages that screen readers announce stay in the page while empty (display: none would take
   them out, and a region that reappears with its text is often not read). Empty, they take no room. */
.hub-signin .form-error:empty, .hub-signin-ready:empty, .hub-dialog-error:empty { display: block; margin: 0; }
.hub-signin-foot { margin: 14px 0 0; }

/* ---------- signed in: the hub shell ---------- */

.hub { margin-top: 14px; }
/* Keyboard focus and "scroll into view" stop below the tab bar that sticks to the top. */
html:has(.hub-tabbar) { scroll-padding-top: 84px; }
.hub-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; margin-top: 16px; }
.hub-hello { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hub-hello-text { min-width: 0; }
.hub-hello .kicker { margin-bottom: 2px; }
.hub-greeting { margin: 0; font-size: clamp(24px, 4.2vw, 32px); overflow-wrap: anywhere; }
.hub-greeting:focus { outline: none; }
.hub-role { margin: 2px 0 0; color: var(--muted); font-weight: 600; }
.hub-top-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.hub-tabbar {
  position: sticky; top: 0; z-index: 6;
  margin: 18px 0 22px; padding: 8px 0;
  background: var(--bg);
}
.hub-tabs {
  position: relative;
  display: flex; gap: 4px; padding: 4px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.hub-tabs::-webkit-scrollbar { display: none; }
/* More tabs off to one side (officers.js sets these while the row scrolls): fade that edge. */
.hub-tabs.more-after {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}
.hub-tabs.more-before {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
}
.hub-tabs.more-before.more-after {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}
.hub-tabs a {
  flex: none; display: inline-flex; align-items: center; min-height: 40px;
  padding: 0 15px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 650; font-size: 14px; white-space: nowrap;
}
.hub-tabs a:hover { color: var(--text); background: var(--surface-2); }
.hub-tabs a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.hub-tabs a:focus-visible { outline-offset: -2px; }

.hub-content { min-height: 240px; transition: opacity 0.15s 0.1s; }
.hub-content.is-loading { opacity: 0.55; pointer-events: none; }
.hub-section:focus { outline: none; }
.hub-section h2[tabindex="-1"]:focus, .hub-message h2:focus, .hub-error h2:focus { outline: none; }

/* ---------- section parts (ui.js) ---------- */

.hub-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.hub-head-text { min-width: 0; }
.hub-title { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
.hub-lede { color: var(--muted); margin: 4px 0 0; max-width: 680px; }
.hub-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.hub-empty {
  text-align: center; padding: 40px 22px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface);
}
.hub-empty-title { font-weight: 750; font-size: 17px; margin: 0 0 6px; }
.hub-empty-body { color: var(--muted); max-width: 460px; margin: 0 auto; }
.hub-empty-action { margin-top: 16px; }

.hub-loading { display: flex; align-items: center; gap: 10px; padding: 36px 4px; color: var(--muted); }
.hub-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: hub-spin 0.8s linear infinite;
}
@keyframes hub-spin { to { transform: rotate(360deg); } }

.hub-error, .hub-message { max-width: 620px; }
.hub-error { border-left: 4px solid var(--danger); }
.hub-error-title, .hub-message h2 { font-size: 19px; }
.hub-error-body { color: var(--muted); }
.hub-error-actions, .hub-message-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.hub-error-details { margin-top: 14px; font-size: 13px; color: var(--muted); }
.hub-error-details summary { cursor: pointer; }
.hub-error-details p { margin: 6px 0 0; overflow-wrap: anywhere; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.hub-field { margin-bottom: 16px; }
.hub-field-hint { margin: 6px 0 0; }

/* Form controls app.css does not style yet, so every section's editors match. */
.hub textarea, .hub-dialog textarea,
.hub input[type="date"], .hub-dialog input[type="date"],
.hub input[type="number"], .hub-dialog input[type="number"],
.hub input[type="email"], .hub-dialog input[type="email"],
.hub input[type="url"], .hub-dialog input[type="url"],
.hub input[type="tel"], .hub-dialog input[type="tel"],
.hub input[type="search"], .hub-dialog input[type="search"] {
  width: 100%; min-height: 46px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px;
}
.hub textarea, .hub-dialog textarea { padding: 10px 12px; line-height: 1.5; min-height: 120px; resize: vertical; }
.hub textarea:focus, .hub-dialog textarea:focus,
.hub input:focus, .hub-dialog input:focus { border-color: var(--accent); }
.hub input[type="checkbox"], .hub-dialog input[type="checkbox"],
.hub input[type="radio"], .hub-dialog input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- badges ---------- */

.hub-badge {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap;
  color: var(--c); border: 1px solid var(--line-strong);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border-color: color-mix(in srgb, var(--c) 40%, transparent);
}
/* Light mode: a little of the text color in the tint keeps 12px text at 4.5:1 or better on every
   surface, the tinted pill included (cyan and red alone fall just under on --surface-2). */
@media (prefers-color-scheme: light) {
  .hub-badge { color: color-mix(in srgb, var(--c) 82%, var(--text)); }
}
.hub-badge[class*="status-"]::before, .hub-badge[class*="contact-"]::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none;
}
.hub-badge.status-todo { --c: var(--muted); }
.hub-badge.status-doing { --c: var(--accent); }
.hub-badge.status-blocked { --c: var(--danger); }
.hub-badge.status-done { --c: var(--ok); }
.hub-badge.priority-high { --c: var(--warn); }
.hub-badge.priority-normal { --c: var(--muted); }
.hub-badge.priority-low { --c: var(--muted); border-style: dashed; background: transparent; }
.hub-badge.contact-new { --c: var(--muted); }
.hub-badge.contact-reached { --c: var(--accent); }
.hub-badge.contact-talking { --c: var(--accent); }
.hub-badge.contact-meeting { --c: var(--warn); }
.hub-badge.contact-partner { --c: var(--ok); }
.hub-badge.contact-no { --c: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.hub-badge.contact-no::before { opacity: 0.5; }

/* ---------- dialogs ---------- */

html.hub-modal-open { overflow: hidden; }
.hub-dialog {
  width: min(540px, calc(100vw - 32px));
  max-width: none;
  max-height: min(88vh, 820px);
  padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}
.hub-dialog.is-wide { width: min(800px, calc(100vw - 32px)); }
.hub-dialog[open] { display: flex; flex-direction: column; }
.hub-dialog::backdrop { background: var(--scrim); }
.hub-dialog-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.hub-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 10px 6px 22px; }
.hub-dialog-head h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.hub-dialog-x {
  flex: none; width: 44px; height: 44px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 26px; line-height: 1; cursor: pointer;
}
.hub-dialog-x:hover { color: var(--text); background: var(--surface-2); }
.hub-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 6px 22px 12px; }
.hub-dialog-body > p:last-child { margin-bottom: 0; }
.hub-dialog-error { margin: 0 22px 10px; }
.hub-dialog-actions {
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px;
  padding: 14px 22px 18px; border-top: 1px solid var(--line);
}
.hub-dialog.is-busy .hub-dialog-actions { cursor: progress; }
/* While an action runs the buttons are marked aria-disabled (not disabled, which would drop the
   keyboard focus): dimmed, and clicks pass to the footer, which shows the busy cursor. */
.hub-dialog.is-busy .hub-dialog-actions .btn, .hub-dialog.is-busy .hub-dialog-x { opacity: 0.55; pointer-events: none; }

/* ---------- toasts ---------- */

.hub-toasts {
  position: fixed; z-index: 60;
  left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  display: grid; gap: 8px;
  pointer-events: none;
}
.hub-toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px 8px 14px; border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  font-weight: 600; font-size: 14px;
  animation: hub-rise 0.18s ease-out;
}
.hub-toast.is-ok { border-left-color: var(--ok); }
.hub-toast.is-warn { border-left-color: var(--warn); }
.hub-toast.is-error { border-left-color: var(--danger); }
.hub-toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hub-toast-close {
  flex: none; width: 36px; height: 36px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.hub-toast-close:hover { color: var(--text); }
@keyframes hub-rise { from { transform: translateY(6px); } }

/* ---------- phones ---------- */

/* Narrow tablets (768 in portrait): tighter tabs, so the President's eight still fit in one row. */
@media (min-width: 760px) and (max-width: 899px) {
  .hub-tabs a { padding: 0 11px; }
}

@media (max-width: 899px) {
  .hub-public-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .hub-signin { position: static; }
  .hub-public.is-deep .hub-signin { order: -1; }
  .hub-jump { display: inline-flex; min-height: 44px; }
  .hub-public.is-deep .hub-jump { display: none; }
}

@media (max-width: 759px) {
  .hub-public-head { align-items: flex-start; flex-direction: column; margin: 12px 0 20px; }
  .hub-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hub-seat { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .hub-seat-name { font-size: 15px; }
  .hub-seat-role, .hub-seat-link { font-size: 13px; }
  .hub-top { margin-top: 10px; }
  .hub-top-actions .btn { min-height: 44px; }
  .hub-tabbar { margin: 14px -16px 18px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .hub-tabs { padding: 2px 16px; border-radius: 0; border: 0; background: transparent; scroll-padding: 0 16px; }
  .hub-tabs a { min-height: 44px; border: 1px solid var(--line); background: var(--surface); }
  .hub-tabs a[aria-current="page"] { border-color: var(--accent); }
  .hub-title { font-size: 21px; }
  .hub-head-actions .btn, .hub-empty-action .btn, .hub-error-actions .btn, .hub-message-actions .btn { min-height: 44px; }
  .hub-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 24px); }
  .hub-dialog-head { padding-left: 18px; }
  .hub-dialog-body { padding: 6px 18px 12px; }
  .hub-dialog-error { margin: 0 18px 10px; }
  .hub-dialog-actions { padding: 12px 18px 16px; }
  .hub-dialog-actions .btn { flex: 1 1 auto; min-height: 46px; }
  .hub-toast-close { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .hub-spinner { animation-duration: 2.4s; }
  .hub-toast { animation: none; }
  .hub-content { transition: none; }
}
