/* core.css
   Styles used across the whole interface: design tokens, reset, the top bar, the panel/grid
   layout, shared widgets (dropdowns, comboboxes, selects) and accessibility
   rules. Load this first. */

/* Rajdhani is self-hosted (assets/). IBM Plex Mono still comes from Google Fonts. */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap');

@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/Rajdhani-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/Rajdhani-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/Rajdhani-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #110c17;
  --bg-grid: #17101f;
  --panel-bg: #1a1421;
  --panel-bg-soft: #201929;
  --border: #392e46;
  --border-soft: #2a2233;
  --accent: #e0227f;
  --accent-dim: #7a1a52;
  --accent-glow: rgba(224, 34, 127, 0.35);
  --cyan: #38e6cf;
  --cyan-dim: #1c6e64;
  --text: #ece6f2;
  --text-dim: #9d8dae;
  --text-faint: #6d5f7c;
  --danger: #ff6b6b;
  --danger-dim: #c25a5a;
  --radius: 2px;
  --font-ui: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-data: 'IBM Plex Mono', 'Consolas', monospace;
}

* {
  box-sizing: border-box;
}

/* Author-level display rules (e.g. .menu-action-btn's display:
   inline-block) beat the user-agent stylesheet's [hidden]{display:none},
   since author styles always win over UA styles regardless of
   specificity. Restating it here, with !important, is what makes
   el.hidden = true actually hide things like the action buttons below. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 34px 34px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  padding-bottom: 60px;
}

/* ---------------------------------------------------------------- */
/* Top bar                                                            */
/* ---------------------------------------------------------------- */
.top-bar {
  position: sticky;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(17, 12, 23, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Narrow screens: a bar that no longer fits wraps instead of spilling off the page
   (the character sheet puts its buttons on the second line, see character-sheet.css;
   the menu's tab row wraps inside itself, see menu.css). */
@media (max-width: 720px) {
  .top-bar {
    flex-wrap: wrap;
    row-gap: 10px;
  }
}

#toast {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--cyan);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#toast.show {
  opacity: 1;
}

.menu-dropdown {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.menu-trigger {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.menu-dropdown:hover .menu-trigger,
.menu-dropdown:focus-within .menu-trigger {
  background: var(--panel-bg);
  color: var(--text);
}

/* Account icon, square box, right-aligned dropdown */
.account-dropdown {
  margin-left: 8px;
}

.meta-select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-select-value:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}

.meta-select-caret {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.12s ease;
}

.meta-select[aria-expanded='true'] .meta-select-caret {
  transform: rotate(180deg);
}

.meta-select-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 2000;
}

.meta-select-option {
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.meta-select-option:hover,
.meta-select-option.is-active {
  background: var(--panel-bg-soft);
  color: var(--cyan);
}

.meta-select-empty {
  padding: 8px 10px;
  font-family: var(--font-data);
  font-size: 12px;
  font-style: italic;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- */
/* Combobox widget (find-as-you-type, combobox.js)                    */
/* Used for the Focus/Talent name fields, styled to sit inline like a */
/* .text-field until edit mode turns the input on.                    */
/* ---------------------------------------------------------------- */
.meta-combo {
  position: relative;
  display: block;
}

.meta-combo-input {
  width: 100%;
  min-height: 30px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 2px 2px;
  border-radius: var(--radius);
}

.meta-combo-input::placeholder {
  color: var(--text-faint);
}

.meta-combo-input:not(:disabled) {
  background: var(--panel-bg-soft);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: text;
}

.meta-combo-input:not(:disabled):focus {
  box-shadow: inset 0 0 0 1px var(--cyan);
}

.meta-combo-input:disabled {
  cursor: default;
}

.meta-combo.is-disabled .meta-combo-input {
  opacity: 0.85;
}

.meta-combo-panel {
  position: fixed;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 1100;
}

.meta-combo-option {
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.meta-combo-option:hover,
.meta-combo-option.is-active {
  background: var(--panel-bg-soft);
  color: var(--cyan);
}

.meta-combo-empty {
  padding: 8px 10px;
  font-family: var(--font-data);
  font-size: 12px;
  font-style: italic;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- */
/* Exit button (top bar, menu pages and modals)                       */
/* ---------------------------------------------------------------- */
.exit-button {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.exit-icon {
  width: 20px;
  height: 20px;
}

.exit-icon path {
  stroke: currentColor;
}

.exit-button:hover,
.exit-icon:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-dim);
}

/* ---------------------------------------------------------------- */
/* Layout grid                                                        */
/* ---------------------------------------------------------------- */
.sheet-grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 24px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

@media (max-width: 860px) {
  .sheet-grid {
    /* minmax(0, ...) lets the column shrink below its content's natural width, so one wide
       row can't push the whole page sideways on the narrowest phones. */
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------------------------------------------------------------- */
/* Panels                                                             */
/* ---------------------------------------------------------------- */
.panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-dim) 100%);
  clip-path: polygon(0 0, 100% 0, calc(100% - 22px) 100%, 0 100%);
  padding: 8px 40px 8px 16px;
  margin-right: -1px;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}

.subhead {
  font-family: var(--font-data);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 14px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.subhead:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ---------------------------------------------------------------- */
/* Select widget (dropdown)                                           */
/* ---------------------------------------------------------------- */
.select-el {
  width: 100%;
  min-height: 30px;
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--text);
  background: var(--panel-bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 6px;
  outline: none;
}

.select-el:focus {
  border-color: var(--cyan);
}

.select-el:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- */
/* Footer note                                                        */
/* ---------------------------------------------------------------- */
.sheet-footer {
  max-width: 1280px;
  margin: 8px auto 0;
  padding: 0 24px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-faint);
  align-self: center;
}

/* ---------------------------------------------------------------- */
/* Accessibility                                                      */
/* ---------------------------------------------------------------- */
button:focus-visible,
.text-field:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---------------------------------------------------------------- */
/* Find-in-text search (doc-search.js): the bar, its count and step buttons, and the highlight on
   matches. Used by the Rules / World pages, where it sits in the contents panel (so on narrow
   screens it slides in and out with the contents), and by the Notes modal. */
.rules-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.rules-search-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--text);
  background: var(--panel-bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  outline: none;
}

.rules-search-input:focus {
  border-color: var(--cyan);
}

.rules-search-count {
  flex-shrink: 0;
  min-width: 3.2em;
  text-align: right;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.rules-search-count.none {
  color: #ffb4a8;
}

.rules-search-step {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--cyan-dim);
  border-radius: var(--radius);
  cursor: pointer;
}

.rules-search-step:hover:not(:disabled) {
  border-color: var(--cyan);
  background: rgba(56, 230, 207, 0.08);
}

.rules-search-step:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Matches in the text; the one being looked at is solid. */
mark.rules-hit {
  color: inherit;
  background: rgba(56, 230, 207, 0.28);
  border-radius: 2px;
}

mark.rules-hit.current {
  color: #04121a;
  background: var(--cyan);
}