:root{
  /* Design-System Tokens (falls vorhanden) – mit Fallbacks */
  --csp_text: var(--csp-token-text, #111827);
  --csp_muted: var(--csp-token-muted, #6b7280);
  --csp_border: var(--csp-token-border, #e5e7eb);
  --csp_surface: var(--csp-token-surface, #ffffff);
  --csp_radius: var(--csp-token-radius, 12px);

  --csp_btn_bg: var(--csp-token-btn-bg, #111827);
  --csp_btn_color: var(--csp-token-btn-color, #ffffff);
  --csp_btn_bg_hover: var(--csp-token-btn-bg-hover, #0b1220);

  --csp_bg: var(--csp-token-bg, #f8fafc);

  /* Höhe Mid-Bar (für sticky offset vom Bottom) */
  --csp_header_mid_h: 72px;

  /* WP Admin Bar offset (wird unten überschrieben) */
  --csp_adminbar_h: 0px;

  /* Breite Content */
  --csp_content_w: 1120px;

  /* Kleine Typo */
  --csp_font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Admin-Bar Offset */
body.admin-bar{ --csp_adminbar_h: 32px; }
@media (max-width: 782px){
  body.admin-bar{ --csp_adminbar_h: 46px; }
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }

body{
  font-family: var(--csp_font);
  color: var(--csp_text);
  background: var(--csp_bg);
  line-height: 1.5;
}

a{ color: inherit; }
a:hover{ opacity: .95; }

/* =====================================================
   Container
   Header/Footer full width – Content zentriert separat
   ===================================================== */
.csp-container{
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 16px;
}

/* =====================================================
   Page Content: zentriert
   ===================================================== */
.csp-page{ width: 100%; }

.csp-page__header{
  max-width: var(--csp_content_w);
  margin: 0 auto;
  padding: 18px 16px 0;
}

.csp-page__title{
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.csp-page__content{
  max-width: var(--csp_content_w);
  margin: 0 auto;
  padding: 18px 16px 40px;
}

/* Basic typography inside content */
.csp-page__content h1,
.csp-page__content h2,
.csp-page__content h3{
  letter-spacing:-0.02em;
  margin: 18px 0 10px;
}
.csp-page__content p{ margin: 0 0 12px; }

/* =====================================================
   HEADER (Shell)
   Wichtig für sticky: KEIN overflow hidden/auto auf ancestors!
   ===================================================== */
.site-header{
  background: var(--csp_surface);
  border-bottom: 1px solid var(--csp_border);
  position: relative;
  z-index: 20;
}

/* =====================================================
   HEADER TOP (scrollt weg)
   dünn + mobile untereinander
   ===================================================== */
.csp-header-top{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding: 6px 0;           /* dünner */
  border-bottom: 1px solid var(--csp_border);
}

.csp-header-top__left,
.csp-header-top__right{
  display:flex;
  align-items:center;
  gap:10px;
  min-height: 22px;
}

/* Widgets / Module – “alte Klassen” wieder sauber */
.csp-widget{ display:block; }
.csp-widget__title{
  font-weight:700;
  font-size:12px;
  margin:0 0 6px;
}
.csp-muted{ color: var(--csp_muted); font-size: 13px; }

/* Block-Widgets im Header-Top sollen kompakter sein */
.csp-header-top .csp-widget{
  font-size: 13px;
  line-height: 1.3;
}
.csp-header-top .wp-block-heading{
  font-size: 13px;
  margin: 0 0 6px;
}
.csp-header-top .wp-block-group{ margin:0; }
.csp-header-top .wp-block-group__inner-container{ padding:0 !important; }
.csp-header-top .wp-block-latest-posts,
.csp-header-top .wp-block-latest-comments,
.csp-header-top .wp-block-archives,
.csp-header-top .wp-block-categories{
  margin: 0;
  padding: 0;
}
.csp-header-top .wp-block-latest-posts__list,
.csp-header-top .wp-block-categories-list,
.csp-header-top .wp-block-archives-list{
  margin: 0;
  padding-left: 16px;
}

/* =====================================================
   HEADER MID (sticky)
   Struktur: .csp-header-mid enthält eigenen .csp-container
   ===================================================== */
.csp-header-mid{
  position: sticky;
  top: var(--csp_adminbar_h);
  z-index: 999;
  background: var(--csp_surface);
  border-bottom: 1px solid var(--csp_border);

  /* Optional: leichte “Kante” beim Scrollen sichtbar */
  box-shadow: 0 0 0 rgba(0,0,0,0);
}

.csp-header-mid > .csp-container{
  min-height: var(--csp_header_mid_h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.csp-header-mid__left{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 0;
}

/* Brand/Logo */
.csp-header-brand{ display:flex; align-items:center; min-width:0; }
.site-title{
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.csp-header-brand .custom-logo-link{ display:inline-flex; align-items:center; }
.csp-header-brand .custom-logo-link img{
  max-height: 46px;
  width:auto;
  height:auto;
  display:block;
}

/* MID RIGHT: Hauptmenü + Actions rechtsbündig */
.csp-header-mid__right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  min-width: 0;
}

/* Hauptmenü (Desktop): horizontal + (wenn eng) horizontal scroll */
.csp-primary-nav{
  min-width: 0;
  max-width: 72vw;
}

.csp-primary-menu{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  gap:8px;
  align-items:center;

  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  white-space: nowrap;
}

.csp-primary-menu > li{ flex: 0 0 auto; }

.csp-primary-menu a{
  display:inline-block;
  text-decoration:none;
  padding: 8px 10px;
  border-radius: 10px;
}
.csp-primary-menu a:hover{ background: rgba(0,0,0,.04); }

/* Actions: rechts neben dem Menü */
.csp-header-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex: 0 0 auto;
}

/* Nur Icons (Labels ausblenden) */
.csp-btn__label{ display:none; }

/* Buttons */
.csp-btn{
  border:0;
  border-radius: 10px;
  padding: 9px 10px;
  cursor:pointer;
  background: var(--csp_btn_bg);
  color: var(--csp_btn_color);
}
.csp-btn:hover{ background: var(--csp_btn_bg_hover); }

.csp-btn--ghost{
  background: #fff;
  color: var(--csp_text);
  border: 1px solid var(--csp_border);
}
.csp-btn--ghost:hover{ background: rgba(0,0,0,.04); }

/* =====================================================
   HEADER BOTTOM (sticky) – Secondary Menü centered
   ===================================================== */
.csp-header-bottom{
  position: sticky;
  top: calc(var(--csp_adminbar_h) + var(--csp_header_mid_h));
  z-index: 998;
  background: var(--csp_surface);
  border-bottom: 1px solid var(--csp_border);
}

.csp-header-bottom > .csp-container{
  padding-top: 8px;
  padding-bottom: 8px;
}

.csp-header-bottom__inner{
  display:flex;
  justify-content:center;
  align-items:center;
}

/* Secondary Menü */
.csp-secondary-menu{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  gap:8px;
  flex-wrap: wrap;
  justify-content:center;
  align-items:center;
}

.csp-secondary-menu a{
  text-decoration:none;
  padding: 7px 10px;
  border-radius: 10px;
}
.csp-secondary-menu a:hover{ background: rgba(0,0,0,.04); }

/* =====================================================
   Mobile Verhalten:
   - Header-Top untereinander
   - Hauptmenü vertikal + scrollbar (dein Wunsch)
   - Actions bleiben rechts/oben erreichbar
   ===================================================== */
@media (max-width: 860px){
  .csp-header-top{
    flex-direction: column;
    align-items: stretch;
  }
  .csp-header-top__left,
  .csp-header-top__right{
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .csp-header-mid > .csp-container{
    gap: 10px;
  }

  /* MID RIGHT: Menü + Actions bleibt rechtsbündig, aber menu wird “Panel” */
  .csp-primary-nav{
    max-width: 100%;
    flex: 1 1 auto;
  }

  /* Jetzt vertikal + scrollbar */
  .csp-primary-menu{
    flex-direction: column;
    align-items: stretch;
    white-space: normal;

    max-height: 42vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
  }

  .csp-primary-menu a{
    display:block;
    width: 100%;
  }
}

/* =====================================================
   Offcanvas
   ===================================================== */
.csp-offcanvas{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
.csp-offcanvas__overlay{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.35);
  opacity:0;
  transition: opacity .2s ease;
}
.csp-offcanvas__panel{
  position:absolute;
  top:0; left:0;
  width: min(86vw, 360px);
  height: 100%;
  background: var(--csp_surface);
  border-right: 1px solid var(--csp_border);
  transform: translateX(-100%);
  transition: transform .22s ease;
  display:flex;
  flex-direction:column;
}
.csp-offcanvas__head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px;
  border-bottom: 1px solid var(--csp_border);
}
.csp-offcanvas__nav{
  padding: 10px 12px 16px;
  overflow:auto;
}
.csp-offcanvas__menu{
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.csp-offcanvas__menu a{
  display:block;
  text-decoration:none;
  padding: 10px 10px;
  border-radius: 10px;
}
.csp-offcanvas__menu a:hover{ background: rgba(0,0,0,.04); }

body.csp-offcanvas-open .csp-offcanvas{ pointer-events: auto; }
body.csp-offcanvas-open .csp-offcanvas__overlay{ opacity:1; }
body.csp-offcanvas-open .csp-offcanvas__panel{ transform: translateX(0); }

/* =====================================================
   Search Modal
   ===================================================== */
.csp-modal{
  position: fixed;
  inset:0;
  pointer-events:none;
  z-index: 9999;
}
.csp-modal__overlay{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.35);
  opacity:0;
  transition: opacity .2s ease;
}
.csp-modal__panel{
  position:absolute;
  left:50%;
  top: 14vh;
  transform: translateX(-50%) translateY(-10px);
  width: min(92vw, 720px);
  background: var(--csp_surface);
  border: 1px solid var(--csp_border);
  border-radius: var(--csp_radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
  opacity:0;
  transition: opacity .2s ease, transform .2s ease;
}
.csp-modal__head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px 12px;
  border-bottom: 1px solid var(--csp_border);
}
.csp-modal__body{ padding: 12px; }

body.csp-search-open .csp-modal{ pointer-events:auto; }
body.csp-search-open .csp-modal__overlay{ opacity:1; }
body.csp-search-open .csp-modal__panel{
  opacity:1;
  transform: translateX(-50%) translateY(0);
}

/* Search Form */
.site-search form{
  display:flex;
  gap:8px;
  align-items:center;
}
.site-search input[type="search"]{
  width: 240px;
  max-width: 60vw;
  padding: 9px 10px;
  border: 1px solid var(--csp_border);
  border-radius: 10px;
  background: #fff;
}
.site-search button[type="submit"]{
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--csp_btn_bg);
  color: var(--csp_btn_color);
  cursor: pointer;
}
.site-search button[type="submit"]:hover{ background: var(--csp_btn_bg_hover); }

/* Main */
.site-main{ min-height: 60vh; }

/* =====================================================
   CSP Core Templates (Blocks/Content)
   ===================================================== */

/* Search Results */
.csp-search-results{
  background: var(--csp_surface);
  border: 1px solid var(--csp_border);
  border-radius: var(--csp_radius);
  padding: 18px;
}
.csp-search-results__header{ margin: 0 0 10px; }
.csp-search-results__title{ margin: 0; font-size: 20px; }
.csp-search-results__meta{ color: var(--csp_muted); margin: 0 0 10px; }

/* Single */
.csp-single{
  background: var(--csp_surface);
  border: 1px solid var(--csp_border);
  border-radius: var(--csp_radius);
  padding: 18px;
}
.csp-single__title{
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.csp-single__featured-wrap{
  margin: 14px 0;
}
.csp-single__featured-wrap img{
  max-width: 100%;
  height: auto;
  border-radius: calc(var(--csp_radius) - 4px);
  display:block;
}
.csp-single__content{
  font-size: 16px;
}
.csp-single__content :is(h2,h3,h4){
  margin-top: 18px;
}
.csp-single__content :is(ul,ol){
  padding-left: 22px;
}
.csp-single__content blockquote{
  margin: 14px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--csp_border);
  background: rgba(0,0,0,.03);
  border-radius: 10px;
}

/* Post Grid / Cards */
.csp-post-grid{
  display:grid;
  gap:16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.csp-post-grid__empty{ color: var(--csp_muted); }
.csp-post-rowlist__empty{ color: var(--csp_muted); }

.csp-post-card{
  border: 1px solid var(--csp_border);
  border-radius: var(--csp_radius);
  padding: 12px;
  background: var(--csp_surface);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.csp-post-card__thumb img{
  width: 100%;
  height: auto;
  display:block;
  border-radius: calc(var(--csp_radius) - 4px);
}
.csp-post-card__title{
  margin: 0;
  font-size: 16px;
}
.csp-post-card__title a{ text-decoration:none; }
.csp-post-card__title a:hover{ text-decoration:underline; }
.csp-post-card__meta{ color: var(--csp_muted); font-size: 13px; }
.csp-post-card__date{ color: inherit; }

/* Post Row List */
.csp-post-list,
.csp-post-rowlist{ display:flex; flex-direction:column; gap: 12px; }

.csp-post-row{
  border: 1px solid var(--csp_border);
  border-radius: var(--csp_radius);
  background: var(--csp_surface);
  padding: 12px;
  display:flex;
  gap: 12px;
}
.csp-post-row__thumb{
  flex: 0 0 92px;
  text-decoration:none;
}
.csp-post-row__thumb img{
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 12px;
  display:block;
}
.csp-post-row__body{ min-width:0; flex:1; }
.csp-post-row__title{ margin: 0 0 4px; font-size: 16px; }
.csp-post-row__title a{ text-decoration:none; }
.csp-post-row__title a:hover{ text-decoration:underline; }
.csp-post-row__meta{ color: var(--csp_muted); font-size: 13px; margin: 0 0 6px; }
.csp-post-row__excerpt{ margin: 0; color: var(--csp_muted); font-size: 14px; }

/* Pagination */
.csp-pagination ul{
  display:flex;
  gap:8px;
  list-style:none;
  padding:0;
  margin:16px 0 0;
  flex-wrap:wrap;
}
.csp-pagination a,
.csp-pagination span{
  display:inline-block;
  padding:6px 10px;
  border:1px solid var(--csp_border);
  border-radius: 10px;
  text-decoration:none;
  color: var(--csp_text);
  background: var(--csp_surface);
}
.csp-pagination a:hover{ background: rgba(0,0,0,.04); }
.csp-pagination .current{
  background: var(--csp_btn_bg);
  color: var(--csp_btn_color);
  border-color: transparent;
}

/* =====================================================
   Footer
   ===================================================== */
.site-footer{
  border-top: 1px solid var(--csp_border);
  background: var(--csp_surface);
}

.csp-footer-grid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 18px 0;
}

.csp-footer-bottom{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 12px;
  padding: 14px 0 18px;
  border-top: 1px solid var(--csp_border);
  color: var(--csp_muted);
}

@media (max-width: 860px){
  .csp-footer-grid{ grid-template-columns: 1fr; }
}
