/**
 * Baseline grid: 7pt
 * Distance from top to content: 12.7mm
 *
 * @author      Kim-Christian Meyer
 * @copyright   2016 Kim-Christian Meyer
 * @license     GPL-3.0+
 */

* {
  margin: 0;
  padding: 0;
}

html {
  font-family: 'Fira Sans', 'Myriad Pro', sans-serif;
  font-size: 10pt;
  line-height: 14pt;
}

body {
  width: 100%;
  margin: 0;
  padding: 0;
}

p {
  margin: 0 0 14pt 0;
}


.page-hd {

}

.clear-storage-btn {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  z-index: 10;
  padding: 8px 20px;
  font-size: 10pt;
  line-height: 14pt;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  text-decoration: none;
}

.clear-storage-btn:hover {
  background: rgba(0, 0, 0, 0.5);
}

.clear-storage-btn:active {
  background: rgba(0, 0, 0, 0.7);
}

.clear-storage-btn.is-visible {
  display: block;
}

.print-btn {
  display: none;
  position: fixed;
  right: 16px;
  top: 5px;
  z-index: 25;
  padding: 4px 14px;
  font-size: 10pt;
  line-height: 14pt;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Fira Sans', 'Myriad Pro', sans-serif;
  transition: all 0.2s ease-in-out;
  box-sizing: border-box;
  text-decoration: none;
}

.print-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  border-color: rgba(255, 255, 255, 0.8);
}

.print-btn:active {
  background: rgba(0, 0, 0, 0.9);
}

.print-btn.is-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.print-btn-group {
  display: none;
  position: fixed;
  right: 16px;
  top: 5px;
  z-index: 20;
}

.print-btn-group.is-visible {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  font-size: 10pt;
  line-height: 14pt;
  text-align: center;
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Fira Sans', 'Myriad Pro', sans-serif;
  transition: all 0.2s ease-in-out;
  box-sizing: border-box;
  text-decoration: none;
}

.btn-action:hover {
  background: rgba(0, 0, 0, 0.85);
  border-color: rgba(255, 255, 255, 0.9);
}

.btn-action-primary {
  background: #1a73e8;
  border-color: #1a73e8;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-action-primary:hover {
  background: #1557b0;
  border-color: #1557b0;
}

.seo-section {
  max-width: 210mm;
  margin: 30px auto 40px auto;
  padding: 24px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  color: #333;
  font-size: 9pt;
  line-height: 13pt;
  box-sizing: border-box;
}

.seo-section h2 {
  font-size: 12pt;
  margin-bottom: 8px;
  color: #111;
}

.seo-section h3 {
  font-size: 10pt;
  margin-top: 14px;
  margin-bottom: 4px;
  color: #222;
}

.seo-section p {
  margin: 0 0 8px 0;
}

.seo-section ul {
  margin: 0 0 10px 20px;
}

.seo-section a {
  color: #0366d6;
  text-decoration: none;
}

.seo-section a:hover {
  text-decoration: underline;
}

/* Legal Modal (Impressum & Datenschutz) */
.legal-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.legal-modal-card {
  background: #ffffff;
  color: #222222;
  border-radius: 10px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.legal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e5e5e5;
  background: #fcfcfc;
}

.legal-modal-title {
  font-size: 13pt;
  font-weight: 600;
  color: #111111;
  margin: 0;
}

.legal-modal-close {
  background: transparent;
  border: none;
  font-size: 22pt;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s ease;
}

.legal-modal-close:hover {
  color: #000;
}

.legal-modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 9.5pt;
  line-height: 15pt;
  color: #333;
}

.legal-modal-body h3 {
  font-size: 11pt;
  font-weight: 600;
  color: #111;
  margin: 16px 0 6px 0;
}

.legal-modal-body h3:first-child {
  margin-top: 0;
}

.legal-modal-body p {
  margin: 0 0 12px 0;
}

.legal-modal-body a {
  color: #1a73e8;
  text-decoration: underline;
}

.editors {
  display: none; /* Not needed anymore because of contenteditable */
  float: left;
  width: 50%;
  background: #ddd;
  height: 100%;
  padding: 24mm;
  box-sizing: border-box;
}

.preview {
  position: relative;
  padding: 24mm;
  width: 210mm; /* DIN A4 */
  box-sizing: border-box;
}

/* DIN lang size: 220mm x 110mm*/
/* DIN A4 size: 210mm x 297mm */
.address-overlay {
  position: absolute;
  /* DIN lang: address window must be 15mm from bottom, and 20mm from left
     horizontal difference envelope vs. paper: 220mm - 210mm = 10mm;

     top:
     105mm (line 1) - 15mm (margin bottom) - 45mm (height) + 1.5mm (puffer) = 46.5mm
     left:
     20mm - 5mm (horizontal difference envelope vs. paper / 2) = 15mm */
  left: 15mm;
  top: 46.5mm;

  /* Standard DIN lang width and height */
  width: 90mm;
  height: 45mm;

  border-radius: 4mm;
  background: rgba(0, 0, 0, 0.05);
  z-index: 0;
}

.address-wrapper {
  position: absolute;
  left: 20mm;
  top: 126pt;
  width: 90mm;
  padding: 14pt 4mm;
  z-index: 10;
  box-sizing: border-box;
}

.address-overline {
  font-size: 8pt;
}

.address {
  font-size: 10pt;
}

.sidebar {
  position: absolute;
  right: 24mm;
  top: 70pt;
  width: 40mm;
  height: 182pt;
  font-size: 8pt;
}

.align-bottom {
  position: absolute;
  bottom: 0;
  width: 100%;
}

.sidebar-date {
  margin-top: 14pt;
}

.sidebar-email {
  margin-top: 14pt;
}

.sidebar-phone {
  margin-top: 14pt;
}

.body {
  position: absolute;
  left: 24mm;
  top: 308pt;
  right: 24mm;
}

.body-subject {
  font-weight: bold;
  margin-bottom: 14pt;
}


.attachments-hd {
  font-style: italic;
  font-size: 8pt;
  line-height: 12pt;
  margin: 0;
}

.attachments-bd {
  font-size: 8pt;
  line-height: 12pt;
}

.line {
  position: absolute;
  left: 5mm;
  height: 0.3mm;
  /* Won´t get printed, using 1x1 pixel instead */
  /*background-color: rgba(0, 0, 0, 0.3);*/
}

.line-img-helper {
  width: 100%;
  height: 100%;
  display: block;
}

.line-1 {
  top: 105mm;
  width: 3mm;
}

.line-2 {
  top: 148.5mm;
  width: 5mm;
}

.line-3 {
  top: 210mm;
  width: 3mm;
}

.baseline-10pt {
  padding-top: 4.7pt;
  margin-bottom: -4.7pt;
}

.baseline-8pt {
  padding-top: 5.1pt;
  margin-bottom: -5.1pt;
}

.baseline-8pt-bottom {
  padding-bottom: 1.4pt;
}

/* Only for debugging */
.baselines {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
}

.baseline {
  height: 14pt;
}

.baseline:nth-child(2n) {
  background: rgba(255,0,0,0.3);
}

@media screen {
  /* Create a wider border around the element without effecting other elements */
  *[contenteditable] {
    position: relative;
    display: inline-block;
    margin: -7pt;
    padding: 7pt;
    width: 100%;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0);
    -webkit-transition: box-shadow 0.2s ease-in-out, background-color 0.2s ease-in-out;
    transition: box-shadow 0.2s ease-in-out, background-color 0.2s ease-in-out;
  }

  *[contenteditable]:focus {
    z-index: 20;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    outline: none;
    background-color: rgba(255, 255, 255, 0.95);
  }

  .baseline-8pt:focus {
    padding-top: 12.1pt;
    margin-bottom: -12.1pt;
  }

  .body-subject:focus {
    margin-bottom: 7pt; /* = 14pt - 7pt */
  }

  body {
    background-color: rgba(0, 0, 0, 0.3);
    min-height: 100%;
    padding: 0 0 40px 0;
    box-sizing: border-box;
  }

  .preview {
    margin: 50px auto;
    background: white;
    height: 297mm;
    box-shadow: 0 5px 50px rgba(0, 0, 0, 0.3);
  }
}


@media print {
  @page {
    size: auto;
    margin: 0mm;
  }

  *, *:before, *:after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    width: 100% !important;
    height: auto !important;
  }

  main {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
  }

  .preview {
    position: relative !important;
    margin: 0 !important;
    padding: 24mm !important;
    width: 210mm !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    background: #ffffff !important;
    page-break-after: avoid !important;
    page-break-before: avoid !important;
    page-break-inside: avoid !important;
    break-after: avoid !important;
    break-before: avoid !important;
    break-inside: avoid !important;
  }

  /* Prevent forced page breaks */
  .page-break {
    page-break-before: auto !important;
    page-break-inside: avoid !important;
    break-before: auto !important;
    break-inside: auto !important;
  }

  header,
  footer,
  .no-print,
  .legal-modal-backdrop,
  .address-overlay,
  .clear-storage-btn,
  .print-btn,
  .pdf-btn,
  .print-btn-group,
  .editors,
  .seo-section,
  .baselines {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    position: absolute !important;
    top: -9999px !important;
  }

  /* Completely remove caret cursor and focus artifacts in print preview (Safari & Chrome) */
  *[contenteditable],
  *[contenteditable]:focus,
  *[contenteditable]:hover {
    caret-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
  }

  ::selection {
    background: transparent !important;
  }
}
