/* MyMaktub – heutiger dunkler Look plus heller Modus.
   Farben nur als Variablen; neue Farbe = in allen drei Blöcken pflegen und Kontrast prüfen. */

/* Hell (Standard, wenn das System hell ist) */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-sunk: #eef0f3;
  --text: #1f2328;
  --muted: #59606b;
  --accent: #1d5fd1;          /* Links und Akzente, 5,6:1 auf Weiß */
  --accent-soft: #dce8fb;
  --on-accent: #ffffff;
  --border: #d9dde3;
  --telegram: #1a76a8;        /* dunkler als Telegram-Blau, damit weiße Schrift lesbar bleibt */
  --shadow: 0 1px 2px rgba(20, 30, 50, .06);
  --danger: #b42318;
  --radius: 12px;
}

/* Dunkel – heutiger Look der Hugo-Seite */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #2c2f36;
    --card: #363a42;
    --card-sunk: #2c2f36;
    --text: #f0f0ef;
    --muted: #a4abb6;
    --accent: #6aabfb;
    --accent-soft: #1e3a5f;
    --on-accent: #0b1b33;     /* dunkle Schrift auf hellblauem Knopf */
    --border: #454a53;
    --telegram: #6cc3ee;
    --shadow: none;
    --danger: #c0392b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #2c2f36;
  --card: #363a42;
  --card-sunk: #2c2f36;
  --text: #f0f0ef;
  --muted: #a4abb6;
  --accent: #6aabfb;
  --accent-soft: #1e3a5f;
  --on-accent: #0b1b33;
  --border: #454a53;
  --telegram: #6cc3ee;
  --shadow: none;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.6;
}

a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Kopfzeile ---------- */
.topbar-wrap { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1100px; margin: 0 auto; padding: 10px 24px; }
.logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-button {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text);
  font: inherit; font-size: 1.05rem; font-weight: 700; line-height: 1; text-decoration: none; cursor: pointer;
}
.icon-button:hover { border-color: var(--muted); }

.menu-wrap { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px;
  display: grid; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.menu-panel[hidden] { display: none; }
.menu-panel a, .menu-panel button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none;
  color: var(--text); font: inherit; font-size: .95rem; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--card-sunk); }
.menu-panel [aria-checked="true"] { color: var(--accent); font-weight: 700; }

/* Ohne JavaScript: kein Darstellungsmenü, das Hamburger-Menü steht offen als Linkleiste. */
html:not(.js) .js-only { display: none; }
html:not(.js) #menu-panel { position: static; display: flex; flex-wrap: wrap; min-width: 0; padding: 0; border: 0; box-shadow: none; background: none; }
html:not(.js) #menu-panel a { width: auto; padding: 4px 8px; font-size: .85rem; }
/* Mit JavaScript sind Menüs zu, bis sie geöffnet werden (auch bevor app.js geladen ist). */
html.js .menu-panel:not(.is-open) { display: none; }

/* ---------- Seite ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 36px 24px 72px; }

.home {
  display: grid; gap: 28px 40px; align-items: start;
  grid-template-columns: 1fr 360px;
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "hero updates" "tiles updates" "more updates";
}
.hero { grid-area: hero; }
.home-tiles { grid-area: tiles; display: grid; gap: 24px; }
.home-updates { grid-area: updates; }
.home-more { grid-area: more; }

.hero h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 12px; }
.subtitle { margin: 0; color: var(--muted); max-width: 520px; }
.motto {
  display: inline-block; margin: 0 0 12px; padding: 4px 11px; border-radius: 99px;
  font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
}

/* ---------- Kacheln ---------- */
.section-label { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.group-hint { margin: 0 0 12px; font-size: .9rem; color: var(--muted); }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile {
  display: grid; justify-items: start; gap: 2px; height: 100%; padding: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-icon { font-size: 1.6rem; line-height: 1.2; margin-bottom: 6px; }
.tile-name { font-weight: 700; }
.tile-hint { font-size: .8rem; color: var(--muted); }

/* ---------- Funktionen, Nerds, Kontakt ---------- */
.features { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 10px; }
.feature { display: flex; gap: 12px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.feature strong { display: block; font-size: .92rem; }
.feature strong + span { font-size: .85rem; color: var(--muted); }

details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin-bottom: 24px; }
summary { padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.nerd-content, .help-item p { margin: 0; padding: 0 16px 16px; font-size: .85rem; color: var(--muted); }
.nerd-content h3 { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; margin: 16px 0 6px; }
.nerd-content ul { list-style: none; padding: 0; margin: 0; }
.nerd-content li::before { content: "→ "; color: var(--accent); }
.stack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stack-item { display: grid; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-sunk); }
.stack-item .label { font-size: .7rem; }
.stack-item .value { color: var(--text); }

.cta { padding: 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.cta h2 { margin: 0 0 8px; font-size: 1.2rem; }
.cta p { color: var(--muted); font-size: .9rem; }
.cta-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 0; }
.button {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .88rem; text-decoration: none;
}
.button-telegram { background: var(--telegram); }

/* ---------- Beiträge ---------- */
.posts { display: grid; gap: 10px; }
.post-card { padding: 16px 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.post-meta { margin: 0 0 4px; font-size: .78rem; color: var(--muted); }
.post-title { margin: 0 0 6px; font-size: 1rem; line-height: 1.35; }
.post-title a { color: var(--text); text-decoration: none; }
.post-title a:hover { color: var(--accent); }
.post-excerpt { margin: 0 0 6px; font-size: .86rem; color: var(--muted); }
.read-more { font-size: .86rem; }
.empty { color: var(--muted); }
.posts-full { max-width: 720px; margin-bottom: 24px; }

.article { max-width: 720px; }
.article h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 24px; }
.prose img { display: block; max-width: min(100%, 560px); height: auto; margin: 16px auto; border-radius: 8px; }
.prose pre { overflow-x: auto; padding: 12px; background: var(--card); border-radius: 8px; }
.help-item { max-width: 720px; }

.footer { padding: 24px; text-align: center; font-size: .8rem; color: var(--muted); }

/* ---------- Handy: Kacheln und Neuigkeiten vor den Details ---------- */
@media (max-width: 820px) {
  .home { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "hero" "tiles" "updates" "more"; }
  .hero h1 { font-size: 1.7rem; }
  .page { padding: 24px 16px 56px; }
  .topbar { padding: 8px 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Anmeldung ---------- */
.menu-account { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
div.menu-account { display: grid; }
.menu-note { display: block; padding: 6px 12px 2px; font-size: .8rem; color: var(--muted); }
.menu-account form { margin: 0; }
.notice { padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); }
.stack { display: grid; gap: 12px; max-width: 360px; }
button.button { border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: .95rem; padding: 12px 18px; }
.button-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border) !important; }

/* ---------- Redaktion ---------- */
.editor { display: grid; gap: 20px; max-width: 820px; }
.editor fieldset { margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); display: grid; gap: 14px; }
.editor legend { padding: 0 6px; font-weight: 700; }
.editor legend small, .field small { font-weight: 400; color: var(--muted); font-size: .8rem; }
.field { display: grid; gap: 6px; }
.field > label { font-weight: 600; font-size: .9rem; }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 1rem;
}
.field textarea { min-height: 260px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; line-height: 1.5; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar button {
  min-height: 40px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer;
}
.toolbar button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.preview { min-height: 260px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; }
.preview[hidden] { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-errors { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--danger); color: var(--text); background: var(--card); }
.form-errors p { margin: 0; font-weight: 700; }
.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.button-danger { background: var(--danger); color: #fff; }
.field-more summary { color: var(--text); }
.field-more .field { padding: 0 16px 16px; }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 820px; }
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-row a { color: var(--text); text-decoration: none; flex: 1 1 240px; }
.admin-row small { color: var(--muted); }
.badge { padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; background: var(--card-sunk); color: var(--muted); }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
