/* ==========================================================================
   WireCode – Basis
   Tokens, Typografie, Buttons, Formulare, LEDs, 7-Segment, Navigation
   ========================================================================== */

:root {
  /* Papier & Tinte */
  --paper: #D3CFC6;
  --paper-2: #C8C3B9;
  --paper-3: #BCB6AA;
  --card: #E5E2DB;
  --white: #F3F1ED;
  --ink: #14161A;
  --ink-2: #2F343B;
  --ink-3: #4F545B;
  --rule: #B9B3A7;
  --rule-strong: #9A9386;

  /* Gerätegehäuse */
  --panel: #14161A;
  --panel-2: #1C1F24;
  --panel-3: #262A31;
  --panel-rule: #30353C;
  --panel-text: #C9CDD2;
  --panel-muted: #7E848C;

  /* Signal */
  --green: #36D26F;
  --green-ink: #13803F;
  --green-soft: #DCF2E3;
  --red: #EF4A36;
  --red-ink: #C02F1D;
  --red-soft: #FBE4E0;
  --amber: #F2B233;
  --amber-ink: #885800;
  --amber-soft: #FAEDCF;

  /* Leiterfarben nach DIN EN 60445 */
  --l1: #7A4A2B;
  --l2: #1F1F1F;
  --l3: #8E9299;
  --n: #2E6BB3;
  --pe-g: #2C9C4E;
  --pe-y: #E9C631;

  --f-display: "Chakra Petch", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --maxw: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --nav-h: 72px;
  --shadow-lg: 0 30px 60px -36px rgba(20, 22, 26, .45);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
p { margin: 0; }

h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

code, kbd, .mono { font-family: var(--f-mono); }

::selection { background: var(--green); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 3px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.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;
}

.c-red { color: var(--red); }
.c-green { color: var(--green); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* --------------------------------------------------------------------------
   Leiterfarben-Leiste (L1 · L2 · L3 · N · PE)
   -------------------------------------------------------------------------- */
.wirebar {
  height: 5px;
  background:
    linear-gradient(90deg,
      var(--l1) 0 20%,
      var(--l2) 20% 40%,
      var(--l3) 40% 60%,
      var(--n) 60% 80%,
      transparent 80%),
    repeating-linear-gradient(115deg, var(--pe-g) 0 10px, var(--pe-y) 10px 20px);
}

/* --------------------------------------------------------------------------
   LEDs
   -------------------------------------------------------------------------- */
.led {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(54, 210, 111, .18), 0 0 8px rgba(54, 210, 111, .55);
}
.led-red   { background: var(--red);   box-shadow: 0 0 0 2px rgba(239, 74, 54, .18), 0 0 8px rgba(239, 74, 54, .55); }
.led-amber { background: var(--amber); box-shadow: 0 0 0 2px rgba(242, 178, 51, .2), 0 0 8px rgba(242, 178, 51, .5); }
.led-off   { background: #3A3F46; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .5); }
.led-grey  { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule-strong); }

.blink { animation: blink 1.2s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: .18; } }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --led: #2F4C3A;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .02em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn .led {
  width: 7px; height: 7px;
  background: var(--led);
  box-shadow: none;
  transition: background-color .15s, box-shadow .15s;
}
.btn:hover .led,
.btn:focus-visible .led {
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(54, 210, 111, .2), 0 0 10px rgba(54, 210, 111, .75);
}

.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #2A2E35; }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:hover { background: var(--paper-2); border-color: var(--ink-3); }

.btn-green { background: var(--green); color: var(--ink); }
.btn-green:hover { background: #52E287; }

.btn-ghost-dark { background: transparent; color: #E9E7E2; border-color: #41474F; }
.btn-ghost-dark:hover { background: rgba(255, 255, 255, .05); border-color: #737A83; }

.btn-danger { background: var(--red-ink); color: #fff; }
.btn-danger:hover { background: #A72818; }

.btn-sm { padding: 8px 14px; font-size: 14.5px; }
.btn-lg { padding: 15px 24px; font-size: 17px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }

/* --------------------------------------------------------------------------
   7-Segment-Anzeige (wird per JS als SVG erzeugt, siehe segment.js)
   -------------------------------------------------------------------------- */
.seg {
  --seg-on: #FF5A44;
  --seg-off: rgba(255, 90, 68, .07);
  --seg-glow: rgba(255, 80, 60, .5);
}
.seg svg {
  height: 100%;
  width: auto;
  overflow: visible;
  filter: drop-shadow(0 0 5px var(--seg-glow));
}
.seg .s-on  { fill: var(--seg-on); }
.seg .s-off { fill: var(--seg-off); }

.seg-green { --seg-on: #3BE07A; --seg-off: rgba(59, 224, 122, .07); --seg-glow: rgba(54, 210, 111, .45); }
.seg-ink   { --seg-on: var(--ink); --seg-off: rgba(20, 22, 26, .06); --seg-glow: transparent; }

/* --------------------------------------------------------------------------
   Formulare
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label,
.field-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field .opt { color: var(--ink-3); font-weight: 400; }

.input, .select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: 400 16px/1.2 var(--f-body);
  transition: border-color .15s, box-shadow .15s;
}
.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2314161A' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
}
.input:hover, .select:hover { border-color: var(--ink-3); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(54, 210, 111, .35);
}
.input::placeholder, .textarea::placeholder { color: #A39F96; }

.textarea {
  width: 100%;
  min-height: 104px;
  padding: 12px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: 400 16px/1.5 var(--f-body);
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.textarea:hover { border-color: var(--ink-3); }
.textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(54, 210, 111, .35); }
.field.has-error .textarea { border-color: var(--red-ink); }

.hint { font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.err  { font-size: 13px; color: var(--red-ink); display: none; line-height: 1.45; }
.field.has-error .input,
.field.has-error .select { border-color: var(--red-ink); }
.field.has-error .err { display: block; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-2);
  cursor: pointer;
}
.check input {
  appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  margin: 1px 0 0;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
}
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after {
  content: "";
  width: 10px; height: 5px;
  border-left: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  transform: translateY(-1px) rotate(-45deg);
}
.check input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.check.has-error input { border-color: var(--red-ink); box-shadow: 0 0 0 3px var(--red-soft); }
.check a { color: var(--ink); }

/* --------------------------------------------------------------------------
   Navigation (Website + Checkout)
   -------------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(211, 207, 198, .9);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.is-scrolled { border-bottom-color: var(--rule); }

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--nav-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brand img { width: 34px; height: 34px; }
.wordmark {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .14em;
  white-space: nowrap;
}

.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links > a:not(.btn) {
  position: relative;
  padding: 6px 0;
  font-size: 15px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.nav-links > a:not(.btn):hover { color: var(--ink); }
.nav-links > a:not(.btn)::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .2s;
}
.nav-links > a:not(.btn):hover::after { transform: scaleX(1); }
.nav-sep { width: 1px; height: 22px; background: var(--rule-strong); }

.nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px; height: 44px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: var(--ink);
  transition: transform .2s, opacity .2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 1120px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: var(--nav-h);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 4px var(--gutter) 22px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 20px 30px -24px rgba(20, 22, 26, .35);
  }
  .nav-links.is-open { display: flex; }
  .nav-links > a:not(.btn) { padding: 14px 0; font-size: 17px; border-bottom: 1px solid var(--rule); }
  .nav-links > a:not(.btn)::after { display: none; }
  .nav-sep { display: none; }
  .nav-links .btn { margin-top: 18px; }
}

/* Aktive Seite */
.nav-links > a[aria-current="page"] { color: var(--ink); font-weight: 500; }
.nav-links > a[aria-current="page"]::after { transform: scaleX(1); }

/* --------------------------------------------------------------------------
   Dropdown „Bereiche"
   -------------------------------------------------------------------------- */
.nav-dd { position: relative; }
.nav-dd-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  border: 0;
  background: none;
  font-size: 15px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.nav-dd-btn:hover, .nav-dd-btn[aria-expanded="true"] { color: var(--ink); }
.nav-dd-btn.is-current { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--green); }
.nav-dd-btn svg { width: 11px; height: 8px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .2s; }
.nav-dd-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

.nav-dd-panel {
  position: absolute;
  left: 50%; top: calc(100% + 14px);
  z-index: 60;
  width: 540px;
  padding: 14px 14px 12px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--panel-text);
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  transform: translate(-50%, 6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .16s, transform .16s, visibility .16s;
}
.nav-dd-panel::before {
  content: "";
  position: absolute;
  left: 50%; top: -6px;
  width: 12px; height: 12px;
  margin-left: -6px;
  background: var(--panel);
  transform: rotate(45deg);
  border-radius: 2px;
}
.nav-dd.is-open .nav-dd-panel { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.dd-head {
  margin: 0 6px 8px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--panel-muted);
}
.dd-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.dd-list a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 6px;
  color: #D9DCE0;
  font-size: 14px;
  text-decoration: none;
}
.dd-list a:hover, .dd-list a:focus-visible { background: var(--panel-3); color: #fff; outline: none; }
.dd-id { font-family: var(--f-mono); font-size: 11.5px; font-weight: 600; color: #6FE79B; }
.dd-short { font-family: var(--f-mono); font-size: 10.5px; color: var(--panel-muted); }
.dd-all {
  display: block;
  margin: 8px 6px 2px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-rule);
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: #6FE79B;
  text-decoration: none;
}
.dd-all:hover { text-decoration: underline; }

@media (max-width: 1120px) {
  .nav-dd { border-bottom: 1px solid var(--rule); }
  .nav-dd-btn { width: 100%; justify-content: space-between; padding: 14px 0; font-size: 17px; }
  .nav-dd-btn.is-current { box-shadow: none; }
  .nav-dd-panel {
    position: static;
    width: auto;
    margin: 0 0 14px;
    transform: none;
    display: none;
    opacity: 1;
    visibility: visible;
  }
  .nav-dd-panel::before { display: none; }
  .nav-dd.is-open .nav-dd-panel { display: block; transform: none; }
  .nav-links { max-height: calc(100vh - var(--nav-h)); overflow-y: auto; }
}
@media (max-width: 520px) {
  .dd-list { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Anruf-Button unten rechts
   -------------------------------------------------------------------------- */
.callfab { position: fixed; right: 20px; bottom: 20px; z-index: 95; }
.callfab-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--green);
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .08);
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, background-color .15s;
}
.callfab-btn:hover { transform: translateY(-2px); background: #23272D; }
.callfab-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.callfab-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--green);
  opacity: 0;
  animation: callRing 3.2s ease-out 1.5s infinite;
  pointer-events: none;
}
@keyframes callRing {
  0% { opacity: .7; transform: scale(1); }
  40%, 100% { opacity: 0; transform: scale(1.55); }
}
.callfab-panel {
  position: absolute;
  right: 0; bottom: 68px;
  width: 270px;
  padding: 16px 16px 14px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--panel-text);
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, .6);
  font-size: 14px;
  line-height: 1.5;
}
.callfab-panel[hidden] { display: none; }
.callfab-panel b { display: block; margin-bottom: 4px; font-family: var(--f-display); font-size: 17px; color: #F1EFEA; }
.callfab-panel .cf-num {
  display: block;
  margin: 8px 0 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #0A0B0D;
  font-family: var(--f-mono);
  font-size: 13px;
  color: #6FE79B;
}
.callfab-panel a { color: #F1EFEA; }
.callfab-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--panel-muted);
  font-size: 18px;
  cursor: pointer;
}
.callfab-close:hover { background: var(--panel-3); color: #fff; }
@media (max-width: 640px) {
  .callfab { right: 14px; bottom: 14px; }
  .callfab-btn { width: 52px; height: 52px; }
}
@media print { .callfab { display: none; } }

/* --------------------------------------------------------------------------
   Seitenwechsel: kurze Überblendung, Navigation bleibt stehen
   -------------------------------------------------------------------------- */
@view-transition { navigation: auto; }
.nav { view-transition-name: site-nav; }
.wirebar { view-transition-name: wirebar; }
::view-transition-old(root) { animation: vtOut .18s ease-in both; }
::view-transition-new(root) { animation: vtIn .34s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes vtOut { to { opacity: 0; } }
@keyframes vtIn { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Dropdown: Einträge fahren gestaffelt ein */
@media (prefers-reduced-motion: no-preference) {
  .nav-dd.is-open .dd-list li { animation: ddIn .28s cubic-bezier(.2, .7, .2, 1) both; }
  .nav-dd.is-open .dd-list li:nth-child(2) { animation-delay: .02s; }
  .nav-dd.is-open .dd-list li:nth-child(3) { animation-delay: .04s; }
  .nav-dd.is-open .dd-list li:nth-child(4) { animation-delay: .06s; }
  .nav-dd.is-open .dd-list li:nth-child(5) { animation-delay: .08s; }
  .nav-dd.is-open .dd-list li:nth-child(6) { animation-delay: .10s; }
  .nav-dd.is-open .dd-list li:nth-child(7) { animation-delay: .12s; }
  .nav-dd.is-open .dd-list li:nth-child(8) { animation-delay: .14s; }
  .nav-dd.is-open .dd-list li:nth-child(9) { animation-delay: .16s; }
  .nav-dd.is-open .dd-list li:nth-child(10) { animation-delay: .18s; }
  .nav-dd.is-open .dd-id { animation: ddLed .5s steps(1, end) both; }
}
@keyframes ddIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes ddLed { 0% { color: var(--panel-muted); } 40% { color: #6FE79B; } 55% { color: var(--panel-muted); } 70%, 100% { color: #6FE79B; } }
