/* ─── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--theme-font-body);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--theme-bg);
  color: var(--theme-fg);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--theme-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5, h6 { font-family: var(--theme-font-display); }

/* ─── Layout ─────────────────────────────────────────────────────── */
.page-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--theme-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--theme-section-heading-fg);
}

.page-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ─── Section ────────────────────────────────────────────────────── */
section {
  background: var(--theme-section-bg);
  color: var(--theme-section-fg);
  border: 1px solid var(--theme-section-border);
  border-radius: 8px;
  padding: 1.25rem;
}

section > header {
  /* negative bleed: pull header back to section edges, add its own border */
  margin: -1.25rem -1.25rem 1.25rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

section > header h1 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--theme-section-heading-fg);
}

/* ─── Item list ──────────────────────────────────────────────────── */
ul.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

ul.item-list li.item {
  background: var(--theme-item-bg);
  color: var(--theme-item-fg);
  border: 1px solid var(--theme-item-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  transition: background 0.15s;
}

ul.item-list li.item:hover {
  background: var(--theme-item-hover-bg);
}

ul.item-list li.item h1 {
  grid-column: 1;
  grid-row: 1;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

ul.item-list li.item h1 a {
  color: inherit;
}

ul.item-list li.item .item-meta {
  grid-column: 1;
  grid-row: 2;
}

.item-meta {
  font-size: 0.8rem;
  color: var(--theme-item-meta-fg);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.badge {
  display: inline-block;
  padding: 0.35em 0.7em 0.25em;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: var(--theme-font-badge);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-jedi   { background: var(--theme-badge-jedi-bg);   color: var(--theme-badge-jedi-fg);   border: 1px solid var(--theme-badge-jedi-border); }
.badge-sith   { background: var(--theme-badge-sith-bg);   color: var(--theme-badge-sith-fg);   border: 1px solid var(--theme-badge-sith-border); }
.badge-alive  { background: var(--theme-badge-alive-bg);  color: var(--theme-badge-alive-fg);  border: 1px solid var(--theme-badge-alive-border); }
.badge-fallen { background: var(--theme-badge-fallen-bg); color: var(--theme-badge-fallen-fg); border: 1px solid var(--theme-badge-fallen-border); }

.item-actions {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  align-self: center;
  gap: 0.4rem;
}

/* ─── Buttons ────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.45em 0.85em;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 5px;
  border: 1px solid var(--theme-btn-border);
  background: var(--theme-btn-bg);
  color: var(--theme-btn-fg);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: var(--theme-font-btn);
  text-transform: var(--theme-btn-text-transform);
}

button:hover, .btn:hover {
  background: var(--theme-btn-hover-bg);
}

button.primary {
  background: var(--theme-btn-primary-bg);
  color: var(--theme-btn-primary-fg);
  border-color: var(--theme-btn-primary-border);
}
button.primary:hover { background: var(--theme-btn-primary-hover); }

button.danger {
  background: var(--theme-btn-danger-bg);
  color: var(--theme-btn-danger-fg);
  border-color: transparent;
}
button.danger:hover { background: var(--theme-btn-danger-hover); }

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--theme-muted);
}
button.ghost:hover {
  background: var(--theme-item-hover-bg);
  color: var(--theme-fg);
}

/* ─── Inputs ─────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 150px;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--theme-muted);
}

input[type="text"],
input[type="search"],
select {
  background: var(--theme-input-bg);
  color: var(--theme-input-fg);
  border: 1px solid var(--theme-input-border);
  border-radius: 5px;
  padding: 0.45em 0.75em;
  font-size: 0.9rem;
  line-height: 1;
  font-family: var(--theme-font-ui);
  width: 100%;
  transition: border-color 0.15s;
}

input::placeholder,
textarea::placeholder { color: var(--theme-input-placeholder); }

input:focus, select:focus {
  outline: none;
  border-color: var(--theme-input-focus-border);
  box-shadow: 0 0 0 3px var(--theme-focus-ring);
}

/* ─── Popup overlay ──────────────────────────────────────────────── */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--theme-popup-overlay);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.popup-overlay.active {
  display: flex;
}

.popup {
  background: var(--theme-popup-bg);
  color: var(--theme-popup-fg);
  border: 1px solid var(--theme-popup-border);
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px #000a;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.popup-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--theme-section-heading-fg);
}

.popup-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--theme-popup-fg);
  margin-bottom: 1.25rem;
}

.popup-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ─── Theme controls ─────────────────────────────────────────────── */
.theme-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--theme-muted);
}
