/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ── Design tokens ───────────────────────────────────────── */
:root {
  --ink:        #1a1510;
  --parchment:  #12100d;
  --surface:    #1e1a14;
  --surface-2:  #28231a;
  --border:     #3a3020;
  --gold:       #c9933a;
  --gold-dim:   #7a5820;
  --text:       #d4c9b0;
  --text-dim:   #7a7060;
  --red:        #8b2a2a;
  --red-bright: #c0392b;
  --green:      #2a5a3a;
  --radius:     4px;
}

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

html, body {
  height: 100%;
  background: var(--parchment);
  color: var(--text);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 18px;
  line-height: 1.6;
}

/* ── Noise texture overlay ───────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.4;
}

/* ── Layout shell ────────────────────────────────────────── */
.shell { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Nav ─────────────────────────────────────────────────── */
nav.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
nav.topbar .brand {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.1rem; color: var(--gold);
  letter-spacing: 0.05em; text-decoration: none;
  flex: 1;
}
nav.topbar a { color: var(--text-dim); text-decoration: none; font-family: 'Cinzel', serif; font-size: 0.8rem; letter-spacing: 0.08em; }
nav.topbar a:hover { color: var(--gold); }

/* ── Main content ────────────────────────────────────────── */
main.content { flex: 1; padding: 2.5rem 2rem; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ── Flash messages ──────────────────────────────────────── */
.flash { padding: 0.7rem 1.2rem; border-radius: var(--radius); margin-bottom: 1.5rem; font-size: 0.9rem; font-family: 'Cinzel', serif; }
.flash.notice { background: var(--green); color: #a0d4b0; border: 1px solid #3a8a5a; }
.flash.alert  { background: var(--red);   color: #e0a0a0; border: 1px solid var(--red-bright); }

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3 { font-family: 'Cinzel', serif; font-weight: 600; color: var(--gold); letter-spacing: 0.04em; }
h1 { font-size: 2rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.3rem; margin-bottom: 1rem; }
h3 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 0.75rem; }

/* ── Ornamental divider ──────────────────────────────────── */
.ornament { text-align: center; color: var(--gold-dim); font-size: 1.2rem; margin: 2rem 0; letter-spacing: 0.4em; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--gold-dim); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 0.5rem 1.2rem;
  font-family: 'Cinzel', serif; font-size: 0.78rem; letter-spacing: 0.1em;
  border-radius: var(--radius); border: 1px solid; cursor: pointer;
  text-decoration: none; transition: all 0.15s;
}
.btn-gold   { background: var(--gold);    color: var(--ink);  border-color: var(--gold); }
.btn-gold:hover { background: #e0a840; }
.btn-ghost  { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--gold-dim); color: var(--gold); }
.btn-danger { background: transparent; color: #e07070; border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #ffd0d0; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.72rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
label { display: block; font-family: 'Cinzel', serif; font-size: 0.75rem; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 0.4rem; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.55rem 0.8rem; font-family: 'Crimson Pro', serif; font-size: 1rem;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-dim); }
textarea { resize: vertical; min-height: 100px; }

/* ── Tables ──────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th { font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.1em; color: var(--text-dim); text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }

/* ── Badge ───────────────────────────────────────────────── */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 2px; font-family: 'Cinzel', serif; font-size: 0.65rem; letter-spacing: 0.08em; }
.badge-type { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); }

/* ── Item grid ───────────────────────────────────────────── */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }

/* ── Entry sections ──────────────────────────────────────── */
.entry-section { margin-top: 2rem; }
.entry-section + .entry-section { border-top: 1px solid var(--border); padding-top: 2rem; }

.entry { background: var(--surface-2); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 0.75rem; position: relative; }
.entry .entry-actions { position: absolute; top: 0.75rem; right: 0.75rem; display: flex; gap: 0.5rem; opacity: 0; transition: opacity 0.15s; }
.entry:hover .entry-actions { opacity: 1; }

.entry-dm   { border-left: 3px solid #8b2a2a; }
.entry-info { border-left: 3px solid var(--gold-dim); }
.entry-pn   { border-left: 3px solid #2a5a6a; }

/* ── Visibility pills ────────────────────────────────────── */
.pill-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.pill { padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.72rem; font-family: 'Cinzel', serif; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); }

/* ── HTMX loading indicator ──────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Utility ─────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 0.85rem; }

/* ── Search ──────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

#campaign-search {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  padding: 0.4rem 0.9rem;
  transition: border-color 0.15s;
}
#campaign-search:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 999;
  max-height: 60vh;
  overflow-y: auto;
}
.search-dropdown[hidden] { display: none; }

/* Keyboard / hover selection */
.search-result.is-active {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--gold);
}
.search-result mark {
  background: transparent;
  color: var(--gold);
  font-weight: 600;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--surface-2); }

.search-result-icon { font-size: 1.1rem; flex-shrink: 0; }

.search-result-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.search-result-title {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-badge {
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.search-result-badge.title       { border-color: var(--gold-dim); color: var(--gold); }
.search-result-badge.information { border-color: #5a4a20; color: #c0a060; }
.search-result-badge.personal_note { border-color: #1a4a5a; color: #60a0c0; }
.search-result-badge.dm_note    { border-color: var(--red); color: #e07070; }

.search-empty {
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
}

/* ── Notification badge ───────────────────────────────────── */
.notif-badge {
  position: absolute;
  top: -6px; right: -10px;
  background: var(--red-bright);
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  min-width: 16px; height: 16px;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

/* ── Timeline ────────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 680px;
}

.timeline-entry {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.timeline-entry:last-child { border-bottom: none; }

.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 0.4rem;
  flex-shrink: 0;
  border: 2px solid;
}
.timeline-dot.item_revealed         { background: var(--gold);    border-color: var(--gold); }
.timeline-dot.information_revealed  { background: transparent;    border-color: var(--gold-dim); }
.timeline-dot.personal_note_created { background: transparent;    border-color: #2a7a8a; }

.timeline-body  { flex: 1; }
.timeline-label { font-family: 'Cinzel', serif; font-size: 0.85rem; margin-bottom: 0.25rem; }
.timeline-excerpt { font-size: 0.9rem; font-style: italic; margin-bottom: 0.25rem; }
.timeline-time  { font-size: 0.75rem; }

/* Trix editor */
.trix-button-group {
  background-color: white;
}
