/* ==========================================================
   Postergenerator — "Druckerei"-Design
   Palette:  Ink #1c1b1a · Paper #f6f1e7 · Table #2c2b29
             Press-Rot #b3311d · Zink #6d6a63
   Typo:     Slab-Serif für Überschriften, System-Sans für UI,
             Monospace für technische Werte (DPI, Pixelmaße).
   ========================================================== */

:root {
  --ink: #1c1b1a;
  --ink-soft: #2c2b29;
  --paper: #f6f1e7;
  --paper-dim: #ece5d6;
  --table: #302f2c;
  --zinc: #6d6a63;
  --zinc-light: #9c988e;
  --press-red: #b3311d;
  --press-red-dark: #8f2617;
  --cyan: #1f8a9e;
  --magenta: #b23a7a;
  --yellow: #d9a017;
  --line: rgba(255, 255, 255, 0.09);
  --line-dark: rgba(0, 0, 0, 0.12);

  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 14px;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Signature-Element: vier CMYK-Registrierpunkte statt Logo-Icon */
.topbar__mark {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: inline-block;
}
.topbar__mark::before,
.topbar__mark::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  mix-blend-mode: screen;
}
.topbar__mark::before { background: var(--cyan); top: 0; left: 0; }
.topbar__mark::after  { background: var(--press-red); bottom: 0; right: 0; }

.topbar__titles h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar__version {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--zinc-light);
}

.topbar__actions {
  display: flex;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, transform 60ms ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--press-red);
  color: #fff;
}
.btn--primary:hover { background: var(--press-red-dark); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--paper);
}
.btn--ghost:hover { background: var(--line); }

.btn--add {
  background: transparent;
  border: 1px dashed var(--zinc);
  color: var(--zinc-light);
  width: 100%;
  padding: 10px;
}
.btn--add:hover { border-color: var(--cyan); color: var(--paper); }

.btn--icon {
  background: transparent;
  border: none;
  color: var(--zinc-light);
  font-size: 13px;
  padding: 2px 8px;
}
.btn--icon:hover { color: var(--press-red); }

/* ---------- Layout ---------- */

.layout {
  display: flex;
  height: calc(100vh - 58px);
}

.panel--form {
  width: 40%;
  min-width: 340px;
  overflow-y: auto;
  padding: 16px 20px 60px;
  background: var(--ink);
  border-right: 1px solid var(--line);
}

.panel--preview {
  width: 60%;
  display: flex;
  flex-direction: column;
  background: var(--table);
}

/* ---------- Collapsible Sections ---------- */

.section {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--ink-soft);
}

.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid transparent;
}
.section[open] > summary { border-bottom-color: var(--line); }
.section > summary::-webkit-details-marker { display: none; }
.section > summary::before {
  content: '▸';
  color: var(--zinc-light);
  transition: transform 120ms ease;
  font-size: 11px;
}
.section[open] > summary::before { transform: rotate(90deg); }

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--press-red);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
}

.section__body {
  padding: 14px;
}

.hint {
  margin: 4px 14px 12px;
  font-size: 11px;
  color: var(--zinc-light);
  line-height: 1.5;
}

/* ---------- Form Fields ---------- */

.grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: 1fr 1fr 1fr; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--zinc-light);
}
.field--wide { grid-column: 1 / -1; }

.field span { font-weight: 600; }

.field input,
.field select,
.field textarea {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--paper);
  background: var(--table);
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  padding: 7px 8px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

.field input[type="color"] {
  padding: 2px;
  height: 32px;
  cursor: pointer;
}

.field--readout output {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--zinc-light);
  padding: 7px 0;
}

.toggle-row { align-items: center; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--paper);
  cursor: pointer;
}

.bg-preview {
  margin-top: 10px;
  max-width: 100%;
  max-height: 120px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

/* ---------- Zeilen-Items ---------- */

.line-item {
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.15);
}
.line-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-light);
}
.line-item > summary::-webkit-details-marker { display: none; }

.f-fixed-row.hidden,
[hidden] { display: none !important; }

/* ---------- Live-Vorschau ---------- */

.preview__meta {
  display: flex;
  gap: 18px;
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--zinc-light);
  border-bottom: 1px solid var(--line);
  background: var(--ink-soft);
}
.preview__meta span::before { content: '· '; color: var(--zinc); }
.preview__meta span:first-child::before { content: ''; }

.preview__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow: auto;
  position: relative;
}

/* Crop-Marks als Signature-Element rund um die Live-Vorschau */
.preview__stage::before,
.preview__stage::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  pointer-events: none;
}

#posterCanvas {
  background: var(--paper);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  max-width: 100%;
  max-height: 100%;
}

.preview__status {
  min-height: 18px;
  padding: 8px 20px;
  font-size: 12px;
  color: var(--zinc-light);
  border-top: 1px solid var(--line);
  background: var(--ink-soft);
}
.preview__status.is-error { color: var(--press-red); }
.preview__status.is-success { color: #7fbf7f; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .layout { flex-direction: column; height: auto; }
  .panel--form, .panel--preview { width: 100%; }
  .grid--3 { grid-template-columns: 1fr 1fr; }
}
