/* ----- RESET & BASE ----- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background: #f8f6f0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.7;
  color: #1e2b2f;
  padding: 1.5rem 1rem 3rem 1rem;
}

a {
    text-decoration: none;
    color: #4993c; 
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  background: #fefcf9;
  border-radius: 28px 28px 18px 18px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.15);
  overflow: visible;
  padding: 0 0 1.8rem 0;
}

/* ----- BANNER (alhambra.jpg) with primary & secondary header inside ----- */
.banner-main {
  background-image: url('alhambra2.jpg');
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  width: 100%;
  padding: 1.8rem 2.2rem 0.8rem 2.2rem;
  box-shadow: inset 0 -30px 40px -20px rgba(0,0,0,0.2);
  position: relative;
  border-radius: 0;
}
.banner-main::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: rgba(10, 20, 18, 0.15);
  pointer-events: none;
  z-index: 1;
}
.banner-main > * {
  position: relative;
  z-index: 2;
}

/* primary header inside banner */
.primary_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 0.4rem 0;
  border-bottom: 2px solid rgba(255, 248, 235, 0.25);
  flex-wrap: wrap;
}
.title {
  font-size: 2.8rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: #f0d9ac;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  display: inline-block;
  padding-left: 3rem;
  padding-right: 1rem;
}

/* secondary header (nav) inside banner */
.secondary_header {
  margin: 0.6rem 0 0.2rem 0;
}
.secondary_header ul {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  gap: 0.2rem 0.6rem;
  background: rgba(20, 30, 28, 0.35);
  backdrop-filter: blur(4px);
  padding: 0.5rem 1.2rem;
  border-radius: 60px;
  justify-content: center;
  border: 1px solid rgba(255, 248, 235, 0.1);
}
.secondary_header ul li a {
  text-decoration: none;
  color: #f5efe8;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border-radius: 40px;
  transition: all 0.15s;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.secondary_header ul li a:hover {
  background: rgba(255, 248, 235, 0.2);
  color: #ffffff;
}

/* ----- MAIN CONTENT ----- */
.row-main {
  background: #fefcf9;
  padding: 2.2rem 2rem 2.5rem 2rem;
  border-radius: 28px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.02), 0 6px 14px rgba(0, 0, 0, 0.02);
  margin: 1.8rem 1.8rem 1.8rem 1.8rem;
}

/* Paragraph spacing in main content */
.row-main > p {
  margin-bottom: 0.6rem;
}

.row-main > p:last-of-type {
  margin-bottom: 0;
}

/* ----- IMAGES IN EDITABLE CONTENT (ONLY in article text, NOT in .row or .next-chapters-wrapper) ----- */
/* Target only direct images in paragraphs within row-main, excluding those in .row and .next-chapters-wrapper */
.row-main > p > img,
.row-main > div:not(.row):not(.next-chapters-wrapper) > img,
.row-main > blockquote > img,
.row-main > table img {
  margin: 1rem 0.5rem;
  border-radius: 8px;
  max-width: 100%;
  height: auto;
}

/* For images with align="right" in the article text */
.row-main > p > img[align="right"],
.row-main > div:not(.row):not(.next-chapters-wrapper) > img[align="right"] {
  margin: 0.5rem 0 0.5rem 1.5rem;
  float: right;
  max-width: 45%;
  height: auto;
}

/* For images with align="left" in the article text */
.row-main > p > img[align="left"],
.row-main > div:not(.row):not(.next-chapters-wrapper) > img[align="left"] {
  margin: 0.5rem 1.5rem 0.5rem 0;
  float: left;
  max-width: 45%;
  height: auto;
}

/* For Vatican image with hspace/vspace */
.row-main > p > img[hspace="15"],
.row-main > div:not(.row):not(.next-chapters-wrapper) > img[hspace="15"] {
  margin: 0.8rem 0.8rem 0.8rem 1.5rem !important;
  float: right;
  max-width: 45%;
  height: auto;
}

/* Remove old hspace/vspace attributes effect - only in article text */
.row-main > p > img[vspace],
.row-main > div:not(.row):not(.next-chapters-wrapper) > img[vspace] {
  margin-top: 0.8rem !important;
  margin-bottom: 0.8rem !important;
}

/* ----- IMAGES INSIDE THE 4-COLUMN GRID (article .row .columns) ----- */
/* Only target .columns that are NOT .unten (the bottom book grid) */
.row-main .row .columns:not(.unten) img {
  margin: 0.8rem auto;
  display: block;
  max-width: 80%;
  height: auto;
  float: none !important;
}

/* ----- BOTTOM BOOK GRID IMAGES (keep at full size) ----- */
.columns.unten img {
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid #e1d6c8;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.03);
  transition: 0.2s;
}
.columns.unten img:hover {
  transform: scale(1.01);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
}

/* Next chapter images - keep as is */
.next-chapters-wrapper img,
.next-chapter img {
  margin: 0 !important;
  float: none !important;
  display: inline-block;
  border-radius: 14px;
  border: 1px solid #d5cbbc;
  width: 90px;
  height: 90px;
  object-fit: cover;
}

/* ----- START PAGE GRID ----- */
.start-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem 1.5rem;
}
.start-grid .columns {
  display: flex;
  flex-direction: column;
  background: #faf8f4;
  border-radius: 20px;
  padding: 1.2rem 1rem 1.5rem 1rem;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}
.start-grid .columns:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.thumbnail_align {
  text-align: center;
  margin-bottom: 0.8rem;
}
.thumbnail {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e1d6c8;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  transition: 0.2s;
  display: block;
  margin: 0 auto;
}
.thumbnail:hover {
  transform: scale(1.03);
  border-color: #b68b6e;
}

.start-grid .columns h4 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  font-weight: 500;
}
.start-grid .columns h4 a {
  color: #1f3a3f;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: 0.15s;
}
.start-grid .columns h4 a:hover {
  border-bottom-color: #b68b6e;
  color: #6d4f38;
}
.start-grid .columns p {
  font-size: 0.92rem;
  color: #2b4945;
  text-align: justify;
  line-height: 1.6;
  flex: 1;
}
.start-grid .columns .link {
  color: #8f6b4b;
  text-decoration: none;
}
.start-grid .columns .link:hover {
  color: #4f3b2b;
}

/* ----- NEXT CHAPTERS (with wrapper) ----- */
.next-chapters-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: 2rem;
}

.next-chapter {
  background: #f2ede6;
  border-radius: 24px;
  padding: 0.8rem 1rem 0.8rem 1.8rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.2rem 1.8rem;
  width: 100%;
}

.next-chapter img {
  border-radius: 14px;
  border: 1px solid #d5cbbc;
  width: 90px;
  height: 90px;
  object-fit: cover;
}
.next-chapter .next-text {
  flex: 1;
}
.next-chapter .next-text strong {
  display: block;
  font-size: 1.2rem;
  color: #1f3a3f;
}

.next-chapter .next-text a {
  font-weight: 600;
  color: #1f3a3f;
  border-bottom: 2px solid #b68b6e;
  padding-bottom: 1px;
  text-decoration: none;
}
.next-chapter .next-text a:hover {
  color: #6d4f38;
}

/* ----- FOOTER BOTTOM GRID ----- */
.footer-icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.2rem 2.2rem;
  padding: 1.2rem 0 1.5rem 0;
  border-top: 1px solid #e3dcd0;
  margin-top: 1.5rem;
  margin-left: 1.8rem;
  margin-right: 1.8rem;
}
.footer-icons a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #3f554b;
  text-decoration: none;
  font-weight: 450;
  transition: 0.15s;
  background: #f2ede6;
  padding: 0.3rem 1rem 0.3rem 0.8rem;
  border-radius: 40px;
  font-size: 0.8rem;
}
.footer-icons a i {
  font-size: 1.2rem;
  width: 1.6rem;
  text-align: center;
  color: #4f6a5e;
}
.footer-icons a:hover {
  background: #ded6c8;
  color: #1d302b;
  transform: translateY(-2px);
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.8rem 1.2rem;
  margin: 2rem 1.8rem 1.2rem 1.8rem;
  background: #faf8f4;
  padding: 1.5rem 1.2rem;
  border-radius: 32px;
}

.columns.unten {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.columns.unten h5 {
  font-size: 1.3rem;
  font-weight: 500;
  color: #1f3a3f;
  border-bottom: 2px solid #dccfc0;
  padding-bottom: 0.4rem;
  margin-bottom: 0.4rem;
}

/* --- LINKS UNDER "THEMEN" (first column) --- */
.columns.unten:first-child p a {
  font-size: 1.1rem;
  line-height: 1.6;
  text-decoration: none;
  color: #2b4945;
  font-weight: 500;
  transition: 0.15s;
  display: inline-block;
  padding: 0.1rem 0;
}
.columns.unten:first-child p a:hover {
  color: #6d4f38;
  padding-left: 6px;
}

/* Regular links in other columns (images) */
.columns.unten a {
  text-decoration: none;
  color: #2b4945;
  font-weight: 400;
  display: inline-block;
  transition: 0.1s;
}
.columns.unten a:hover {
  color: #6d4f38;
  padding-left: 4px;
}

/* Bottom book images - already defined above, but keeping here for organization */
.columns.unten p {
  margin-bottom: 0.1rem;
}

/* ----- BACK TO TOP (FIXED) ----- */
.back-top {
  text-align: center;
  padding: 1.5rem 0 0.8rem 0;
  font-weight: 450;
  clear: both;
  position: relative;
  z-index: 5;
}
.back-top a {
  text-decoration: none;
  color: #4a6056;
  background: #ece5d9;
  padding: 0.5rem 2.5rem;
  border-radius: 60px;
  transition: 0.2s;
  display: inline-block;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.back-top a:hover {
  background: #d5cbbc;
  color: #1d2f2a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

hr { border: none; border-top: 2px dashed #ddd2c4; margin: 1.8rem 0; }
.footnote-sep { margin: 1.8rem 0 0.6rem 0; border: 0; height: 1px; background: linear-gradient(to right, #ddd2c4, transparent); }

/* ----- RESPONSIVE ----- */
@media (max-width: 1024px) {
  .start-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (max-width: 700px) {
  .container { padding: 0 0 0.8rem 0; }
  .banner-main { padding: 1.2rem 1rem 0.6rem 1rem; }
  .primary_header { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
  .title { font-size: 1.8rem; padding-left: 0.5rem; }
  .secondary_header ul { border-radius: 30px; padding: 0.4rem 0.8rem; gap: 0.1rem; }
  .secondary_header ul li a { font-size: 0.8rem; padding: 0.2rem 0.5rem; }
  .row-main { padding: 1.5rem 1rem; margin: 1.2rem 0.8rem; }
  .footer-icons { margin-left: 0.8rem; margin-right: 0.8rem; }
  
  .start-grid {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  .start-grid .columns {
    padding: 1rem;
  }
  .thumbnail {
    width: 80px;
    height: 80px;
  }
  .start-grid .columns h4 {
    font-size: 0.95rem;
  }
  .start-grid .columns p {
    font-size: 0.85rem;
  }
  
  .themen-heading-mobile {
    display: block !important;
    font-size: 1.5rem;
    font-weight: 500;
    color: #1f3a3f;
    border-bottom: 2px solid #dccfc0;
    padding-bottom: 0.4rem;
    margin: 0 0.8rem 0.5rem 0.8rem;
  }
  
  .columns.unten h5 {
    display: none;
  }
  
  .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
    margin: 0 0.8rem 1.2rem 0.8rem;
    padding: 0.3rem 0.2rem;
    background: transparent;
    border-radius: 0;
  }
  
  /* Only article text images - using direct child selector to avoid .row images */
  .row-main > p > img,
  .row-main > div:not(.row):not(.next-chapters-wrapper) > img,
  .row-main > p > img[align="right"],
  .row-main > p > img[align="left"],
  .row-main > div:not(.row):not(.next-chapters-wrapper) > img[align="right"],
  .row-main > div:not(.row):not(.next-chapters-wrapper) > img[align="left"] {
    float: none !important;
    display: block;
    margin: 1.2rem auto !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto;
  }
  
    .next-chapter {
    flex-direction: column;
    align-items: center;
    text-align: justify;
  }

  
  /* Images inside the 4-column grid on mobile - only target .columns without .unten */
  .row-main .row .columns:not(.unten) img {
    max-width: 80% !important;
    margin: 0.8rem auto !important;
    float: none !important;
  }
  
  /* Bottom book images on mobile - keep full size */
  .columns.unten img {
    max-width: 100% !important;
    width: 100% !important;
    height: auto;
    border-radius: 10px;
    border: 1px solid #e1d6c8;
  }
  
  .columns.unten {
    display: contents;
  }
  
  .columns.unten p {
    margin-bottom: 0.1rem;
  }
  .columns.unten p a {
    font-size: 0.85rem;
  }
  
  /* Make Themen links bigger on mobile too */
  .columns.unten:first-child p a {
    font-size: 1rem;
  }
  
  .columns.unten a {
    margin-top: 0.2rem;
  }
  
  .columns.unten p:last-of-type {
    margin-bottom: 0.8rem;
    border-bottom: 1px dashed #ddd2c4;
    padding-bottom: 0.6rem;
  }
  
  .back-top {
    padding: 1.2rem 0 0.5rem 0;
  }
  .back-top a {
    padding: 0.4rem 1.8rem;
    font-size: 0.85rem;
  }
}