/* ═══════════════════════════════════════════════════════
   DDApp-DM-theme-sketch.css
   Parchment / hand-drawn sketch theme for DM Suite
   Requires: Rubik Dirt + Cabin from Google Fonts
   <link href="https://fonts.googleapis.com/css2?family=Rubik+Dirt&family=Cabin:wght@400;600&display=swap" rel="stylesheet"/>
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:     #1a1209;
  --paper:   #f2ead8;
  --paper2:  #ede4cc;
  --muted:   #7a6f5e;
  --green:   #2a5c2a;
  --gold:    #8b6914;
  --red:     #8b1a1a;
  --orange:  #a04000;

  /* Legacy var aliases (used by page-specific inline styles) */
  --accent:  #8b6914;
  --accent2: #2a5c2a;
  --text:    #1a1209;
  --card:    #fffdf5;
  --surface: #f2ead8;
  --border:  #1a1209;
  --radius:  8px;
}

/* ── BODY & BACKGROUND ── */
body {
  font-family: 'Cabin', sans-serif;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 27px,
    rgba(0,0,0,0.035) 27px, rgba(0,0,0,0.035) 28px
  );
}

/* ── ROUGH CARD (::before border trick) ── */
.card, .rcard, .panel, .section-box, .enc-card, .pc-card, .add-form {
  position: relative;
  margin-bottom: 16px;
  padding: 16px 14px 14px;
}
.card::before, .rcard::before, .panel::before, .section-box::before,
.enc-card::before, .pc-card::before, .add-form::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #fffdf5;
  border: 2.5px solid #1a1209;
  filter: url(#noise);
  z-index: 0;
  pointer-events: none;
}
.card > *, .rcard > *, .panel > *, .section-box > *,
.enc-card > *, .pc-card > *, .add-form > * {
  position: relative;
  z-index: 1;
}

/* ── TOPBAR ── */
.topbar, #topbar {
  background: #fff9ee;
  border-bottom: 2.5px solid var(--ink);
  padding: 10px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  width: 100%;
}
.topbar h1, #topbar h1 {
  font-family: 'Rubik Dirt', cursive;
  font-size: 16px; flex: 1; color: var(--ink);
}
.top-nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.nav-links { display: flex; gap: 8px; align-items: center; }

/* ── PAGE TITLE FRAME ── */
.page-title-frame, .page-header {
  position: relative;
  margin-bottom: 24px;
  padding: 16px 18px 14px;
  width: 100%;
}
.page-title-frame::before, .page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #fffdf5;
  border: 2.5px solid #1a1209;
  filter: url(#noise);
  z-index: 0;
  pointer-events: none;
}
.page-title-frame > *, .page-header > * { position: relative; z-index: 1; }
.page-title-frame h2, .page-header h2 {
  font-family: 'Rubik Dirt', cursive;
  font-size: 32px; line-height: 1.1; margin-bottom: 4px;
}
.page-title-frame p, .page-header p {
  font-size: 18px; color: var(--muted);
}

/* ── PAGE CONTAINER ── */
.page-container {
  max-width: 1020px;
  margin: 0 auto;
  padding: 24px 16px;
  width: 100%;
}

/* ── HEADINGS ── */
.card-title,
.panel-title,
.form-title,
h3 {
  font-family: 'Rubik Dirt', cursive;
  font-size: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-start;   /* was space-between */
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1.5px dashed #bbb;
}
h2 { font-family: 'Rubik Dirt', cursive; }

/* ── BUTTONS ── */
.btn, .btn-primary, .btn-secondary, .btn-icon, .btn-add,
.btn-danger, .btn-full, .dice-btn, .dmg-btn, .heal-btn, .remove-btn {
  font-family: 'Cabin', sans-serif;
  font-size: 12px;
  border: 2px solid var(--ink);
  background: #fff9ee;
  color: var(--ink);
  padding: 5px 14px;
  cursor: pointer;
  border-radius: 125px 8px 120px 10px / 8px 120px 10px 125px;
  transition: background 0.1s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.btn:hover, .btn-secondary:hover, .btn-icon:hover,
.btn-add:hover, .remove-btn:hover { background: var(--paper2); }
.btn-primary { background: var(--ink); color: #fff9ee; }
.btn-primary:hover { background: #3a3020; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fde8e8; }
.btn-full { width: 100%; text-align: center; }
.btn-sm  { font-size: 11px; padding: 3px 10px; }
.btn-xs  { font-size: 10px; padding: 2px 7px; }
.remove-btn {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  height: 32px; width: 32px;
  padding: 0;
  text-align: center;
}
.remove-btn:hover { border-color: var(--red); color: var(--red); }

/* ── INPUTS ── */
input, select, textarea {
  font-family: 'Cabin', sans-serif;
  font-size: 13px;
  border: 2px solid #aaa;
  border-radius: 8px 60px 8px 60px / 60px 8px 60px 8px;
  padding: 5px 8px;
  background: #fffdf5;
  color: var(--ink);
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); }
.search-input, .dice-input, .name-input, .num-input { width: auto; }

/* ── FIELDS ── */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: #fffdf5;
  border: 3px solid var(--ink);
  padding: 28px 24px;
  max-width: 560px;
  width: 100%;
}
.modal-box h2 { font-family: 'Rubik Dirt', cursive; font-size: 22px; margin-bottom: 8px; }
.modal-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.modal-error { color: var(--red); font-size: 13px; margin-bottom: 8px; }

/* ── ENC LIST ITEM ── */
.enc-list-item {
  background: #fffdf5;
  border: 2px solid #aaa;
  border-radius: 8px 40px 8px 40px / 40px 8px 40px 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.enc-list-item:hover  { border-color: var(--ink); }
.enc-list-item.active { border-color: var(--ink); background: var(--paper2); }
.enc-list-item-name   { font-weight: bold; font-size: 13px; }
.enc-list-item-meta   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.enc-list-actions     { display: flex; gap: 4px; }

/* ── MON RESULT ── */
.mon-result {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px; align-items: center;
  background: #fffdf5;
  border: 2px solid #aaa;
  border-radius: 8px 40px 8px 40px / 40px 8px 40px 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.mon-result:hover { border-color: var(--ink); }
.mon-result-img {
  width: 44px; height: 44px;
  border-radius: 6px; object-fit: cover;
  background: var(--paper2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; overflow: hidden;
}
.mon-result-img img { width: 100%; height: 100%; object-fit: cover; }
.mon-result-name { font-weight: bold; font-size: 13px; }
.mon-result-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── COMBATANT ROW ── */
.combatant-row {
  display: grid;
  grid-template-columns: 56px 32px 1fr auto;
  align-items: stretch;
  border-bottom: 1.5px dashed #ccc;
  padding: 6px 4px;
}
.combatant-row:last-child { border-bottom: none; }
.combatant-row.active-turn { background: #fffbe0; border-left: 3px solid var(--gold); }
.combatant-row.dead { opacity: 0.45; }
.avatar {
  width: 100%; height: 100%; min-height: 64px;
  background: var(--paper2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; overflow: hidden;
  border-right: 2px solid #ccc;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── HP BAR ── */
.hp-bar-wrap, .c-hp-bar-wrap {
  height: 5px; background: #ddd; border-radius: 3px; margin-top: 4px;
}
.hp-bar, .c-hp-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* ── BADGES & PILLS ── */
.init-badge, .round-display {
  font-family: 'Rubik Dirt', cursive;
  font-size: 15px;
  border: 2px solid var(--ink);
  padding: 3px 12px;
  background: #fff9ee;
  border-radius: 255px 8px 180px 12px / 8px 255px 12px 180px;
  white-space: nowrap;
}
.cond-badge {
  font-size: 10px;
  border: 1.5px solid var(--ink);
  padding: 1px 7px;
  border-radius: 255px;
  background: #fff9ee;
  display: inline-block;
  margin: 1px;
}
.pc-tag     { color: var(--green); font-size: 10px; }
.monster-tag{ color: var(--red);   font-size: 10px; }

/* ── CAMP TAB ── */
.camp-tab {
  background: #fff9ee;
  border: 2px solid #aaa;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Cabin', sans-serif;
}
.camp-tab.active, .camp-tab:hover {
  border-color: var(--ink);
  background: var(--paper2);
}

/* ── STATUS / MISC ── */
.hidden   { display: none !important; }
.sub, .muted { color: var(--muted); }
.no-data  { color: var(--muted); font-size: 13px; padding: 12px 0; text-align: center; }
.status-banner {
  padding: 8px 16px;
  font-size: 13px;
  border-bottom: 1.5px dashed #bbb;
  background: #fffbe0;
}
.conn-indicator { font-size: 12px; }
.conn-indicator.disconnected { color: var(--red); }
.conn-indicator.connected    { color: var(--green); }

/* ── DICE ROLLER ── */
.dice-roller {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.dice-result {
  font-family: 'Rubik Dirt', cursive;
  font-size: 20px;
  color: var(--gold);
  min-width: 32px;
  text-align: center;
}

/* ── NOTES BAR ── */
.notes-bar {
  border-top: 1.5px dashed #bbb;
  padding-top: 10px;
  margin-top: 10px;
}

/* ── IMG UPLOAD CELL ── */
.img-cell { display: flex; flex-direction: row; gap: 4px; align-items: flex-start; }
.img-preview {
  border-radius: 6px; overflow: hidden;
  background: var(--paper2);
  border: 2px solid #aaa;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-cell-btns { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.img-pick-btn {
  cursor: pointer;
  background: #fff9ee;
  border: 2px solid #aaa;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center;
}
.img-pick-btn:hover { border-color: var(--ink); color: var(--ink); }

/* ── ACTION BAR ── */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1.5px dashed #bbb;
  margin-top: 8px;
}

/* ── LAYOUT HELPERS ── */
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }
