/* =====================================================
   Tis Wörterbuch & Wiki — Fürstentum Tismú
   Gemeinsames Stylesheet · tis.ewaldini.de
   ===================================================== */

:root {
  --bg:          #0e0e1a;
  --bg-card:     #13131f;
  --bg-el:       #1e1e30;
  --border:      #2a2a3e;
  --accent:      #c9a84c;
  --accent-h:    #e8c96a;
  --text:        #e8e0d0;
  --text-dim:    #a89070;
  --text-dark:   #0e0e1a;
  --danger:      #c97a7a;
  --danger-bg:   #2a1a1a;
  --font:        Georgia, 'Times New Roman', serif;
  --radius:      8px;
  --radius-lg:   12px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  padding: 1.5rem 2rem;
  text-align: center;
  border-bottom: 2px solid var(--accent);
  position: relative;
}

header h1 {
  font-size: 1.9rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

header p {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.88rem;
}

.header-buttons {
  position: absolute;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Buttons (allgemein) ── */
.btn {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: var(--text-dark); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--text-dark);
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.btn-danger {
  background: transparent;
  border: 1px solid #8a3a3a;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

/* Aktiv-Zustand (z.B. Richtungsbutton) */
.btn-toggle { background: var(--bg-el); border: 1px solid var(--border); color: var(--text); }
.btn-toggle:hover  { border-color: var(--accent); }
.btn-toggle.active { background: var(--accent); border-color: var(--accent); color: var(--text-dark); }

/* ── Legal-Panel (klappt unter Header) ── */
.legal-panel {
  display: none;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  text-align: right;
  font-size: 0.82rem;
  gap: 1.5rem;
}
.legal-panel.open { display: flex; justify-content: flex-end; }
.legal-panel a { color: var(--text-dim); text-decoration: none; }
.legal-panel a:hover { color: var(--text); }

/* ── Suchleiste / Controls ── */
.controls {
  background: var(--bg-card);
  padding: 0.9rem 1.5rem;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.search-wrap {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.2rem;
  background: var(--bg-el);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.search-wrap input:focus { border-color: var(--accent); }

.search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

select {
  padding: 0.55rem 0.8rem;
  background: var(--bg-el);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
}

.count {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ── Kachel-Raster ── */
.tiles {
  padding: 1.2rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.85rem;
}

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 100px;
}
.tile:hover {
  border-color: var(--accent);
  background: #1a1a2e;
}

.tile-tis {
  font-size: 1.05rem;
  color: var(--accent);
  font-style: italic;
  font-weight: bold;
  word-break: break-word;
  line-height: 1.3;
}
.tile-de {
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}
.tile-badge { margin-top: auto; padding-top: 0.5rem; }

/* ── Badges / Kategorien ── */
.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  border: 1px solid;
  white-space: nowrap;
}

.b-woerterbuch    { background: #1a2a1a; color: #7ab87a; border-color: #2a5c2a; }
.b-personen       { background: #2a1a2a; color: #b87ab8; border-color: #5c2a5c; }
.b-tiere          { background: #2a1a1a; color: #b8907a; border-color: #5c3a2a; }
.b-koerper        { background: #1a2a2a; color: #7ab8b8; border-color: #2a5c5c; }
.b-sprachen       { background: #2a2a1a; color: #b8b87a; border-color: #5c5c2a; }
.b-suffixe        { background: #2a1a2a; color: #c9a84c; border-color: #5c4a2a; }
.b-zahlen         { background: #1a1a2a; color: #8a9ab8; border-color: #2a2a5c; }
.b-default        { background: #1a2a1a; color: #7ab87a; border-color: #2a5c2a; }

/* Suchmarkierung */
mark { background: #4a4a00; color: #fff; border-radius: 2px; padding: 0 1px; }

/* ── Leer-Zustand ── */
.empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-dim);
  font-style: italic;
  grid-column: 1 / -1;
}

/* ── Modals (allgemein) ── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  max-width: 520px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
}
.modal-close:hover { color: var(--text); }

/* Detail-Modal */
.modal-tis   { font-size: 1.8rem; color: var(--accent); font-style: italic; margin-bottom: 0.2rem; line-height: 1.2; }
.modal-aussr { color: #7a9ab8; font-size: 0.85rem; margin-bottom: 0.8rem; }
.modal-de    { font-size: 1rem; margin-bottom: 1rem; }

.modal-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.4rem;
}
.modal-label { color: var(--text-dim); font-size: 0.8rem; min-width: 90px; }
.modal-val   { font-size: 0.88rem; }

.modal-beschr {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.6;
}

.modal-admin {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: none;
  gap: 0.5rem;
}
.modal-admin.open { display: flex; }

/* ── Formular (Add/Edit) ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.form-label {
  color: var(--text-dim);
  font-size: 0.8rem;
}
.form-input {
  padding: 0.5rem 0.8rem;
  background: var(--bg-el);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; min-height: 80px; }

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.form-msg {
  font-size: 0.82rem;
  color: var(--danger);
  display: none;
  margin-top: 0.2rem;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.2rem;
  color: #4a4a6a;
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
footer a { color: #6a6a8a; text-decoration: none; }
footer a:hover { color: var(--text-dim); }

/* ── Responsive ── */
@media (max-width: 640px) {
  header { padding: 1rem 1rem 0.8rem; }
  header h1 { font-size: 1.4rem; }

  .header-buttons {
    position: static;
    transform: none;
    justify-content: center;
    margin-top: 0.8rem;
  }

  .tiles {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.65rem;
    padding: 0.9rem 1rem;
  }

  .modal { padding: 1.3rem; }
}
