/* Zeichnungsblatt: hell = geplottetes Blatt, dunkel = CAD-Modellbereich. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }

:root {
  --desk: #e3e8eb;
  --paper: #f6f8f9;
  --ink: #14202b;
  --ink-2: #4b5a67;
  --hair: rgb(20 32 43 / 0.22);
  --rev: #1745c2;
  --rev-ink: #f6f8f9;
  --grid: transparent;

  --m: 28px;            /* Rahmenrand mit Zonenteilung */
  --pad: clamp(20px, 3.2vw, 48px);
  --line: 2px;          /* breite Linie (Rahmen, Schriftfeld) */
  --thin: 1px;          /* schmale Linie */

  --sans: "Barlow", ui-sans-serif, system-ui, sans-serif;
  --cond: "Barlow Condensed", "Barlow", ui-sans-serif, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light dark;
}

@media screen and (prefers-color-scheme: dark) {
  :root {
    --desk: #070a0d;
    --paper: #0d1318;
    --ink: #dde6ec;
    --ink-2: #95a5b1;
    --hair: rgb(221 230 236 / 0.2);
    --rev: #7ea2ff;
    --rev-ink: #0d1318;
    --grid: rgb(221 230 236 / 0.07);
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  padding: clamp(8px, 1.4vw, 20px);
  background: var(--desk);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--rev); color: var(--rev-ink); }
html { scrollbar-color: var(--ink-2) var(--desk); }

a { color: inherit; text-decoration-thickness: var(--thin); text-underline-offset: 0.22em; }
a:hover { color: var(--rev); }
:focus-visible { outline: var(--line) solid var(--rev); outline-offset: 2px; }

main { display: grid; gap: clamp(8px, 1.4vw, 20px); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.print-only { display: none; }
.sep { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.c-muted { color: var(--ink-2); }

.label {
  display: block;
  font: 500 0.75rem/1.2 var(--cond);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ---------- Blatt & Rahmen ---------- */

.sheet {
  position: relative;
  background-color: var(--paper);
  background-image: radial-gradient(var(--grid) 1px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: var(--m) var(--m);
  padding: var(--m);
}
.sheet-1 { min-height: calc(100svh - 2 * clamp(8px, 1.4vw, 20px)); display: flex; }
.sheet-1 > .sheet-body { flex: 1; }

.frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
}
.frame rect { fill: none; stroke: var(--ink); vector-effect: non-scaling-stroke; }
.frame-trim { stroke-width: var(--thin); opacity: 0.5; }
.frame-line {
  stroke-width: var(--line);
  x: var(--m); y: var(--m);
  width: calc(100% - 2 * var(--m)); height: calc(100% - 2 * var(--m));
}

.zones { position: absolute; display: flex; pointer-events: none; }
.zones-x { left: var(--m); right: var(--m); height: var(--m); }
.zones-top { top: 0; }
.zones-bottom { bottom: 0; }
.zones-y { top: var(--m); bottom: var(--m); width: var(--m); flex-direction: column; }
.zones-left { left: 0; }
.zones-right { right: 0; }

.zone {
  flex: 1;
  display: grid; place-items: center;
  font: 500 0.75rem/1 var(--cond);
  color: var(--ink-2);
  transition: color 120ms linear, background-color 120ms linear;
}
.zones-x .zone + .zone { border-left: var(--thin) solid var(--hair); }
.zones-y .zone + .zone { border-top: var(--thin) solid var(--hair); }
.zone.is-hot { color: var(--rev-ink); background: var(--rev); }

.sheet-body {
  position: relative;
  padding: var(--pad);
}

/* ---------- Blatt 1 ---------- */

.sheet-1 > .sheet-body {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "title    portrait"
    "notes    portrait"
    ".        block";
  column-gap: clamp(24px, 4vw, 72px);
  row-gap: clamp(28px, 4vh, 56px);
}

.title-view { grid-area: title; align-self: start; }

.drawing-title {
  margin: 0;
  font: 500 clamp(3rem, 7.4vw, 6rem)/0.9 var(--cond);
  letter-spacing: -0.005em;
  text-transform: uppercase;
  text-wrap: balance;
}
.drawing-subtitle {
  margin: 0.9em 0 0;
  font: 500 clamp(1.125rem, 1.6vw, 1.5rem)/1.3 var(--sans);
}
.drawing-subtitle .sep { padding: 0 0.2em; }

.portrait {
  grid-area: portrait;
  margin: 0;
  justify-self: end;
  align-self: start;
  width: min(100%, 340px);
  padding-right: 44px;   /* Platz für die senkrechte Maßlinie */
}
.portrait-view { position: relative; }
.portrait img {
  display: block;
  width: 100%; height: auto;
  aspect-ratio: 1;
  filter: grayscale(1) contrast(1.06);
  mix-blend-mode: multiply;
  outline: var(--thin) solid var(--ink);
}
@media screen and (prefers-color-scheme: dark) {
  .portrait img { mix-blend-mode: normal; filter: grayscale(1) brightness(0.92) contrast(1.04); }
}

/* Maßlinien: Maßhilfslinien am Bild, Maßlinie mit Pfeilspitzen, Maßzahl */
.portrait-view::before, .portrait-view::after {
  content: ""; position: absolute; pointer-events: none;
  border: 0 solid var(--ink);
}
.portrait-view::before { left: 0; right: 0; top: calc(100% + 6px); height: 28px; border-width: 0 var(--thin); }
.portrait-view::after { top: 0; bottom: 0; left: calc(100% + 6px); width: 28px; border-width: var(--thin) 0; }

.dim { position: absolute; background: var(--ink); }
.dim-x { left: 0; right: 0; top: calc(100% + 26px); height: var(--thin); }
.dim-y { top: 0; bottom: 0; left: calc(100% + 26px); width: var(--thin); }
.dim::before, .dim::after { content: ""; position: absolute; background: var(--ink); }
.dim-x::before, .dim-x::after { top: -3px; width: 10px; height: 7px; }
.dim-x::before { left: 0; clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.dim-x::after { right: 0; clip-path: polygon(100% 50%, 0 0, 0 100%); }
.dim-y::before, .dim-y::after { left: -3px; width: 7px; height: 10px; }
.dim-y::before { top: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.dim-y::after { bottom: 0; clip-path: polygon(50% 100%, 100% 0, 0 0); }
.dim-label {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 0 6px;
  background: var(--paper);
  font: 500 0.8125rem/1 var(--cond);
  letter-spacing: 0.04em;
  color: var(--ink);
}
.dim-y .dim-label { transform: translate(-50%, -50%) rotate(-90deg); }

.portrait figcaption {
  margin-top: 46px;
  white-space: nowrap;
  font: 500 0.875rem/1.2 var(--cond);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}

.callout-line { display: inline-block; width: 28px; height: var(--thin); background: var(--ink); position: relative; }
.callout-line::before {
  content: ""; position: absolute; left: -3px; top: -3px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink);
}

.notes { grid-area: notes; align-self: start; max-width: 60ch; }
.notes ol {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: note;
  border-top: var(--thin) solid var(--ink);
}
.notes li {
  counter-increment: note;
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  padding: 0.6rem 0;
  border-bottom: var(--thin) solid var(--hair);
  font-size: 1.0625rem;
  text-wrap: pretty;
}
.notes li::before {
  content: counter(note) ".";
  font: 500 1rem/1.6 var(--cond);
  color: var(--ink-2);
}

.xref {
  font: 500 0.8125rem/1 var(--cond);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rev);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: var(--thin) solid currentColor;
}
.xref:hover { color: var(--ink); }

/* ---------- Schriftfeld ---------- */

.titleblock {
  grid-area: block;
  align-self: end;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: var(--line) solid var(--ink);
  background: var(--paper);
}
.tb-cell {
  min-width: 0;
  padding: 7px 10px 8px;
  border-right: var(--thin) solid var(--ink);
  border-bottom: var(--thin) solid var(--ink);
}
.tb-designation { grid-column: span 3; }
.tb-no { border-right: 0; }
.tb-company { grid-column: span 2; }
.tb-focus { grid-column: span 2; border-right: 0; }
.tb-cell:nth-child(8) { border-right: 0; }
.tb-value {
  display: block;
  margin-top: 3px;
  font: 500 1rem/1.25 var(--sans);
  overflow-wrap: anywhere;
}
.tb-big { font: 600 clamp(1.375rem, 2vw, 1.75rem)/1.1 var(--cond); text-transform: uppercase; letter-spacing: 0.01em; }
.tb-no .tb-value { font-family: var(--cond); letter-spacing: 0.04em; }
.tb-lang { display: flex; gap: 10px; }
.tb-lang [aria-current] { font-weight: 600; text-decoration: underline; text-decoration-thickness: var(--line); text-underline-offset: 0.25em; }
.tb-lang a { color: var(--ink-2); text-decoration: none; }
.tb-lang a:hover { color: var(--rev); }

.tb-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tb-action {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px;
  padding: 10px 12px;
  border: 0;
  border-right: var(--thin) solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: 600 0.9375rem/1.15 var(--cond);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.tb-action:last-child { border-right: 0; }
.tb-action:hover { background: var(--ink); color: var(--paper); }
.tb-action.is-primary { background: var(--rev); color: var(--rev-ink); }
.tb-action.is-primary:hover { background: var(--ink); color: var(--paper); }
.tb-action:focus-visible { outline-offset: -4px; outline-color: currentColor; }

.icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; }

/* ---------- Blatt 2 ---------- */

.sheet-2 > .sheet-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "rev   parts"
    "edu   parts"
    "certs certs"
    "scope scope"
    "foot  foot";
  column-gap: clamp(24px, 4vw, 72px);
  row-gap: clamp(36px, 5vw, 64px);
}
.block-rev { grid-area: rev; }
.block-edu { grid-area: edu; }
.block-parts { grid-area: parts; }
.block-certs { grid-area: certs; }
.block-scope { grid-area: scope; }
.sheet-2 .sheet-foot { grid-area: foot; }

.block-title {
  margin: 0 0 0.9rem;
  font: 600 1.375rem/1.1 var(--cond);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.block-title-lg { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: 0.01em; margin-bottom: 1.5rem; }

.table {
  width: 100%;
  border-collapse: collapse;
  border-top: var(--line) solid var(--ink);
  border-bottom: var(--line) solid var(--ink);
}
.table th {
  padding: 8px 12px 7px 0;
  text-align: left;
  font: 500 0.75rem/1.2 var(--cond);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  border-bottom: var(--thin) solid var(--ink);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px 11px 0;
  vertical-align: top;
  border-bottom: var(--thin) solid var(--hair);
}
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.c-note { display: block; color: var(--ink-2); font-size: 0.9375rem; }
.c-pos { width: 3rem; color: var(--ink-2); }
.c-code { font: 600 1rem/1.5 var(--cond); letter-spacing: 0.04em; white-space: nowrap; }
.c-company { font-weight: 600; }

.c-rev { width: 3.25rem; }
.rev-mark { display: block; width: 28px; height: 24px; overflow: visible; }
.rev-mark path { fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-linejoin: miter; }
.rev-mark text { font: 600 11px var(--cond); fill: var(--ink); }
.rev-mark.is-current path { fill: var(--rev); stroke: var(--rev); }
.rev-mark.is-current text { fill: var(--rev-ink); }
.table-rev .is-current .c-company,
.table-rev .is-current .c-period { color: var(--rev); }

.facts { margin: 0; border-top: var(--line) solid var(--ink); border-bottom: var(--line) solid var(--ink); }
.facts > div {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: var(--thin) solid var(--hair);
}
.facts > div:last-child { border-bottom: 0; }
.facts dt { padding-top: 0.2rem; }
.facts dd { margin: 0; }
.facts strong { font-weight: 600; }

.sheet-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}
.legal { display: flex; flex-wrap: wrap; gap: 6px 22px; font: 500 0.9375rem/1.3 var(--cond); letter-spacing: 0.05em; text-transform: uppercase; }
.titleblock-mini { grid-template-columns: auto auto auto; min-width: min(100%, 440px); }
.titleblock-mini .tb-cell { border-bottom: 0; }
.titleblock-mini .tb-cell:last-child { border-right: 0; }

/* ---------- Rechtliches ---------- */

.sheet-legal { min-height: calc(100svh - 2 * clamp(8px, 1.4vw, 20px)); }
.sheet-legal > .sheet-body { display: grid; gap: 48px; align-content: space-between; min-height: 100%; }
.legal-text { max-width: 68ch; }
.legal-text h2 { margin: 2rem 0 0.4rem; font: 600 1.0625rem/1.3 var(--cond); letter-spacing: 0.06em; text-transform: uppercase; }
.legal-text p { margin: 0 0 0.8rem; text-wrap: pretty; }

/* ---------- Fadenkreuz ---------- */

.crosshair { position: fixed; inset: 0; pointer-events: none; z-index: 10; opacity: 0; transition: opacity 120ms linear; }
.crosshair.is-on { opacity: 1; }
.crosshair-x, .crosshair-y { position: absolute; background: var(--rev); opacity: 0.45; }
.crosshair-x { left: 0; right: 0; height: 1px; top: 0; transform: translateY(var(--cy, 0)); }
.crosshair-y { top: 0; bottom: 0; width: 1px; left: 0; transform: translateX(var(--cx, 0)); }
.crosshair-ref {
  position: absolute; left: 0; top: 0;
  transform: translate(calc(var(--cx, 0) + 10px), calc(var(--cy, 0) + 10px));
  padding: 2px 5px;
  background: var(--rev); color: var(--rev-ink);
  font: 600 0.75rem/1 var(--cond); letter-spacing: 0.06em;
}
.crosshair-ref:empty { display: none; }
@media (pointer: fine) { .sheet { cursor: crosshair; } .sheet a, .sheet button { cursor: pointer; } }

/* ---------- Plotten beim Laden ---------- */

@media screen and (prefers-reduced-motion: no-preference) {
  .frame-line { stroke-dasharray: 1; animation: plot 1400ms var(--ease) both; }
  .sheet-2 .frame-line { animation-delay: 200ms; }
  .dim-x { animation: plot-x 900ms var(--ease) 500ms both; }
  .dim-y { animation: plot-y 900ms var(--ease) 650ms both; }
  .dim-label, .zone { animation: fade 500ms linear 900ms both; }
}
@keyframes plot { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes plot-x { from { transform: scaleX(0); } }
@keyframes plot-y { from { transform: scaleY(0); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 900px) {
  .sheet-1 > .sheet-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "title" "portrait" "notes" "block";
  }
  .portrait { justify-self: start; width: min(78%, 300px); }
  .notes { align-self: start; }
  .sheet-2 > .sheet-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "rev" "edu" "parts" "certs" "scope" "foot";
  }
}

@media (max-width: 600px) {
  :root { --m: 18px; --pad: 18px; }
  .zone[data-wide] { display: none; }
  .zone { font-size: 0.6875rem; }
  .drawing-title { font-size: clamp(2.5rem, 13.5vw, 4rem); }
  .titleblock { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-designation, .tb-company, .tb-focus { grid-column: 1 / -1; border-right: 0; }
  .tb-no { grid-column: 1 / -1; }
  .tb-cell:nth-child(5), .tb-cell:nth-child(7) { border-right: var(--thin) solid var(--ink); }
  .tb-cell:nth-child(6), .tb-cell:nth-child(8) { border-right: 0; }
  .tb-actions { grid-template-columns: minmax(0, 1fr); }
  .tb-action { border-right: 0; border-bottom: var(--thin) solid var(--ink); }
  .tb-action:last-child { border-bottom: 0; }

  .table-rev thead { display: none; }
  .table-rev tr { display: grid; grid-template-columns: 3.25rem 1fr; padding: 12px 0; border-bottom: var(--thin) solid var(--hair); }
  .table-rev tbody tr:last-child { border-bottom: 0; }
  .table-rev td { border: 0; padding: 0; grid-column: 2; }
  .table-rev td.c-rev { grid-column: 1; grid-row: 1 / span 3; }
  .table-certs thead { display: none; }
  .table-certs tr { display: grid; grid-template-columns: 5rem 1fr; padding: 11px 0; border-bottom: var(--thin) solid var(--hair); }
  .table-certs tbody tr:last-child { border-bottom: 0; }
  .table-certs td { border: 0; padding: 0; }
  .table-certs td:last-child { grid-column: 2; }
  .facts > div { grid-template-columns: 1fr; gap: 4px; }
  .titleblock-mini { grid-template-columns: 1fr auto; width: 100%; }
  .titleblock-mini .tb-cell:nth-child(2) { display: none; }
}

/* ---------- Druck / PDF ---------- */

@media print {
  @page { size: A4; margin: 9mm; }
  :root { --m: 6mm; --pad: 7mm; --desk: #fff; }
  html, body { background: #fff; }
  body { padding: 0; font-size: 9.5pt; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  main { display: block; }
  .sheet { min-height: 0; height: 279mm; break-inside: avoid; overflow: hidden; }
  .sheet + .sheet { break-before: page; }
  .crosshair, .screen-only { display: none !important; }
  .print-only { display: block; font: 400 8.5pt/1.2 var(--sans); text-transform: none; letter-spacing: 0; }
  .zone[data-wide] { display: grid; }

  .sheet-1 > .sheet-body {
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "title portrait" "notes notes" "block block";
    row-gap: 8mm;
  }
  .sheet-1 > .sheet-body { grid-template-columns: minmax(0, 1fr) 68mm; row-gap: 12mm; }
  .drawing-title { font-size: 46pt; }
  .drawing-subtitle { font-size: 14pt; }
  .portrait { width: 68mm; padding-right: 9mm; }
  .notes { align-self: start; max-width: none; }
  .notes li { font-size: 12pt; padding: 3mm 0; }
  .xref { font-size: 9pt; }
  .legal { display: none; }
  .titleblock { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tb-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-action { min-height: 0; flex-wrap: wrap; white-space: normal; column-gap: 8px; row-gap: 2px; }
  .print-only { overflow-wrap: anywhere; }
  .tb-action .icon { display: none; }
  .tb-action.is-primary { background: transparent; color: var(--ink); }
  .tb-action:nth-child(2) { border-right: 0; }

  .sheet-2 > .sheet-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "rev parts" "edu parts" "certs certs" "scope scope" "foot foot";
    row-gap: 6mm; column-gap: 7mm;
  }
  .table td { padding-top: 4px; padding-bottom: 4px; font-size: 9pt; }
  .c-note { font-size: 8.5pt; }
  .facts > div { padding: 5px 0; }
  .block-title { font-size: 13pt; margin-bottom: 3mm; }
  a { text-decoration: none; }
}
