/* ============================================================================
   INNOVATURA — Labor (Live-Demos)
   Self-contained demo page. Reuses tokens/base/components; adds demo widgets.
   ============================================================================ */

/* Layer-Reihenfolge fixieren (labor-Chunk lädt vor dem Shared-Chunk). */
@layer tokens, reset, base, components, sections, animations, entdecker;

@layer sections {

  /* Muted text that sits on the tinted stage / CTA surfaces needs a darker
     tone than --color-neutral to keep >= 4.5:1 (AA) — neutral is only AA on
     the pure page surface. */
  .lab__main { --lab-muted: var(--farbe-text-leise); }

  /* ======================== SHELL ======================== */
  .lab__header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--gutter);
    background: color-mix(in srgb, var(--color-surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
  }
  .lab__logo {
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    font-size: 1.1rem;
  }

  .lab__main {
    max-width: var(--max-width);
    margin-inline: auto;
    padding: var(--space-3xl) var(--gutter) var(--space-4xl);
  }

  /* ======================== INTRO ======================== */
  .lab__intro { margin-bottom: var(--space-4xl); max-width: 42rem; }
  .lab__eyebrow {
    font-size: var(--text-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--color-accent-deep);
    margin-bottom: var(--space-md);
  }
  .lab__title {
    font-size: var(--text-hero);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--space-lg);
  }
  .lab__lead {
    font-size: var(--text-body);
    line-height: var(--leading-body);
    color: var(--color-primary);
    margin-bottom: var(--space-md);
  }
  .lab__note-global {
    font-size: var(--text-small);
    color: var(--color-neutral);
    line-height: var(--leading-small);
  }

  /* ======================== DEMO FRAME ======================== */
  .lab__demo {
    padding: var(--space-3xl) 0;
    border-top: 1px solid var(--color-border);
  }
  .lab__demo-head { max-width: 42rem; margin-bottom: var(--space-xl); }
  .lab__demo-tag {
    display: inline-block;
    font-size: var(--text-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--color-accent-deep);
    margin-bottom: var(--space-sm);
  }
  .lab__demo-title {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    letter-spacing: var(--tracking-section);
    margin-bottom: var(--space-sm);
  }
  .lab__demo-desc {
    font-size: var(--text-body);
    color: var(--color-neutral);
    line-height: var(--leading-body);
  }
  .lab__demo-desc em { color: var(--color-primary); font-style: normal; font-weight: 600; }

  .lab__stage {
    background: color-mix(in srgb, var(--color-surface) 96%, var(--color-border));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: clamp(var(--space-lg), 4vw, var(--space-2xl));
    box-shadow: var(--shadow-sm);
  }

  /* Not flex: inline children (<strong>, <em>, text runs) must flow as one
     paragraph. The dot is absolutely positioned so text wraps normally. */
  .lab__real {
    position: relative;
    padding-left: 1.1rem;
    margin-top: var(--space-lg);
    font-size: var(--text-small);
    color: var(--color-neutral);
    line-height: var(--leading-small);
  }
  .lab__real strong { color: var(--color-primary); }
  .lab__real em { font-style: normal; color: var(--color-primary); }
  .lab__real-dot {
    position: absolute;
    left: 0;
    top: 0.5em;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
  }

  /* ======================== DEMO 1 · RESERVIERUNG ======================== */
  .resv { display: flex; flex-direction: column; gap: var(--space-lg); max-width: 34rem; margin-inline: auto; }
  .resv__step { display: flex; flex-direction: column; gap: var(--space-sm); }
  .resv__label {
    font-size: var(--text-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--lab-muted);
  }
  .resv__days {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: var(--space-xs);
    scrollbar-width: thin;
  }
  .resv__day {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 3.6rem;
    padding: var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font: inherit;
    transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease;
  }
  .resv__day:hover { border-color: var(--color-accent); }
  .resv__day[aria-checked="true"] {
    background: var(--color-accent-deep);
    border-color: var(--color-accent-deep);
    color: var(--farbe-flaeche-1);
  }
  .resv__day-wd { font-size: var(--text-label); text-transform: uppercase; letter-spacing: 0.04em; }
  .resv__day-num { font-size: 1.1rem; font-weight: 600; }

  .resv__stepper { display: flex; align-items: center; gap: var(--space-md); }
  .resv__pm {
    width: 44px; height: 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    font-size: 1.25rem;
    cursor: pointer;
    transition: border-color var(--duration-fast) ease;
  }
  .resv__pm:hover { border-color: var(--color-accent); }
  .resv__count { font-size: 1.35rem; font-weight: 600; min-width: 1.5ch; text-align: center; }
  .resv__count-label { color: var(--lab-muted); font-size: var(--text-small); }

  .resv__slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr));
    gap: 0.75rem;
  }
  .resv__slot {
    padding: var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font: inherit;
    text-align: center;
    transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease;
  }
  .resv__slot:hover:not(:disabled) { border-color: var(--color-accent); }
  .resv__slot[aria-checked="true"] {
    background: var(--color-accent-deep);
    border-color: var(--color-accent-deep);
    color: var(--farbe-flaeche-1);
  }
  .resv__slot:disabled { opacity: 0.4; cursor: not-allowed; text-decoration: line-through; }

  .resv__done {
    padding: var(--space-lg);
    background: color-mix(in srgb, var(--color-success) 12%, var(--color-surface));
    border: 1px solid var(--color-success);
    border-radius: var(--radius-md);
    text-align: center;
    line-height: var(--leading-body);
  }
  .resv__done strong { color: var(--color-primary); }

  /* ======================== DEMO 2 · EDITOR ======================== */
  .editor { max-width: 34rem; margin-inline: auto; }
  .editor__bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
  }
  .editor__toggle, .editor__save {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font: inherit;
    font-size: var(--text-small);
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
  }
  .editor__toggle { background: var(--color-surface); border: 1px solid var(--color-border); }
  .editor__toggle[aria-pressed="true"] { background: var(--color-accent-deep); border-color: var(--color-accent-deep); color: var(--farbe-flaeche-1); }
  .editor__save { background: var(--color-accent-deep); border: none; color: var(--farbe-flaeche-1); }
  .editor__hint { font-size: var(--text-small); color: var(--lab-muted); }

  .editor__preview {
    padding: var(--space-2xl);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-align: center;
  }
  .editor__eyebrow {
    font-size: var(--text-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--editor-accent, var(--color-accent-deep));
    margin-bottom: var(--space-sm);
  }
  .editor__h {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--space-sm);
  }
  .editor__p { color: var(--color-neutral); line-height: var(--leading-body); margin-bottom: var(--space-lg); max-width: 30ch; margin-inline: auto; }
  .editor__btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    background: var(--editor-accent, var(--color-accent-deep));
    color: var(--farbe-flaeche-1);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-small);
  }
  /* Edit mode: fields become obviously editable */
  .editor.is-editing [data-field] {
    outline: 2px dashed var(--color-accent);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
    cursor: text;
  }
  .editor.is-editing .editor__btn { cursor: text; }

  .editor__controls { margin-top: var(--space-md); }
  .editor__ctrl { display: flex; align-items: center; gap: var(--space-md); font-size: var(--text-small); color: var(--color-neutral); }
  .editor__swatches { display: flex; gap: var(--space-sm); }
  .editor__swatch {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    cursor: pointer;
    padding: 0;
  }
  .editor__swatch[aria-checked="true"] { border-color: var(--color-primary); transform: scale(1.12); }

  .editor__toast {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: color-mix(in srgb, var(--color-success) 14%, var(--color-surface));
    border: 1px solid var(--color-success);
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 600;
    font-size: var(--text-small);
  }

  /* ======================== DEMO 3 · KI-TEXT ======================== */
  .kitext { max-width: 40rem; margin-inline: auto; display: flex; flex-direction: column; gap: var(--space-lg); }
  .kitext__field { display: flex; flex-direction: column; gap: var(--space-sm); }
  .kitext__label {
    font-size: var(--text-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--lab-muted);
  }
  .kitext__hint { text-transform: none; letter-spacing: normal; font-weight: 400; }
  .kitext__pills { display: flex; flex-wrap: wrap; gap: 0.75rem; }
  .kitext__pill {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1.05rem;
    min-height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font: inherit;
    font-size: var(--text-small);
    cursor: pointer;
    transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease;
  }
  .kitext__pill:hover { border-color: var(--color-accent); }
  .kitext__pill[aria-checked="true"] { background: var(--color-accent-deep); border-color: var(--color-accent-deep); color: var(--farbe-flaeche-1); }
  .kitext__pill:disabled { opacity: 0.4; cursor: not-allowed; }
  .kitext__go { align-self: flex-start; }
  .kitext__out {
    padding: var(--space-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }
  .kitext__result { font-size: 1.1rem; line-height: var(--leading-body); min-height: 3em; }
  .kitext__result::after { content: '▍'; color: var(--color-accent); animation: labBlink 1s step-end infinite; }
  .kitext__result.is-done::after { content: none; }
  .kitext__actions { display: flex; gap: 0.75rem; margin-top: var(--space-md); flex-wrap: wrap; }
  @keyframes labBlink { 50% { opacity: 0; } }

  /* ======================== DEMO 4 · CHATBOT ======================== */
  .chat { max-width: 34rem; margin-inline: auto; display: flex; flex-direction: column; gap: var(--space-md); }
  .chat__window {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    min-height: 14rem;
    max-height: 22rem;
    overflow-y: auto;
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }
  .chat__msg {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-lg);
    line-height: var(--leading-small);
    font-size: var(--text-small);
    white-space: pre-line;
  }
  .chat__msg--bot { align-self: flex-start; background: color-mix(in srgb, var(--color-border) 40%, var(--color-surface)); border-bottom-left-radius: var(--radius-sm); }
  .chat__msg--user { align-self: flex-end; background: var(--color-accent-deep); color: var(--farbe-flaeche-1); border-bottom-right-radius: var(--radius-sm); }
  .chat__msg--typing { color: var(--color-neutral); font-style: italic; }
  .chat__suggest { display: flex; flex-wrap: wrap; gap: 0.625rem; }
  .chat__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.95rem;
    min-height: 40px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font: inherit;
    font-size: var(--text-small);
    color: var(--color-accent-deep);
    cursor: pointer;
    transition: border-color var(--duration-fast) ease;
  }
  .chat__chip:hover { border-color: var(--color-accent); }
  .chat__form { display: flex; gap: var(--space-sm); }
  .chat__input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    font: inherit;
  }
  .chat__input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; border-color: var(--color-accent); }
  .chat__send {
    flex: none;
    width: 44px; height: 44px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--color-accent-deep);
    color: var(--farbe-flaeche-1);
    font-size: 1.2rem;
    cursor: pointer;
  }

  /* ======================== CTA + FOOTER ======================== */
  .lab__cta {
    margin-top: var(--space-4xl);
    padding: var(--space-3xl);
    text-align: center;
    background: color-mix(in srgb, var(--color-accent-muted) 60%, var(--color-surface));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
  }
  .lab__cta-title { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: var(--tracking-section); margin-bottom: var(--space-md); }
  .lab__cta-text { max-width: 42ch; margin: 0 auto var(--space-xl); color: var(--lab-muted); line-height: var(--leading-body); }
  .lab__cta-actions { display: flex; gap: var(--space-md); justify-content: center; flex-wrap: wrap; }

  .lab__footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    padding: var(--space-2xl) var(--gutter);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-small);
  }
  .lab__footer-link { color: var(--color-neutral); }
  .lab__footer-link:hover { color: var(--color-accent-deep); }
  .lab__footer-sep { color: var(--color-border); }

  @media (prefers-reduced-motion: reduce) {
    .kitext__result::after { animation: none; }
  }
}
