/* ════════════════════════════════════════════════════════════════════
   Eapheron DM Tools — shared styles for the Succession Crisis tool pages.
   Linked from every tool page; design tokens defined here once.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --parchment:    #FDF0D0;
  --ink:          #2C1810;
  --wine:         #5C2248;
  --wine-bright:  #7B1E54;
  --wine-dark:    #3D1630;
  --tint:         #F0E0C0;
  --tint-dark:    #E8D5A3;
  --gold:         #E8C88A;
  --gold-dark:    #C8A060;
  --rule:         2px solid #5C2248;
  --font-display: 'IM Fell English SC', serif;
  --font-body:    'Crimson Pro', serif;

  /* pressure colour scale */
  --p-stable:   #2C6E49;  /* 1-3 green  */
  --p-elevated: #C9820A;  /* 4-6 amber  */
  --p-critical: #8B2000;  /* 7-9 red    */
  /* 10 = crisis -> var(--wine) */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--wine); line-height: 1.2; }
a { color: var(--wine-bright); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--gold); }

/* ─── Site nav (brand strip) ──────────────────────────────────────── */
.site-nav { background: var(--wine); position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(44,24,16,0.25); }
.site-nav__inner { display: flex; align-items: center; justify-content: space-between; max-width: 1100px; margin: 0 auto; padding: 0 2rem; }
.site-nav__brand { font-family: var(--font-display); color: var(--gold); font-size: 1.05rem; letter-spacing: 0.05em; padding: 0.9rem 0; text-decoration: none; }
.site-nav__brand:hover { color: #fff; text-decoration: none; }

/* ─── Tool switcher (persistent secondary nav) ────────────────────── */
.tool-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0; background: var(--tint-dark); border-bottom: 1px solid rgba(92,34,72,0.25); }
.tool-nav a { font-family: var(--font-display); font-size: 0.85rem; letter-spacing: 0.04em; color: var(--wine); padding: 0.5rem 0.95rem; border-bottom: 2px solid transparent; }
.tool-nav a:hover { background: var(--tint); text-decoration: none; }
.tool-nav a.active { border-bottom-color: var(--wine); color: var(--wine-bright); background: var(--parchment); }
@media print { .tool-nav { display: none !important; } }

/* ─── DM tool header ──────────────────────────────────────────────── */
.dm-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 2rem 0.75rem;
}
.dm-header-left { justify-self: start; }
.dm-header-right { justify-self: end; }
.dm-header-title { font-family: var(--font-display); color: var(--wine); font-size: clamp(1.6rem, 4vw, 2.4rem); text-align: center; }
.back-link { color: var(--wine-bright); font-size: 0.95rem; }

/* ─── Layout shells ───────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 2rem 3rem; flex: 1; width: 100%; }
.narrow { max-width: 820px; }

.panel {
  background: var(--parchment);
  border: 1px solid rgba(92,34,72,0.25);
  border-top: 3px solid var(--wine);
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
}
.panel > h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.panel > h2.section-rule { border-bottom: var(--rule); padding-bottom: 0.4rem; }

/* two-panel master/detail (missions, characters) */
.split { display: grid; grid-template-columns: 30% 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }

/* ─── Forms ───────────────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; font-family: var(--font-display); color: var(--wine); font-size: 0.95rem; letter-spacing: 0.02em; margin-bottom: 0.3rem; }
label.field .req { color: var(--wine-bright); }
label.field .hint { font-family: var(--font-body); font-style: italic; opacity: 0.6; font-size: 0.82rem; letter-spacing: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

input[type="text"], input[type="number"], input[type="date"], textarea, select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(92,34,72,0.35);
  border-radius: 0;
  padding: 0.55rem 0.7rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--wine); box-shadow: 0 0 0 2px rgba(123,30,84,0.18); }
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.5; }

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  padding: 0.7rem 1.5rem;
  border: 2px solid var(--wine);
  border-radius: 0;
  background: var(--wine);
  color: var(--parchment);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--wine-dark); text-decoration: none; }
.btn--outline { background: transparent; color: var(--wine); }
.btn--outline:hover { background: var(--wine); color: var(--parchment); }
.btn--danger { background: transparent; border-color: #8B2000; color: #8B2000; }
.btn--danger:hover { background: #8B2000; color: #fff; }
.btn--small { padding: 0.4rem 0.9rem; font-size: 0.82rem; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; background: var(--tint-dark); color: var(--ink); border-color: var(--gold-dark); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 1rem; }

/* tab-style toggle buttons (journal categories, filters) */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tab {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.45rem 1rem;
  border: 1px solid var(--wine);
  background: var(--tint);
  color: var(--ink);
  cursor: pointer;
}
.tab.active { background: var(--wine); color: var(--gold); }

/* ─── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 0;
  white-space: nowrap;
}
/* mission status */
.badge--seeded    { background: var(--tint); color: var(--ink); }
.badge--active    { background: #2C6E49; color: #fff; }
.badge--escalated { background: #C9820A; color: #fff; }
.badge--closed    { background: #888; color: #fff; }
/* reputation */
.badge--trusted   { background: #2C6E49; color: #fff; }
.badge--neutral   { background: var(--tint); color: var(--ink); }
.badge--flagged   { background: #C9820A; color: #fff; }
.badge--suspended { background: var(--wine); color: var(--gold); }
/* journal categories */
.badge--people     { background: var(--wine); color: var(--gold); }
.badge--places     { background: var(--tint); color: var(--wine); }
.badge--atmosphere { background: var(--ink); color: var(--parchment); }

/* ─── Tables ──────────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th { font-family: var(--font-display); color: var(--wine); text-align: left; border-bottom: var(--rule); padding: 0.5rem 0.6rem; font-weight: normal; }
table.data td { border-bottom: 1px solid rgba(92,34,72,0.15); padding: 0.55rem 0.6rem; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }

/* pressure cell colouring */
.p-cell { font-family: var(--font-display); text-align: center; color: #fff; font-size: 1.05rem; }
.p-stable   { background: var(--p-stable); }
.p-elevated { background: var(--p-elevated); }
.p-critical { background: var(--p-critical); }
.p-crisis   { background: var(--wine); }

/* ─── Cards (journal, list panels) ────────────────────────────────── */
.card {
  position: relative;
  background: var(--parchment);
  border: 1px solid rgba(92,34,72,0.2);
  border-left: 3px solid var(--wine);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
}
.card__meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.card__time { font-style: italic; opacity: 0.6; font-size: 0.85rem; }
.card__body { white-space: pre-wrap; }
.card__tags { margin-top: 0.5rem; font-size: 0.82rem; opacity: 0.75; }
.card__del { position: absolute; top: 0.5rem; right: 0.6rem; border: none; background: none; color: var(--wine); font-size: 1.2rem; line-height: 1; cursor: pointer; opacity: 0.5; }
.card__del:hover { opacity: 1; }

/* selectable list items (master panel) */
.list-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--parchment);
  border: 1px solid rgba(92,34,72,0.2);
  border-left: 3px solid transparent;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink);
}
.list-item:hover { border-left-color: var(--gold-dark); }
.list-item.selected { border-left-color: var(--wine); background: var(--tint); }
.list-item__title { font-family: var(--font-display); color: var(--wine); font-size: 1rem; }
.list-item__sub { font-size: 0.82rem; opacity: 0.7; }

/* ─── Collapsible (prep layers) ───────────────────────────────────── */
details.layer { border: 1px solid rgba(92,34,72,0.25); border-left: 3px solid var(--wine); margin-bottom: 1rem; background: var(--parchment); }
details.layer > summary { font-family: var(--font-display); color: var(--wine); font-size: 1.15rem; padding: 0.8rem 1rem; cursor: pointer; list-style: none; }
details.layer > summary::-webkit-details-marker { display: none; }
details.layer > summary::before { content: '▸ '; color: var(--gold-dark); }
details.layer[open] > summary::before { content: '▾ '; }
details.layer .layer__body { padding: 0 1rem 1rem; }
details.layer .layer__hint { font-style: italic; opacity: 0.6; font-size: 0.85rem; margin-bottom: 0.5rem; }

/* ─── Help / "how to use this tool" panel ─────────────────────────── */
.help { background: var(--tint); border: 1px solid rgba(92,34,72,0.25); border-left: 4px solid var(--gold-dark); margin-bottom: 1.5rem; }
.help > summary { font-family: var(--font-display); color: var(--wine); font-size: 1.05rem; letter-spacing: 0.02em; padding: 0.75rem 1.1rem; cursor: pointer; list-style: none; }
.help > summary::-webkit-details-marker { display: none; }
.help > summary::before { content: '\24D8'; color: var(--gold-dark); margin-right: 0.45rem; }
.help[open] > summary { border-bottom: 1px solid rgba(92,34,72,0.2); }
.help__body { padding: 0.9rem 1.25rem 1.1rem; font-size: 0.95rem; }
.help__body > p { margin-bottom: 0.6rem; }
.help__body h4 { font-size: 0.95rem; margin: 0.8rem 0 0.3rem; letter-spacing: 0.03em; }
.help__body ul { margin: 0.2rem 0 0.7rem 1.1rem; }
.help__body li { margin-bottom: 0.35rem; }
.help__body strong { font-family: var(--font-display); font-weight: normal; color: var(--wine-bright); }
.help__body .tip { font-style: italic; opacity: 0.82; margin-top: 0.4rem; }
.help__body code { background: rgba(92,34,72,0.1); padding: 0.05rem 0.3rem; font-size: 0.88em; }
@media print { .help { display: none !important; } }

/* ─── Loading & empty states ──────────────────────────────────────── */
.loading { display: flex; align-items: center; gap: 0.7rem; color: var(--wine); font-style: italic; padding: 1rem 0; }
.spinner { width: 1.1rem; height: 1.1rem; border: 2px solid rgba(92,34,72,0.25); border-top-color: var(--wine); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { font-style: italic; opacity: 0.65; padding: 1rem 0; }

/* ─── Save-state indicator + draft restore banner ─────────────────── */
.save-state { font-style: italic; font-size: 0.85rem; align-self: center; }
.save-state.unsaved { color: #8B2000; }
.save-state.saved { color: var(--p-stable); }
.draft-banner { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; background: var(--tint); border: 1px solid var(--gold-dark); border-left: 4px solid #C9820A; padding: 0.7rem 1rem; margin-bottom: 1rem; }
.draft-banner__msg { flex: 1; font-style: italic; min-width: 12rem; }
@media print { .save-state, .draft-banner { display: none !important; } }

/* ─── Toast ───────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--wine);
  color: var(--gold);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  padding: 0.8rem 1.5rem;
  box-shadow: 0 4px 18px rgba(44,24,16,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #8B2000; color: #fff; }

/* ─── Reference pages (Ontstead, Expundeus, gazetteer) ────────────── */
.reference { max-width: 860px; }
.reference .lead { font-size: 1.08rem; font-style: italic; opacity: 0.9; margin-bottom: 1.25rem; }
.reference h2 { font-size: 1.5rem; border-bottom: var(--rule); padding-bottom: 0.3rem; margin: 2.25rem 0 0.9rem; scroll-margin-top: 1rem; }
.reference h3 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; }
.reference h4 { font-size: 1rem; margin: 1rem 0 0.3rem; letter-spacing: 0.02em; }
.reference p { margin-bottom: 0.85rem; }
.reference ul, .reference ol { margin: 0.3rem 0 1rem 1.3rem; }
.reference li { margin-bottom: 0.4rem; }
.reference blockquote { background: var(--wine); color: #F5E6C8; padding: 1rem 1.3rem; margin: 1.25rem 0; font-style: italic; }
.reference blockquote p:last-child { margin-bottom: 0; }

/* table of contents box */
.toc-box { background: var(--tint); border-left: 3px solid var(--wine); padding: 1rem 1.3rem; margin-bottom: 1.5rem; }
.toc-box h2 { border: none; margin: 0 0 0.5rem; font-size: 1.1rem; padding: 0; }
.toc-box ul { list-style: none; margin: 0; columns: 2; column-gap: 1.5rem; }
@media (max-width: 620px) { .toc-box ul { columns: 1; } }
.toc-box li { margin-bottom: 0.3rem; }

/* DM-only / behind-the-screen block */
.secret { background: var(--ink); color: #F0E0C0; border-left: 4px solid var(--gold-dark); padding: 1rem 1.3rem; margin: 1.1rem 0; }
.secret > .secret__tag { display: block; font-family: var(--font-display); color: var(--gold); font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 0.5rem; }
.secret h3, .secret h4 { color: var(--gold); margin-top: 0.6rem; }
.secret h3:first-of-type, .secret h4:first-of-type { margin-top: 0; }
.secret a { color: var(--gold); }
.secret strong { color: #fff; }

/* figure / NPC / district card */
.figure { border: 1px solid rgba(92,34,72,0.2); border-left: 3px solid var(--wine); background: var(--parchment); padding: 0.85rem 1.1rem; margin-bottom: 0.9rem; }
.figure__name { font-family: var(--font-display); color: var(--wine); font-size: 1.1rem; }
.figure__role { font-style: italic; opacity: 0.75; font-size: 0.92rem; margin-bottom: 0.35rem; }
.figure p { margin-bottom: 0.4rem; }
.figure .tellpressure { font-size: 0.9rem; }
.figure .tellpressure b { font-family: var(--font-display); font-weight: normal; color: var(--wine-bright); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }

/* compact "back to top" */
.toplink { display: inline-block; font-size: 0.8rem; font-style: italic; opacity: 0.6; margin-top: 0.3rem; }

@media print {
  .reference .secret { background: #fff; color: var(--ink); border-left: 4px solid var(--ink); }
  .reference .secret .secret__tag, .reference .secret h3, .reference .secret h4, .reference .secret a { color: var(--ink); }
}

/* ─── Footer ──────────────────────────────────────────────────────── */
.site-footer { background: var(--ink); color: rgba(245,230,200,0.7); padding: 1.5rem; text-align: center; font-size: 0.85rem; }
.site-footer__copy { opacity: 0.45; font-size: 0.78rem; line-height: 1.6; }

/* ─── Print (prep sheet & session brief) ──────────────────────────── */
@media print {
  .site-nav, .dm-header, .site-footer, .no-print, .btn, .btn-row, .tabs { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .panel, .card, details.layer { border: none; box-shadow: none; padding: 0.3rem 0; }
  details.layer[open] > summary::before, details.layer > summary::before { content: ''; }
  details.layer:not([open]) { display: none; }
  textarea { border: none; resize: none; height: auto; min-height: 0; padding: 0; background: none; }
  a { color: var(--ink); }
}
