/*
  Zweck: Grundbausteine und Panel-Matrix der Kommandozentrale.
  Zielpfad: /home/mckiede/public_html/design/components.css
  Verantwortlich: mckie-Portal

  Page title: container query on #page-title only (not .header-brand),
  so font-size tracks the title column — not the full header incl. NAV sensor.
*/
.header-brand #page-title {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(0.48rem, 8.25cqi, 4.45rem);
  line-height: 0.88;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  text-transform: uppercase;
}

.header-controls {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  flex: 0 0 auto;
  width: 7rem;
  min-width: 7rem;
  height: 3.15rem;
  margin-top: 1rem;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--surface-accent);
  box-shadow:
    inset 0 0 0 var(--segment-line) var(--orange),
    0 0 0.45rem color-mix(in srgb, var(--orange) 28%, transparent);
}

.header-controls::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--wash-primary-18), transparent 58%);
  pointer-events: none;
}

.header-control {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--peach);
  cursor: pointer;
}

.header-control:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.header-control:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.header-control + .header-control {
  border-left: var(--segment-line-thin) solid color-mix(in srgb, var(--orange) 52%, transparent);
}

.header-control:hover,
.header-control:focus-visible {
  background: var(--wash-primary-24);
}

.header-control:first-child:hover,
.header-control:first-child:focus-visible {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.header-control:last-child:hover,
.header-control:last-child:focus-visible {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.sound-toggle.is-off {
  opacity: 0.55;
}

.sound-toggle.is-off .sound-wave {
  opacity: 0;
}

.sound-toggle.is-off::after {
  content: "";
  position: absolute;
  width: 2rem;
  height: 0.16rem;
  background: currentColor;
  transform: rotate(-35deg);
}

.control-icon {
  position: relative;
  width: 1.55rem;
  height: 1.55rem;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen-toggle .control-icon {
  fill: none;
}

.sound-wave {
  fill: none;
}

.rail-button {
  border: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: var(--rail-button-min-height);
  padding: var(--rail-button-pad-y) var(--rail-button-pad-x-end) var(--rail-button-pad-y) var(--rail-button-pad-x-start);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  clip-path: none;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--tone) 26%, transparent), transparent 70%),
    linear-gradient(180deg, var(--wash-white-5), transparent),
    var(--surface-dark);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: right;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow:
    inset -0.35rem 0 0 color-mix(in srgb, var(--tone) 44%, transparent),
    inset 0.18rem 0 0 var(--wash-white-8),
    inset 0 0 0 0.1rem color-mix(in srgb, var(--tone) 28%, transparent);
}

.rail-button::before {
  content: "";
  position: absolute;
  top: 0.45rem;
  left: 0.55rem;
  width: min(42%, 4rem);
  height: var(--segment-line);
  background: color-mix(in srgb, var(--tone) 72%, transparent);
  border-radius: var(--radius-pill);
}

.rail-button:hover,
.rail-button:focus-visible {
  filter: brightness(1.12);
  text-decoration: none;
  color: color-mix(in srgb, var(--green) 34%, var(--peach));
  text-shadow: 0 0 0.9rem color-mix(in srgb, var(--green) 42%, transparent);
  box-shadow:
    inset -0.35rem 0 0 color-mix(in srgb, var(--tone) 72%, transparent),
    inset 0.18rem 0 0 color-mix(in srgb, var(--green) 34%, transparent),
    inset 0 0 0 0.12rem color-mix(in srgb, var(--green) 28%, transparent),
    0 0 1.2rem color-mix(in srgb, var(--green) 18%, transparent);
}

.rail-button.active {
  outline: 0;
  box-shadow:
    inset -0.35rem 0 0 var(--tone),
    inset 0.18rem 0 0 var(--tone),
    inset 0 0 0 0.18rem color-mix(in srgb, var(--tone) 42%, transparent),
    0 0 0 0.08rem var(--wash-white-12);
}

/*
  Orange bar above “Bereit für Eingabe” — fixed flex basis (never grows with scroll/sensor).
*/
.main-console::before {
  content: "";
  display: block;
  flex: 0 0 var(--console-top-bar);
  width: 100%;
  height: var(--console-top-bar);
  min-height: var(--console-top-bar);
  max-height: var(--console-top-bar);
  margin: 0 0 var(--console-panel-inset);
  padding: 0;
  border: 0;
  background: var(--console-frame);
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  box-sizing: border-box;
}

.status-strip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: 0 0 auto;
  min-height: 5rem;
  padding: 1rem 1.25rem;
  background:
    linear-gradient(90deg, var(--wash-primary-18), transparent 48%),
    linear-gradient(180deg, var(--panel-glass), transparent),
    var(--panel);
  border: 0;
  border-radius: var(--radius-md);
  clip-path: none;
  box-shadow:
    inset 0 0 0 var(--segment-line-thin) var(--wash-white-5),
    inset var(--segment-line-strong) 0 0 var(--wash-frame-34);
}

.status-strip::before {
  display: none;
}

.status-strip::after {
  content: "";
  position: absolute;
  inset: 0;
  border-top: var(--segment-line) solid color-mix(in srgb, var(--orange) 58%, transparent);
  border-right: var(--segment-line-thin) solid color-mix(in srgb, var(--orange) 24%, transparent);
  border-radius: inherit;
  pointer-events: none;
  animation: status-line-pulse 7s ease-in-out infinite;
}

@keyframes status-line-pulse {
  0%,
  100% {
    border-top-color: color-mix(in srgb, var(--orange) 58%, transparent);
    box-shadow: none;
  }

  50% {
    border-top-color: color-mix(in srgb, var(--green) 58%, var(--orange));
    box-shadow: inset 0 var(--segment-line) 0 color-mix(in srgb, var(--green) 28%, transparent);
  }
}

.status-strip .system-label,
.status-strip h2 {
  margin: 0;
}

.status-strip .system-label {
  display: none;
}

.status-strip h2 {
  color: var(--peach);
  font-size: clamp(1.5rem, 3vw, 2.7rem);
  line-height: 1;
  text-align: right;
  text-transform: uppercase;
  width: 100%;
  animation: status-text-pulse 7s ease-in-out infinite;
}

@keyframes status-text-pulse {
  0%,
  100% {
    color: var(--peach);
    text-shadow: none;
  }

  50% {
    color: color-mix(in srgb, var(--green) 36%, var(--peach));
    text-shadow:
      0 0 0.55rem color-mix(in srgb, var(--green) 42%, transparent),
      0 0 1.2rem color-mix(in srgb, var(--green) 22%, transparent);
  }
}

.module-buttons {
  display: grid;
  gap: 0.55rem;
  overflow: visible;
}

.module-button {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.65rem;
  align-items: center;
  min-height: 4.25rem;
  padding: 0.85rem 0.65rem 0.6rem;
  border: 0;
  border-radius: var(--radius-md);
  clip-path: none;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--tone) 20%, transparent), transparent 68%),
    linear-gradient(180deg, var(--wash-white-6), transparent 55%),
    var(--surface-dark);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow:
    inset -0.28rem 0 0 color-mix(in srgb, var(--tone) 46%, transparent),
    inset 0 0 0 0.14rem color-mix(in srgb, var(--tone) 34%, transparent);
}

.module-button::before {
  content: "";
  position: absolute;
  top: 0.38rem;
  left: 2.85rem;
  right: 0.8rem;
  height: var(--module-top-line);
  min-height: var(--module-top-line);
  max-height: var(--module-top-line);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 78%, transparent), transparent);
  border-radius: var(--radius-pill);
  pointer-events: none;
}

.module-button:hover,
.module-button:focus-visible {
  filter: brightness(1.08);
}

.module-button:hover::before,
.module-button:focus-visible::before,
.module-button.active::before {
  filter: none;
  height: var(--module-top-line);
}

.module-button.active {
  outline: 0;
  box-shadow:
    inset -0.28rem 0 0 var(--tone),
    inset 0 0 0 0.18rem color-mix(in srgb, var(--tone) 62%, transparent),
    0 0 0 0.1rem var(--wash-white-16);
}

/* Primary selection: frame + filled number (same module). */
.module-button.active .module-number {
  background: var(--tone);
  color: var(--black);
  box-shadow: 0 0 0 0.14rem color-mix(in srgb, var(--tone) 48%, transparent);
}

.module-number {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tone) 58%, var(--black));
  color: var(--black);
  font-weight: 900;
}

.module-label {
  overflow: hidden;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-overflow: ellipsis;
}

.module-kicker {
  overflow: hidden;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0.75;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-view {
  flex: 1;
  min-height: 0;
  margin-top: clamp(0.75rem, 2vw, 1.25rem);
  overflow: auto;
  scroll-margin-top: 1rem;
}

.module-view.is-history,
.module-view.is-single {
  overflow: auto;
}

.module-stack {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  height: auto;
  min-height: auto;
}

.module-stack:has(.module-card:nth-child(2)) {
  grid-template-rows: minmax(18rem, auto) minmax(8rem, auto);
}

.module-stack:has(.module-card:nth-child(3)) {
  grid-template-rows: minmax(18rem, auto) repeat(2, minmax(7rem, auto));
}

.module-stack:has(.module-card:nth-child(4)) {
  grid-template-rows: minmax(16rem, auto) repeat(3, minmax(6.25rem, auto));
}

.module-card {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(13rem, 0.62fr) minmax(20rem, 1fr);
  gap: clamp(1rem, 3vw, 2rem);
  min-width: 0;
  min-height: clamp(14rem, 38svh, 26rem);
  padding: clamp(1rem, 3vw, 2rem);
  overflow: visible;
  background:
    linear-gradient(180deg, var(--wash-white-5), transparent 34%),
    linear-gradient(90deg, color-mix(in srgb, var(--tone) 10%, transparent), transparent 46%),
    var(--panel-soft);
  border: 0;
  border-radius: var(--radius-lg);
  clip-path: none;
  box-shadow:
    inset 0 0 0 var(--segment-line-thin) var(--wash-white-5),
    inset 0 -2.5rem 5rem var(--wash-black-22);
}

.module-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: var(--segment-rail) solid var(--tone, var(--orange));
  border-right: var(--segment-line-thin) solid color-mix(in srgb, var(--tone) 34%, transparent);
  border-bottom: var(--segment-line-thin) solid color-mix(in srgb, var(--tone) 22%, transparent);
  border-left: var(--segment-line-strong) solid color-mix(in srgb, var(--tone) 78%, transparent);
  border-radius: inherit;
  box-shadow:
    inset var(--dock-offset-sm) 0 0 color-mix(in srgb, var(--tone) 18%, transparent),
    inset calc(-1 * var(--dock-offset-sm)) 0 0 var(--wash-black-18);
  opacity: var(--segment-opacity-strong);
  pointer-events: none;
}

.module-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: calc(var(--dock-offset-lg) + var(--step-corner-sm));
  width: min(42%, var(--segment-guide-medium));
  height: var(--segment-rail);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone, var(--orange)) 90%, transparent), color-mix(in srgb, var(--tone, var(--orange)) 42%, transparent), transparent);
  border-radius: 0 0 var(--radius-pill) 0;
  opacity: var(--segment-opacity-strong);
  pointer-events: none;
}

.module-card.is-secondary {
  min-height: 7rem;
  cursor: pointer;
  opacity: 0.86;
}

.module-card.is-secondary::before {
  border-top-width: var(--segment-line-strong);
  border-left-width: var(--segment-line);
  opacity: var(--segment-opacity-soft);
}

.module-card.is-secondary::after {
  display: none;
}

.module-card.is-secondary:hover,
.module-card.is-secondary:focus-visible {
  opacity: 1;
  filter: brightness(1.08);
}

.module-card.is-secondary .module-intro h2 {
  font-size: clamp(1.6rem, 3vw, 2.6rem);
}

.module-card.is-secondary .module-description {
  display: none;
}

.module-card.is-secondary .segment-link-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: calc(var(--console-matrix-gap) * 2);
}

.module-card.is-secondary .segment-link {
  --segment-cap-width: 3.75rem;
  align-self: stretch;
  min-width: 0;
  min-height: 4.25rem;
  height: 100%;
}

.module-card.is-secondary .segment-link__body {
  align-self: stretch;
  justify-content: center;
}

.module-card.is-secondary .segment-link__body strong {
  font-size: 0.95rem;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.module-card.is-secondary .segment-link__body span {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.module-intro .system-label {
  color: var(--tone, var(--orange));
}

.module-intro {
  container-type: inline-size;
  min-width: 0;
}

.module-intro h2 {
  margin-bottom: 1rem;
  color: var(--peach);
  font-size: clamp(1rem, 14cqi, 4.35rem);
  line-height: 0.92;
  /* Lange/zweiwortige Titel (z. B. „ZENTRALE INHALTE") umbrechen lassen statt waagerecht in die
     Modulspalte zu überlaufen. Schriftgröße bleibt cqi-gedeckelt → Kachel wird nicht riesig. */
  white-space: normal;
  overflow-wrap: break-word;
  text-wrap: balance;
  text-transform: uppercase;
}

.module-description,
.module-meta {
  color: var(--muted);
  font-size: 1.1rem;
}

.module-meta {
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.segment-link-list {
  display: grid;
  align-content: start;
  gap: calc(var(--console-matrix-gap) * 2);
  min-height: 0;
  padding-block: 1px;
  overflow: visible;
}

.segment-link-section {
  margin: 0.2rem 0 0;
  padding-top: 0.55rem;
  border-top: var(--segment-line-thin) solid color-mix(in srgb, var(--tone, var(--orange)) 32%, transparent);
  color: color-mix(in srgb, var(--tone, var(--orange)) 78%, var(--muted));
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.segment-link-list > .segment-link-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.module-card.is-secondary .segment-link-section {
  grid-column: 1 / -1;
}

/*
  Segment-link: skalierende SVG-Cap (buildCapPath in render.js) + __body + Top-Balken.
  Hover: Outline + Flächen-Glow; filter auf Cap-SVG und __body::before.
*/
.segment-link {
  position: relative;
  display: flex;
  align-items: stretch;
  margin-left: 0;
  min-height: 5.2rem;
  border: 0;
  border-radius: var(--radius-md);
  outline: var(--segment-line-thin) solid transparent;
  background: var(--surface-accent);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  overflow: visible;
  box-shadow: inset 0 0 0 var(--segment-line-thin) color-mix(in srgb, var(--tone) 24%, transparent);
  transition:
    outline-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
}

.segment-link__cap {
  position: relative;
  flex-shrink: 0;
  align-self: stretch;
  width: var(--segment-cap-width);
  color: var(--tone, var(--orange));
}

.segment-link__cap svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  transition: filter 160ms ease;
}

.segment-link__body {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  /* Oben: Body-Pad + Höhe des Top-Balkens (::before), damit Text nicht in den Verlauf ragt */
  padding: calc(var(--segment-body-pad-y) + var(--segment-cap-cut-h)) var(--segment-body-pad-x)
    var(--segment-body-pad-y);
}

.segment-link__body::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: var(--segment-cap-cut-h);
  border-radius: 0 0.1rem 0 0;
  background: linear-gradient(
    90deg,
    var(--tone, var(--orange)) 0%,
    color-mix(in srgb, var(--tone, var(--orange)) 55%, transparent) 35%,
    color-mix(in srgb, var(--tone, var(--orange)) 20%, transparent) 65%,
    transparent 100%
  );
  pointer-events: none;
  transition: filter 160ms ease;
}

.segment-link__body strong {
  position: relative;
  z-index: 1;
  overflow: hidden;
  color: var(--peach);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 160ms ease;
}

.segment-link__body span {
  position: relative;
  z-index: 1;
  overflow: hidden;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-link:hover,
.segment-link:focus-visible {
  z-index: 1;
  color: color-mix(in srgb, var(--green) 28%, var(--text));
  text-decoration: none;
  outline: var(--segment-line) solid color-mix(in srgb, var(--green) 70%, transparent);
  outline-offset: 0;
  box-shadow:
    0 0 1.5rem color-mix(in srgb, var(--green) 40%, transparent),
    0 0 3rem color-mix(in srgb, var(--green) 18%, transparent),
    inset 0 0 3rem color-mix(in srgb, var(--green) 20%, transparent),
    inset 0 0 1rem color-mix(in srgb, var(--green) 12%, transparent);
}

.segment-link:hover .segment-link__cap svg,
.segment-link:focus-visible .segment-link__cap svg {
  filter:
    brightness(1.25)
    drop-shadow(0 0 8px color-mix(in srgb, var(--green) 60%, transparent));
}

.segment-link:hover .segment-link__body::before,
.segment-link:focus-visible .segment-link__body::before {
  filter:
    brightness(1.3)
    drop-shadow(0 0 6px color-mix(in srgb, var(--green) 60%, transparent));
}

.segment-link:hover .segment-link__body strong,
.segment-link:focus-visible .segment-link__body strong {
  color: color-mix(in srgb, var(--green) 40%, var(--peach));
  text-shadow: none;
}

/* Button als Segment-Link (Web-Apps-Teaser): Browser-Defaults zurücksetzen. */
button.segment-link {
  appearance: none;
  width: 100%;
  font: inherit;
  text-align: left;
}

/* Gesperrte Web-App (kein Zugriff laut Matrix): durchgestrichen, Klick = Errorsound. */
.segment-link.is-locked {
  cursor: not-allowed;
  opacity: 0.6;
}

.segment-link.is-locked .segment-link__body strong {
  color: var(--muted);
  text-decoration: line-through;
}

.segment-link.is-locked:hover,
.segment-link.is-locked:focus-visible {
  color: var(--text);
  outline-color: color-mix(in srgb, var(--red) 65%, transparent);
  box-shadow:
    0 0 1rem color-mix(in srgb, var(--red) 28%, transparent),
    inset 0 0 0 var(--segment-line-thin) color-mix(in srgb, var(--red) 45%, transparent);
}

.segment-link.is-locked:hover .segment-link__cap svg,
.segment-link.is-locked:focus-visible .segment-link__cap svg {
  filter: brightness(1.1) drop-shadow(0 0 5px color-mix(in srgb, var(--red) 55%, transparent));
}

.segment-link.is-locked:hover .segment-link__body strong,
.segment-link.is-locked:focus-visible .segment-link__body strong {
  color: var(--muted);
}

/* Einstellungen-Kachel: Zahnrad-Umriss statt Nummer. */
.module-number--settings,
.module-number--admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.module-number--settings svg,
.module-number--admin svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

