/* ════════════════════════════════════════════════════════════════════════════
   Linkbox — Design übernommen von agp/agcms (agcms/assets/css/style.css)
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Schrift (aus agp): Borna Regular + Bold ── */
@font-face {
  font-family: 'Borna';
  src: url('fonts/borna-regular-webfont.woff2') format('woff2'),
       url('fonts/borna-regular-webfont.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Borna';
  src: url('fonts/borna-bold-webfont.woff2') format('woff2'),
       url('fonts/borna-bold-webfont.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

:root {
  color-scheme: light;

  --bg:      #ffffff;
  --surface: #fafafa;
  --border:  #e2e2e2;
  --text:    #1a1917;
  --muted:   #9a9690;
  --accent:  #1a1917;
  --danger:  #c0392b;

  --on-accent:       #ffffff;
  --fill-subtle:     rgba(0, 0, 0, 0.06);
  --badge-bg:        #f0ede8;
  --badge-danger-bg: #fbe9e7;

  --sans: 'Borna', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: var(--sans);   /* agp nutzt keine Monospace-Schrift; Labels bleiben über Versalien + Sperrung erkennbar */

  --text-xs:   12px;
  --text-s:    13px;
  --text-base: clamp(16px, calc(0.9rem + 0.375vw), 19px);
  --text-m:    clamp(18px, calc(1.05rem + 0.5vw), 22px);
  --text-l:    clamp(19px, calc(1.2rem + 0.3vw), 22px);
  --text-xl:   clamp(26px, calc(1.5rem + 1vw), 34px);
  --text-xxl:  clamp(34px, calc(1.8rem + 1.5vw), 48px);

  --radius:      20px;
  --radius-pill: 999px;
}

/* Dark Mode: folgt der Systemeinstellung */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg:      #161613;
    --surface: #201f1c;
    --border:  #35332e;
    --text:    #ece9e3;
    --muted:   #8d8880;
    --accent:  #ece9e3;
    --danger:  #e8705f;

    --on-accent:       #161613;
    --fill-subtle:     rgba(255, 255, 255, 0.06);
    --badge-bg:        rgba(255, 255, 255, 0.09);
    --badge-danger-bg: rgba(232, 112, 95, 0.18);
  }
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.45;
}

input, select, button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── Navigation ── */
.cms-nav { margin-bottom: 28px; border-bottom: 1px solid var(--border); }

.cms-mainnav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  max-width: 960px; margin: 0 auto;
}
.cms-mainnav-links { display: flex; align-items: center; gap: 24px; }
.cms-mainnav-right { display: flex; align-items: center; gap: 16px; }

.cms-main-link {
  font-size: 14px; font-weight: 500;
  color: var(--muted); text-decoration: none; transition: color .15s;
}
.cms-main-link:hover  { color: var(--text); }
.cms-main-link.active { color: var(--text); font-weight: 700; }

.cms-meta-link {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); text-decoration: none; transition: color .15s;
}
.cms-meta-link:hover,
.cms-meta-link.active { color: var(--text); }


/* ── Buttons ── */
.btn {
  padding: 7px 16px;
  border: none;
  cursor: pointer;
  font-size: var(--text-s);
  border-radius: var(--radius-pill);
  background: var(--fill-subtle);
  color: var(--text);
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { opacity: 0.75; }
.btn-danger:hover { background: var(--badge-danger-bg); color: var(--danger); opacity: 1; }
.btn-icon { padding: 6px 9px; }

.btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.8; }

.icon-trash, .icon-info {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: url('img/trash-2.svg') center / contain no-repeat;
          mask: url('img/trash-2.svg') center / contain no-repeat;
  flex-shrink: 0;
}
.icon-info {
  -webkit-mask-image: url('img/info.svg');
          mask-image: url('img/info.svg');
}

/* ── List view ── */
#listView {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 96px;
}

.input {
  width: 100%;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

.search { margin-bottom: 16px; }

/* Kategorie-Filter (genre-pills aus agcms) */
.genre-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.genre-pill {
  font-size: var(--text-s);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--muted);
  padding: 5px 14px;
  text-decoration: none;
  transition: all 0.15s;
}
.genre-pill:hover  { border-color: var(--accent); color: var(--text); }
.genre-pill.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.genre-pill small  { font-family: var(--mono); font-size: 11px; opacity: 0.65; margin-left: 2px; }

.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -6px 0 12px 2px;
  min-height: 32px;
}
.list-count { font-size: var(--text-s); color: var(--muted); }

.empty-msg {
  font-family: var(--mono);
  font-size: var(--text-s);
  color: var(--muted);
  padding: 24px 0;
}

/* ── Link-Karten: Bild links, quadratisch; Desktop zweispaltig ── */
.link-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.link-card {
  display: flex;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
  transition: border-color 0.15s;
}
.link-card:hover { border-color: var(--accent); }

.link-thumb {
  position: relative;
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.link-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Favicon statt Vorschaubild: klein und mittig */
.link-thumb.is-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}
/* Weder Bild noch Favicon: Anfangsbuchstabe der Domain */
.link-thumb.no-img img { display: none; }
.link-thumb.no-img::after {
  content: attr(data-letter);
  font-size: 28px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.link-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.link-title {
  font-size: var(--text-base);
  font-weight: bold;
  line-height: 1.3;
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-title:hover { text-decoration: underline; }

.link-meta {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-wrap: anywhere;
}

/* Aufgeklappte Details (Info-Knopf): ganzer Text, Karte über die volle Breite */
.link-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.link-desc { font-size: var(--text-s); line-height: 1.55; }
.link-note { color: var(--muted); font-style: italic; }
.link-url {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.link-card.open { border-color: var(--accent); }
.link-card.open .link-title { display: block; overflow: visible; }

.link-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
}
.link-actions form:first-child { min-width: 0; }
.link-tools { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.info-toggle[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); opacity: 1; }

.select {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
  background: var(--badge-bg);
  color: var(--muted);
  padding: 4px 10px;
  outline: none;
  border-radius: var(--radius-pill);
  max-width: 100%;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.select:hover, .select:focus { border-color: var(--accent); color: var(--text); }

/* ── Abschnitte unten ── */
.section {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 460px;
}
.section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.add-form { display: flex; gap: 8px; }

.backup-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.backup-list a {
  font-family: var(--mono);
  font-size: var(--text-s);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.backup-list a:hover { color: var(--text); }

/* ── Nach-oben-Knopf (aus agp): runder Knopf mit um 90° gedrehtem Pfeil ── */
#scrolltop {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 90;
}
#scrolltop:hover { transform: scale(1.12); }
#scrolltop.visible { opacity: 1; pointer-events: auto; }
#scrolltop::before {
  content: "←";
  display: block;
  line-height: 1;
  transform: rotate(90deg);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  font-size: var(--text-base);
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}
.toast.show  { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.login-heading {
  font-size: var(--text-xxl);
  font-weight: bold;
  line-height: 1.1;
}
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form input[type="password"] {
  width: 100%;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.15s;
}
.login-form input[type="password"]:focus { border-color: var(--accent); }
.login-submit {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.login-submit:hover { opacity: 0.8; }
.login-error { font-size: 14px; color: var(--danger); }

/* ── Responsive ── */
@media (min-width: 760px) {
  .link-grid  { grid-template-columns: 1fr 1fr; }
  /* Aufgeklappt wächst nur die Karte selbst nach unten; die Nachbarkarte derselben Zeile
     (per JS markiert) behält ihre Höhe, statt mitgezogen zu werden. */
  .link-card.row-mate { align-self: start; }
  .link-thumb { width: 104px; height: 104px; }
}

@media (max-width: 720px) {
  .cms-mainnav       { padding: 8px 14px; }
  .cms-mainnav-right { gap: 12px; }
  #listView          { padding: 0 14px 80px; }
  .cms-nav           { margin-bottom: 20px; }
}

@media (max-width: 420px) {
  .link-thumb { width: 72px; height: 72px; }
  .link-card  { gap: 12px; }
}
