/* ===== Shared site-wide base ===== */
/* Loaded by every page before its own style.css. Contains everything
   that's genuinely identical across pages: color variables (each page
   overrides --accent to its own system color right after loading this
   file, everything else here is meant to stay shared), typography,
   the site header/footer, the deck/form/preview panel layout, form
   elements, buttons, and the back-to-top control. Card-specific styling
   (the actual statblock/item/settlement/etc. card layout) stays in each
   page's own style.css, since that's genuinely different per page. */

:root {
  --bg: #f0ead9;
  --panel: #e6dfc8;
  --panel-border: #a8a077;
  --text: #2e2b1f;
  --text-dim: #6b6650;
  --accent: #6b3fa0;
  --gold: #a9843f;
  --mono: 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at top, #f6f1e0 0%, #e9e0c4 70%);
  color: var(--text);
  font-family: 'Work Sans', -apple-system, sans-serif;
}

.site-header {
  padding: 30px 20px 18px;
  text-align: center;
  border-bottom: 1px solid var(--panel-border);
}

.back-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.back-link:hover { color: var(--gold); }

.cross-link {
  display: block;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--gold);
  text-decoration: none;
}

.cross-link:hover { text-decoration: underline; }

.site-header h1 {
  margin: 0;
  font-family: 'Spectral', Georgia, serif;
  font-weight: 700;
  font-size: 2.1rem;
  letter-spacing: 1.5px;
  color: var(--text);
}

.tagline {
  color: var(--text-dim);
  margin: 6px 0 0;
  font-size: 0.95rem;
  font-style: italic;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 24px 20px 60px;
  max-width: 1300px;
  margin: 0 auto;
}

.deck-panel {
  flex: 0 1 220px;
  min-width: 200px;
  position: sticky;
  top: 16px;
  align-self: flex-start;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.form-panel, .preview-panel {
  flex: 1 1 420px;
  min-width: 320px;
}

.deck-panel h2 {
  font-family: 'Spectral', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gold);
  margin: 0 0 10px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
}

#deck-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  max-height: 260px;
  overflow-y: auto;
}

.deck-item {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--panel-border);
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s ease;
}

.deck-item.active {
  border-left-color: var(--accent);
  background: rgba(169, 132, 63, 0.22);
  color: var(--text);
}

.deck-panel button, .file-btn {
  display: block;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 8px;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Work Sans', -apple-system, sans-serif;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.deck-panel button:hover, .file-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.file-btn { box-sizing: border-box; }

.deck-io {
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
  margin-top: 8px;
}

#deck-status {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  min-height: 1.2em;
  font-style: italic;
}

#deck-status a {
  color: var(--gold);
}

.type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.type-btn {
  flex: 1;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: 'Work Sans', -apple-system, sans-serif;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.type-btn:hover { border-color: var(--accent); }

.type-btn.active {
  background: var(--accent);
  color: #f3ead8;
  border-color: var(--accent);
}

fieldset {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-top: 2px solid var(--accent);
  margin-bottom: 18px;
  padding: 16px 18px 18px;
}

legend {
  padding: 0 8px;
  color: var(--gold);
  font-family: 'Spectral', Georgia, serif;
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  background: #f7f2e2;
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Work Sans', -apple-system, sans-serif;
}
.combobox-wrapper { position: relative; }

.combobox-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  margin: 2px 0 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.combobox-dropdown li {
  padding: 7px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
}

.combobox-dropdown li:hover { background: var(--gold); color: var(--panel); }

#back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  padding: 10px 18px;
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-family: 'Work Sans', -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  transition: background 0.15s ease, transform 0.1s ease;
}

#back-to-top:hover { background: var(--accent); color: #f3ead8; transform: translateY(-1px); }

.randomize-bar {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 14px;
  text-align: center;
}

.randomize-bar button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #f3ead8;
  border: none;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.randomize-bar button:hover { opacity: 0.9; }

.stats-randomize-row { display: flex; gap: 8px; }
.stats-randomize-row button { width: auto; flex: 1; }
#reset-stats { background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); }
#reset-stats:hover { border-color: var(--gold); color: var(--gold); opacity: 1; }
.randomize-bar.stats-disabled { opacity: 0.5; pointer-events: none; }

.randomize-bar .hint { margin: 8px 0 0; text-align: left; }

.field-highlighted {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  background: rgba(169, 132, 63, 0.12);
  border-radius: 2px;
  transition: background 0.15s ease, outline-color 0.15s ease;
}

@media (max-width: 760px) {
  #back-to-top { bottom: 16px; right: 16px; padding: 9px 14px; font-size: 0.78rem; }
}


input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="color"] { padding: 2px; height: 38px; }

textarea { resize: vertical; }

.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 20px;
  border-top: 1px solid var(--panel-border);
  font-style: italic;
}

.kofi-footer-link { margin-top: 10px; font-style: normal; }
.kofi-footer-link a { color: var(--gold); text-decoration: none; font-size: 0.78rem; }
.kofi-footer-link a:hover { text-decoration: underline; }

/* The newer "tool" pages (Settlement, Pantheon, Session Zero, Conditions)
   use a slightly different header/layout markup convention than the
   original Daggerheart/5E/PF2E pages above, a bare <p> under
   .site-header instead of a .tagline class, and a bare <main> as the
   flex layout container instead of a .layout class. Both conventions
   are supported here side by side since they use different selectors
   and never conflict, each page's own HTML only matches whichever
   convention it actually uses. */
.site-header p {
  color: var(--text-dim);
  font-size: 0.92rem;
  font-style: italic;
  margin: 0;
}
main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
/* Tool pages render deck items as plain divs rather than a scrolling
   flex column, so #deck-list only needs a simple list reset here. */
#deck-list { list-style: none; margin: 0 0 14px; padding: 0; }

