/*
 * Public visual contract for every adventure and the standalone character sheet.
 * Module styles may add illustrations and special panels, but shared typography,
 * spacing, notes and information controls belong here.
 */
:root {
  --ui-font-body: var(--sans);
  --ui-font-reading: var(--serif);
  --ui-font-display: var(--serif);

  --ui-entry-title-color: #8f141b;
  --ui-entry-title-size: clamp(3rem, 7vw, 5rem);
  --ui-entry-text-title-size: clamp(2.3rem, 4.5vw, 3.25rem);
  --ui-entry-title-weight: 700;
  --ui-entry-title-line: .96;
  --ui-entry-title-spacing: .06em;
  --ui-entry-heading-margin: 28px 0 30px;

  --ui-section-title-color: var(--ink);
  --ui-section-title-size: 1rem;
  --ui-section-title-weight: 600;
  --ui-section-title-line: 1.3;
  --ui-section-title-spacing: .07em;

  --ui-note-color: var(--muted);
  --ui-note-size: .68rem;
  --ui-note-line: 1.5;
  --ui-note-spacing: .02em;

  --ui-info-size: 16px;
  --ui-info-border: #6f6a60;
  --ui-info-color: var(--gold);
  --ui-info-hover: #fff2c2;
  --ui-info-font-size: .58rem;
}

/* Every story entry, including introductions and rules pages, uses one title. */
.reader-heading { margin: var(--ui-entry-heading-margin); }
.reader-heading h1,
.reader-heading.preface h1 {
  margin: 0;
  color: var(--ui-entry-title-color);
  font-family: var(--ui-font-display);
  font-size: var(--ui-entry-text-title-size);
  font-weight: var(--ui-entry-title-weight);
  line-height: var(--ui-entry-title-line);
  letter-spacing: var(--ui-entry-title-spacing);
}
.reader-heading .entry-number {
  font-family: Georgia, serif;
  font-size: var(--ui-entry-title-size);
  letter-spacing: 0;
}
.reader-heading p,
.reader-heading.preface p {
  margin: 0 0 10px 2px;
  color: #7a6e61;
  font-family: var(--ui-font-body);
  font-size: var(--ui-note-size);
  line-height: var(--ui-note-line);
  letter-spacing: .16em;
  transform: none;
}

/* Shared section-heading contract. */
.sheet-section-heading h2,
.sheet-card .sheet-section-heading h2,
.rules-dialog-copy .rules-heading,
.story-copy .rules-heading {
  color: var(--ui-section-title-color);
  font-family: var(--ui-font-display);
  font-size: var(--ui-section-title-size);
  font-weight: var(--ui-section-title-weight);
  line-height: var(--ui-section-title-line);
  letter-spacing: var(--ui-section-title-spacing);
}

/* Notes and explanatory copy share one tone and rhythm. */
.ui-note,
.sheet-hint,
.sheet-field small,
.sheet-section-heading > span,
.heading-actions > span,
.age-rule,
.occupation-summary,
.skill-point-summary,
.attribute-total,
.panel-heading span:last-child:not(:first-child),
.interaction-heading span,
.status-change-heading span,
.record-dialog header p,
.rules-dialog header p,
.clue-resource-button small {
  color: var(--ui-note-color);
  font-family: var(--ui-font-body);
  font-size: var(--ui-note-size);
  font-weight: 400;
  line-height: var(--ui-note-line);
  letter-spacing: var(--ui-note-spacing);
}

/* One information-icon component, regardless of where it is used. */
.info-button,
.attribute-info-button,
.skill-info-button,
.growth-info-button,
.ending .growth-info-button,
.derived-title .attribute-info-button {
  position: relative;
  display: grid;
  flex: 0 0 var(--ui-info-size);
  width: var(--ui-info-size);
  height: var(--ui-info-size);
  min-width: var(--ui-info-size);
  min-height: var(--ui-info-size);
  margin: 0;
  padding: 0;
  place-items: center;
  border: 1px solid var(--ui-info-border);
  border-radius: 50%;
  color: var(--ui-info-color);
  background: transparent;
  cursor: help;
  font: 700 var(--ui-info-font-size)/1 Georgia, serif;
}
.info-button::before,
.attribute-info-button::before,
.skill-info-button::before,
.growth-info-button::before { position: absolute; inset: -5px; content: ""; }
.info-button:hover,
.info-button:focus-visible,
.attribute-info-button:hover,
.attribute-info-button:focus-visible,
.attribute-info-button[aria-expanded="true"],
.skill-info-button:hover,
.skill-info-button:focus-visible,
.skill-info-button[aria-expanded="true"],
.growth-info-button:hover,
.growth-info-button:focus-visible,
.growth-info-button[aria-expanded="true"] {
  border-color: var(--ui-info-color);
  color: var(--ui-info-hover);
  outline: 0;
  background: rgba(203, 166, 92, .1);
}

.skill-tooltip,
.attribute-tooltip,
.info-tooltip {
  border-color: #665944;
  color: #d6d1c7;
  background: #1b1a18;
  font: .75rem/1.58 var(--ui-font-reading);
}
.skill-tooltip strong,
.attribute-tooltip strong,
.info-tooltip strong {
  color: var(--ui-info-color);
  font-family: var(--ui-font-display);
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.35;
}

/* Shared lightweight portrait atlas. Each sheet is 4 × 2 at 256 px per tile. */
.game-avatar-crop { display: block; width: 100%; height: 100%; background-image: url("../assets/character-portraits/default-investigators-lite.webp?v=20260929-architecture1"); background-repeat: no-repeat; background-size: 400% 200%; }
.game-avatar-crop.extra { background-image: url("../assets/character-portraits/default-investigators-extra-lite.webp?v=20260929-architecture1"); }
.game-avatar-crop.diverse { background-image: url("../assets/character-portraits/default-investigators-diverse-lite.webp?v=20260929-architecture1"); }
.game-avatar-crop.longhair { background-image: url("../assets/character-portraits/default-investigators-longhair-lite.webp?v=20260929-architecture1"); }
.game-avatar-crop.men { background-image: url("../assets/character-portraits/default-investigators-men-lite.webp?v=20260929-architecture1"); }
.game-avatar-crop.chinese-women { background-image: url("../assets/character-portraits/default-investigators-chinese-women-lite.webp"); }
.game-avatar-crop.chinese-men { background-image: url("../assets/character-portraits/default-investigators-chinese-men-lite.webp"); }

/* Large occupation lists use the same searchable combobox on every device.
   Other datalist-backed fields keep the compact native mobile selector. */
.mobile-choice-field { display: block; width: 100%; min-width: 0; }
.mobile-choice-select { display: none; }

.occupation-search-field { position: relative; }
.occupation-search-input-row { position: relative; display: block; width: 100%; }
.occupation-search-input-row .occupation-search-input {
  display: block;
  width: 100%;
  min-width: 0;
  padding-right: 38px;
}
.occupation-search-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: rgba(203, 166, 92, .12);
  cursor: pointer;
}
.occupation-search-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(-50%, -70%) rotate(45deg);
}
.occupation-search-toggle:hover,
.occupation-search-toggle:focus-visible,
.occupation-search-toggle[aria-expanded="true"] { background: rgba(203, 166, 92, .24); outline: 0; }
.occupation-search-panel {
  position: absolute;
  z-index: 80;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid #706046;
  border-radius: 7px;
  background: #1d1b18;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .4);
}
.occupation-search-panel[hidden] { display: none; }
.occupation-search-results {
  display: block;
  max-height: min(42vh, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.occupation-search-option,
.occupation-search-custom {
  display: block;
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  color: #e8e1d4;
  background: transparent;
  text-align: left;
  font: .9rem/1.35 var(--ui-font-reading);
  cursor: pointer;
}
.occupation-search-option:hover,
.occupation-search-option:focus-visible,
.occupation-search-option.is-active { color: #fff3c4; background: rgba(203, 166, 92, .18); outline: 0; }
.occupation-search-custom { border-top: 1px solid #4d4436; color: #d7bd75; }
.occupation-search-custom:hover,
.occupation-search-custom:focus-visible { color: #fff0b7; background: rgba(203, 166, 92, .12); outline: 0; }
.occupation-search-empty { display: block; padding: 13px 12px; color: #aaa295; font: .84rem/1.5 var(--ui-font-reading); }
.weapon-search-panel { position: fixed; z-index: 320; }
.weapon-search-panel .occupation-search-results { max-height: var(--weapon-options-height,min(48vh,430px)); }
.weapon-search-panel .occupation-search-option,
.weapon-search-panel .occupation-search-custom { padding: 9px 13px; font-size: .82rem; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 760px), (pointer: coarse) {
  .mobile-choice-select { display: block; width: 100%; }
  .mobile-choice-input { display: none; }
  .mobile-choice-field.is-custom .mobile-choice-input { display: block; margin-top: 6px; }
  .occupation-search-field .occupation-search-input { display: block; margin-top: 0; }
  .game-weapon-table .occupation-search-field .occupation-search-input { font-size: 16px; }
  .occupation-search-panel { position: fixed; z-index: 260; top: auto; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; }
  .occupation-search-results { max-height: min(56dvh, 430px); }
  .weapon-search-panel { box-sizing: border-box; top: auto !important; right: 12px !important; bottom: max(12px, env(safe-area-inset-bottom)) !important; left: 12px !important; width: auto !important; max-width: none; }
  .weapon-search-panel .occupation-search-results { max-height: min(58dvh,460px); }
  .weapon-search-panel .occupation-search-option,
  .weapon-search-panel .occupation-search-custom { min-height: 42px; padding: 10px 12px; font-size: .88rem; }
}

@media (max-width: 430px) {
  .reader-heading { margin: 22px 0 24px; }
  .reader-heading h1,
  .reader-heading.preface h1 { font-size: clamp(2.1rem, 10.5vw, 2.85rem); }
  .reader-heading .entry-number { font-size: clamp(2.55rem, 13vw, 3.35rem); }
}

@media (pointer: coarse) {
  .info-button,
  .attribute-info-button,
  .skill-info-button,
  .growth-info-button,
  .ending .growth-info-button { cursor: pointer; }
}

/* Browser-independent confirmation card for mobile browsers that suppress confirm(). */
body.app-confirm-open { overflow: hidden; }
.app-confirm-overlay {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow: hidden;
  border: 0;
  color: inherit;
  background: transparent;
}
.app-confirm-overlay[open] { display: grid; place-items: center; }
.app-confirm-overlay::backdrop { background: rgba(0, 0, 0, .86); backdrop-filter: blur(5px); }
.app-confirm-card {
  box-sizing: border-box;
  width: min(100%, 440px);
  padding: 30px 32px 28px;
  border: 1px solid var(--ember, #8f141b);
  border-top: 3px solid var(--ember-bright, #b1262e);
  border-radius: 0;
  color: var(--ink, #e8e1d4);
  background: #171715;
  box-shadow: 0 30px 120px rgba(0, 0, 0, .8);
}
.app-confirm-eyebrow { color: var(--ember-bright, #c8353d); font: .62rem/1.2 var(--ui-font-body); letter-spacing: .2em; }
.app-confirm-card h2 { margin: 8px 0 18px; color: var(--ember-bright, #c8353d); font: 600 1.45rem/1.3 var(--ui-font-display); letter-spacing: .06em; }
.app-confirm-card p { margin: 0; color: #d2cbc0; font: .88rem/1.8 var(--ui-font-reading); }
.app-confirm-input { box-sizing: border-box; width: 100%; min-height: 42px; margin: 18px 0 0; padding: 0 11px; border: 1px solid #575149; border-radius: 0; color: var(--ink, #e8e1d4); background: #11110f; font: .88rem var(--ui-font-body); }
.app-confirm-input:focus { border-color: var(--ember-bright, #b1262e); outline: 0; }
.app-confirm-input[hidden],
.app-confirm-actions button[hidden] { display: none; }
.app-confirm-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }
.app-confirm-actions button { min-width: 82px; min-height: 36px; margin: 0; padding: 0 12px; border: 1px solid var(--line, #4b463d); border-radius: 0; color: var(--muted, #aaa69c); background: #24231f; cursor: pointer; }
.app-confirm-actions button:hover,
.app-confirm-actions button:focus-visible { border-color: #6c675e; color: #ded8cc; background: #2b2a26; }
.app-confirm-actions .app-confirm-primary { border-color: #9e2f34; color: #fff3e2; background: #771d23; }
.app-confirm-actions .app-confirm-primary:hover,
.app-confirm-actions .app-confirm-primary:focus-visible { background: #94252c; }
@media (max-width: 430px) {
  .app-confirm-card { padding: 24px 20px 22px; }
  .app-confirm-card h2 { font-size: 1.3rem; }
}
