/**
 * My RPG Source
 * Shared Character Sheet Layout
 * ------------------------------------------
 *
 * Shared by the D&D 5e 2014 and 2024 builders.
 *
 * Theme colours and variables belong in themes.css.
 * Print-specific rules belong in print.css.
 * Mobile rules belong in responsive.css.
 */


/* ==========================================================
   FORM CONTROL NORMALIZATION
   ========================================================== */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}


/* ==========================================================
   GLOBAL RESET
   ========================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  max-width: 100%;
}

body {
  font-family: "Lora", serif;
  background-color: var(--bg-app);
  color: var(--text-main);

  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;

  min-height: 100vh;
  padding: 20px;
}

.app-container {
  display: flex;
  justify-content: center;

  gap: 20px;

  width: 100%;
  max-width: 1150px;
}


/* ==========================================================
   CONTROL PANEL SIDEBAR
   ========================================================== */

.controls {
  width: 220px;
  padding: 15px;

  flex-shrink: 0;

  display: flex;
  flex-direction: column;
  gap: 12px;

  position: sticky;
  top: 20px;

  background: #1a252f;
  color: #ffffff;

  border-radius: 8px;

  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4);
}

.controls h3 {
  padding-bottom: 6px;

  border-bottom:
    1px solid #415a77;

  font-family: "Cinzel", serif;
  font-size: 16px;
  text-align: center;
}

.controls label {
  font-size: 12px;
  font-weight: bold;
}

.controls select,
.controls button {
  width: 100%;
  padding: 8px;

  border: none;
  border-radius: 4px;

  font-family: inherit;
  font-size: 12px;

  cursor: pointer;
}

.controls select {
  background: #ffffff;
  color: #333333;
}

.controls button {
  background: #27ae60;
  color: #ffffff;

  font-weight: bold;

  transition:
    background 0.2s;
}

.controls button:hover {
  background: #219653;
}

.controls button.export {
  background: #c0392b;
}

.controls button.export:hover {
  background: #a93226;
}


/* ==========================================================
   CHARACTER DOCUMENT AND PAGES
   ========================================================== */

.document-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.sheet-page {
  width: 816px;

  height: 1045px;
  max-height: 1045px;

  padding: 20px;

  position: relative;

  display: flex;
  flex-direction: column;
  gap: 8px;

  overflow: hidden;

  background-color:
    var(--bg-sheet);

  border:
    2px solid var(--border-color);

  box-shadow:
    0 10px 25px var(--shadow-color);

  page-break-inside: avoid;
  break-inside: avoid;

  box-sizing: border-box;
}

.sheet-page + .sheet-page {
  page-break-before: always;
  break-before: page;
}


/* ==========================================================
   PDF EXPORT MODE
   ========================================================== */

.document-container.exporting {
  gap: 0 !important;
  padding: 0 !important;
}

.document-container.exporting
.sheet-page {
  margin: 0 !important;

  border:
    1px solid transparent !important;

  box-shadow: none !important;
}


/* ==========================================================
   PAGE 1 TWO-COLUMN LAYOUT
   ========================================================== */

.sheet-page.two-column-layout {
  display: flex;
  flex-direction: row;

  gap: 10px;
}

.master-stack {
  display: flex;
  flex-direction: column;

  gap: 8px;

  min-width: 0;
}

.left-stack {
  width: 330px;
  flex: 0 0 330px;
}

.right-stack {
  width: 436px;
  flex: 0 0 436px;
}


/* ==========================================================
   TYPOGRAPHY AND INPUTS
   ========================================================== */

h2.fantasy-header,
h3.fantasy-header {
  margin-bottom: 2px;
  padding-bottom: 2px;

  border-bottom:
    1px solid var(--border-color);

  color:
    var(--accent-color);

  font-family:
    "Cinzel", serif;

  font-size: 13px;

  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
}

.fantasy-input {
  width: 100%;
  min-width: 0;

  padding: 3px 6px;

  background:
    var(--input-bg);

  border:
    1px solid var(--border-color);

  border-radius: 3px;

  color:
    var(--text-main);

  font-family: inherit;
}

.fantasy-input:focus {
  outline: none;

  border-color:
    var(--accent-color);
}

label {
  color:
    var(--border-color);

  font-family:
    "Cinzel", serif;

  font-size: 10px;
  font-weight: 700;

  text-transform: uppercase;
}

.center-text {
  text-align: center;
}

.big-text {
  font-size: 15px;
  font-weight: bold;
}


/* ==========================================================
   CHARACTER NAME AND DETAILS
   ========================================================== */

.name-container {
  height: 105px;
  min-height: 105px;
  max-height: 105px;

  padding: 6px 8px;

  display: flex;
  flex-direction: column;
  gap: 4px;

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.big-input {
  padding: 2px 6px;

  font-family:
    "Cinzel", serif;

  font-size: 14px;
  font-weight: bold;
}

.details-grid {
  width: 436px;
  min-width: 0;

  padding: 8px;

  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 6px;

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.detail-box {
  display: flex;
  flex-direction: column;

  min-width: 0;
}


/* ==========================================================
   CLASS AND MULTICLASS AREA
   ========================================================== */

#class-level-container {
  max-height: 95px;

  overflow-y: auto;

  display: flex;
  flex-direction: column;
  gap: 4px;
}


/* ==========================================================
   COMBAT BLOCKS
   ========================================================== */

.left-combat-block,
.right-combat-block {
  display: flex;

  gap: 6px;

  min-width: 0;
}

.combat-box {
  padding: 5px;

  position: relative;

  flex: 1;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-width: 0;

  background:
    rgba(0, 0, 0, 0.02);

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.ac-box {
  background:
    rgba(139, 69, 19, 0.1);
}

.hp-box {
  flex: 1.4;

  overflow: hidden;
}

.heart-bg {
  width: 100%;
  height: 100%;

  position: absolute;
  top: 0;
  left: 0;

  z-index: 0;

  fill:
    rgba(192, 57, 43, 0.15);
}

.hp-content {
  width: 100%;

  position: relative;

  z-index: 1;

  display: flex;
  flex-direction: column;
  align-items: center;
}

.hp-inputs {
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 2px;
}


/* ==========================================================
   MAIN SHEET COLUMNS
   ========================================================== */

.left-column {
  width: 330px;

  flex-shrink: 0;

  display: flex;
  flex-direction: column;

  gap: 6px;
}

.right-column {
  width: 436px;

  flex-shrink: 0;

  display: flex;
  flex-direction: column;

  gap: 6px;
}


/* ==========================================================
   ABILITY SCORES
   ========================================================== */

.stats-grid {
  width: 100%;

  display: flex;
  flex-direction: column;

  gap: 2px;
}

.stat-row {
  padding-bottom: 1px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  border-bottom:
    1px dashed rgba(92, 64, 51, 0.3);
}

.stat-row label {
  font-size: 10.5px;
  font-weight: bold;
}

.stat-group {
  display: flex;
  align-items: center;

  gap: 4px;
}

.stat-mod {
  width: 24px;

  color:
    var(--accent-color);

  font-size: 12px;
  font-weight: bold;
  text-align: right;
}

.stat-val {
  width: 36px;

  font-size: 11px;
  font-weight: bold;
  text-align: center;
}


/* ==========================================================
   DEATH SAVES
   ========================================================== */

.death-saves-box {
  display: flex;
  flex-direction: column;

  gap: 2px;
}

.death-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  font-family:
    "Cinzel", serif;

  font-size: 9px;

  text-transform: uppercase;
}

.death-circles {
  display: flex;

  gap: 4px;
}

.death-check {
  width: 12px;
  height: 12px;

  accent-color:
    var(--accent-color);

  cursor: pointer;
}


/* ==========================================================
   SAVING THROWS AND SKILLS
   ========================================================== */

.saves-list {
  width: 100%;

  display: flex;
  flex-direction: column;

  gap: 1px;

  font-size: 10px;
}
.saving-throws-grid {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  column-gap: 8px;
  row-gap: 2px;
}

.saving-throws-grid label {
  min-width: 0;

  gap: 3px;

  font-size: 9px;
}

.saving-throws-grid .save-mod {
  width: 23px;

  flex-shrink: 0;
}
.saves-list label {
  display: flex;
  align-items: center;

  gap: 5px;

  color:
    var(--text-main);

  font-family: inherit;
  font-size: 10px;
  font-weight: normal;

  text-transform: none;
}

.save-check,
.skill-check {
  width: 11px;
  height: 11px;

  accent-color:
    var(--accent-color);

  cursor: pointer;
}

.save-mod,
.skill-mod {
  width: 24px;
  margin-left: auto;
  padding: 1px;

  background:
    var(--input-bg);

  border:
    1px solid var(--border-color);

  border-radius: 2px;

  color:
    var(--text-main);

  font-size: 9.5px;
  text-align: center;
}

.stat-hint {
  color:
    var(--text-main);

  font-size: 8.5px;

  opacity: 0.7;
}


/* ==========================================================
   ATTACKS AND SPELLCASTING
   ========================================================== */

.attacks-box {
  padding: 5px;

  display: flex;
  flex-direction: column;

  gap: 3px;

  min-width: 0;

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.header-row {
  display: grid;

  grid-template-columns:
    2fr 1fr 1fr 2fr;

  gap: 4px;

  min-width: 0;

  color:
    var(--border-color);

  font-family:
    "Cinzel", serif;

  font-size: 8.5px;
  font-weight: bold;

  text-align: center;
  text-transform: uppercase;
}

.attack-row {
  display: grid;

  grid-template-columns:
    2fr 1fr 1fr 2fr;

  gap: 4px;

  min-width: 0;
}

.attack-row input {
  padding: 2px 4px;

  min-width: 0;

  font-size: 10.5px;
}

.extra-attacks {
  height: 44px;

  min-width: 0;

  resize: none;

  font-size: 10.5px;
}


/* ==========================================================
   CLASS ABILITIES AND FEATS
   ========================================================== */

.abilities-box {
  padding: 5px;

  display: flex;
  flex-direction: column;

  gap: 3px;

  min-width: 0;

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.abilities-grid {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 2px 6px;

  min-width: 0;
}

.ability-input {
  padding: 2px 4px;

  min-width: 0;

  font-size: 9.5px;
}


/* ==========================================================
   EQUIPMENT AND CURRENCY
   ========================================================== */

.equipment-box {
  padding: 5px;

  display: flex;

  gap: 6px;

  min-width: 0;

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.money-column {
  width: 55px;

  flex-shrink: 0;

  display: flex;
  flex-direction: column;

  gap: 3px;
}

.money-field {
  display: flex;
  align-items: center;

  overflow: hidden;

  background:
    var(--input-bg);

  border:
    1px solid var(--border-color);

  border-radius: 2px;
}

.money-field label {
  width: 20px;
  padding: 2px;

  background:
    var(--accent-color);

  color: #ffffff;

  font-size: 8.5px;
  text-align: center;
}

.money-field input {
  width: 33px;
  padding: 1px;

  background: transparent;

  border: none;

  color:
    var(--text-main);

  font-size: 9.5px;
  text-align: center;
}

.inventory-text {
  height: 105px;

  flex: 1;

  min-width: 0;

  resize: none;

  font-size: 10.5px;
}


/* ==========================================================
   PAGE 2 AND GENERAL SECTIONS
   ========================================================== */

.full-width-body {
  flex: 1;

  display: flex;
  flex-direction: column;

  gap: 8px;
}

.flair-container {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;
}

.flair-ornament {
  color:
    var(--accent-color);

  font-size: 10px;
}

.flair-quote {
  width: 70%;

  font-size: 11px;
  font-style: italic;
}

.flex-row-sections {
  height: 140px;

  display: flex;

  gap: 8px;
}

.half-width {
  flex: 1;

  display: flex;
  flex-direction: column;

  min-width: 0;
}

.trait-section {
  display: flex;
  flex-direction: column;

  gap: 2px;

  min-width: 0;
}

.trait-box {
  flex: 1;

  min-width: 0;
  padding: 5px;

  resize: none;

  font-size: 10.5px;
}

.flex-grow-section {
  display: flex;
  flex-direction: column;

  min-width: 0;
}


/* ==========================================================
   SPELL PAGES
   ========================================================== */

.spell-tier {
  padding: 5px;

  flex: 1;

  display: flex;
  flex-direction: column;

  gap: 3px;

  min-width: 0;

  border:
    1px solid var(--border-color);

  border-radius: 4px;
}

.spell-tier-header {
  padding-bottom: 2px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  border-bottom:
    1px dashed rgba(92, 64, 51, 0.4);
}

.spell-guide-tip {
  font-size: 8px;

  opacity: 0.7;
}

.spell-box {
  flex: 1;

  min-width: 0;
  padding: 5px;

  resize: none;

  font-size: 10.5px;
}

/* ==========================================================
   DYNAMIC SPECIES CHOICES
   ========================================================== */

.species-choice-panel {
  grid-column: 1 / -1;

  padding: 5px;

  background:
    rgba(0, 0, 0, 0.025);

  border:
    1px dashed var(--border-color);

  border-radius: 4px;
}

.species-choice-grid {
  display: grid;

  grid-template-columns:
    repeat(
      auto-fit,
      minmax(110px, 1fr)
    );

  gap: 4px;
}

.species-choice-field[hidden] {
  display: none;
}
.species-choice-field {
  display: flex;
  flex-direction: column;

  gap: 2px;

  min-width: 0;
}

.species-choice-field label {
  font-size: 8px;
}

.species-choice-field select {
  padding: 2px 4px;

  font-size: 9px;
}

.species-choice-note {
  max-height: 28px;
  margin-top: 3px;

  overflow-y: auto;

  font-size: 7.5px;
  line-height: 1.25;

  opacity: 0.8;
}

/* ==========================================================
   SITE VERSION FOOTER
   ========================================================== */

.site-version {
  margin-top: 30px;

  flex: 0 0 100%;

  display: flex;
  align-items: center;
  flex-direction: column;

  gap: 8px;

  color: var(--text-main);

  font-size: 0.8rem;
  text-align: center;
}

.site-version-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;

  gap: 6px 14px;
}

.site-version-nav a {
  color: inherit;

  font-style: normal;
  text-decoration: none;

  opacity: 0.72;
}

.site-version-nav a:hover,
.site-version-nav a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;

  opacity: 1;
}

.site-version-copy {
  font-style: italic;
  opacity: 0.58;
}

/* ==========================================================
   BUILDER SUPPORT LINK
   Kept visually secondary to character-building controls.
   ========================================================== */

.builder-support {
  margin-top: 3px;
  padding-top: 12px;
  display: grid;
  gap: 7px;
  text-align: center;
  border-top: 1px solid #415a77;
}

.builder-support p,
.builder-support small {
  margin: 0;
}

.builder-support p {
  color: #d9e2ec;
  font-size: 11px;
}

.builder-support small {
  color: #aebdca;
  font-size: 10px;
  line-height: 1.35;
}

.builder-support-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  width: 100%;
  padding: 8px 10px;
  color: #f3d28a;
  font-family: "Cinzel", serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  background: rgba(243, 210, 138, 0.06);
  border: 1px solid rgba(243, 210, 138, 0.62);
  border-radius: 4px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.builder-support-link:hover,
.builder-support-link:focus-visible {
  color: #ffffff;
  background: rgba(243, 210, 138, 0.13);
  border-color: #f3d28a;
  outline: none;
}

.builder-support-link:focus-visible {
  box-shadow: 0 0 0 2px rgba(243, 210, 138, 0.28);
}

