/*
  Zweck: Desktop-Raster (Header, Rail, Hauptkonsole) der Kommandozentrale.
  Zielpfad: /home/mckiede/public_html/design/layout-desktop.css
  Verantwortlich: mckie-Portal
*/

.page-shell {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 100vh;
  margin: 0;
  padding: var(--gap);
  overflow: hidden;
}

.page-shell::before,
.page-shell::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.page-shell::before,
.page-shell::after {
  display: none;
}

.command-header,
.command-footer {
  display: grid;
  position: relative;
  z-index: 1;
  grid-template-columns: minmax(0, 2.2fr) minmax(15rem, 0.8fr);
  gap: var(--gap);
}

.command-header {
  --header-bar: clamp(1.25rem, 2vw, 1.8rem);
  --header-bar-sm: calc(var(--header-bar) * 0.56);
  --header-action-h: 3.85rem;
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr) minmax(11rem, 12.5rem) 2.8rem;
  grid-template-rows: var(--header-bar-sm) minmax(6.6rem, auto);
  gap: 0;
  min-height: 8.25rem;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-frame);
  background: var(--console-bg);
  box-shadow: none;
}

.header-bars {
  display: grid;
  position: absolute;
  top: 0;
  left: 12rem;
  right: 2.8rem;
  z-index: 0;
  /* study-bars: orange hoch, violett niedrig, oben bündig (Prototyp) */
  grid-template-columns: minmax(7rem, 0.36fr) minmax(0, 1fr) minmax(9rem, 0.22fr);
  align-items: start;
  gap: var(--console-matrix-gap);
  height: var(--header-bar);
  background: var(--console-bg);
}

.header-bar {
  display: block;
  height: var(--header-bar-sm);
  border-radius: 0 0 var(--radius-control) var(--radius-control);
}

.header-bar-orange {
  height: var(--header-bar);
  background: var(--console-frame);
}

.header-bar-violet {
  height: var(--header-bar-sm);
  background: var(--violet);
}

.header-bars .header-bar:first-child {
  border-bottom-left-radius: 0;
}

.header-bars .header-bar:last-child {
  border-bottom-right-radius: 0;
}

.console-svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.svg-frame-primary {
  fill: var(--console-frame);
}

.svg-frame-secondary {
  fill: var(--violet);
}

.svg-cutout {
  fill: var(--console-bg);
}

.header-block,
.command-footer {
  background: transparent;
  color: var(--text);
  border: 0;
}

.header-frame-svg,
.footer-frame-svg {
  filter: drop-shadow(0 1rem 2.2rem var(--wash-black-45));
}

.header-frame-svg {
  display: none;
}

.header-frame-svg .svg-frame-secondary:first-of-type {
  fill: var(--console-frame);
}

.header-elbow {
  position: relative;
  z-index: 1;
  min-height: 100%;
}

.header-elbow-left {
  grid-row: 1 / span 2;
  border-radius: var(--radius-frame) 0 0 var(--radius-frame);
  background: var(--console-frame);
}

.header-elbow-left::after {
  content: "";
  position: absolute;
  top: var(--header-bar);
  right: 0;
  bottom: var(--header-bar);
  width: calc(var(--header-bar) * 1.45);
  border-radius: var(--radius-cutout) 0 0 var(--radius-cutout);
  background: var(--console-bg);
}

.header-elbow-right {
  grid-column: 4;
  grid-row: 1 / span 2;
  border-radius: 0 var(--radius-frame) var(--radius-frame) 0;
  background: var(--violet);
}

.header-elbow-right::after {
  content: "";
  position: absolute;
  top: var(--header-bar);
  left: 0;
  bottom: var(--header-bar);
  width: calc(var(--header-bar) * 1.2);
  border-radius: 0 var(--radius-cutout) var(--radius-cutout) 0;
  background: var(--console-bg);
}

.header-elbow .system-label {
  position: absolute;
  top: 1.1rem;
  left: 1.1rem;
  max-width: 7rem;
  color: var(--black);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.header-brand {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 0;
  margin-top: var(--header-bar);
  padding: 1rem 0.75rem 1.1rem 0.85rem;
  overflow: visible;
  border-radius: 0;
  border-right: 0;
  clip-path: none;
  box-shadow: none;
}

.header-brand::before,
.header-brand::after {
  display: none;
}

.header-brand p {
  margin: 0;
  color: var(--orange);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-brand h1 {
  display: block;
  margin: 0;
  min-width: 0;
}

.header-brand .title-combo {
  display: inline;
  white-space: nowrap;
}

.header-status {
  position: relative;
  z-index: 2;
  grid-column: 3;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  min-width: 0;
  margin-top: var(--header-bar);
  padding: 1rem 0.45rem 1.1rem 0.35rem;
  border-radius: 0;
  clip-path: none;
  text-align: right;
  text-transform: uppercase;
  border-left: 0;
  box-shadow: none;
  /* MUC pill sits above this box (top: negative) — must not clip */
  overflow: visible;
}

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

.header-status > span {
  position: absolute;
  z-index: 4;
  top: calc(var(--header-bar) * -1);
  right: 0;
  display: grid;
  align-items: center;
  min-width: 10rem;
  height: var(--header-bar);
  padding: 0 0.75rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--console-frame);
  color: var(--black);
  font-size: 0.58rem;
  font-weight: 900;
  justify-content: center;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.header-status strong {
  container-type: inline-size;
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: auto;
  margin-bottom: 0.45rem;
  align-self: flex-end;
  overflow: hidden;
  font-size: clamp(0.58rem, 3.8cqi, 1.45rem);
  line-height: 1;
  white-space: nowrap;
}

.header-status .header-controls {
  flex-shrink: 0;
  height: var(--header-action-h);
  margin-top: 0;
  margin-left: auto;
}

.command-layout {
  display: grid;
  position: relative;
  z-index: 1;
  grid-template-columns: var(--side-rail-width) minmax(0, 1fr) var(--module-rail-width);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  margin-top: var(--gap);
  align-items: stretch;
}

/*
  Desktop scroll chain
  --------------------
  Grid/flex children default to min-height:auto (content-sized). Long link panels
  (Lagebild, Freizeit) then grow past the viewport; page-shell clips with no scroll.
  minmax(0,1fr) on the row plus min-height:0 on columns lets #module-view scroll.
*/
.command-layout > * {
  min-height: 0;
  min-width: 0;
}

.side-rail {
  position: relative;
  display: grid;
  grid-template-rows: minmax(15rem, 0.42fr) minmax(15rem, 0.58fr);
  gap: var(--gap);
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background: transparent;
  border-radius: 0;
  clip-path: none;
  border: 0;
  border-right: 0;
  box-shadow: none;
}

.side-rail-frame-svg {
  display: none;
}

.side-block {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.side-block-top {
  border-radius: var(--radius-frame) 0 0 var(--radius-frame);
  background: var(--side-rail-frame);
}

.side-block-bottom {
  border-radius: 0 0 0 var(--radius-frame);
  background: var(--violet);
}

.side-cutout {
  position: absolute;
  top: 3rem;
  right: 0;
  left: 1.55rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 1.35rem 0.75rem 1.35rem 0.95rem;
  border-radius: var(--radius-cutout) 0 0 var(--radius-cutout);
  background: var(--console-bg);
}

.side-notch {
  position: absolute;
  top: 39%;
  right: 0;
  width: 76%;
  height: 8.5rem;
  border-radius: var(--radius-cutout) 0 0 var(--radius-cutout);
  background: var(--console-bg);
}

.side-rail .rail-button {
  width: calc(100% + 0.75rem);
  margin-left: auto;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--tone) 24%, transparent), transparent 70%),
    var(--surface-dark);
  box-shadow:
    inset -0.42rem 0 0 color-mix(in srgb, var(--tone) 54%, transparent),
    inset 0.16rem 0 0 color-mix(in srgb, var(--tone) 42%, transparent),
    inset 0 0 0 0.12rem color-mix(in srgb, var(--tone) 36%, transparent);
}

.side-rail .rail-button + .rail-button {
  margin-top: -0.15rem;
}

.main-console {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: clamp(1rem, 3vw, 2rem);
  background:
    radial-gradient(circle at 10% 0%, var(--wash-primary-12), transparent 19rem),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-dark) 97%, transparent), color-mix(in srgb, var(--console-bg) 97%, transparent));
  border: var(--console-seam) solid var(--console-frame);
  border-left-width: 1.1rem;
  border-right-width: var(--console-seam);
  border-radius: 0;
  clip-path: none;
  box-shadow:
    inset 0 0 0 0.12rem var(--wash-white-6),
    var(--shadow);
}

/* Orange accent bar: see components.css (.main-console::before) — one height everywhere. */

.module-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1181px) {
  /*
    Header action row: Kommandozentrale | NAV-Sensor | Icons auf einer Höhe.
    display:contents auf brand/status — Kinder landen im Header-Grid.
  */
  .command-header {
    grid-template-columns: 12rem minmax(0, 1fr) minmax(7.25rem, 10.25rem) minmax(14rem, 18rem) 2.8rem;
    grid-template-rows: var(--header-bar) auto var(--header-action-h);
    padding-bottom: 1.1rem;
    overflow: visible;
  }

  .header-bars {
    left: 12rem;
    right: 2.8rem;
  }

  .header-elbow-left {
    grid-column: 1;
    grid-row: 1 / -1;
  }

  .header-elbow-right {
    grid-column: 5;
    grid-row: 1 / -1;
  }

  .header-brand,
  .header-status {
    margin-top: 0;
    padding: 0;
    overflow: visible;
  }

  .header-brand {
    display: contents;
  }

  .header-brand p {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin: 0;
    padding: calc(var(--header-bar) + 0.25rem) 0 0 0.85rem;
  }

  .header-brand h1 {
    display: flex;
    grid-column: 2;
    grid-row: 3;
    align-items: center;
    align-self: center;
    margin: 0;
    padding: 0 0 0 0.85rem;
    height: var(--header-action-h);
    min-height: var(--header-action-h);
    container-type: inline-size;
  }

  .header-brand #page-title {
    font-size: clamp(0.52rem, 5.25cqi, 2.65rem);
    line-height: 0.9;
  }

  .header-brand .nav-sensor-map {
    grid-column: 3;
    grid-row: 3;
    align-self: center;
    justify-self: end;
    width: 100%;
    max-width: 10.25rem;
    height: var(--header-action-h);
    margin: 0 0.45rem 0 0;
  }

  .header-status {
    display: contents;
  }

  .header-status > span {
    position: relative;
    top: auto;
    right: auto;
    grid-column: 4;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    margin: 0 0.35rem 0 0;
  }

  .header-status strong {
    grid-column: 4;
    grid-row: 2;
    align-self: end;
    margin: 0;
    padding: calc(var(--header-bar) + 0.2rem) 0.35rem 0.15rem 0;
  }

  .header-status .header-controls {
    grid-column: 4;
    grid-row: 3;
    align-self: center;
    justify-self: end;
    height: var(--header-action-h);
    margin: 0 0.35rem 0 0;
  }

  /* Desktop only: unwrap panel matrix into the 3-column command grid. */
  .command-panel-matrix {
    display: contents;
  }

  .side-rail {
    grid-column: 1;
    grid-row: 1;
  }

  .main-console {
    grid-column: 2;
    grid-row: 1;
  }

  .module-rail {
    grid-column: 3;
    grid-row: 1;
  }

  .status-strip {
    flex: 0 0 auto;
  }

  .module-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

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

  .module-stack {
    min-height: 0;
  }

  .module-rail {
    gap: 0.75rem;
    padding: 1rem;
    background:
      linear-gradient(180deg, var(--wash-primary-16), transparent 30%),
      var(--console-rail);
    color: var(--text);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    clip-path: none;
    border: var(--console-seam) solid var(--console-frame);
    border-left: 0;
    box-shadow:
      inset 0.42rem 0 0 var(--segment-muted),
      var(--shadow);
  }

  .module-rail .module-buttons {
    flex: 1 1 auto;
    min-height: 0;
    align-content: start;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .module-rail .module-button {
    min-height: 4.25rem;
    height: auto;
  }

}

.module-rail-header h2 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 0.95;
  text-transform: uppercase;
}

