/* mts survey kiosk — runtime-themed via CSS custom properties set from the API. */
:root {
    --k-theme: #ec1a3b;
    --k-bg: #ffffff;
    --k-text: #111827;
    --k-btn: #ec1a3b;
    --k-btn-text: #ffffff;
    --k-font: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--k-bg);
    background-size: cover;
    background-position: center;
    color: var(--k-text);
    font-family: var(--k-font);
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: clamp(1.5rem, 4vw, 4rem);
    min-height: 0;
}

.screen__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: clamp(1.5rem, 4vh, 3rem);
    min-height: 0;
}

.logo { max-height: 12vh; width: auto; object-fit: contain; }

.q-title {
    font-size: clamp(1.9rem, 4.6vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 0;
    max-width: 20ch;
}

.q-help { font-size: clamp(1rem, 2vw, 1.4rem); opacity: 0.7; margin: 0; max-width: 40ch; }

.hint { font-size: clamp(1rem, 2vw, 1.3rem); opacity: 0.6; margin-top: 1rem; }

/* Progress bar */
.progress {
    height: 8px;
    width: 100%;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
    flex: none;
    margin-bottom: 2rem;
}
.progress__fill {
    height: 100%;
    background: var(--k-theme);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* ---- Base option button --------------------------------------------- */
.options { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 42rem; }
.options--row { flex-direction: row; }
.options--row .option { flex: 1; min-height: 6rem; font-size: clamp(1.25rem, 3vw, 1.9rem); }

.option {
    appearance: none;
    border: none;
    border-radius: 1.25rem;
    padding: clamp(1rem, 2.5vw, 1.6rem);
    min-height: 3.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: clamp(1.15rem, 2.2vw, 1.5rem);
    font-weight: 600;
    font-family: inherit;
    background: var(--k-btn);
    color: var(--k-btn-text);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.option:active { transform: scale(0.97); }
/* Selected = clear inversion so it reads on any button colour. */
.option.is-selected {
    background: var(--k-btn-text);
    color: var(--k-btn);
    box-shadow: inset 0 0 0 3px var(--k-btn);
}
.option.is-selected::after {
    content: '✓';
    margin-left: 0.5rem;
    font-weight: 800;
}

/* ---- Rating / NPS number buttons ------------------------------------ */
.scale { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; max-width: 48rem; }
.scale__btn {
    appearance: none;
    border: none;
    width: clamp(3.25rem, 7vw, 5rem);
    height: clamp(3.25rem, 7vw, 5rem);
    border-radius: 1rem;
    font-size: clamp(1.2rem, 2.4vw, 1.7rem);
    font-weight: 700;
    font-family: inherit;
    background: var(--k-btn);
    color: var(--k-btn-text);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.08s ease;
}
.scale__btn:active { transform: scale(0.92); }
.scale__btn.is-selected {
    background: var(--k-btn-text);
    color: var(--k-btn);
    box-shadow: inset 0 0 0 3px var(--k-btn);
    transform: scale(1.08);
}
.scale__ends { display: flex; justify-content: space-between; width: 100%; max-width: 48rem; font-size: 1rem; opacity: 0.55; margin-top: 0.25rem; }

/* Footer nav */
.nav {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2rem;
    gap: 1rem;
}
.btn {
    appearance: none;
    border: none;
    border-radius: 1rem;
    padding: 1rem 2.25rem;
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.btn--primary { background: var(--k-theme); color: var(--k-btn-text); box-shadow: 0 6px 16px color-mix(in srgb, var(--k-theme) 40%, transparent); }
.btn--ghost { background: transparent; color: inherit; opacity: 0.65; }
.btn--big { padding: 1.25rem 3rem; font-size: clamp(1.2rem, 2.6vw, 1.7rem); }
.btn--sm { padding: 0.6rem 1.5rem; border-radius: 0.85rem; font-size: clamp(0.9rem, 1.8vw, 1.15rem); }
.btn[disabled] { opacity: 0.3; pointer-events: none; box-shadow: none; }

/* Conversation (chat) mode */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat .progress { max-width: 52rem; margin: clamp(0.75rem, 2vw, 1.5rem) auto 0; }
.chat__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: clamp(1rem, 3vw, 2rem);
    width: 100%;
    max-width: 52rem;
    margin: 0 auto;
}
.chat__row { display: flex; align-items: flex-end; gap: 0.6rem; }
.chat__row--in { justify-content: flex-start; }
.chat__row--out { justify-content: flex-end; }
.chat__avatar {
    flex: none;
    width: clamp(2.4rem, 6vw, 3.4rem);
    height: clamp(2.4rem, 6vw, 3.4rem);
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.chat__avatar--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--k-theme);
    color: var(--k-btn-text);
    font-weight: 800;
    font-size: 1.3rem;
}
.chat__bubble {
    max-width: min(80%, 34rem);
    padding: 0.85rem 1.2rem;
    border-radius: 1.25rem;
    font-size: clamp(1.05rem, 2.2vw, 1.45rem);
    line-height: 1.3;
    animation: chatIn 0.25s ease;
}
.chat__bubble--in {
    background: color-mix(in srgb, var(--k-text) 8%, #ffffff);
    color: var(--k-text);
    border-bottom-left-radius: 0.35rem;
}
.chat__bubble--out {
    background: var(--k-btn);
    color: var(--k-btn-text);
    border-bottom-right-radius: 0.35rem;
    font-weight: 600;
}
.chat__q { font-weight: 700; }
.chat__help { margin-top: 0.3rem; font-size: 0.82em; opacity: 0.7; }
@keyframes chatIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Typing indicator */
.chat__typing { display: inline-flex; align-items: center; gap: 0.35rem; padding: 1.1rem 1.2rem; }
.chat__typing span {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--k-text) 45%, transparent);
    animation: chatDot 1.2s infinite ease-in-out;
}
.chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatDot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Inline answer controls within the conversation */
.chat__controls {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin: 0.3rem 0 0.5rem calc(clamp(2.4rem, 6vw, 3.4rem) + 0.6rem);
}
.chat__controls > * { max-width: 100%; }
.chat__controls .options,
.chat__controls .options--list,
.chat__controls .options--grid,
.chat__controls .options--cards,
.chat__controls .scale { max-width: 100%; }
.chat__controls .options--row .option { min-height: 4.5rem; }
.chat__nav { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; margin-top: 0.25rem; }
.chat__nav .btn--ghost { margin-right: auto; }
.btn__spacer { flex: 1; }

/* Attract / start screen */
.attract { cursor: pointer; position: relative; }
.attract__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    border: 0;
}
/* Embedded players (YouTube/Vimeo) must not capture taps, so the
   tap-anywhere-to-start handler on the attract screen still fires. */
.attract__video--embed { pointer-events: none; }
/* Configurable scrim over video backgrounds so dark/red text stays legible.
   Sits above the video (same z-index, later in DOM) and below the body content
   (z-index 1). The tint colour/opacity is set from the admin via --k-attract-scrim. */
.attract__scrim {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--k-attract-scrim, transparent);
    pointer-events: none;
}
.attract .screen__body { position: relative; z-index: 1; }

/* ---- Start-screen effects ------------------------------------------------
   Optional per-element text/drop shadows and looping animations, configured
   in the admin under "Start screen effects" and applied via CSS custom
   properties set by applyTheme(). Each element reads a per-element shadow and
   animation shorthand, plus a magnitude (`--anim-amp`) the keyframes consume.
   Everything defaults to `none`, so untouched surveys are unaffected. */
.attract .q-title {
    font-size: calc(clamp(1.9rem, 4.6vw, 3.2rem) * var(--k-as-title-scale, 1));
    text-shadow: var(--k-as-title-shadow, none);
    animation: var(--k-as-title-anim, none);
    --anim-amp: var(--k-as-title-amp, 0);
    will-change: transform;
}
.attract .q-help {
    font-size: calc(clamp(1rem, 2vw, 1.4rem) * var(--k-as-subtitle-scale, 1));
    text-shadow: var(--k-as-subtitle-shadow, none);
    animation: var(--k-as-subtitle-anim, none);
    --anim-amp: var(--k-as-subtitle-amp, 0);
    will-change: transform;
}
/* Button effects land on the button itself: `box-shadow` (glow/shadow) rather
   than the label's text-shadow. Disabled → app.css's default primary glow. */
.attract .btn--primary {
    font-size: calc(clamp(1.2rem, 2.6vw, 1.7rem) * var(--k-as-button-scale, 1));
    box-shadow: var(--k-as-button-shadow, 0 6px 16px color-mix(in srgb, var(--k-theme) 40%, transparent));
    animation: var(--k-as-button-anim, none);
    --anim-amp: var(--k-as-button-amp, 0);
}
.attract .logo {
    filter: var(--k-as-logo-shadow, none);
    animation: var(--k-as-logo-anim, none);
    --anim-amp: var(--k-as-logo-amp, 0);
}

/* Keyframes read `--anim-amp`, whose unit is chosen (px/deg/scale factor) by
   applyTheme() to match the active animation type — only one runs per element. */
@keyframes k-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(var(--anim-amp, 1.06)); } }
@keyframes k-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(calc(-1 * var(--anim-amp, 12px))); } }
@keyframes k-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(calc(-1 * var(--anim-amp, 3deg))); } 75% { transform: rotate(var(--anim-amp, 3deg)); } }
@keyframes k-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(calc(-1 * var(--anim-amp, 6px))); }
    40% { transform: translateX(var(--anim-amp, 6px)); }
    60% { transform: translateX(calc(-0.6 * var(--anim-amp, 6px))); }
    80% { transform: translateX(calc(0.6 * var(--anim-amp, 6px))); }
}
@media (prefers-reduced-motion: reduce) {
    .attract .q-title, .attract .q-help, .attract .btn--primary, .attract .logo { animation: none !important; }
}

/* Pairing / status screens */
.center-card {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    max-width: 30rem;
}
.pair-input {
    font-size: 2rem;
    letter-spacing: 0.4rem;
    text-align: center;
    text-transform: uppercase;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.75rem;
    width: 12rem;
    font-family: inherit;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
}
.error { color: var(--k-theme); font-weight: 600; min-height: 1.2em; }

/* Offline / sync indicator */
.status-dot {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: none;
}
.status-dot.is-visible { display: inline-flex; align-items: center; gap: 0.35rem; }

/* ---- Display variants ------------------------------------------------ */

/* Choice: LIST — outlined rows with a lettered badge, left-aligned. */
.options--list { display: flex; flex-direction: column; gap: 0.9rem; max-width: 40rem; }
.option--list {
    justify-content: flex-start;
    gap: 1.1rem;
    text-align: left;
    padding: 1.2rem 1.4rem;
    background: var(--k-bg);
    color: var(--k-text);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--k-text) 16%, transparent), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.option--list .option__badge {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 999px;
    font-weight: 800;
    background: var(--k-btn);
    color: var(--k-btn-text);
}
.option--list .option__label { flex: 1; }
.option--list.is-selected { background: var(--k-btn); color: var(--k-btn-text); box-shadow: 0 4px 14px color-mix(in srgb, var(--k-theme) 35%, transparent); }
.option--list.is-selected .option__badge { background: var(--k-btn-text); color: var(--k-btn); }
.option--list.is-selected::after { content: none; }

/* Choice: GRID — solid, bold, square-ish tiles. */
.options--grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; max-width: 44rem; }
.option--tile {
    flex-direction: column;
    min-height: 7rem;
    justify-content: center;
    font-size: clamp(1.25rem, 3vw, 1.7rem);
    font-weight: 700;
}

/* Choice: CARDS — elevated cards with a media / accent header + label. */
.options--cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.4rem; max-width: 46rem; }
.option--card {
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    min-height: 9rem;
    background: var(--k-bg);
    color: var(--k-text);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
    border: 1px solid color-mix(in srgb, var(--k-text) 8%, transparent);
}
.option--card img { display: block; width: 100%; height: 8rem; object-fit: cover; }
.option--card .option__accent { display: block; width: 100%; height: 0.6rem; background: var(--k-theme); flex: none; }
.option--card .option__label {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 1.4rem 1rem;
    font-size: clamp(1.2rem, 2.6vw, 1.6rem);
    font-weight: 700;
}
.option--card.is-selected {
    background: color-mix(in srgb, var(--k-theme) 8%, var(--k-bg));
    color: var(--k-text);
    box-shadow: 0 0 0 4px var(--k-theme), 0 10px 26px rgba(0, 0, 0, 0.12);
}
.option--card.is-selected::after { content: none; }

/* Boolean: emoji / thumbs tiles */
.option--icon {
    flex-direction: column;
    gap: 0.75rem;
    min-height: 10rem;
    background: color-mix(in srgb, var(--k-theme) 5%, var(--k-bg));
    color: var(--k-text);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--k-text) 12%, transparent);
}
.option--icon.is-selected {
    background: color-mix(in srgb, var(--k-theme) 12%, var(--k-bg));
    color: var(--k-text);
    box-shadow: inset 0 0 0 3px var(--k-theme);
}
.option--icon.is-selected::after { content: none; }
.option__glyph { font-size: clamp(3rem, 11vw, 5rem); line-height: 1; }

/* Boolean: animated 50/50 split screen */
.options--split {
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    width: 100%;
    max-width: 60rem;
    align-items: stretch;
    min-height: 46vh;
}
.option--split {
    flex: 1;
    flex-direction: column;
    gap: 1rem;
    border-radius: 2rem;
    font-size: clamp(1.5rem, 3.5vw, 2.4rem);
    font-weight: 700;
    color: #fff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    animation: splitInLeft 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.option--split:last-child { animation-name: splitInRight; }
.option--split-yes,
.option--split-yes.is-selected { background: #16a34a; color: #fff; }
.option--split-no,
.option--split-no.is-selected { background: #dc2626; color: #fff; }
.option--split .option__glyph { font-size: clamp(4.5rem, 15vw, 8rem); }
.option--split.is-selected { box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.85), 0 12px 30px rgba(0, 0, 0, 0.18); }
.option--split.is-selected::after { content: none; }
@keyframes splitInLeft { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes splitInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* Thank-you pop-in */
.thankyou-pop { animation: thankyouPop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes thankyouPop { 0% { opacity: 0; transform: scale(0.85); } 60% { transform: scale(1.03); } 100% { opacity: 1; transform: scale(1); } }

/* Rating: STARS */
.scale--stars { gap: 0.35rem; }
.scale__star {
    background: transparent;
    box-shadow: none;
    width: auto;
    height: auto;
    padding: 0 0.15rem;
    font-size: clamp(2.75rem, 8vw, 4.5rem);
    color: color-mix(in srgb, var(--k-text) 20%, transparent);
    transition: transform 0.08s ease, color 0.12s ease;
}
.scale__star.is-selected {
    background: transparent;
    box-shadow: none;
    transform: none;
    color: var(--k-theme);
}

/* Rating: EMOJI faces */
/* Keep all 5 faces on one row. `container-type` makes the emoji size track
   the control's own width (not the viewport), so they scale down to fit the
   narrower, avatar-indented column in chat mode instead of wrapping. */
.scale--emoji {
    flex-wrap: nowrap;
    width: 100%;
    gap: clamp(0.4rem, 2vw, 1.75rem);
    container-type: inline-size;
}
.emoji-btn {
    background: transparent;
    box-shadow: none;
    width: auto;
    height: auto;
    flex: 0 0 auto;
    padding: 0.15rem 0.3rem;
    font-size: clamp(2.25rem, 14cqw, 6rem);
    opacity: 0.5;
    transform: scale(0.9);
    transition: transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
}
.emoji-btn.is-selected {
    background: transparent;
    box-shadow: none;
    opacity: 1;
    transform: scale(1.25);
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.25));
}

/* Rating: SLIDER / potentiometer */
.slider { width: 100%; max-width: 34rem; display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.slider__readout { font-size: clamp(3.5rem, 14vw, 6rem); font-weight: 800; line-height: 1; color: var(--k-theme); }
.slider__range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 18px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.12);
    outline: none;
}
.slider__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--k-theme);
    border: 5px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}
.slider__range::-moz-range-thumb {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--k-theme);
    border: 5px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.fade-in { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* "Are you there?" idle prompt — overlays the survey after inactivity. */
.idle-prompt {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.55);
    animation: fadeIn 0.2s ease;
}
.idle-prompt__box {
    background: var(--k-bg);
    color: var(--k-text);
    border-radius: 1.5rem;
    padding: clamp(2rem, 5vw, 3rem);
    max-width: 32rem;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    animation: thankyouPop 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.idle-prompt__title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; margin: 0; }
.idle-prompt__text { font-size: clamp(1.05rem, 2.4vw, 1.4rem); opacity: 0.75; margin: 0; }
.idle-prompt__text span { font-weight: 700; opacity: 1; }
