/* Shared components. Feature-specific CSS goes in public/css/features/<name>.css. */

/* ---------- layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack--sm { gap: var(--s-2); }
.stack--lg { gap: var(--s-6); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }
.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .grid--2, .grid--3, .grid--main-side { grid-template-columns: minmax(0, 1fr); } }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-head__text { flex: 1; min-width: 220px; }
.page-head__kicker { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--s-1); }
.page-head h1 { font-size: var(--fs-3xl); margin: 0; }
.page-head__sub { color: var(--text-2); margin: var(--s-2) 0 0; max-width: 62ch; }
.page-head__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-4);
  border: 1px solid var(--btn-line); border-radius: var(--radius);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 700; font-size: var(--fs-sm); text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { border-color: var(--text-3); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-line: transparent; }
.btn--primary:hover { --btn-line: transparent; filter: brightness(1.07); }
.btn--ghost { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--surface); --btn-fg: var(--text); }
.btn--danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-line: transparent; }
.btn--sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn--lg { min-height: 50px; padding: 0 var(--s-6); font-size: var(--fs-md); border-radius: var(--radius-lg); }
.btn--discord { --btn-bg: #5865f2; --btn-fg: #fff; --btn-line: transparent; }
.btn--discord:hover { filter: brightness(1.08); }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: var(--radius); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.field .help { font-size: var(--fs-xs); color: var(--text-3); }
.field .error { font-size: var(--fs-xs); color: var(--danger); font-weight: 700; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg-2); color: var(--text);
  transition: border-color var(--dur) var(--ease);
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); border-radius: var(--radius); }
.form-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form-actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s-2); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--s-5); box-shadow: var(--shadow-1); min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card--pearl { position: relative; overflow: hidden; }
.card--pearl::after { content: ''; position: absolute; inset: 0 0 auto; height: 2px; background: var(--nacre-line); opacity: .8; }
.card__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.card__head h2, .card__head h3 { margin: 0; flex: 1; font-size: var(--fs-lg); font-family: var(--font-body); font-weight: 700; }
.card--flush > .card__head { padding: var(--s-5) var(--s-5) 0; margin-bottom: var(--s-3); }
.card__head > svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.card__foot { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--line); }
a.card { color: inherit; text-decoration: none; display: block; transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
a.card:hover { border-color: var(--line-strong); transform: translateY(-2px); }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value { font-family: var(--font-mono); font-size: var(--fs-2xl); line-height: 1.1; }
.stat__label { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-5); overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"] {
  position: relative; padding: var(--s-3) var(--s-4); border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); white-space: nowrap;
}
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); }
.tabs [role="tab"][aria-selected="true"]::after { content: ''; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }

/* ---------- chips & badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: var(--radius-pill); border: 1px solid var(--line-strong);
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); background: transparent; white-space: nowrap;
}
button.chip { cursor: pointer; }
button.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip--gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chip--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip--sea { background: var(--sea-soft); color: var(--sea); border-color: transparent; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* job badge: notched tag in the job color */
.job {
  --job: var(--text-3);
  display: inline-flex; align-items: center; height: 22px; padding: 0 7px 0 9px;
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 700; letter-spacing: .06em;
  color: var(--job); background: color-mix(in srgb, var(--job) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--job) 45%, transparent);
  border-radius: 3px 11px 11px 3px; white-space: nowrap; line-height: 1;
}
.job::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--job); margin-right: 6px; }
[data-theme="light"] .job { color: color-mix(in srgb, var(--job) 55%, #101525); border-color: color-mix(in srgb, var(--job) 55%, #9aa0ae); background: color-mix(in srgb, var(--job) 18%, #ffffff); }
.job--lg { height: 28px; font-size: var(--fs-xs); padding: 0 10px 0 12px; }
.job--none { --job: var(--text-3); }

.role {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-3);
}
.role--leader { color: var(--gold); }
.role--officer { color: var(--sea); }
.role--pending { color: var(--accent); }
.role svg { width: 14px; height: 14px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex: none; }
.avatar--sm { width: 26px; height: 26px; }
.avatar--lg { width: 72px; height: 72px; }
.avatar-wrap { position: relative; flex: none; display: inline-block; line-height: 0; }
.avatar-wrap .presence { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }

.online-pill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); padding: 0 10px; height: 30px; border-radius: var(--radius-pill); border: 1px solid var(--line); text-decoration: none; }
.online-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* ---------- countdown & ticker ---------- */
.countdown { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.countdown--soon { color: var(--accent); }
.countdown--live { color: var(--ok); }
.ticker { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 85%, transparent); }
.ticker::-webkit-scrollbar { display: none; }
.ticker__item {
  display: inline-flex; align-items: center; gap: var(--s-2); flex: none; height: 30px; padding: 0 12px;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--text-2); text-decoration: none;
}
.ticker__item:hover { border-color: var(--line-strong); color: var(--text); }
.ticker__item b { color: var(--text); font-weight: 700; }
.ticker__empty { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; display: block; overflow: hidden; text-overflow: ellipsis; line-height: 30px; height: 30px; }
.ticker__empty svg { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: var(--s-1); }

/* ---------- search ---------- */
.search { position: relative; width: 220px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--text-3); pointer-events: none; }
.search input { width: 100%; height: 36px; padding: 0 34px 0 32px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: var(--fs-sm); }
.search input:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); border-radius: var(--radius-pill); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.search-toggle { display: none; }
.search-wrap { position: relative; }
.search-pop { position: absolute; top: calc(100% + 6px); right: 0; width: min(360px, calc(100vw - 24px)); max-height: min(70vh, 460px); overflow: auto;
  z-index: 60; padding: var(--s-2); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.search-pop__sec { padding: var(--s-2) var(--s-3) 2px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.search-pop__opt { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.search-pop__opt:hover, .search-pop__opt.is-active { background: var(--surface-2); }
.search-pop__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.search-pop__main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pop__none { margin: 0; padding: var(--s-3); }
.dot--ok { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
@media (max-width: 520px) {
  .search-wrap.is-open { position: fixed; top: 8px; left: 12px; right: 12px; z-index: 70; }
  .topbar .search-wrap.is-open .search { display: block; width: 100%; }
  .search-wrap.is-open .search-pop { left: 0; right: 0; width: auto; }
}

/* ---------- lists & tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); min-width: 0; color: inherit; text-decoration: none; }
a.list-row:hover { background: var(--surface-2); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- empty / coming soon / skeleton ---------- */
.empty { text-align: center; padding: var(--s-10) var(--s-6); color: var(--text-2); }
.empty__art { width: 72px; height: 72px; margin: 0 auto var(--s-4); color: var(--text-3); }
.empty h3 { color: var(--text); }
.empty p { max-width: 46ch; margin-left: auto; margin-right: auto; }
.soon {
  position: relative; overflow: hidden; text-align: center;
  padding: var(--s-12) var(--s-6); border-radius: var(--radius-lg);
  border: 1px dashed var(--line-strong); background: linear-gradient(180deg, var(--surface), transparent);
}
.soon__pearl { width: 96px; height: 96px; margin: 0 auto var(--s-5); }
.soon__pearl .orbit { transform-origin: 48px 48px; animation: orbit 9s linear infinite; }
.soon__pearl .o1 { fill: var(--accent); }
.soon__pearl .o2 { fill: var(--gold); }
.soon__pearl .ring { stroke: var(--line-strong); }
.soon__pearl .core { fill: var(--pearl); opacity: .85; }
@keyframes orbit { to { transform: rotate(360deg); } }
.soon h2 { font-size: var(--fs-2xl); }
.soon p { color: var(--text-2); max-width: 52ch; margin: 0 auto var(--s-4); }
.soon ul { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; list-style: none; padding: 0; margin: 0; }
.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; min-height: 14px; }
.skeleton[data-w="1"] { width: 82%; }
.skeleton[data-w="2"] { width: 56%; }
.skeleton--block { height: 84px; border-radius: var(--radius-lg); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 90; display: flex; flex-direction: column; gap: var(--s-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--radius); background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2); font-size: var(--fs-sm); animation: toast-in 220ms var(--ease) both;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--nacre); }
.toast--ok::before { background: var(--ok); }
.toast--error::before { background: var(--danger); }
.toast.is-leaving { animation: toast-out 180ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ---------- modal ---------- */
.modal { border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-2); }
.modal::backdrop { background: rgba(2, 5, 12, .6); backdrop-filter: blur(2px); }
.modal[open] { animation: toast-in 200ms var(--ease) both; }
.modal__body { padding: var(--s-6); }
.modal__body h2 { font-size: var(--fs-xl); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--bg-2); }

/* ---------- user menu ---------- */
.user-btn { display: inline-flex; align-items: center; gap: var(--s-2); padding: 3px 10px 3px 3px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); font-size: var(--fs-sm); font-weight: 700; max-width: 180px; }
.user-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .user-btn span { display: none; } .user-btn { padding: 3px; } }

/* ---------- Vana'diel clock (sidebar footer) ---------- */
.vclock { display: flex; flex-direction: column; gap: var(--s-2); }
.vclock__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.vclock__time { font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: 700; letter-spacing: .02em; }
.vclock__day { font-size: var(--fs-xs); font-weight: 700; color: var(--day-color, var(--text-2)); text-transform: uppercase; letter-spacing: .08em; }
.vclock__days { display: flex; gap: 6px; align-items: center; }
.vclock__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: .38; transition: opacity var(--dur); }
.vclock__dot.is-today { opacity: 1; width: 14px; height: 14px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent), 0 0 12px color-mix(in srgb, var(--c) 60%, transparent); }
.vclock__meta { display: flex; flex-direction: column; font-size: var(--fs-xs); color: var(--text-3); gap: 2px; }
.vclock__meta > span { display: flex; align-items: center; gap: 6px; }
.vclock__meta .mono { color: var(--text-2); }
.moon { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }

/* ---------- pearl logo ---------- */
.pearl-logo { width: 38px; height: 38px; flex: none; }
.pearl-logo--xl { width: 120px; height: 120px; }
@media (prefers-reduced-motion: no-preference) {
  .pearl-logo .glint { animation: glint 6s var(--ease) infinite; }
}
@keyframes glint { 0%, 80%, 100% { opacity: .9; } 88% { opacity: .2; } }

/* ---------- misc ---------- */
.notice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--radius); background: var(--gold-soft); color: var(--text); font-size: var(--fs-sm); }
.notice--accent { background: var(--accent-soft); }
.notice--danger { background: var(--danger-soft); }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--gold); }
.kbd { font-family: var(--font-mono); font-size: var(--fs-xs); padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 4px; }
.code-pill { font-family: var(--font-mono); background: var(--bg-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: var(--radius-sm); }
.divider-label { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.divider-label::before, .divider-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }
@media (max-width: 520px) {
  .list-row--actions { flex-wrap: wrap; }
  .list-row--actions .list-row__main { flex-basis: calc(100% - 100px); }
}

/* ---------- shared bits added at integration ---------- */
/* Text directly inside a flush card (lists use .list-row padding instead). */
.card--flush .card__pad, .card__pad { padding: 0 var(--s-5) var(--s-5); margin: 0; }
/* Widget placeholders while dashboard / profile slots load. */
.slot-ph:empty { display: none; }
/* Sidebar badges: live dot + counts (admin pending already uses .count). */
.nav-link .count--soft { background: var(--surface-3); color: var(--text-2); }
.nav-link .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: auto; box-shadow: 0 0 0 3px var(--danger-soft); }
/* Progress meter (native <progress>, so no inline styles are needed). */
progress.meter { width: 100%; height: 8px; margin-top: var(--s-2); border: 0; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; appearance: none; }
progress.meter::-webkit-progress-bar { background: var(--surface-3); border-radius: var(--radius-pill); }
progress.meter::-webkit-progress-value { background: var(--sea); border-radius: var(--radius-pill); }
progress.meter::-moz-progress-bar { background: var(--sea); border-radius: var(--radius-pill); }
.nav-badge { margin-left: auto; display: inline-flex; align-items: center; }
.nav-badge:empty { display: none; }
.nav-badge .count, .nav-badge .live-dot { margin-left: 0; }
@media (max-width: 440px) { .topbar .online-pill { display: none; } }
