/* =============================================================================
 * Schild-Konfigurator — Styles (Bildschirm + Druck)
 * ===========================================================================*/

:root {
  --bg:        #f4f1ec;
  --panel:     #ffffff;
  --ink:       #2b2722;
  --muted:     #7d756a;
  --line:      #e4ddd2;
  --accent:    #8a5a30;   /* warmes Holzbraun */
  --accent-ink:#5d3a1c;
  --on-bg:     #fbf3e9;
  --on-line:   #c89a63;
  --shadow:    0 8px 30px rgba(60, 45, 25, 0.10);
  --radius:    16px;
  --font:      'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --serif:     Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -10%, #fff8ef 0%, transparent 60%),
    var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---- Kopf -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; flex-direction: column; }
#app-title { font-family: var(--serif); font-size: 22px; margin: 0; letter-spacing: .2px; }
#app-sub   { font-size: 12.5px; color: var(--muted); }
.topbar__actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 13.5px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 10px; transition: .15s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--on-line); background: var(--on-bg); }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; }

/* ---- Layout ------------------------------------------------------------ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 26px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 22px 80px;
  align-items: start;
}
@media (max-width: 940px) and (min-width: 761px) {
  .layout { grid-template-columns: 1fr; }
  .side { order: -1; position: static; top: auto; }
}

/* Mobile-only Elemente sind am Desktop ausgeblendet */
.mobilebar, .drawer-backdrop, .side__actions { display: none; }

/* ---- Schritte / Karten ------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 22px;
  margin-bottom: 20px;
}
.card__head h2 { margin: 0 0 4px; font-size: 17px; font-family: var(--serif); }
.card__head p  { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .3px;
  color: var(--accent-ink); background: var(--on-bg);
  border: 1px solid var(--on-line); padding: 2px 8px; border-radius: 999px;
  margin-bottom: 12px;
}

/* ---- Material-Auswahl -------------------------------------------------- */
.mat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .mat-grid { grid-template-columns: 1fr; } }
.mat {
  text-align: left; cursor: pointer; font: inherit;
  border: 1.5px solid var(--line); background: #fff; border-radius: 14px;
  padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; transition: .15s;
}
.mat:hover { border-color: var(--on-line); transform: translateY(-2px); }
.mat--on { border-color: var(--accent); background: var(--on-bg); box-shadow: 0 0 0 3px rgba(138,90,48,.12); }
.mat__icon { font-size: 26px; }
.mat__label { font-weight: 700; font-size: 15px; }
.mat__desc { font-size: 12px; color: var(--muted); }

/* ---- Option-Tiles ------------------------------------------------------ */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  position: relative; text-align: left; font: inherit; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 12px 11px 12px; display: flex; gap: 9px; align-items: flex-start; transition: .15s;
}
.tile:hover { border-color: var(--on-line); background: #fffdf9; }
.tile--on { border-color: var(--accent); background: var(--on-bg); box-shadow: 0 0 0 3px rgba(138,90,48,.12); }
.tile__mark {
  flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px;
  border: 1.5px solid var(--on-line); border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; line-height: 1;
}
.tile--multi .tile__mark { border-radius: 5px; }
.tile--on .tile__mark { background: var(--accent); border-color: var(--accent); }
.tile__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tile__label { font-weight: 600; font-size: 13.5px; }
.tile__hint { font-size: 11.5px; color: var(--muted); }
.swatch {
  display: inline-block; width: 15px; height: 15px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,.18); vertical-align: -2px; margin-right: 2px;
}
.swatch--none {
  background:
    linear-gradient(45deg, transparent 45%, #c33 46%, #c33 54%, transparent 55%),
    #fff;
}

/* ---- Textfelder -------------------------------------------------------- */
.fields { display: flex; flex-direction: column; gap: 12px; }
.field-row { display: flex; flex-direction: column; gap: 5px; }
.field-row__label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field {
  font: inherit; font-size: 14px; padding: 9px 11px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; resize: vertical;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138,90,48,.12); }

/* ---- Seitenspalte: Vorschau ------------------------------------------- */
.side { position: sticky; top: 84px; }
.preview-wrap {
  background: linear-gradient(160deg, #fffaf2, #f3ece1);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.preview-wrap h2 { margin: 0 0 10px; font-size: 15px; font-family: var(--serif); }
.preview-stage {
  background:
    repeating-linear-gradient(45deg, #efe7da 0 12px, #eae1d2 12px 24px);
  border-radius: 12px; padding: 16px; aspect-ratio: 420 / 320;
  display: flex; align-items: center; justify-content: center;
}
.preview-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 12px; }

.progress { margin-top: 14px; }
.progress__track { height: 8px; background: #e9e0d2; border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--on-line), var(--accent)); transition: width .25s; }
.progress__text { font-size: 12px; color: var(--muted); margin-top: 7px; }

.side__hint { font-size: 11.5px; color: var(--muted); margin-top: 14px; line-height: 1.5; }

/* ---- Druckbereich am Bildschirm versteckt ----------------------------- */
#print-area { display: none; }

/* =============================================================================
 * MOBIL (≤ 760px): schlanker Header, Vorschau als unterer Drawer,
 * sticky Menüleiste am unteren Rand mit „Vorschau"-/Details-Button.
 * ===========================================================================*/
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; }
  #app-title { font-size: 18px; }
  .topbar__actions { display: none; }          /* Buttons wandern nach unten */

  .layout {
    grid-template-columns: 1fr;
    gap: 0; padding: 16px 14px calc(64px + env(safe-area-inset-bottom));
  }

  /* Vorschau wird zum Bottom-Drawer */
  .side {
    order: 0; position: fixed; left: 0; right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom));
    z-index: 70; margin: 0; top: auto;
    transform: translateY(112%); transition: transform .28s ease;
    max-height: 76vh; overflow-y: auto;
    background: #fff; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: 0 -12px 34px rgba(60,45,25,.22);
    padding: 8px 14px 16px;
  }
  .side::before {           /* Ziehgriff */
    content: ""; display: block; width: 44px; height: 5px; border-radius: 999px;
    background: var(--line); margin: 4px auto 10px;
  }
  body.drawer-open .side { transform: translateY(0); }
  .side .preview-wrap { background: none; border: 0; box-shadow: none; padding: 0; }

  .side__actions { display: flex; gap: 10px; margin-top: 14px; }
  .side__actions .btn { flex: 1; justify-content: center; }

  .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(20,16,10,.38); opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  /* untere Menüleiste */
  .mobilebar {
    display: flex; align-items: stretch; gap: 10px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.95); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }
  .mobilebar__details {
    flex: 1; display: flex; align-items: center; gap: 9px;
    font: inherit; text-align: left; cursor: pointer;
    background: var(--on-bg); border: 1px solid var(--on-line); color: var(--ink);
    border-radius: 10px; padding: 8px 12px;
  }
  .mobilebar__chev { color: var(--accent); transition: transform .25s ease; font-size: 12px; }
  body.drawer-open .mobilebar__chev { transform: rotate(180deg); }
  .mobilebar__label { font-weight: 700; font-size: 14px; }
  .mobilebar__progress { margin-left: auto; font-size: 11.5px; color: var(--muted); }
  .mobilebar__btn { white-space: nowrap; }
}

/* =============================================================================
 * DRUCK
 * ===========================================================================*/
@media print {
  @page { size: A4; margin: 16mm; }

  /* Im Druckmodus nur den Druckbereich zeigen */
  body.printing .topbar,
  body.printing .layout { display: none !important; }
  body.printing #print-area { display: block !important; }

  .print { page-break-after: always; color: #1c1c1c; }
  .print:last-child { page-break-after: auto; }

  /* --- Zusammenfassung --- */
  .print--summary .print__head h1 { font-family: var(--serif); font-size: 26px; margin: 0 0 2px; }
  .print--summary .print__head p { color: #555; margin: 0 0 18px; }
  .print-sum { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
  .print-sum__preview { border: 1px solid #ddd; border-radius: 10px; padding: 10px; background: #faf7f1; }
  .print-sum__table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .print-sum__table th, .print-sum__table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
  .print-sum__table th { width: 38%; color: #555; font-weight: 600; }
  .print__foot { margin-top: 26px; font-size: 12px; color: #777; }

  /* --- Katalog-Booklet --- */
  .print--cover .cover { text-align: center; padding-top: 40mm; }
  .cover__badge {
    display: inline-block; letter-spacing: 2px; text-transform: uppercase; font-size: 11px;
    border: 1px solid #c89a63; color: #8a5a30; padding: 5px 14px; border-radius: 999px; margin-bottom: 22px;
  }
  .cover h1 { font-family: var(--serif); font-size: 40px; margin: 0 0 6px; }
  .cover__for { font-size: 20px; color: #8a5a30; font-style: italic; margin: 0 0 26px; }
  .cover__intro { max-width: 130mm; margin: 0 auto 14px; color: #444; }
  .cover__hint { max-width: 130mm; margin: 0 auto; color: #777; font-size: 13px; }

  .cat-step { font-family: var(--serif); font-size: 22px; border-bottom: 2px solid #8a5a30; padding-bottom: 6px; margin: 0 0 6px; }
  .cat-lead { color: #555; margin: 0 0 14px; }
  .cat-cols { columns: 2; column-gap: 14mm; }
  .cat-block { break-inside: avoid; margin-bottom: 12px; }
  .cat-block h3 { font-size: 14px; margin: 0 0 2px; }
  .cat-block__hint { font-size: 11px; color: #777; margin: 0 0 6px; }
  .cat-opt { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; font-size: 12.5px; }
  .cat-box { flex: 0 0 14px; width: 14px; height: 14px; border: 1.4px solid #555; border-radius: 3px; margin-top: 1px; }
  .cat-opt__label em { color: #777; font-style: italic; }
  .cat-write { margin: 10px 0; }
  .cat-line { display: block; border-bottom: 1px solid #999; height: 22px; margin-top: 4px; }
}

/* Vorschau-SVG soll im Druck-Summary mitskalieren */
.print-sum__preview svg { width: 100%; height: auto; display: block; }
