/**
 * hh.css — Heimliebe Planner app surface
 *
 * Mobile-first. Mirrors DESIGN.md tokens; if a value disagrees with
 * theme/assets/css/tokens.css the theme wins — these tokens are a
 * defensive copy in case the plugin is loaded against a different theme.
 *
 * Component scope: Q-flow, voice mic, dashboard, mini-plan form,
 * mid-flow upsell, magic-link gate, toast, eure-hochzeit guest page.
 */

/* ──────────────────────────────────────────────────────────────────────
 * 1. Token mirror (full copy of theme/assets/css/tokens.css :root)
 *    Defensive: lets the plugin run on themes that don't load tokens.css.
 * ────────────────────────────────────────────────────────────────────── */
:root {
  --hh-color-primary:    #1A1F2C;
  --hh-color-secondary:  #6E7686;
  --hh-color-tertiary:   #E8B547;
  --hh-color-accent:     #F4A48A;
  --hh-color-neutral:    #CFE0EC;
  --hh-color-surface:    #FFFFFF;
  --hh-color-paper:      #FAF4E8;
  --hh-color-on-surface: #1A1F2C;
  --hh-color-border:     #1A1F2C;
  --hh-color-hairline:   #B5C8D6;
  --hh-color-success:    #5C8A6E;
  --hh-color-error:      #B3463E;

  --hh-font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --hh-font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --hh-type-display-hero: clamp(2.5rem, 6vw + 1rem, 6rem);
  --hh-type-display-lg:   clamp(2rem,   4.5vw + .5rem, 4rem);
  --hh-type-display-md:   clamp(1.5rem, 3vw + .5rem, 2.5rem);
  --hh-type-question:     clamp(1.5rem, 2.5vw + .25rem, 1.75rem);
  --hh-type-body-lg:      clamp(1rem, .25vw + 1rem, 1.125rem);
  --hh-type-body-md:      1rem;
  --hh-type-body-sm:      0.8125rem;
  --hh-type-label-lg:     0.9375rem;
  --hh-type-label-caps:   0.6875rem;
  --hh-type-numeric:      clamp(1.5rem, 3vw, 2rem);

  --hh-weight-regular:  400;
  --hh-weight-medium:   500;
  --hh-weight-semibold: 600;

  --hh-tracking-tight:    -0.015em;
  --hh-tracking-display:  -0.01em;
  --hh-tracking-question: -0.005em;
  --hh-tracking-caps:     0.14em;

  --hh-leading-hero:    1.05;
  --hh-leading-display: 1.15;
  --hh-leading-md:      1.25;
  --hh-leading-question:1.3;
  --hh-leading-body:    1.55;
  --hh-leading-tight:   1.1;
  --hh-leading-flat:    1.0;

  --hh-radius-none: 0px;
  --hh-radius-sm:   8px;
  --hh-radius-md:   16px;
  --hh-radius-lg:   20px;
  --hh-radius-xl:   28px;
  --hh-radius-2xl:  36px;
  --hh-radius-full: 9999px;

  --hh-space-xs:   4px;
  --hh-space-sm:   8px;
  --hh-space-md:   12px;
  --hh-space-lg:   16px;
  --hh-space-xl:   24px;
  --hh-space-2xl:  32px;
  --hh-space-3xl:  48px;
  --hh-space-4xl:  64px;

  --hh-gutter:     16px;
  --hh-margin:     20px;

  --hh-content-narrow: 640px;
  --hh-content-prose:  720px;
  --hh-content-wide:   1280px;
  --hh-form-max:       480px;

  --hh-ease:          cubic-bezier(0.4, 0, 0.2, 1);
  --hh-duration:      200ms;
  --hh-duration-slow: 350ms;
}

@media (min-width: 768px) {
  :root {
    --hh-space-md:  16px;
    --hh-space-lg:  24px;
    --hh-space-xl:  32px;
    --hh-space-2xl: 40px;
    --hh-space-3xl: 56px;
    --hh-space-4xl: 88px;
    --hh-gutter:    24px;
  }
}
@media (min-width: 1024px) {
  :root {
    --hh-space-2xl: 48px;
    --hh-space-3xl: 72px;
    --hh-space-4xl: 120px;
  }
}

/* ──────────────────────────────────────────────────────────────────────
 * 2. Utility primitives used by the app surface only.
 *    Theme defines .hh-card / .hh-btn globally; we only add app-specific
 *    layout helpers here so we don't fight the theme at higher specificity.
 * ────────────────────────────────────────────────────────────────────── */
.hh-stack { display: flex; flex-direction: column; gap: var(--hh-space-lg); }
.hh-stack-xl { display: flex; flex-direction: column; gap: var(--hh-space-xl); }
.hh-center { text-align: center; }
.hh-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ──────────────────────────────────────────────────────────────────────
 * 3. Q-flow container
 * ────────────────────────────────────────────────────────────────────── */
.hh-q-flow {
  max-width: var(--hh-content-narrow);
  margin: 0 auto;
  padding: var(--hh-space-xl) var(--hh-margin);
  padding-bottom: calc(var(--hh-space-4xl) + env(safe-area-inset-bottom, 0px));
}

.hh-q-flow__progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--hh-space-xs);
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-label-caps);
  letter-spacing: var(--hh-tracking-caps);
  text-transform: uppercase;
  color: var(--hh-color-secondary);
  margin-bottom: var(--hh-space-xl);
}

.hh-q-flow__screen {
  position: relative;
  min-height: 360px;
}

/* ──────────────────────────────────────────────────────────────────────
 * 4. Q-card — the cream paper question card
 * ────────────────────────────────────────────────────────────────────── */
.hh-q-card {
  background: var(--hh-color-paper);
  color: var(--hh-color-on-surface);
  border-radius: var(--hh-radius-2xl);
  padding: var(--hh-space-2xl) var(--hh-space-xl);
  max-width: var(--hh-content-narrow);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-xl);
}
@media (min-width: 768px) {
  .hh-q-card { padding: var(--hh-space-2xl); }
}

.hh-q-card__prompt {
  font-family: var(--hh-font-display);
  font-size: var(--hh-type-question);
  line-height: var(--hh-leading-question);
  letter-spacing: var(--hh-tracking-question);
  font-weight: var(--hh-weight-medium);
  text-align: center;
  margin: 0;
  /* Cap to ~2 visual lines on xs without truncating with ellipsis. */
  text-wrap: balance;
}

.hh-q-card__helper {
  margin: 0;
  text-align: center;
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-body-sm);
  color: var(--hh-color-secondary);
  line-height: var(--hh-leading-body);
}

.hh-q-card__input-row {
  display: flex;
  gap: var(--hh-space-md);
  align-items: center;
  width: 100%;
  max-width: var(--hh-form-max);
  margin: 0 auto;
}

.hh-q-card__input,
.hh-q-card__textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 48px;
  padding: var(--hh-space-md) var(--hh-space-lg);
  font-family: var(--hh-font-body);
  font-size: 1rem;             /* >=16px → no iOS zoom */
  line-height: var(--hh-leading-body);
  color: var(--hh-color-on-surface);
  background: var(--hh-color-surface);
  border: 1px solid var(--hh-color-hairline);
  border-radius: var(--hh-radius-md);
  transition: border-color var(--hh-duration) var(--hh-ease);
}
.hh-q-card__textarea {
  min-height: 6.5rem;
  resize: vertical;
}
.hh-q-card__input:focus-visible,
.hh-q-card__textarea:focus-visible {
  outline: 2px solid var(--hh-color-primary);
  outline-offset: 2px;
  border-color: var(--hh-color-primary);
}

/* Microphone button — accent (Korallenrosé), 56px lg+, 72px xs/sm */
.hh-q-card__mic {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: var(--hh-radius-full);
  background: var(--hh-color-accent);
  color: var(--hh-color-primary);
  border: 1px solid var(--hh-color-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--hh-duration) var(--hh-ease),
              background-color var(--hh-duration) var(--hh-ease);
}
@media (min-width: 768px) {
  .hh-q-card__mic { width: 56px; height: 56px; }
}
.hh-q-card__mic:focus-visible {
  outline: 2px solid var(--hh-color-primary);
  outline-offset: 3px;
}
.hh-q-card__mic svg {
  width: 26px;
  height: 26px;
  display: block;
}
.hh-q-card__mic.is-listening {
  animation: hh-mic-pulse 1.6s var(--hh-ease) infinite;
}
.hh-q-card__mic.is-processing {
  opacity: 0.6;
  cursor: wait;
}
@keyframes hh-mic-pulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(244, 164, 138, 0.65); }
  70%  { transform: scale(1.04); box-shadow: 0 0 0 14px rgba(244, 164, 138, 0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(244, 164, 138, 0); }
}

/* Mic hint caption (first-tap only) */
.hh-q-card__mic-hint {
  text-align: center;
  font-size: var(--hh-type-body-sm);
  color: var(--hh-color-secondary);
  margin: 0;
}

/* Two-name + two-text variants */
.hh-q-card__split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--hh-space-md);
  width: 100%;
  max-width: var(--hh-form-max);
  margin: 0 auto;
}
@media (min-width: 640px) {
  .hh-q-card__split { grid-template-columns: 1fr 1fr; }
}
.hh-q-card__split-field {
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-xs);
}
.hh-q-card__split-field label {
  font-size: var(--hh-type-label-caps);
  letter-spacing: var(--hh-tracking-caps);
  text-transform: uppercase;
  color: var(--hh-color-secondary);
}

/* Choice / multi-choice / yes-no — pill row */
.hh-q-card__choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hh-space-sm);
  justify-content: center;
}
.hh-q-card__choice {
  appearance: none;
  background: var(--hh-color-surface);
  color: var(--hh-color-on-surface);
  border: 1px solid var(--hh-color-border);
  border-radius: var(--hh-radius-full);
  padding: 10px var(--hh-space-lg);
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-body-md);
  cursor: pointer;
  min-height: 44px;
  transition: background-color var(--hh-duration) var(--hh-ease),
              color var(--hh-duration) var(--hh-ease);
}
.hh-q-card__choice:hover { background: var(--hh-color-paper); }
.hh-q-card__choice.is-selected,
.hh-q-card__choice[aria-pressed="true"] {
  background: var(--hh-color-primary);
  color: var(--hh-color-paper);
}
.hh-q-card__choice:focus-visible {
  outline: 2px solid var(--hh-color-primary);
  outline-offset: 2px;
}

/* Weiter (primary) CTA */
.hh-q-card__weiter {
  align-self: center;
  min-width: 200px;
  min-height: 48px;
  padding: 0 var(--hh-space-2xl);
  border-radius: var(--hh-radius-full);
  background: var(--hh-color-primary);
  color: var(--hh-color-paper);
  border: 1px solid var(--hh-color-primary);
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-body-md);
  font-weight: var(--hh-weight-medium);
  cursor: pointer;
  transition: opacity var(--hh-duration) var(--hh-ease);
}
.hh-q-card__weiter:hover { opacity: 0.92; }
.hh-q-card__weiter:disabled { opacity: 0.45; cursor: not-allowed; }
.hh-q-card__weiter:focus-visible {
  outline: 2px solid var(--hh-color-primary);
  outline-offset: 3px;
}

.hh-q-card__back {
  align-self: center;
  background: none;
  border: 0;
  padding: var(--hh-space-sm) var(--hh-space-md);
  color: var(--hh-color-secondary);
  font-size: var(--hh-type-body-sm);
  cursor: pointer;
  text-decoration: underline;
}

.hh-q-card__error[hidden] { display: none; }
.hh-q-card__error {
  text-align: center;
  color: var(--hh-color-error);
  font-size: var(--hh-type-body-sm);
}

/* Loading shimmer placeholder for schema fetch */
.hh-q-card__loading {
  text-align: center;
  color: var(--hh-color-secondary);
  font-size: var(--hh-type-body-sm);
  padding: var(--hh-space-2xl) 0;
}

/* ──────────────────────────────────────────────────────────────────────
 * 5. „Verstanden: …" confirmation panel
 * ────────────────────────────────────────────────────────────────────── */
.hh-q-confirm {
  background: var(--hh-color-neutral);
  border-radius: var(--hh-radius-xl);
  padding: var(--hh-space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-md);
  text-align: center;
}
.hh-q-confirm__lead {
  font-family: var(--hh-font-display);
  font-size: var(--hh-type-body-lg);
  margin: 0;
}
.hh-q-confirm__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--hh-space-xs);
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-body-md);
}
.hh-q-confirm__list li {
  background: var(--hh-color-surface);
  border-radius: var(--hh-radius-md);
  padding: var(--hh-space-sm) var(--hh-space-md);
}
.hh-q-confirm__actions {
  display: flex;
  gap: var(--hh-space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ──────────────────────────────────────────────────────────────────────
 * 6. Mid-flow coral upsell card
 * ────────────────────────────────────────────────────────────────────── */
.hh-mid-flow-card {
  background: var(--hh-color-accent);
  color: var(--hh-color-primary);
  border: 1px solid var(--hh-color-border);
  border-radius: var(--hh-radius-2xl);
  padding: var(--hh-space-2xl) var(--hh-space-xl);
  max-width: var(--hh-content-narrow);
  margin: var(--hh-space-xl) auto;
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-lg);
  text-align: center;
}
.hh-mid-flow-card__eyebrow {
  font-size: var(--hh-type-label-caps);
  letter-spacing: var(--hh-tracking-caps);
  text-transform: uppercase;
}
.hh-mid-flow-card__reason {
  font-family: var(--hh-font-display);
  font-size: var(--hh-type-display-md);
  line-height: var(--hh-leading-display);
  margin: 0;
  max-width: 32ch;
  margin-inline: auto;
}
.hh-mid-flow-card__bundle-line {
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-body-sm);
  color: var(--hh-color-primary);
}
.hh-mid-flow-card__cta {
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-sm);
  align-items: center;
}
@media (min-width: 640px) {
  .hh-mid-flow-card__cta { flex-direction: row; justify-content: center; }
}

/* ──────────────────────────────────────────────────────────────────────
 * 7. Form (mini-plan, magic-link)
 * ────────────────────────────────────────────────────────────────────── */
.hh-form {
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-lg);
  max-width: var(--hh-form-max);
  margin: 0 auto;
}
.hh-field {
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-xs);
}
.hh-field label {
  font-family: var(--hh-font-body);
  font-size: var(--hh-type-label-lg);
  color: var(--hh-color-on-surface);
  font-weight: var(--hh-weight-medium);
}
.hh-field input,
.hh-field select,
.hh-field textarea {
  min-height: 48px;
  padding: var(--hh-space-md) var(--hh-space-lg);
  font-family: var(--hh-font-body);
  font-size: 1rem;
  line-height: var(--hh-leading-body);
  background: var(--hh-color-surface);
  color: var(--hh-color-on-surface);
  border: 1px solid var(--hh-color-hairline);
  border-radius: var(--hh-radius-md);
  width: 100%;
}
.hh-field input:focus-visible,
.hh-field select:focus-visible,
.hh-field textarea:focus-visible {
  outline: 2px solid var(--hh-color-primary);
  outline-offset: 2px;
}
.hh-field--pill input { border-radius: var(--hh-radius-full); }
.hh-field__error {
  font-size: var(--hh-type-body-sm);
  color: var(--hh-color-error);
}
.hh-form output {
  text-align: center;
  display: block;
  min-height: 1.5em;
  font-size: var(--hh-type-body-sm);
}
.hh-form output[data-state="error"]   { color: var(--hh-color-error); }
.hh-form output[data-state="success"] { color: var(--hh-color-success); }

/* ──────────────────────────────────────────────────────────────────────
 * 8. Dashboard (post-checkout)
 * ────────────────────────────────────────────────────────────────────── */
.hh-dashboard {
  max-width: var(--hh-content-wide);
  margin: 0 auto;
  padding: var(--hh-space-xl) var(--hh-margin);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--hh-space-xl);
}
@media (min-width: 1024px) {
  .hh-dashboard {
    grid-template-columns: 280px 1fr;
    gap: var(--hh-space-3xl);
    align-items: start;
  }
}

.hh-dashboard__sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-md);
}
.hh-dashboard__nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--hh-color-surface);
  border: 1px solid var(--hh-color-hairline);
  border-radius: var(--hh-radius-md);
  padding: var(--hh-space-md) var(--hh-space-lg);
  font-family: var(--hh-font-body);
  color: var(--hh-color-on-surface);
  cursor: pointer;
  transition: border-color var(--hh-duration) var(--hh-ease);
}
.hh-dashboard__nav-item.is-active {
  border-color: var(--hh-color-border);
  background: var(--hh-color-paper);
}
.hh-dashboard__nav-title {
  display: block;
  font-weight: var(--hh-weight-medium);
}
.hh-dashboard__nav-status {
  display: block;
  font-size: var(--hh-type-body-sm);
  color: var(--hh-color-secondary);
}

.hh-dashboard__main {
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-xl);
  min-width: 0; /* prevents grid blowout from long content */
}

.hh-dashboard__title {
  font-family: var(--hh-font-display);
  font-size: var(--hh-type-display-md);
  line-height: var(--hh-leading-display);
  margin: 0;
}

/* Style picker */
.hh-dashboard__style-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--hh-space-md);
}
@media (min-width: 768px) {
  .hh-dashboard__style-picker { grid-template-columns: repeat(5, 1fr); }
}

.hh-style-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--hh-color-paper);
  border: 1px solid var(--hh-color-hairline);
  border-radius: var(--hh-radius-lg);
  padding: var(--hh-space-md);
  aspect-ratio: 4 / 5;
  min-height: 180px;
  cursor: pointer;
  transition: transform var(--hh-duration) var(--hh-ease),
              border-color var(--hh-duration) var(--hh-ease);
  font-family: var(--hh-font-body);
  color: var(--hh-color-on-surface);
}
.hh-style-thumb:hover { transform: translateY(-2px); }
.hh-style-thumb.is-selected,
.hh-style-thumb[aria-pressed="true"] {
  border-color: var(--hh-color-primary);
  background: var(--hh-color-surface);
}
.hh-style-thumb__preview {
  flex: 1 1 auto;
  width: 100%;
  border-radius: var(--hh-radius-md);
  background: var(--hh-color-neutral);
  margin-bottom: var(--hh-space-sm);
}
.hh-style-thumb__name {
  font-family: var(--hh-font-display);
  font-size: var(--hh-type-body-md);
  letter-spacing: var(--hh-tracking-display);
}

/* PDF render area */
.hh-render-status {
  font-size: var(--hh-type-body-sm);
  color: var(--hh-color-secondary);
  text-align: center;
  min-height: 1.5em;
}
.hh-pdf-link {
  align-self: center;
  display: inline-block;
  margin-top: var(--hh-space-md);
}

/* Eure Hochzeit (guest info) — single-column, photo card up top, info blocks under */
.hh-eure-hochzeit {
  max-width: var(--hh-content-prose);
  margin: 0 auto;
  padding: var(--hh-space-xl) var(--hh-margin);
  display: flex;
  flex-direction: column;
  gap: var(--hh-space-xl);
}
.hh-eure-hochzeit__hero {
  background: var(--hh-color-paper);
  border-radius: var(--hh-radius-2xl);
  padding: var(--hh-space-2xl);
  text-align: center;
}
.hh-eure-hochzeit__couple {
  font-family: var(--hh-font-display);
  font-size: var(--hh-type-display-md);
  margin: 0 0 var(--hh-space-sm);
}
.hh-eure-hochzeit__date {
  color: var(--hh-color-secondary);
  font-size: var(--hh-type-body-lg);
  margin: 0;
}

/* ──────────────────────────────────────────────────────────────────────
 * 9. Toast (mic no-result, network error, etc.)
 * ────────────────────────────────────────────────────────────────────── */
.hh-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hh-space-xl) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: var(--hh-color-primary);
  color: var(--hh-color-paper);
  padding: var(--hh-space-md) var(--hh-space-lg);
  border-radius: var(--hh-radius-full);
  font-size: var(--hh-type-body-sm);
  max-width: calc(100vw - (var(--hh-margin) * 2));
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hh-duration) var(--hh-ease),
              transform var(--hh-duration) var(--hh-ease);
  z-index: 9999;
}
.hh-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hh-toast--error { background: var(--hh-color-error); }

/* ──────────────────────────────────────────────────────────────────────
 * 10. Sticky action bar (used by checkout-bound CTAs on long pages)
 * ────────────────────────────────────────────────────────────────────── */
.hh-action-bar--sticky {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--hh-color-surface);
  padding: var(--hh-space-md) var(--hh-margin) calc(var(--hh-space-md) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hh-color-hairline);
  z-index: 50;
  display: flex;
  justify-content: center;
}

/* ──────────────────────────────────────────────────────────────────────
 * 11. Reduced motion
 * ────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hh-q-card__mic.is-listening { animation: none; }
  .hh-style-thumb:hover { transform: none; }
  .hh-toast { transition: none; }
}
