/* components.css — shared UI pieces: top nav, buttons, panels, form fields, connection status. */

/* ---- top nav, shared across every page (core/nav.js) ----
   Tabs on the left scroll sideways when they don't fit (thin scrollbar,
   mouse wheel, faded edges); the dice switch and the identity badge stay on
   the right. Narrow screens: inactive tabs show only their icon. */
.app-nav {
  display: flex;
  align-items: stretch;
  background: var(--nav-bg);
  border-radius: 6px;
  margin-bottom: 22px;
  box-shadow: 0 2px 6px var(--card-shadow);
  min-width: 0;
}
.nav-tabs {
  display: flex;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
.nav-tabs::-webkit-scrollbar { height: 4px; }
.nav-tabs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 2px; }
.nav-tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.nav-tabs.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }
.nav-tabs.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.nav-btn {
  flex: 1 0 auto;
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 13px 9px 10px;
  color: var(--nav-ink);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-btn.home { flex-grow: 0; padding-left: 10px; padding-right: 10px; }
.nav-btn .ic { font-size: 14px; line-height: 1; }
.nav-btn:hover { color: #fff; }
.nav-btn.active { color: #fff; border-bottom-color: var(--wax); }
.nav-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.nav-side {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 0 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
@media (max-width: 760px) {
  .nav-btn:not(.active) .lbl { display: none; } /* icon only; the current page keeps its name */
  .nav-btn { padding-left: 11px; padding-right: 11px; }
  .nav-side { padding: 0 6px; gap: 4px; }
  .dice-toggle .lbl { display: none; }
}

button { font-family: var(--font-body); cursor: pointer; border: none; }
.btn {
  background: var(--wax);
  color: #fff;
  padding: 10px 16px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.97); }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--ink-soft); opacity: 1; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px var(--card-shadow);
}

.field label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--wax);
  outline-offset: 1px;
}

.conn-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-soft); margin-right: 6px; vertical-align: middle;
}
.conn-dot.live { background: var(--good); }
.conn-status { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; }

/* ---- who-are-you: DM / player identity (core/join.js) ---- */
body:not(.is-dm) .dm-only { display: none !important; }
body.is-dm .player-only { display: none !important; }
.id-badge {
  flex: 0 0 auto; align-self: center; white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.08); color: #fff; border-radius: 14px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.id-badge:hover { background: rgba(255, 255, 255, 0.16); }
.dice-toggle { display: inline-flex; align-items: center; gap: 5px; }
.dice-toggle.on { background: rgba(212, 174, 76, 0.28); }
@media (max-width: 420px) { .id-badge { max-width: 96px; padding: 5px 9px; } }

/* "Roll my own dice" dialog (core/diceDialog.js); shares .spell-dlg. */
.dice-rows { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; max-height: 50vh; overflow-y: auto; }
.dice-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.dice-name { overflow-wrap: anywhere; }
.dice-row input {
  width: 72px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); color: var(--ink); font: inherit; text-align: center;
}
.dice-msg { color: var(--wax); font-size: 12.5px; min-height: 1em; }
.dice-dlg .spell-dlg-btns { flex-wrap: wrap; }

.join-overlay {
  position: fixed; inset: 0; z-index: 1000; background: rgba(10, 11, 12, 0.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(40px, env(safe-area-inset-top, 0px)) 16px 24px; overflow-y: auto;
}
.join-box {
  background: var(--bg-panel); color: var(--ink); border-radius: 10px;
  width: 100%; max-width: 420px; padding: 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.join-title { margin: 0 0 4px; font-family: var(--font-display); font-size: 24px; }
.join-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 13px; }
.join-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 50vh; overflow-y: auto; }
.join-loading { color: var(--ink-soft); font-size: 13px; padding: 6px 2px; }
.join-option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
}
.join-option:hover { border-color: var(--wax); }
.join-option.dm { border-color: var(--gold); }
.join-pic {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--bg-panel);
  border: 2px solid var(--good); font-family: var(--font-display); font-weight: 700; color: var(--ink-soft);
}
.join-pic.dm { border-color: var(--gold); font-size: 18px; }
.join-pic img { width: 100%; height: 100%; object-fit: cover; }
.join-text { display: flex; flex-direction: column; min-width: 0; }
.join-name { font-weight: 600; font-size: 15px; }
.join-meta { color: var(--ink-soft); font-size: 12px; }
.join-cancel { margin-top: 12px; }
.join-group {
  display: flex; align-items: center; gap: 8px; margin: 8px 2px 0;
  font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--ink-soft);
}
.join-group:first-child { margin-top: 0; }
.join-group.active { color: var(--gold); }
.join-new {
  margin-left: auto; font-size: 11.5px; font-weight: 600; text-transform: none; letter-spacing: 0;
  font-family: var(--font-body); background: none; border: 1px solid var(--line); border-radius: 10px;
  padding: 1px 9px; color: var(--blue); cursor: pointer;
}
.join-new:hover { border-color: var(--blue); }
.join-others { margin-top: 4px; }
.join-others > summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); padding: 6px 2px; }
.join-others > .join-option, .join-others > .join-group { margin-bottom: 6px; }
.join-others > .join-group { margin-top: 10px; }
.join-count { font-size: 11px; font-weight: 700; border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; letter-spacing: 0; }
.join-option.current { border-color: var(--good); }
.join-you { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--good); }

/* ---- character actions (core/attacks.js): sheet + combat tracker ---- */
.action-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.action-row:last-child { border-bottom: none; }
.action-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.action-name { font-weight: 700; font-size: 14px; }
.action-stat { font-family: var(--font-display); font-size: 14px; color: var(--ink); }
.action-detail { color: var(--ink-soft); font-size: 11.5px; }
.action-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.action-result { font-size: 12.5px; margin-top: 4px; color: var(--ink); font-weight: 600; }
.action-result:empty { display: none; }
.action-result.crit { color: var(--wax); }
/* Monster actions (core/monsterActions.js), read from the stat block. */
.monster-section {
  margin-top: 8px; font-family: var(--font-display); font-weight: 700; font-size: 12px;
  letter-spacing: 0.5px; text-transform: uppercase; color: var(--wax);
}
.monster-section:first-child { margin-top: 0; }
.monster-text { white-space: normal; line-height: 1.35; }
.spell-info { font-size: 12.5px; font-weight: 600; color: var(--blue); padding: 4px 0 6px; border-bottom: 1px solid var(--line); }
.action-row.spell .action-name::before { content: '✦ '; color: var(--blue); }
/* Sections of the Actions list: Attacks, Actions, Bonus Actions, Reactions,
   No action needed, Spells (core/attacks.js renderActions). */
.action-group {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; padding-bottom: 3px; border-bottom: 2px solid var(--line);
}
.action-group:first-child, .mod-toggles + .action-group { margin-top: 6px; }
.action-group-title {
  font-family: var(--font-display); font-weight: 700; font-size: 12.5px;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink);
}
.action-group[data-group="attack"] .action-group-title { color: var(--wax); }
.action-group[data-group="bonus"] .action-group-title { color: var(--good); }
.action-group[data-group="reaction"] .action-group-title { color: var(--gold); }
.action-group[data-group="spell"] .action-group-title { color: var(--blue); }
.action-group-hint { font-size: 11.5px; color: var(--ink-soft); }
.action-row.feature .action-name::before { content: '◆ '; color: var(--ink-soft); font-size: 11px; }
/* A spell's casting time, next to its name. */
.cast-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px;
  font-size: 10.5px; font-weight: 700; line-height: 16px; vertical-align: 1px;
  border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap;
}
.cast-tag.action { border-color: var(--ink-soft); color: var(--ink); }
.cast-tag.bonus { border-color: var(--good); color: var(--good); }
.cast-tag.reaction { border-color: var(--gold); color: var(--gold); }
.slot-select {
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 12.5px;
}

/* SRD attribution (pages listing SRD content) */
.srd-credit { color: var(--ink-soft); font-size: 11.5px; text-align: center; margin: 28px 0 8px; }
.srd-credit a { color: inherit; }
.action-note { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; padding-left: 8px; border-left: 2px solid var(--line); }
.mod-toggles { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.mod-chip {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft);
}
.mod-chip.on { background: var(--wax); border-color: var(--wax); color: #fff; }

/* Spell dialog (core/spellDialog.js): concentration + targets. Combat Tracker and Battle Map. */
.spell-dlg {
  border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; width: min(420px, calc(100vw - 32px));
  background: var(--bg-panel); color: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.spell-dlg::backdrop { background: rgba(0,0,0,0.45); }
.spell-dlg h3 { margin: 0 0 10px; font-family: var(--font-display); font-size: 17px; }
.spell-dlg-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-soft); }
.spell-dlg-field input {
  padding: 7px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); font: inherit;
}
.spell-dlg-check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 10px 0; }
.spell-dlg-sub { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.spell-dlg-targets { display: flex; flex-direction: column; gap: 2px; max-height: 45vh; overflow-y: auto; }
.spell-dlg-targets label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 5px 4px; border-radius: 4px; cursor: pointer; }
.spell-dlg-targets label:hover { background: rgba(212, 174, 76, 0.12); }
.spell-dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---- "Add characters" / "Join the fight" list (combat/party.js): the
   combat page and the battle map. The bestiary list reuses the rows. */
.party-list { display: flex; flex-direction: column; gap: 14px; }
.party-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 6px; border-bottom: 2px solid var(--line);
}
.party-group-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.party-group-count {
  margin-left: 8px; font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px;
}
.party-list .empty { padding: 14px 10px; }
.party-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.party-group-head + .party-row { border-top: none; }
.party-who { min-width: 0; flex: 1 1 200px; }
.party-name { font-weight: 600; font-size: 15px; }
.party-sub { color: var(--ink-soft); font-size: 12px; }
.party-controls { display: flex; align-items: center; gap: 8px; }
.party-init {
  width: 104px; height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 18px; font-weight: 600; text-align: center;
}
.party-init::placeholder { font-size: 14px; font-weight: 400; }
.party-init:focus { outline: none; border-color: var(--gold); }
.party-controls .btn { height: 40px; }
.party-in { color: var(--good); font-size: 12.5px; font-weight: 600; }
.party-who.with-pic { display: flex; align-items: center; gap: 10px; }
.mini-pic {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  border: 2px solid var(--line); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: var(--ink-soft);
}
.mini-pic.mon { border-color: var(--wax); }
.mini-pic.pc { border-color: var(--good); }
.mini-pic img { width: 100%; height: 100%; object-fit: cover; }
.party-hint { color: var(--ink-soft); font-size: 12px; margin-top: 8px; }
/* A character's familiar under it in "Add characters" (party.js). */
.party-row.party-fam { padding-top: 0; padding-left: 46px; border-top: 0; }
@media (max-width: 600px) { .party-init { width: 84px; } }

/* ---- Allies / Enemies add panels (core/addPanels.js): combat page + map ---- */
.add-panel { padding: 0; }
.add-panel > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none;
  padding: 14px 18px; margin: 0;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink);
}
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel > summary::before { content: '▸'; color: var(--ink-soft); transition: transform 0.15s; }
.add-panel[open] > summary::before { transform: rotate(90deg); }
.add-panel > summary .add-note { margin-left: auto; text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-weight: 400; font-size: 12.5px; color: var(--ink-soft); }
.add-panel.allies > summary { border-left: 4px solid var(--good); border-radius: inherit; }
.add-panel.enemies > summary { border-left: 4px solid var(--wax); border-radius: inherit; }
.add-body { padding: 0 18px 16px; }
.add-sub { font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--ink-soft); margin: 16px 0 8px; }
.add-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 620px) { .add-form { grid-template-columns: 1fr 1fr; } }
.hidden-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
.bestiary-search {
  width: 100%; padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--bg); color: var(--ink); font: inherit;
}

/* Allies list: characters outside the current campaign, folded (party.js). */
.party-others { border: 1px dashed var(--line); border-radius: 8px; padding: 0 12px; }
.party-others > summary { cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.party-others[open] { padding-bottom: 12px; }
.party-others > .party-group + .party-group { margin-top: 14px; }
/* "Show all N …" under a capped group (core/cappedGroup.js: Items, Spells). */
.show-more { grid-column: 1 / -1; justify-self: center; margin: 4px 0 10px; }
/* "Who are you playing?" in accounts mode: who's signed in + change password (core/join.js). */
.join-account { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); }
.join-account-name { flex: 1 1 100%; }
.join-link { background: none; border: none; padding: 0; color: var(--blue); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.join-field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.join-field input {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; font-size: 15px;
}
.join-field input:focus { outline: none; border-color: var(--gold); }
.join-msg { min-height: 1.2em; font-size: 13px; color: var(--wax); margin: 2px 0 10px; }
.join-btns { display: flex; justify-content: flex-end; gap: 8px; }
/* DM view ⇄ player view at a table you run and play at (core/join.js). */
.id-badge.view-switch { border-style: dashed; }
@media (max-width: 760px) { .id-badge.view-switch { max-width: 44px; overflow: hidden; white-space: nowrap; } }
