/* assets/css/grid.css
   Metro Grid System — Layout, tile visuals, effects, link-buttons, slider.
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
  --page-bg:                    #fff;
  --metro-gap:                  20px;
  --metro-max-width:            1496px;
  --tile-min-height:            240px;
  --tile-min-height-vw:         25vw;
  --tile-border-radius:         30px;
  --tile-visual-max-height:     200px;
  --tile-text-container-radius: 20px;
  --tile-topic-radius:          20px;
  --tile-topic-font-size:       1.0em;
  --tile-title-font-size:       1.7rem;
  --tile-offset:                15px;

  /* --- Title-Segment System --- */
  --title-size-default:         1.4rem;
  --title-size-large:           2.8rem;
  --title-size-script:          3.5rem;
  --title-font-script:          'PinyonScript', 'Dancing Script', cursive;
}

/* ---- Grid Container ---- */
.metro-grid {
  max-width: var(--metro-max-width);
  margin: 0 auto calc(var(--metro-gap) * 2);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: auto;
  gap: var(--metro-gap);
  grid-auto-flow: dense;
}

/* ---- Tile base ---- */
/* overflow: visible so caption below the visual is not clipped.
   Rounded corners are handled by .tile-visual instead. */
.tile {
  overflow: visible;
  min-width: 0; /* Grid-Items dürfen kleiner als ihr Content werden */
  background: var(--page-bg, #fff);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---- Tile Column Spans ---- */
.tile-1 { grid-column: span 1; grid-row: span 1; }
.tile-2 { grid-column: span 2; grid-row: span 1; }
.tile-3 { grid-column: span 3; grid-row: span 1; }
.tile-4 { grid-column: span 4; grid-row: span 1; }
.tile-5 { grid-column: span 5; grid-row: span 1; }
.tile-6 { grid-column: span 6; grid-row: span 1; }
.tile-3-tall { grid-column: span 3; grid-row: span 2; }
.tile-4-tall { grid-column: span 4; grid-row: span 2; }
.tile-5-tall { grid-column: span 5; grid-row: span 2; }
.tile-6-tall { grid-column: span 6; grid-row: span 2; }

/* ---- Visual Area ---- */
/* overflow: visible so link-button is not clipped.
   Clipping of img/video at border-radius is handled by .tile-visual__media. */
.tile-visual {
  min-height: max(var(--tile-min-height), var(--tile-min-height-vw));
  width: 100%;
  overflow: visible;
  position: relative;
  flex: 1 0 auto;
  display: block;
  /* Default: top corners rounded; bottom flat (caption follows) */
  border-radius: var(--tile-border-radius) var(--tile-border-radius) 0 0;
}

/* ---- Media wrapper — clips img/video at border-radius ---- */
/* Separate from .tile-visual so overflow:hidden doesn't cut the button. */
.tile-visual__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.tile-visual__media img,
.tile-visual__media video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- tile-3+ – visual fills entire tile, caption hidden ---- */
.tile-3 .tile-visual,
.tile-4 .tile-visual,
.tile-5 .tile-visual,
.tile-6 .tile-visual,
.tile-3-tall .tile-visual,
.tile-4-tall .tile-visual,
.tile-5-tall .tile-visual,
.tile-6-tall .tile-visual {
  height: 100%;
  flex: 1 1 100%;
  border-radius: var(--tile-border-radius);
}

/* Breite Tiles brauchen mehr Höhe, damit Bilder nicht überproportional
   gecroppt werden — vor allem wenn tile-6 alleine in einer Reihe steht */
.tile-5 .tile-visual,
.tile-6 .tile-visual,
.tile-5-tall .tile-visual,
.tile-6-tall .tile-visual {
  min-height: max(var(--tile-min-height), 35vw);
}

/* ---- Text container for md/lg (white card, top-left of visual) ---- */
.tile-text-container {
  position: absolute;
  top: var(--tile-offset);
  left: var(--tile-offset);
  right: auto;
  background: var(--page-bg, #ffffff);
  border-radius: var(--tile-text-container-radius);
  padding: 15px 30px 20px 15px;
  z-index: 3;
  max-width: calc(100% - 30px);
  width: auto;
  box-sizing: border-box;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

/* ---- Topic badge (shared base) ---- */
.tile-topic {
  display: inline-block;
  font-size: var(--tile-topic-font-size);
  font-weight: 400;
  color: #000000;
  background: #00796b; /* default; override via inline style */
  border-radius: var(--tile-topic-radius);
  padding: 5px 10px;
  line-height: 1.4;
  align-self: flex-start;
}

/* ---- Titles — unified size for all tile types ---- */
.tile-text-container .tile-title,
.tile-caption .tile-title {
  font-size: var(--tile-title-font-size);
  font-weight: 700;
}

.tile-text-container .tile-title {
  color: #111;
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.2;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ---- tile-1, tile-2 visual: all four corners round + height bounded ---- */
/* max-height caps the visual so very tall images don't dominate;
   min-height ensures media never collapses to 0. */
.tile-1 .tile-visual,
.tile-2 .tile-visual {
  border-radius: var(--tile-border-radius);
  max-height: var(--tile-visual-max-height);
  height: var(--tile-visual-max-height); /* gibt position:absolute Kindelementen (SVG) einen Referenzwert */
}

/* ---- Decorative tile-1/tile-2: Visual füllt den Raum, den sonst Caption+Visual zusammen einnehmen würden.
   Nachbarunabhängig (funktioniert auch in Rows, die nur aus decorative Tiles bestehen). ---- */
.tile-1.tile-decorative .tile-visual,
.tile-2.tile-decorative .tile-visual {
  max-height: none;
  height: calc(var(--tile-visual-max-height) + 40px);
}

/* ---- Video inside tile-visual: hardware-composited layer for smooth playback ---- */
.tile-visual .video-bg {
  transform: scale(1);
  will-change: transform;
}

/* For hover-zoom/hover-play tiles: remove pre-compositing so CSS transition works cleanly */
.tile.hover-zoom .tile-visual .video-bg,
.tile.hover-play .tile-visual .video-bg {
  transform: none;
  will-change: auto;
}

/* ---- Topic badge on tile-1/tile-2 (absolute, on .tile-visual) ---- */
.tile-1 .tile-topic,
.tile-2 .tile-topic {
  position: absolute;
  top: var(--tile-offset);
  left: var(--tile-offset);
  z-index: 3;
}

/* ---- Caption for sm tiles (below the visual) ---- */
.tile-caption {
  padding: 8px 0;
}

.tile-caption .tile-title {
  margin: 0 0 6px 0;
  overflow: visible;
}

.tile-1 .tile-caption .tile-title {
  font-size: 1.1rem;
}

.tile-caption .tile-summary {
  font-weight: 400;
  margin: 0;
  color: #333;
  line-height: 1.2;
  font-size: 1.1rem;
  display: -webkit-box;
  -webkit-line-clamp: 15;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Tile link overlay ---- */
.tile-link {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  text-decoration: none;
}

/* ---- Hover-Zoom ---- */
.tile.hover-zoom:not(.parallax-box) .tile-visual__media img,
.tile.hover-zoom:not(.parallax-box) .tile-visual__media video {
  transition: transform 0.4s ease;
}
.tile.hover-zoom:not(.parallax-box):hover .tile-visual__media img,
.tile.hover-zoom:not(.parallax-box):hover .tile-visual__media video {
  transform: scale(var(--zoom-strength, 1.05));
}

/* ---- Hover-Play: Video pausiert, startet bei Hover ---- */
.tile.hover-play .tile-visual__media video {
  transition: transform 0.4s ease; /* auch wenn hover-zoom nicht aktiv ist */
}

/* Parallax-Kacheln: overflow hidden damit jarallax-img nicht aus der Kachel ragt */
.tile.parallax-box {
  overflow: hidden;
  border-radius: var(--tile-border-radius);
  min-height: 50vh;
  margin-bottom: 0; /* parallax.css setzt margin-bottom: 20px – im Grid nicht nötig */
}

/* ---- Cutout: Visual füllt volle Kachelhöhe (überschreibt sm max-height) ---- */
.tile-visual.tile-visual-fullheight {
  max-height: none;
  height: 100%;
  flex: 1 1 100%;
}

/* ---- SVG Text-Cutout ---- */
/* Gleiches Pattern wie .hero-cutout-svg in hero.css */
.tile-cutout-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
}

.tile-cutout-title-svg {
  fill: #000000;
  font-family: 'MatterSQ', Arial, sans-serif;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

/* Badge über SVG-Maske bei tile-3+ Cutout-Kacheln (Badge direkt in .tile-visual, nicht in .tile-text-container) */
.tile-3 .tile-visual > .tile-topic,
.tile-4 .tile-visual > .tile-topic,
.tile-5 .tile-visual > .tile-topic,
.tile-6 .tile-visual > .tile-topic,
.tile-3-tall .tile-visual > .tile-topic,
.tile-4-tall .tile-visual > .tile-topic,
.tile-5-tall .tile-visual > .tile-topic,
.tile-6-tall .tile-visual > .tile-topic {
  position: absolute;
  top: var(--tile-offset);
  left: var(--tile-offset);
  z-index: 3;
}

/* ---- Link-Button (organischer Ausschnitt unten rechts) ---- */
.tile__corner-mask {
  all: unset;
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 101px;
  height: 101px;
  z-index: 12;
  pointer-events: none;
}

.tile__corner-mask svg {
  fill: var(--page-bg);
  display: block;
  width: 102px;
  height: 102px;
}

.tile__button-anchor {
  all: unset;
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 13;
  pointer-events: none;
}

.tile__button-wrapper {
  all: unset;
  display: block;
  background-color: var(--page-bg);
  padding: 10px;
  border-radius: 50% 0 0 0;
  margin: 0 -10px -10px 0;
  position: relative;
  box-sizing: content-box;
}

.tile__curve {
  all: unset;
  display: block;
  width: 20px;
  height: 20px;
  position: absolute;
  z-index: 3;
  pointer-events: none;
  transform: rotate(180deg) scale(1.01);
}

.tile__curve--top {
  top: -20px;
  right: 10px;
}

.tile__curve--left {
  bottom: 10px;
  left: -20px;
}

.tile__curve svg {
  fill: var(--page-bg);
  display: block;
  width: 20px;
  height: 20px;
}

.tile__link-button {
  all: unset;
  position: relative;
  box-sizing: content-box;
  width: 50px;
  height: 50px;
  background-color: #000;
  border: 1px solid #000;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile:hover .tile__link-button {
  transform: rotate(-45deg);
}

/* ---- Text-Tile: Markdown-Inhalt füllt das Visual ---- */
.tile-text-content {
  padding: 30px;
  overflow: hidden;
  height: 100%;
  box-sizing: border-box;
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
}

.tile-1 .tile-text-content,
.tile-2 .tile-text-content { column-count: 1; }
.tile-3 .tile-text-content,
.tile-4 .tile-text-content { column-count: 2; column-gap: 30px; }
.tile-5 .tile-text-content,
.tile-6 .tile-text-content,
.tile-3-tall .tile-text-content,
.tile-4-tall .tile-text-content,
.tile-5-tall .tile-text-content,
.tile-6-tall .tile-text-content { column-count: 2; column-gap: 30px; }

/* ---- Gradient inside grid tiles ---- */
.tile .tile-visual.gradient-box {
  height: 100%;
  margin-bottom: 0;
  border-radius: var(--tile-border-radius);
  overflow: visible;
}

.tile .tile-visual.gradient-box::before {
  border-radius: var(--tile-border-radius);
}

.tile-1 .tile-visual.gradient-box,
.tile-2 .tile-visual.gradient-box {
  max-height: none;
  height: 100%;
  flex: 1 1 100%;
}

/* ---- Grid Slider Tile ---- */
.tile-slider {
  grid-column: span 6;
  grid-row: span 1;
  display: flex;
  flex-direction: row; /* overrides .tile { flex-direction: column } */
  gap: var(--metro-gap);
  height: auto;
  background: transparent;
  overflow: visible;
}

.slider-slide-area {
  /* Exact 4-column + 3-gap width to match 6-col grid alignment */
  flex: 0 0 calc((100% - var(--metro-gap) * 5) / 6 * 4 + var(--metro-gap) * 3);
  min-width: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--tile-border-radius);
}

.slider-slide-track {
  display: flex;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-slide {
  width: 100%;
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
  overflow: hidden;
}

.slider-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.slider-slide:hover img {
  transform: scale(1.03);
}

.slider-info-panel {
  /* Exact 2-column + 1-gap width to match 6-col grid alignment */
  flex: 0 0 calc((100% - var(--metro-gap) * 5) / 6 * 2 + var(--metro-gap));
  min-width: 0;
  position: relative;
  background: var(--slider-info-bg, #f9f8f6);
  border-radius: var(--tile-border-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.slider-info-track {
  flex: 1;
  display: flex;
  /* no overflow:hidden here — panel clips */
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-info-slide {
  width: 100%;
  min-width: 100%;
  padding: 25px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  overflow-y: auto;
}

.slider-info-slide .tile-topic {
  position: static;
}

.slider-info-slide .tile-title {
  font-size: var(--tile-title-font-size);
  font-weight: 700;
  color: var(--slider-text-color, #111);
  margin: 0;
  line-height: 1.3;
}

.slider-info-excerpt {
  font-size: 1rem;
  color: var(--slider-text-color, #555);
  opacity: 0.75;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Slider link-button: sits on .tile-slider (outside panel to avoid overflow clip) */
.tile-slider .slider-info-link {
  pointer-events: auto;
  text-decoration: none;
}

.tile-slider .slider-info-link .tile__link-button {
  pointer-events: auto;
}

.tile-slider .slider-info-link:hover .tile__link-button {
  transform: rotate(-45deg);
}

.slider-progress {
  display: flex;
  gap: 5px;
  padding: 0 20px 20px 20px;
  flex-shrink: 0;
}

.tile-slider .slider-progress .progress-bar {
  width: 27px;
  height: 7px;
  background-color: var(--progress-unfilled, #98ace3);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}

.tile-slider .slider-progress .progress-fill {
  width: 0%;
  height: 100%;
  background-color: var(--progress-filled, #1b45c0);
  border-radius: 4px;
}

/* ---- Responsive — single breakpoint ---- */
@media (max-width: 600px) {
  .metro-grid {
    grid-template-columns: 1fr;
    overflow-x: clip; /* Link-Buttons ragen über Tiles hinaus — auf Mobile clippen */
  }

  .tile-1,
  .tile-2,
  .tile-3,
  .tile-4,
  .tile-5,
  .tile-6,
  .tile-3-tall,
  .tile-4-tall,
  .tile-5-tall,
  .tile-6-tall {
    grid-column: span 1;
    grid-row: span 1;
  }

  .tile-slider {
    grid-column: span 1;
    flex-direction: column;
    height: auto;
  }

  .slider-slide-area {
    flex: 1 1 auto;
    width: 100%;
  }

  .slider-info-panel {
    flex: 1 1 auto;
    width: 100%;
  }

  /* Fixed min-height on mobile — prevents collapse of absolute-positioned media */
  .tile-visual {
    min-height: 220px;
  }
}

/* ---- Akkordeon-Kachel im Grid ---- */

/* Override .tile defaults: clip to border-radius, no white background */
.tile.tile-accordion {
  overflow: hidden;
  border-radius: var(--tile-border-radius);
  background: transparent;
  min-height: max(var(--tile-min-height), var(--tile-min-height-vw));
}

/* accordion-wrapper fills the entire tile */
.tile.tile-accordion .accordion-wrapper.in-grid {
  max-width: none;
  width: 100%;
  padding: 0;
  margin: 0;
  flex: 1;
}

/* First li: remove top radius — the tile's own border-radius handles the top corners */
.tile.tile-accordion .accordion-wrapper.in-grid li:first-child {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Last items: accordion.css already applies border-bottom-*-radius: 30px (--fallback-acc-radius).
   That matches --tile-border-radius, so we let it stand — no override needed.
   The tile's overflow:hidden backs this up. */
