/**
 * SCL Stufen-Kacheln — Frontend.
 *
 * Farben und Schriften kommen aus den Tokens des Schwesterplugins scl-design;
 * jeder Zugriff trägt einen Fallback, damit das Raster auch allein läuft.
 */

.scls-scope {
  /* Das Grau der Vorlage (#7a7568) erreicht auf hellem Grund nur rund 4,4:1
     und verfehlt damit die 4,5:1 aus WCAG 2.1 AA für Fließtext. Der Ton wird
     deshalb leicht abgedunkelt — dieselbe Farbfamilie, rund 5,4:1. */
  --scls-muted: color-mix(in srgb, var(--scl-muted, #7a7568) 82%, var(--scl-forest, #1a1a1a));
  --scls-focus: var(--scl-terracotta, #e8521a);
}

@supports not (color: color-mix(in srgb, red, blue)) {
  .scls-scope { --scls-muted: #695f52; }
}

.scls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.scls-cols-2 { grid-template-columns: repeat(2, 1fr); }
.scls-cols-4 { grid-template-columns: repeat(4, 1fr); }

.scls-card {
  background: #ffffff;
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: 6px;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.scls-card:not(.scls-card-static):hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(232, 82, 26, 0.14);
}

/* Der Fokus liegt auf dem Titel-Link; sichtbar markiert wird die ganze Karte,
   weil sie die Klickfläche ist. */
.scls-card:focus-within {
  outline: 3px solid var(--scls-focus);
  outline-offset: 3px;
}

.scls-media {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  margin: -2.5rem -2.5rem 1.75rem;
}

/* Die weiße Nummer steht auf dem Foto; über hellen Motiven trägt der
   Textschatten allein nicht. Der Verlauf hält den Kontrast unabhängig vom
   Bildinhalt. */
.scls-media::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 45%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.10), transparent);
  z-index: 1;
  pointer-events: none;
}

.scls-media-empty::before { content: none; }

.scls-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}

.scls-card:not(.scls-card-static):hover .scls-media img { transform: scale(1.04); }

/* Ohne Beitragsbild bleibt eine ruhige Fläche stehen, damit Nummer und
   Kartenhöhe erhalten bleiben. */
.scls-media-empty {
  background: var(--scl-sand, #f0ece8);
}

.scls-number {
     font-family: 'Cormorant Garamond', serif;
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    position: absolute;
    top: -10px;
    left: 1rem;
    z-index: 2;
    color: #e8521a;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    user-select: none;

}

.scls-media-empty .scls-number {
  color: var(--scl-forest, #1a1a1a);
  opacity: 0.25;
  text-shadow: none;
}

.scls-label {
  font-family: var(--scl-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--scls-muted);
  margin-bottom: 0.5rem;
}

.scls-name {
  font-family: var(--scl-serif, Georgia, serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--scl-forest, #1a1a1a);
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

.scls-link {
  color: inherit;
  text-decoration: none;
}

/* Macht die ganze Karte klickbar, ohne den Linktext um Bild, Label und
   Beschreibung aufzublähen. */
.scls-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
}

.scls-link:hover { text-decoration: underline; }

/* Der Fokusring sitzt an der Karte (:focus-within), am Link selbst wäre er
   doppelt. */
.scls-link:focus-visible { outline: none; }

.scls-desc {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--scls-muted);
  flex-grow: 1;
  margin: 0 0 1.5rem;
}

.scls-arrow {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--scl-forest, #1a1a1a);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--scl-forest, #1a1a1a);
  font-size: 1rem;
  transition: background 0.2s, color 0.2s;
}

.scls-card:hover .scls-arrow,
.scls-card:focus-within .scls-arrow {
  background: var(--scl-forest, #1a1a1a);
  color: var(--scl-white, #ffffff);
}

/* Nur für Screenreader, z. B. der Hinweis auf ein neues Tab. */
.scls-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Redaktionshinweis, nur für eingeloggte Benutzer sichtbar. */
.scls-hint {
  font-family: var(--scl-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  color: var(--scl-terracotta, #e8521a);
}

@media (max-width: 1024px) {
  .scls-grid,
  .scls-cols-4 { grid-template-columns: 1fr 1fr; }

  /* Bei ungerader Kachelzahl füllt die letzte Karte die Reihe, damit keine
     halbe Lücke stehen bleibt. */
  .scls-grid > .scls-card:last-child:nth-child(odd) { grid-column: span 2; }
}

@media (max-width: 640px) {
  .scls-grid,
  .scls-cols-2,
  .scls-cols-4 { grid-template-columns: 1fr; }

  .scls-grid > .scls-card:last-child:nth-child(odd) { grid-column: span 1; }

  .scls-card { padding: 2rem; }
  .scls-media { margin: -2rem -2rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .scls-card,
  .scls-media img,
  .scls-arrow { transition: none; }

  .scls-card:not(.scls-card-static):hover { transform: none; }
  .scls-card:not(.scls-card-static):hover .scls-media img { transform: none; }
}

/* Im Kontrastmodus von Windows verschwinden Hintergrundflächen; die Kontur
   der Karte muss dann aus einer Rahmenfarbe kommen, nicht aus dem Schatten. */
@media (forced-colors: active) {
  .scls-card { border-color: CanvasText; }
  .scls-arrow { border-color: ButtonText; color: ButtonText; }
}
