:root {
  --hat-red: #b5122b;
  --hat-red-dark: #7f0d20;
  --hat-yellow: #f2b705;
  --hat-ink: #17212b;
  --hat-muted: #596774;
  --hat-line: #dce2e7;
  --hat-surface: #fff;
  --hat-soft: #f5f7f8;
  --hat-radius: 12px;
  --hat-shadow: 0 4px 18px rgba(23, 33, 43, .08);
}

.hat-warning-grid,
.hat-warning-grid *,
.hat-warning-compact,
.hat-warning-compact *,
.hat-popup-backdrop,
.hat-popup-backdrop * {
  box-sizing: border-box;
}

/* Ausführliche Warnübersicht */
.hat-warning-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1rem, 2.2vw, 1.5rem);
  margin: 1.25rem 0;
}

.hat-warning-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--hat-line);
  border-radius: var(--hat-radius);
  background: var(--hat-surface);
  box-shadow: var(--hat-shadow);
  overflow: hidden;
}

.hat-warning-card > header {
  position: relative;
  padding: 1.15rem 1.25rem 1rem;
  border-bottom: 1px solid var(--hat-line);
  background: var(--hat-surface);
}

.hat-warning-card > header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--hat-red);
}

/* Absichtlich keine Schriftgröße: Die reguläre h4-Gestaltung des Themes bleibt erhalten. */
.hat-warning-card .hat-card-title {
  margin: 0;
  color: var(--hat-ink);
}

.hat-warning-card > header span {
  display: block;
  margin-top: .3rem;
  color: var(--hat-muted);
  line-height: 1.4;
}

.hat-warning-body {
  flex: 1;
  min-width: 0;
  padding: 1.25rem;
}

.hat-warning-card > footer {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--hat-line);
  background: var(--hat-soft);
}

.hat-warning-card > footer a,
.hat-alert-link a {
  color: var(--hat-red-dark);
  font-weight: 700;
  text-underline-offset: .16em;
}

.hat-status {
  margin: 0;
  padding: 1rem 1rem 1rem 3rem;
  border-radius: 9px;
  background-repeat: no-repeat;
  background-position: 1rem 1.05rem;
  background-size: 1.15rem;
  line-height: 1.5;
}

.hat-status-ok {
  color: #18592d;
  background-color: #eaf6ed;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2318592d' stroke-width='2.3'%3E%3Cpath d='m5 12 4 4L19 6'/%3E%3C/svg%3E");
}

.hat-status-error {
  color: #6a4a00;
  background-color: #fff4d6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a4a00' stroke-width='2.2'%3E%3Cpath d='M12 3 2 21h20L12 3Z'/%3E%3Cpath d='M12 9v5m0 3h.01'/%3E%3C/svg%3E");
}

.hat-alert {
  position: relative;
  margin: 0 0 1rem;
  padding: 1.1rem 1.1rem 1.1rem 1.25rem;
  border: 1px solid var(--hat-line);
  border-left: 6px solid #7b8794;
  border-radius: 9px;
  background: #fafbfc;
  overflow-wrap: anywhere;
}

.hat-alert:last-child {
  margin-bottom: 0;
}

.hat-alert > h6 {
  margin: 0 0 .45rem;
  color: var(--hat-ink);
  line-height: 1.35;
}

.hat-instructions h6 {
  margin: .9rem 0 .3rem;
  color: var(--hat-ink);
}

.hat-alert p {
  margin: .55rem 0;
  line-height: 1.55;
}

.hat-instructions {
  margin-top: 1rem;
  padding: .8rem 1rem;
  border: 0;
  border-radius: 8px;
  background: #eef2f5;
}

.hat-instructions h6:first-child,
.hat-instructions p:last-child {
  margin-top: 0;
  margin-bottom: 0;
}

/* DWD: Warnung Gelb, markantes Wetter Orange, Unwetter Rot, extremes Unwetter Violett. */
.hat-scale-dwd .hat-alert.severity-minor { border-left-color: #ffeb3b; background: #fffef0; }
.hat-scale-dwd .hat-alert.severity-moderate { border-left-color: #fb8c00; background: #fff8ef; }
.hat-scale-dwd .hat-alert.severity-severe { border-left-color: #d32f2f; background: #fff5f5; }
.hat-scale-dwd .hat-alert.severity-extreme { border-left-color: #8e24aa; background: #fbf3fd; }

/* MoWaS/NINA: Gefahreninformation Gelb, Gefahr Orange, extreme Gefahr Rot. */
.hat-scale-mowas .hat-alert.severity-minor { border-left-color: #f5cf2e; background: #fffdf0; }
.hat-scale-mowas .hat-alert.severity-moderate { border-left-color: #ef8c00; background: #fff8ef; }
.hat-scale-mowas .hat-alert.severity-severe,
.hat-scale-mowas .hat-alert.severity-extreme { border-left-color: #c8102e; background: #fff5f6; }

/* Hochwasserportale liefern CAP-Schweregrade, aber keine bundesweit einheitliche Farbskala. */
.hat-scale-flood .hat-alert.severity-minor { border-left-color: #f5cf2e; }
.hat-scale-flood .hat-alert.severity-moderate { border-left-color: #ef8c00; background: #fff8ef; }
.hat-scale-flood .hat-alert.severity-severe { border-left-color: #d32f2f; background: #fff5f5; }
.hat-scale-flood .hat-alert.severity-extreme { border-left-color: #8e24aa; background: #fbf3fd; }

.hat-period,
.hat-sender {
  color: var(--hat-muted);
}

.hat-period {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #e9edf0;
}

.hat-alert-link {
  margin-top: .8rem !important;
}

/* Vegetationsbrandindizes */
.hat-index-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 1rem;
}

.hat-index {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 1.15rem 1rem;
  border: 1px solid rgba(23, 33, 43, .1);
  border-radius: 10px;
  background: #eef1f4;
  text-align: center;
  overflow-wrap: anywhere;
}

.hat-index-title {
  max-width: 100%;
  color: var(--hat-ink);
  hyphens: auto;
  line-height: 1.3;
}

.hat-index-value {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin: .8rem;
  border: 3px solid currentColor;
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
}

.hat-index small {
  max-width: 100%;
  margin-top: .5rem;
  overflow-wrap: anywhere;
}

.hat-index.index-1 { background: #e5f4e7; color: #245d30; }
.hat-index.index-2 { background: #f4f1c7; color: #655c00; }
.hat-index.index-3 { background: #ffddb0; color: #714000; }
.hat-index.index-4 { background: #f8bfbb; color: #7c1717; }
.hat-index.index-5 { background: #dfc3e7; color: #592462; }

.hat-index-note,
.hat-warning-meta {
  color: var(--hat-muted);
  line-height: 1.5;
}

.hat-index-note {
  margin: 1rem 0 0;
}

/* Kompakte Startseitenanzeige */
.hat-warning-compact {
  margin: 1rem 0;
  border: 1px solid var(--hat-line);
  border-radius: var(--hat-radius);
  background: var(--hat-surface);
  box-shadow: var(--hat-shadow);
  overflow: hidden;
}

.hat-warning-compact.hat-compact-important {
  border-top: 6px solid var(--hat-red);
}

.hat-warning-compact.hat-compact-advisory {
  border-top: 6px solid #d98400;
}

.hat-compact-ok {
  padding: 1rem 1.1rem;
  border-left: 6px solid #27823f;
  background: #edf8f0;
  box-shadow: none;
  color: #174f28;
  line-height: 1.5;
}

.hat-warning-compact a {
  font-weight: 700;
}

.hat-compact-group {
  padding: 1rem 1.15rem;
}

.hat-compact-group + .hat-compact-group {
  border-top: 1px solid var(--hat-line);
}

.hat-compact-priority { background: #fff5f6; }
.hat-compact-secondary { background: #fffaf0; }

.hat-compact-label {
  display: block;
  margin-bottom: .65rem;
  color: var(--hat-red-dark);
  line-height: 1.3;
}

.hat-compact-secondary .hat-compact-label {
  color: #704800;
}

.hat-compact-group ul {
  display: grid;
  gap: .55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hat-compact-group li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .4rem .75rem;
  align-items: center;
}

.hat-compact-category {
  display: inline-block;
  padding: .2rem .58rem;
  border-radius: 999px;
  background: var(--hat-red);
  color: #fff;
  font-weight: 800;
  line-height: 1.45;
  white-space: nowrap;
}

.hat-compact-secondary .hat-compact-category {
  background: #a86600;
}

.hat-compact-title {
  min-width: 0;
  color: var(--hat-ink);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.hat-compact-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.15rem;
  border-top: 1px solid var(--hat-line);
  background: var(--hat-surface);
  color: var(--hat-red-dark);
  text-decoration: none;
}

.hat-compact-link::after {
  content: "→";
  line-height: 1;
}

.hat-compact-link:hover,
.hat-compact-link:focus {
  background: var(--hat-soft);
  text-decoration: underline;
}

.severity-rank-4 {
  border-color: #7d3688;
  background: #fbf5fc;
}

/* Globales Warnfenster */
.hat-popup-open { overflow: hidden; }
.hat-popup-backdrop[hidden] { display: none !important; }

.hat-popup-backdrop {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(12, 20, 28, .76);
  backdrop-filter: blur(2px);
}

.hat-warning-popup {
  position: relative;
  width: min(46rem, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: clamp(1.25rem, 3vw, 2rem);
  border-top: 9px solid var(--hat-red);
  border-radius: 14px;
  background: var(--hat-surface);
  box-shadow: 0 22px 75px rgba(0, 0, 0, .4);
  color: var(--hat-ink);
}

.hat-warning-popup:focus {
  outline: 3px solid var(--hat-yellow);
  outline-offset: 3px;
}

.hat-warning-popup > h6 {
  margin: .15rem 3rem 1rem 0;
  line-height: 1.15;
}

.hat-popup-label {
  margin: 0;
  color: var(--hat-red-dark);
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.hat-popup-close {
  position: absolute;
  top: .8rem;
  right: .8rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #edf0f2;
  color: var(--hat-ink);
  line-height: 1;
  cursor: pointer;
}

.hat-popup-close:hover,
.hat-popup-close:focus {
  background: #dce2e6;
  outline: 3px solid var(--hat-yellow);
}

.hat-popup-content {
  max-height: 52vh;
  overflow: auto;
  padding-right: .25rem;
}

.hat-popup-alert {
  padding: 1rem;
  margin: 0 0 1rem;
  border: 1px solid var(--hat-line);
  border-left: 5px solid var(--hat-red);
  border-radius: 9px;
  background: #fff7f8;
}

.hat-popup-alert:last-child { margin-bottom: 0; }
.hat-popup-alert h6 { margin: 0 0 .45rem; }
.hat-popup-alert p { margin: .45rem 0; line-height: 1.5; }

.hat-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.4rem;
}

.hat-popup-primary,
.hat-popup-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: .65rem 1rem;
  border: 2px solid var(--hat-red-dark);
  border-radius: 7px;
  font-weight: 700;
  text-decoration: none !important;
}

.hat-popup-primary {
  background: var(--hat-red-dark);
  color: #fff !important;
}

.hat-popup-secondary {
  background: #fff;
  color: var(--hat-red-dark);
  cursor: pointer;
}

@media (max-width: 520px) {
  .hat-warning-body,
  .hat-warning-card > header { padding-left: 1rem; padding-right: 1rem; }

  .hat-compact-group li {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hat-compact-category {
    justify-self: start;
    white-space: normal;
  }

  .hat-popup-backdrop {
    align-items: flex-start;
    padding: .5rem;
  }

  .hat-warning-popup {
    max-height: calc(100vh - 1rem);
    padding: 1.1rem;
  }

  .hat-popup-actions > * { width: 100%; }
  .hat-popup-content { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hat-warning-compact *,
  .hat-warning-grid *,
  .hat-popup-backdrop * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
