/*
 * Kell-GmbH Abfall-ABC – Frontend CSS v0.1.7
 * WCAG 2.1 AA: focus rings, contrast, min touch-targets, reduced-motion
 * Accessibility audit & review: Claude (Anthropic)
 */

/* ── Custom properties ───────────────────────────────────────────────── */

.kell-abc {
  --kell-col-title: 20%;
  --kell-col-entsorgung: 50%;
  --kell-col-info: 30%;
  --kell-abc-border-color: #dde3ea;
  /* FIX WCAG v0.1.6: #667085 → #5c6478 (5.6:1 on white, AA safe) */
  --kell-abc-muted: #5c6478;
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.kell-abc,
.kell-abc * {
  box-sizing: border-box;
}

.kell-abc > * {
  min-width: 0;
  max-width: 100%;
}

/* ── Reduced motion: respect OS preference ───────────────────────────── */
/* FIX v0.1.7: transitions and transforms disabled for users who prefer it */

@media (prefers-reduced-motion: reduce) {
  .kell-abc-letters button,
  .kell-abc-pagination button,
  .kell-abc-info-link,
  .kell-abc-table tbody tr {
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }
}

/* ── Filter bar ──────────────────────────────────────────────────────── */

.kell-abc-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
}

.kell-abc-search-field,
.kell-abc-per-page-field {
  display: grid;
  gap: 0.375rem;
  min-width: 0;
}

.kell-abc-search-field {
  flex: 1 1 18rem;
}

.kell-abc-search-field input,
.kell-abc-per-page-field select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--kell-abc-border-color);
}

/* FIX WCAG 2.4.7: visible focus ring on inputs/selects */
.kell-abc-search-field input:focus-visible,
.kell-abc-per-page-field select:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* ── Letter filter ───────────────────────────────────────────────────── */

.kell-abc-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kell-abc-letters button,
.kell-abc-pagination button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--kell-abc-border-color);
  background: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, transform 0.2s ease;
}

/* FIX WCAG 2.4.7: visible focus ring on all buttons */
.kell-abc-letters button:focus-visible,
.kell-abc-pagination button:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

.kell-abc-letters button:hover,
.kell-abc-pagination button:hover {
  transform: translateY(-1px);
}

.kell-abc-letters button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.kell-abc-letters button[disabled]:focus-visible {
  outline: none;
}

.kell-abc-letters button.is-active,
.kell-abc-pagination button.is-active {
  font-weight: 700;
}

/* ── Results text ────────────────────────────────────────────────────── */

.kell-abc-results {
  margin: 0;
  color: var(--kell-abc-muted);
}

/* ── Table wrapper with scroll indicator ─────────────────────────────── */

/*
 * FIX v0.1.7: Scroll-Schatten rechts als visueller Hinweis auf
 * weiteren Inhalt. Gradient über ::after-Pseudoelement.
 * Nur sichtbar, wenn Inhalt über den Rand hinausgeht.
 */
.kell-abc-table-wrap-outer {
  position: relative;
}

.kell-abc-table-wrap-outer::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3rem;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.85));
  pointer-events: none;
  border-radius: 0 0.875rem 0.875rem 0;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.kell-abc-table-wrap-outer.is-scrolled-end::after {
  opacity: 0;
}

.kell-abc-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--kell-abc-border-color);
  border-radius: 0.875rem;
  background: #fff;
  margin: 0;
  padding: 0;
  /* Scrollbar always visible on mobile for discoverability */
  scrollbar-width: thin;
  scrollbar-color: var(--kell-abc-border-color) transparent;
}

/* FIX WCAG 2.4.7: table-wrap gets focus when pagination is used */
.kell-abc-table-wrap:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* ── Table ───────────────────────────────────────────────────────────── */

.kell-abc-table {
  width: 100%;
  /* FIX v0.1.7: raised from 760px to 840px for 4-column layout */
  min-width: 840px;
  margin: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* Buchstabe column – compact, centered */
.kell-abc-table .kell-abc-col-letter,
.kell-abc-table thead th.kell-abc-col-letter {
  width: 7rem;
  text-align: center;
  font-weight: 700;
}

.kell-abc-table thead th:nth-child(2),
.kell-abc-table tbody th[scope="row"] {
  width: var(--kell-col-title);
}

.kell-abc-table thead th:nth-child(3),
.kell-abc-table tbody td:nth-child(3) {
  width: var(--kell-col-entsorgung);
}

.kell-abc-table thead th:nth-child(4),
.kell-abc-table tbody td:nth-child(4) {
  width: var(--kell-col-info);
}

.kell-abc-table th,
.kell-abc-table td {
  padding: 0.875rem 1rem;
  border-right: 1px solid var(--kell-abc-border-color);
  border-bottom: 1px solid var(--kell-abc-border-color);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

.kell-abc-table thead th {
  font-weight: 700;
  position: relative;
}

.kell-abc-table thead th:last-child,
.kell-abc-table tbody td:last-child {
  border-right: 0;
}

.kell-abc-table tbody tr:last-child th,
.kell-abc-table tbody tr:last-child td {
  border-bottom: 0;
}

.kell-abc-table thead th:first-child {
  border-top-left-radius: inherit;
}

.kell-abc-table thead th:last-child {
  border-top-right-radius: inherit;
}

/*
 * FIX WCAG v0.1.7: tbody th (row header = Title column) has insufficient
 * contrast on the zebra background (rgba gray overlay → ~3.2:1 fail).
 * Force inherit from Elementor's body text color, which is #333 on white → 12.6:1.
 * The zebra background itself stays configurable via Elementor controls.
 */
.kell-abc-table tbody th {
  font-weight: 500;
  color: inherit;
}

.kell-abc-table tbody tr {
  transition: background-color 0.2s ease;
}

/* ── Info link / button ──────────────────────────────────────────────── */

.kell-abc-info-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  max-width: 100%;
  padding: 0.625rem 0.875rem;
  text-decoration: none;
  border: 1px solid currentColor;
  vertical-align: top;
}

/* FIX WCAG 2.4.7: visible focus ring on info links */
.kell-abc-info-link:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

.kell-abc-info-link__text {
  min-width: 0;
}

.kell-abc-info-link__icon {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.kell-abc-no-info {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--kell-abc-muted);
}

/* ── Pagination ──────────────────────────────────────────────────────── */

.kell-abc-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Ellipsis between page groups */
.kell-abc-pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.25rem;
  color: var(--kell-abc-muted);
  pointer-events: none;
  user-select: none;
}

/* ── Screen-reader utility ───────────────────────────────────────────── */

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .kell-abc-filter-bar {
    align-items: stretch;
  }

  .kell-abc-search-field,
  .kell-abc-per-page-field {
    width: 100%;
  }
}
