/* Template-Detail-Page: Hero, Split-Screen Fill Engine, Live Preview, Downloads. */

/* Prose column on the detail page (the_content + Rechtlicher Hinweis + Quellen).
   Constrains the line-length to ~68ch for readability but left-anchors the column
   to the page-edge so it lines up with the hero, fill engine and related grid above
   — instead of being center-floated inside the 1200px container. */
.vorlage-prose {
  max-width: var(--max-width-content);
  margin-inline: 0;
}

/* ======= Template Hero (rotating display H1) ======= */
.vorlage-hero {
  padding-block: var(--space-12);
}
@media (min-width: 768px)  { .vorlage-hero { padding-block: var(--space-16); } }
@media (min-width: 1024px) { .vorlage-hero { padding-block: var(--space-24); } }
.vorlage-hero__display,
.vorlage-hero__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--hero-display-size);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--color-ink);
  margin-bottom: var(--space-8);
  max-width: 100%;
  text-wrap: balance;
  overflow-wrap: break-word;
  hyphens: manual;
}
.vorlage-hero__display-main,
.vorlage-hero__title-main { display: block; }

.vorlage-hero__display-sub,
.vorlage-hero__title-sub {
  display: block;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--hero-sub-size);
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--color-ink-mute);
  margin-top: var(--space-2);
}
.vorlage-hero__meta {
  display: flex; align-items: center; gap: var(--space-6);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.vorlage-hero__meta-label {
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  color: var(--color-ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.vorlage-hero__bullets {
  color: var(--color-ink-mute);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-8);
}
.vorlage-hero__bullets span + span::before { content: " · "; margin-inline: 0.4em; opacity: 0.5; }
.vorlage-hero__actions { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: center; }

/* Letter-rise feature is disabled site-wide; defensive overrides live in motion.css
   so they also cover the homepage hero (vorlage.css is single-template-only). */
.letter {
  display: inline-block;
}

/* ======= Split-Screen Fill Engine ======= */
/* Hidden until the user clicks "Schnell ausfüllen". The HTML [hidden]
   attribute would normally do this, but the explicit `display: grid` below
   overrides the user-agent `[hidden] { display: none }` rule via specificity,
   so two empty boxes leak onto the page. Forcing display:none here fixes it. */
.schnell-ausfuellen[hidden] { display: none !important; }

.schnell-ausfuellen {
  margin-block: var(--space-12);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}
@media (min-width: 1024px) {
  .schnell-ausfuellen {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: var(--space-8);
  }
}
@media (min-width: 1280px) {
  .schnell-ausfuellen { gap: var(--space-12); }
}

.schnell-ausfuellen__form {
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: 16px;
  padding: var(--space-5, 1.25rem);
  min-width: 0; /* let inputs shrink inside grid without overflow */
}
@media (min-width: 480px) {
  .schnell-ausfuellen__form { padding: var(--space-6); }
}
@media (min-width: 768px) {
  .schnell-ausfuellen__form { padding: var(--space-8); }
}
.schnell-ausfuellen__form h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.375rem;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-2);
  color: var(--color-ink);
}
.form-section {
  margin-bottom: var(--space-8);
  border: 0;
  padding: 0;
}
.form-section + .form-section {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-line-soft);
}
.form-section__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-ink);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-5, 1.25rem);
  padding: 0;
  border: 0;
  display: block;
  width: 100%;
}

.schnell-ausfuellen__preview {
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: 16px;
  padding: var(--space-6);
  min-height: 480px;
  box-shadow: 0 1px 2px rgba(10, 10, 10, 0.03), 0 8px 24px -12px rgba(10, 10, 10, 0.08);
}
@media (min-width: 768px) {
  .schnell-ausfuellen__preview { padding: var(--space-8); min-height: 600px; }
}
/* Sticky preview only when the form + preview sit side-by-side. On mobile
   the panes stack and a sticky preview would awkwardly float over the form. */
@media (min-width: 1024px) {
  .schnell-ausfuellen__preview {
    position: sticky;
    top: 100px;
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}
.schnell-ausfuellen__preview-content {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-ink);
  min-height: 400px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'cv11', 'ss01', 'kern';
  transition: opacity var(--motion-duration-preview) var(--motion-ease-cinema);
  touch-action: pan-x pan-y pinch-zoom;
}
.schnell-ausfuellen__preview-content.is-fading { opacity: 0.7; }
.schnell-ausfuellen__preview-content h1,
.schnell-ausfuellen__preview-content h2 {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  margin-block: var(--space-3);
  line-height: var(--line-height-snug);
}
.schnell-ausfuellen__preview-content p { margin-block: 0; max-width: none; line-height: 1.55; }
/* DIN-5008-style preview rendering */
.schnell-ausfuellen__preview-content .vmh-prev-blank   { height: 0.9em; margin: 0; }
.schnell-ausfuellen__preview-content .vmh-prev-date    { text-align: right; margin-block: 1.6em 1em; }
.schnell-ausfuellen__preview-content .vmh-prev-betreff { font-weight: 700; margin-block: 1.2em 1.4em; }
.schnell-ausfuellen__preview-content .vmh-prev-sigline { margin-top: 2.4em; letter-spacing: -0.05em; }

.schnell-ausfuellen__privacy-note {
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-line-soft);
  background: var(--color-stone-soft);
  border-radius: 10px;
  color: var(--color-ink-soft);
  font-size: 0.8125rem;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.schnell-ausfuellen__privacy-note::before {
  content: "🔒";
  font-size: 0.875rem;
  opacity: 0.7;
}
/* Download block — visually highlighted "card" so the primary CTA after the
   user has reviewed the preview is unmistakable. Soft warm background +
   centered heading + hint + larger buttons. */
.schnell-ausfuellen__downloads-block {
  margin-top: var(--space-6);
  padding: var(--space-6) var(--space-4);
  background: var(--color-stone-soft);
  border: 1.5px solid var(--color-line-soft);
  border-radius: 16px;
  text-align: center;
}
.schnell-ausfuellen__downloads-title {
  margin: 0 0 var(--space-1);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--color-ink);
  display: inline-flex; align-items: center; gap: var(--space-2);
  line-height: 1.2;
}
.schnell-ausfuellen__downloads-title > [aria-hidden] {
  font-size: 1.4em;
  line-height: 1;
  color: var(--color-ink-soft);
}
.schnell-ausfuellen__downloads-hint {
  margin: 0 0 var(--space-5);
  font-size: var(--font-size-sm);
  color: var(--color-ink-mute);
}
.schnell-ausfuellen__downloads {
  display: flex; flex-direction: column; gap: var(--space-3);
  align-items: stretch;
}
@media (min-width: 640px) {
  .schnell-ausfuellen__downloads {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: var(--space-4);
  }
  /* Centered, generously sized download CTAs — bolder than the page-default
     button so they stand out as the primary action. */
  .schnell-ausfuellen__downloads .btn {
    flex: 0 1 auto;
    min-width: 220px;
    justify-content: center;
    padding: 0.95rem 1.75rem;
    font-size: var(--font-size-base);
    font-weight: 600;
    letter-spacing: 0.01em;
  }
}
@media (min-width: 768px) {
  .schnell-ausfuellen__downloads-block { padding: var(--space-8) var(--space-6); }
  .schnell-ausfuellen__downloads-title  { font-size: var(--font-size-xl); }
}

/* "Formular zurücksetzen" — destructive action, now visibly bordered so the
   user can clearly see the undo-everything path. Pill-shape, red outline,
   semi-bold; on hover/focus fills with red so the destructive intent reads. */
.schnell-ausfuellen__reset-row {
  display: flex; justify-content: center;
  margin-top: var(--space-4);
}
.schnell-ausfuellen__reset {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: transparent;
  border: 1.5px solid var(--color-error);
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--font-size-sm);
  letter-spacing: 0.01em;
  color: var(--color-error);
  cursor: pointer;
  text-decoration: none;
  transition: background 200ms var(--motion-ease-standard),
              color 200ms var(--motion-ease-standard),
              transform 120ms var(--motion-ease-standard);
}
.schnell-ausfuellen__reset > [aria-hidden] {
  font-size: 1.1em; line-height: 1;
}
.schnell-ausfuellen__reset:hover,
.schnell-ausfuellen__reset:focus-visible {
  background: var(--color-error);
  color: var(--color-white);
}
.schnell-ausfuellen__reset:active { transform: translateY(1px); }
.schnell-ausfuellen__reset:focus-visible {
  outline: 2px solid var(--color-error);
  outline-offset: 3px;
}

/* "Vorschau anzeigen"-Button — initial empty state of the preview pane */
.schnell-ausfuellen__preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  padding: var(--space-8);
}
.schnell-ausfuellen__preview-empty p { max-width: 32ch; }
[data-fill-preview-empty][hidden] { display: none !important; }

/* Fill Engine Loading State */
.fill-engine-loading {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-12);
  color: var(--color-ink-mute);
}
.fill-engine-loading .spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--color-line);
  border-top-color: var(--color-ink);
  border-radius: 50%;
  animation: vmh-spin 0.8s linear infinite;
}
@keyframes vmh-spin { to { transform: rotate(360deg); } }

/* Disabled fallback when JS is blocked */
.schnell-ausfuellen__noscript {
  padding: var(--space-6);
  background: var(--color-stone-soft);
  border: 1.5px solid var(--color-line);
  border-radius: 12px;
}

/* ======= Conditional Field Visibility ======= */
[data-show-when] { display: none; }
[data-show-when].is-visible { display: block; }

/* ======= Preview Image (static PNG for Excel templates etc.) ======= */
.preview-image-wrap {
  border: 1.5px solid var(--color-line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--color-white);
}
.preview-image-wrap img { width: 100%; height: auto; }

/* ======= Draft Restore Chip ======= */
.draft-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-stone-soft);
  border: 1px solid var(--color-line);
  color: var(--color-ink-soft);
  border-radius: 12px;
  font-size: 0.875rem;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.draft-chip button {
  color: var(--color-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.draft-chip button[data-dismiss] {
  color: var(--color-ink-mute);
  font-weight: 400;
}

/* ======= Sources Block ======= */
.sources-list {
  list-style: none;
  display: flex; flex-direction: column; gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-ink-soft);
}
.sources-list li::before { content: "§ "; color: var(--color-ink-mute); }

/* ======= Kopiert Toast ======= */
.copied-toast {
  position: fixed;
  bottom: var(--space-8); left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--color-ink);
  color: var(--color-stone);
  padding: var(--space-3) var(--space-6);
  border-radius: 999px;
  font-size: var(--font-size-sm);
  z-index: 400;
  transition: transform var(--motion-duration-base) var(--motion-ease-entrance);
}
.copied-toast.is-visible { transform: translateX(-50%) translateY(0); }
