/* ==========================================================================
   content.css – what the content team writes in the WordPress editor

   1. Entry layouts (single post, play page, normal page)
   2. Text, lists, quotes
   3. Tables
   4. Images, galleries, videos
   5. Clean-up for old classic-editor content
   6. Pages with their own arrangement (Rezensionen, Video)

   Also loaded inside the block editor, so writing looks like the result.
   ========================================================================== */

/* ---------- 1. Entry layouts ---------- */

.entry {
  padding-top: var(--space-section);
}

/* Posts and plays with a poster: text on the left, poster on the right, the rest below. */
.entry--with-poster {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 22rem);
  grid-template-areas:
    "content poster"
    "gallery gallery"
    "footer  footer";
  gap: 2.5rem 3.5rem;
  align-items: start;
}

/* A butter-yellow blob peeks out from behind the poster. */
.entry--with-poster {
  position: relative;
}

.entry--with-poster::before {
  content: "";
  position: absolute;
  top: calc(var(--space-section) - 2rem);
  right: calc(var(--gutter) * -0.7);
  width: 10rem;
  height: 10rem;
  border-radius: 45% 55% 48% 52% / 55% 44% 56% 45%;
  background: var(--color-butter);
}

.entry--with-poster > * {
  position: relative; /* in front of the blob */
}

.entry--with-poster > .entry-content { grid-area: content; }
.entry--with-poster > .entry__poster { grid-area: poster; }
.entry--with-poster > .entry__gallery { grid-area: gallery; }
.entry--with-poster > .entry__footer { grid-area: footer; }

/* The poster hangs a little crooked in a white frame, like the posters on the start page. */
.entry__poster {
  margin: 0;
  padding: 0.6rem;
  border: 2px solid var(--color-line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: 0 6px 0 var(--color-line);
  rotate: 1.5deg;
}

.entry__poster img {
  display: block;
  width: 100%;
  border-radius: 18px;
}

.entry__gallery {
  margin-top: 1.5rem;
}

.entry__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
}

.entry__meta {
  margin: 0;
  font-size: var(--text-small);
  color: var(--color-ink-soft);
}

@media (max-width: 799px) {
  .entry--with-poster {
    grid-template-columns: 1fr;
    grid-template-areas:
      "poster"
      "content"
      "gallery"
      "footer";
  }

  .entry__poster {
    justify-self: center;
    max-width: 20rem;
  }
}

/*
 * Normal pages: the text column has the reading width and is centered. Blocks set to "wide" or
 * "full width" in the editor break out of it; 100cqw is the width of .site-main (without scrollbar).
 */
.site-main {
  container-type: inline-size;
}

.entry-content--flow {
  width: min(100% - 2 * var(--gutter), var(--width-content));
  margin-inline: auto;
}

.entry-content--flow > :is(.alignwide, .alignfull) {
  width: min(100cqw - 2 * var(--gutter), var(--width-wide));
  max-width: none;
  margin-left: 50%;
  translate: -50% 0;
}

.entry-content--flow > .alignfull {
  width: 100cqw;
}

/* ---------- 2. Text, lists, quotes ---------- */

.entry-content > * {
  margin-block: 0 1.1em;
}

.entry-content > :last-child {
  margin-bottom: 0;
}

.entry-content :is(h1, h2, h3, h4) {
  margin-top: 1.6em;
}

.entry-content > :is(h1, h2, h3, h4):first-child {
  margin-top: 0;
}

/* The page title is the only real h1; an h1 typed into the text is shown like an h2. */
.entry-content h1 {
  font-size: var(--text-h2);
}

.entry-content :is(ul, ol) {
  padding-left: 1.4em;
}

.entry-content li {
  margin-bottom: 0.4em;
}

.entry-content li::marker {
  color: var(--color-tomato);
}

.entry-content blockquote {
  margin-inline: 0;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-card);
  font-family: var(--font-display);
  font-size: var(--text-large);
  background: var(--color-butter);
}

.entry-content hr {
  height: 2px;
  border: 0;
  background: var(--color-line);
}

/* ---------- 3. Tables ---------- */

/* Tables look like a white card; announcement tables ("Wann / Stück / Wo") get their labels from <th>. */
.entry-content table {
  width: 100%;
  overflow: hidden;
  border: 2px solid var(--color-line);
  border-radius: var(--radius-card);
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  box-shadow: 0 6px 0 var(--color-line);
}

.entry-content :is(th, td) {
  padding: 0.8rem 1.1rem;
  border: 0; /* resets the borders of the core table block */
  border-bottom: 2px dotted var(--color-line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.entry-content tr:last-child > :is(th, td) {
  border-bottom: 0;
}

.entry-content th {
  width: 1%; /* as narrow as its text */
  font-size: var(--text-small);
  font-weight: 700;
  line-height: 1.9;
  color: var(--color-ink-soft);
  white-space: nowrap;
}

.entry-content .wp-block-table {
  margin-inline: 0;
  padding-bottom: 6px; /* room for the table's paper edge */
  overflow-x: auto;
}

/* ---------- 4. Images, galleries, videos ---------- */

.entry-content img {
  border-radius: 14px;
}

.entry-content figure {
  margin-inline: 0;
}

.entry-content figcaption,
.entry-content .wp-caption-text {
  margin-top: 0.5em;
  font-size: var(--text-small);
  color: var(--color-ink-soft);
  text-align: center;
}

/* Galleries made with old versions of the gallery block are lists. */
.entry-content .blocks-gallery-grid {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Alignment classes of the classic editor. */
.entry-content .alignleft {
  float: left;
  max-width: 50%;
  margin: 0.3em 1.5em 1em 0;
}

.entry-content .alignright {
  float: right;
  max-width: 50%;
  margin: 0.3em 0 1em 1.5em;
}

.entry-content .aligncenter {
  display: block;
  margin-inline: auto;
}

.entry-content::after {
  content: "";
  display: block;
  clear: both;
}

.entry-content iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-card);
}

/* ---------- 5. Clean-up for old classic-editor content ---------- */

/* Leftover empty headings and paragraphs take up no room. */
.entry-content :is(h1, h2, h3, h4, p):empty {
  display: none;
}

/* Text that was colored red by hand ("für Kinder ab 2 Jahren …") uses the theme's red instead. */
.entry-content span[style*="color: #ff0000"] {
  font-weight: 700;
  color: var(--color-tomato) !important;
}

/* ---------- 6. Pages with their own arrangement ---------- */

/*
 * These rules hang on the page slug (body class "page-<slug>", see ttt_body_classes()).
 * Rezensionen: scanned guest book pages, side by side instead of one endless column.
 * Video: the videos side by side.
 */
.page-rezensionen .entry-content--flow,
.page-video .entry-content--flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1.5rem;
  align-items: start;
  width: min(100% - 2 * var(--gutter), var(--width-wide));
}

.page-video .entry-content--flow {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
}

.page-rezensionen .entry-content--flow > *,
.page-video .entry-content--flow > * {
  margin: 0;
}

.page-rezensionen .entry-content img {
  display: block;
  width: 100% !important; /* some images carry a fixed inline width */
  border: 2px solid var(--color-line);
}
