/*
 * Bildschirmfüllender Fokusmodus für alle Stilfinder-Einbauten.
 * Die Landingpage bleibt als SEO-/Vertrauensrahmen erhalten; erst eine
 * bewusste Nutzeraktion hebt denselben Stilfinder-DOM in diese Ansicht.
 */

.stilfinder-focus-host .stilfinder-focus-toolbar {
  display: none;
}

body.stilfinder-focus-open {
  position: fixed;
  top: calc(var(--stilfinder-page-scroll, 0px) * -1);
  right: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.stilfinder-focus-host.is-focus-open {
  position: fixed;
  z-index: 2147483000;
  top: var(--stilfinder-visual-top, 0px);
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--stilfinder-visual-height, 100vh);
  height: var(--stilfinder-visual-height, 100dvh);
  max-width: none;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #f5f1eb;
  box-shadow: none;
  overflow: hidden;
  overscroll-behavior: contain;
}

.stilfinder-focus-host.is-focus-open .stilfinder-focus-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  flex: 0 0 auto;
  min-height: calc(58px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(18px, env(safe-area-inset-right, 0px)) 0 max(18px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid rgba(140, 106, 79, 0.2);
  background: rgba(251, 250, 247, 0.98);
  color: #1f2937;
}

.stilfinder-focus-brand {
  justify-self: start;
  color: #76533d;
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.stilfinder-focus-progress {
  justify-self: center;
  overflow: hidden;
  max-width: min(46vw, 520px);
  color: #555;
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stilfinder-focus-close {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #1f2937;
  font: 700 14px/1 "Nunito Sans", system-ui, sans-serif;
  cursor: pointer;
}

.stilfinder-focus-close:hover {
  background: rgba(140, 106, 79, 0.1);
}

.stilfinder-focus-close:focus-visible {
  outline: 3px solid rgba(118, 83, 61, 0.38);
  outline-offset: 2px;
}

.stilfinder-focus-close svg {
  width: 20px;
  height: 20px;
}

.stilfinder-focus-host.is-focus-open > .kk-stilfinder {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .app-shell {
  display: flex;
  flex-direction: column;
  width: min(100% - 32px, 1440px);
  height: 100%;
  min-height: 0;
  margin-inline: auto;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .topbar,
.stilfinder-focus-host.is-focus-open .kk-stilfinder .site-footer {
  display: none;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .journey {
  flex: 0 0 auto;
  padding: 10px 2px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .journey-step {
  min-height: 36px;
  padding: 7px 14px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 0 max(14px, env(safe-area-inset-bottom, 0px));
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .panel {
  flex: 1 1 auto;
  width: 100%;
  /* Keine feste 100 %-Höhe: Das Strecken im Flex-Container berücksichtigt
     die geerbten Außenabstände, sonst ragt die Aktionsleiste aus dem Bild. */
  height: auto;
  min-height: 0;
  padding: clamp(18px, 3.2vh, 38px) clamp(20px, 4vw, 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz.panel {
  overflow: hidden;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz h2 {
  font-size: clamp(1.5rem, 3vw + 0.25rem, 2.5rem);
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .question-help {
  margin: 8px 0 14px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .selection-message {
  min-height: 1.25em;
  margin: -6px 0 8px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-grid,
.stilfinder-focus-host.is-focus-open .kk-stilfinder .text-grid {
  flex: 1 1 auto;
  min-height: 0;
  margin: 4px 0 12px;
  padding: 2px 4px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  /* Karten mit overflow:hidden würden sonst auf die Resthöhe gestaucht;
     volle Kartenhöhe und stattdessen innerhalb des Rasters scrollen. */
  grid-auto-rows: max-content;
  gap: clamp(10px, 1.5vw, 18px);
  align-content: start;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card {
  min-height: 0;
  padding: 14px 16px 16px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card.has-image {
  display: flex;
  flex-direction: column;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card.has-image .answer-swatch {
  height: clamp(92px, 18vh, 190px);
  margin: -4px -6px 12px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card strong {
  font-size: 16px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card small {
  margin-top: 4px;
  font-size: 14px;
}

.stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz-footer {
  position: relative;
  flex: 0 0 auto;
  margin-top: 0;
  padding: 12px 0 0;
  background: var(--surface);
  box-shadow: none;
}

@media (max-width: 1099px) {
  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  /* Reserve unter der Aktionsleiste: Browserleisten, Home-Indikator und die
     Meta-In-App-Steuerung liefern nicht zuverlässig eine Safe-Area. */
  .stilfinder-focus-host.is-focus-open {
    --stilfinder-mobile-action-clearance: 20px;
  }

  html.is-meta-inapp .stilfinder-focus-host.is-focus-open {
    --stilfinder-mobile-action-clearance: 48px;
  }

  .stilfinder-focus-host.is-focus-open .stilfinder-focus-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: calc(54px + env(safe-area-inset-top, 0px));
    padding-inline: max(10px, env(safe-area-inset-left, 0px)) max(10px, env(safe-area-inset-right, 0px));
  }

  .stilfinder-focus-brand {
    display: none;
  }

  .stilfinder-focus-progress {
    grid-column: 1;
    justify-self: start;
    max-width: calc(100vw - 142px);
    padding-left: 6px;
  }

  .stilfinder-focus-close {
    grid-column: 2;
    padding-inline: 10px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .app-shell {
    width: 100%;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .journey {
    padding: 6px 10px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .journey-step {
    min-height: 32px;
    padding: 5px 11px;
    font-size: 14px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .main {
    padding-bottom: 0;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .panel {
    padding: 12px max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    border: 0;
    border-radius: 0;
    box-shadow: none;
    scrollbar-gutter: auto;
  }

  /* Die Aktionsleiste trägt die untere Reserve selbst und sitzt bündig am Rand. */
  .stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz.panel {
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz h2 {
    margin-top: 0;
    font-size: clamp(1.5rem, 3vw + 0.25rem, 2.5rem);
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .question-help {
    margin: 4px 0 10px;
    font-size: 14px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .multiple-hint {
    margin-top: 6px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .selection-message {
    margin: -4px 0 4px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 6px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card {
    padding: 8px 8px 11px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card.has-image .answer-swatch {
    height: auto;
    aspect-ratio: 4 / 3;
    margin: 0 0 8px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card strong {
    padding-inline: 3px;
    font-size: 14px;
    line-height: 1.25;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card small {
    padding-inline: 3px;
    font-size: 14px;
    line-height: 1.3;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-inline: 0;
    padding: 10px 0 0;
    padding-bottom: max(var(--stilfinder-mobile-action-clearance), calc(env(safe-area-inset-bottom, 0px) + 8px));
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .intro {
    display: block;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .intro-visual {
    display: none;
  }
}

@media (max-height: 620px) {
  .stilfinder-focus-host.is-focus-open .kk-stilfinder .journey {
    display: none;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .panel {
    padding-top: 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz h2 {
    font-size: clamp(1.25rem, 2vw + 0.25rem, 1.75rem);
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .question-help {
    margin-bottom: 6px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card.has-image .answer-swatch {
    height: clamp(72px, 20vh, 118px);
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .stilfinder-focus-host.is-focus-open .stilfinder-focus-toolbar {
    min-height: 44px;
    padding-top: max(4px, env(safe-area-inset-top, 0px));
    padding-bottom: 4px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .panel {
    padding-top: 5px;
    padding-bottom: max(5px, env(safe-area-inset-bottom, 0px));
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .question-meta {
    margin-bottom: 2px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz h2 {
    margin-bottom: 2px;
    font-size: clamp(1.25rem, 2vw + 0.25rem, 1.75rem);
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .question-help {
    display: none;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card.has-image .answer-swatch {
    height: clamp(48px, 14vh, 68px);
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-card small {
    display: none;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .main {
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .answer-grid,
  .stilfinder-focus-host.is-focus-open .kk-stilfinder .text-grid {
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .stilfinder-focus-host.is-focus-open .kk-stilfinder .quiz-footer {
    padding-top: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stilfinder-focus-host.is-focus-open,
  .stilfinder-focus-host.is-focus-open * {
    scroll-behavior: auto !important;
  }
}
