/* =========================================================
   pw.zhl-ubt.de — Shortlink-Tool
   Theme: „editorial ink" — warmes Dark-Theme, Serifen-Display,
   Monospace als Leitmotiv für Slugs/URLs.
   Schriften lokal (DSGVO): .woff2 unter /assets/fonts/.
   ========================================================= */

/* ---------- Lokale Schriften ---------- */
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/assets/fonts/schibsted-grotesk-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/assets/fonts/schibsted-grotesk-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Design-Tokens ---------- */
:root {
  --ink:        #15130f;   /* warmes Off-Black, Grund */
  --ink-2:      #1d1a15;   /* Panel */
  --ink-3:      #272219;   /* Felder / Rahmen-Fill */
  --paper:      #f4efe6;   /* Haupttext */
  --muted:      #a39a88;   /* Sekundärtext */
  --muted-2:    #6f685a;   /* noch leiser */
  --line:       #38322833; /* feine Linien (mit Alpha) */
  --line-solid: #3a3326;
  --accent:     #d8f24a;   /* Signal-Akzent (Chartreuse) */
  --accent-ink: #1a1c05;   /* Text auf Akzent */
  --danger:     #e8714e;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 14px;
  --maxw: 880px;
}

/* ---------- Reset / Grund ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Atmosphäre: weiche Lichtquelle + feines Korn */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 80% at 12% -10%, #2a2519 0%, transparent 55%),
    radial-gradient(90% 70% at 100% 0%, #211d14 0%, transparent 50%);
  z-index: -2;
  pointer-events: none;
}
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }

/* ---------- Typo-Bausteine ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.1rem;
}
.display {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
}
.lede {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 46ch;
  margin: 0;
}

/* ---------- Öffentliche Seiten (Landing / 404) ---------- */
body.public { display: grid; place-items: center; padding: 2rem; }
.stage {
  width: min(100%, var(--maxw));
  padding: clamp(1.5rem, 5vw, 4rem) 0;
  animation: fadeUp 0.7s cubic-bezier(.2,.7,.2,1) both;
}
.slug-badge {
  font-family: var(--mono);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
  word-break: break-all;
}
.slug-badge .host { color: var(--muted-2); }
.slug-badge .slug { color: var(--accent); }

/* ---------- Auth-Karten (Setup / Login / Edit) ---------- */
body.auth { display: grid; place-items: center; padding: 2rem; }
.card {
  width: min(100%, 440px);
  background: var(--ink-2);
  border: 1px solid var(--line-solid);
  border-radius: var(--radius);
  padding: clamp(1.8rem, 4vw, 2.6rem);
  box-shadow: 0 30px 80px -40px #000, inset 0 1px 0 #ffffff0a;
  animation: fadeUp 0.6s cubic-bezier(.2,.7,.2,1) both;
}
.card .display { font-size: clamp(2.1rem, 6vw, 3rem); margin-bottom: 0.8rem; }
.card .lede { margin-bottom: 1.6rem; }
.back { color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }

/* ---------- Formularelemente ---------- */
.lbl {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.1rem 0 0.45rem;
}
input[type="text"], input[type="password"], input[type="url"], input:not([type]) {
  width: 100%;
  background: var(--ink-3);
  border: 1px solid var(--line-solid);
  border-radius: 10px;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.95rem;
  padding: 0.7rem 0.85rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}
input::placeholder { color: var(--muted-2); }
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #d8f24a33;
}

/* Slug-Eingabe mit Präfix */
.slug-input {
  display: flex;
  align-items: stretch;
  background: var(--ink-3);
  border: 1px solid var(--line-solid);
  border-radius: 10px;
  overflow: hidden;
  cursor: text;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.slug-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #d8f24a33;
}
.slug-input .prefix {
  display: flex;
  align-items: center;
  padding: 0 0.2rem 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted-2);
  white-space: nowrap;
  user-select: none;        /* Präfix nicht markierbar */
  pointer-events: none;     /* Klicks fallen auf das Feld durch → Cursor landet im Input */
}
.slug-input input {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding-left: 0.1rem;
  color: var(--accent);
}
.slug-input input:focus { box-shadow: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 0.7rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s, background 0.18s, color 0.18s, border-color 0.18s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line-solid);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: #5a3a30;
}
.btn.danger:hover { background: var(--danger); color: #1a0e0a; border-color: transparent; }
.btn.sm { padding: 0.45rem 0.8rem; font-size: 0.82rem; }
form { margin: 0; }
.actions-row { display: flex; gap: 0.6rem; margin-top: 1.4rem; }
.card .btn { width: 100%; margin-top: 1.6rem; }
.card .actions-row .btn { width: auto; margin-top: 0; }

/* ---------- Hinweise ---------- */
.alert {
  background: #3a201a;
  border: 1px solid #5a3024;
  color: #f3b9a6;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  margin: 0 0 1.2rem;
}
.empty { color: var(--muted); font-style: italic; padding: 0.5rem 0; }

/* ---------- Admin-Layout ---------- */
.topbar {
  width: min(100%, var(--maxw));
  margin: 0 auto;
  padding: 2rem 1.5rem 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.01em;
  margin: 0.1rem 0 0;
}
.wrap {
  width: min(100%, var(--maxw));
  margin: 0 auto;
  padding: 1.6rem 1.5rem 4rem;
}
.panel {
  background: var(--ink-2);
  border: 1px solid var(--line-solid);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  margin-top: 1.2rem;
  box-shadow: inset 0 1px 0 #ffffff08;
}
.section-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.count {
  font-size: 0.7rem;
  color: var(--accent);
  border: 1px solid #4a5212;
  background: #d8f24a14;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

/* Neuer-Link-Formular */
.newlink {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem;
}
.newlink .grow { flex: 1 1 220px; }
.newlink .lbl { margin-top: 0; }
.newlink .btn { flex: 0 0 auto; }

/* Linkliste */
.links { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--line);
  animation: fadeUp 0.5s cubic-bezier(.2,.7,.2,1) both;
}
.row:first-child { border-top: 0; }
.row-main { flex: 1 1 auto; min-width: 0; }
.slug-link {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.98rem;
  text-decoration: none;
  margin-bottom: 0.15rem;
}
.slug-link .host { color: var(--muted-2); }
.slug-link .slug { color: var(--accent); }
.slug-link:hover .slug { text-decoration: underline; }
.target {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.target:hover { color: var(--paper); }
.row-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted-2);
  text-align: right;
}
.row-meta .clicks { color: var(--muted); }
.row-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.45rem;
  opacity: 0;
  transition: opacity 0.18s;
}
.row:hover .row-actions,
.row:focus-within .row-actions { opacity: 1; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsiv ---------- */
@media (max-width: 620px) {
  .row { flex-wrap: wrap; gap: 0.5rem; }
  .row-meta { flex-direction: row; gap: 0.8rem; order: 3; width: 100%; }
  .row-actions { opacity: 1; order: 2; }
  .newlink .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
