/* Survey flow: rate frame, dot tape, race grid, profile chips, team filter bar. */
/* ── Team assessment layout ──────────────────────────────────────────── */
.team-filter-bar {
    position: sticky;
    top: var(--mud-appbar-height, 64px);
    z-index: 10;
    background: var(--mud-palette-background);
    padding: 8px 0;
    box-shadow: none;
    opacity: 1;
    transition: box-shadow 0.3s ease, opacity 0.25s ease;
}
.team-filter-bar.team-filter-scrolled {
    box-shadow: 0 3px 3px -2px rgba(0,0,0,0.15);
}
.team-filter-bar.team-filter-hidden {
    opacity: 0;
    pointer-events: none;
}
/* Mobile: force manager portion to wrap in attention chips */
@media (max-width: 600px) {
    .team-attention-chip > :nth-child(2) {
        flex-basis: 100%;
    }
}


/* ── Survey flow ─────────────────────────────────────────────────────── */
.survey-flow {
    touch-action: pan-y;
    position: relative; /* establish stacking context */
    min-height: calc(calc(var(--dvh, 1vh) * 100) - var(--mud-appbar-height, 48px) - 80px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Rate phase: fixed header + scrollable levels + fixed footer */
/* Survey rate frame — normal flow, levels scroll within a capped area */
.survey-flow-panel, .survey-rate-frame { margin: 0 auto; }
@media (min-width: 960px) { .survey-flow-panel, .survey-rate-frame { margin: 0; } }
.survey-rate-frame {
    max-width: 700px;
    background: var(--mud-palette-surface);
    border-radius: 8px;
    border: 1px solid var(--mud-palette-divider);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(calc(var(--dvh, 1vh) * 100) - var(--mud-appbar-height, 48px) - 120px);
}
.survey-rate-header {
    padding: 8px 12px 0 12px;
    border-bottom: 1px solid var(--mud-palette-divider);
}
.survey-rate-levels {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.survey-rate-footer {
    padding: 6px 8px;
    border-top: 1px solid var(--mud-palette-divider);
    position: sticky;
    bottom: 0;
    background: var(--mud-palette-surface);
    z-index: 1;
}
@media (max-width: 600px) {
    .survey-rate-footer {
        position: fixed;
        bottom: env(safe-area-inset-bottom, 0);
        left: 0;
        right: 0;
        z-index: 100;
        padding: 6px 12px;
        box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
        transition: transform 0.25s ease;
    }
    .survey-rate-footer.footer-hidden {
        transform: translateY(100%);
    }
    .survey-rate-frame {
        padding-bottom: calc(52px + env(safe-area-inset-bottom, 0));
    }
}
/* Dot tape: horizontal scroll, fades at edges */
.survey-dot-tape {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    -webkit-mask-image: linear-gradient(to right, transparent, black 12%, black 88%, transparent);
    mask-image: linear-gradient(to right, transparent, black 12%, black 88%, transparent);
}
.survey-dot-tape::-webkit-scrollbar { display: none; }
/* Desktop: allow click-drag scrolling without selecting dot/chip contents */
@media (hover: hover) and (pointer: fine) {
    .survey-dot-tape { user-select: none; -webkit-user-select: none; }
}
.survey-dot-tape-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 40px; /* extra padding so edge dots can scroll to center */
    width: max-content;
    min-width: 100%;
}
.survey-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.15s;
    /* No cursor:pointer — dots are now decorative visual progress markers.
       The surrounding .survey-dot-group-chip button carries the click. */
}
.survey-dot-current {
    width: 10px; height: 10px;
}
.survey-dot-group-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 5px;
    border-radius: 10px;
    border: 1.5px solid;
    margin: 0 2px;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    min-height: 24px;
    /* Button-default overrides — .survey-dot-group-chip is now a <button>.
       Border-color + background come from the inline style (per-group
       colour); reset font/colour/text-align so button UA styles don't
       leak. */
    font: inherit;
    color: inherit;
    text-align: inherit;
}
.survey-dot-group-chip:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
}
.survey-dot-group-chip.active {
    transform: scale(1.08);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
/* Larger dots + spacing + nav buttons on touch devices */
@media (pointer: coarse) {
    .survey-dot { width: 10px; height: 10px; }
    .survey-dot-current { width: 14px; height: 14px; }
    .survey-dot-group-chip { gap: 6px; padding: 4px 7px; }
    .survey-rate-footer > div { padding: 0 8px; }
    .survey-rate-footer .survey-nav-btn { margin: 0 -8px; padding: 12px; }
}

/* Slide transition animations */
@keyframes survey-slide-in-right {
    from { transform: translateX(50px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes survey-slide-in-left {
    from { transform: translateX(-50px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.survey-slide-right {
    animation: survey-slide-in-right 0.25s ease-out;
}
.survey-slide-left {
    animation: survey-slide-in-left 0.25s ease-out;
}

/* Gentle glow pulse for overview dots — opacity + outline glow for sub-pixel smooth rendering */
@keyframes survey-dot-pulse {
    0%, 100% { opacity: 0.55; filter: brightness(0.9); }
    50% { opacity: 1; filter: brightness(1.2) drop-shadow(0 0 1px currentColor); }
}
/* Grey and red pulse in sync (same duration + shared timing) */
.survey-dot-unrated,
.survey-dot-below {
    animation: survey-dot-pulse 2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

/* Countdown bar under selected level */
.survey-countdown-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--mud-palette-primary);
    border-radius: 0 0 2px 2px;
    transform-origin: left;
    animation: survey-bar-in var(--anim-speed, 150ms) ease-out forwards,
               survey-bar-shrink var(--countdown-duration) linear var(--anim-speed, 150ms) forwards;
}
@keyframes survey-bar-in {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}
@keyframes survey-bar-shrink {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}
.survey-transition-bar {
    height: 3px;
    margin-top: 12px;
    border-radius: 2px;
    background: var(--bar-color, var(--mud-palette-primary));
    transform-origin: left;
    animation: survey-bar-in 300ms ease-out forwards,
               survey-bar-shrink var(--transition-duration, 6000ms) linear 300ms forwards;
}

/* Subtle pulse on the "Ready!" check in the transition card. One brief scale-up
   repeating every 1.5s — no confetti, no looping hard animation. */
.survey-ready-pulse {
    animation: survey-ready-pulse 1.6s ease-in-out infinite;
}
@keyframes survey-ready-pulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    30%      { transform: scale(1.18); filter: brightness(1.15); }
}

/* ── Race grid: level rows + track columns side by side ── */
.survey-race-grid {
    display: grid;
    grid-template-columns: 1fr auto;
}
.survey-race-track {
    display: flex;
    gap: 4px;
    padding: 0 8px 0 4px;
}
.survey-race-track.team-mode {
    gap: 2px;
    padding: 0 4px 0 2px;
}
.survey-race-col {
    width: 24px;
    position: relative;
}
.team-mode .survey-race-col {
    width: 18px;
}
.team-mode .survey-race-line-check,
.team-mode .survey-race-line-target,
.team-mode .survey-race-line-self {
    width: 8px;
}
/* Continuous check line — color set inline to match rating grade */
.survey-race-line-check {
    width: 10px;
    margin: 0 auto;
    border-radius: 5px;
    opacity: 0.5;
    outline: 1.5px solid;
    outline-offset: -1px;
}
/* Continuous target line — single element */
.survey-race-line-target {
    width: 10px;
    margin: 0 auto;
    border-radius: 5px;
    opacity: 0.5;
    outline: 1.5px solid color-mix(in srgb, var(--mud-palette-warning) 70%, black);
    outline-offset: -1px;
    background: repeating-linear-gradient(
        to bottom,
        var(--mud-palette-warning) 0, var(--mud-palette-warning) 6px,
        transparent 6px, transparent 12px
    );
}
/* Self-rating line (team mode) — dimmed info color, dashed */
.survey-race-line-self {
    width: 10px;
    margin: 0 auto;
    border-radius: 5px;
    opacity: 0.35;
    outline: 1.5px solid color-mix(in srgb, var(--mud-palette-info) 70%, black);
    outline-offset: -1px;
    background: repeating-linear-gradient(
        to bottom,
        var(--mud-palette-info) 0, var(--mud-palette-info) 4px,
        transparent 4px, transparent 8px
    );
}
/* Missing self-assessment — wavy/curly placeholder line */
.survey-race-line-missing {
    width: 8px;
    height: 100%;
    margin: 0 auto;
    opacity: 0.3;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12'%3E%3Cpath d='M0,6 Q2,0 4,6 Q6,12 8,6' fill='none' stroke='%239e9e9e' stroke-width='1.5'/%3E%3C/svg%3E") repeat-y center;
}
/* Icon floats at the correct vertical position */
.survey-race-icon {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

/* Level row selection nudge */
@keyframes survey-nudge {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.survey-level-nudge {
    animation: survey-nudge 0.35s ease-out;
}

/* ── Profile list expand/collapse animation ── */
.survey-profile-list {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
}
.survey-profile-list > * {
    overflow: hidden;
}
.survey-profile-list.expanded {
    grid-template-rows: 1fr;
    opacity: 1;
}

/* ── Unified profile chip (overview) ── */
.survey-profile-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.survey-unified-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    border-radius: 16px;
    overflow: hidden;
    min-width: 0;
}
.survey-unified-chip.primary { background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent); }
.survey-unified-chip.info    { background: color-mix(in srgb, var(--mud-palette-info) 12%, transparent); }
.survey-chip-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 8px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    flex-shrink: 0;
    height: 28px;
    box-sizing: border-box;
}
.survey-chip-label.primary { background: var(--mud-palette-primary); }
.survey-chip-label.info    { background: var(--mud-palette-info); }
.survey-chip-dots {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    padding: 4px 10px 4px 8px;
    min-height: 28px;
    box-sizing: border-box;
}

/* Level rows */
.survey-level-row {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
/* Hover and active highlights only on devices with a real pointer (prevents false highlights on mobile scroll) */
@media (hover: hover) {
    .survey-rate-levels:not(.survey-slide-right):not(.survey-slide-left) .survey-level-row:hover {
        background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent) !important;
    }
    .survey-level-row:active {
        background: color-mix(in srgb, var(--mud-palette-primary) 15%, transparent) !important;
    }
}
/* Visible focus indicator for keyboard navigation (WCAG 2.4.7) */
.survey-level-row:focus {
    outline: none;
}
.survey-level-row:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
    border-radius: 4px;
}

/* Progress bar */
.survey-progress-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--mud-palette-divider);
    overflow: hidden;
}
.survey-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--mud-palette-primary);
    transition: width 0.3s ease;
}

/* Mobile: tighter spacing */
@media (max-width: 600px) {
    .survey-rate-frame {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin: 0 -16px; /* extend to screen edges on mobile (counteract pa-4) */
    }
    .survey-rate-header {
        padding: 6px 8px 0 8px;
    }
    .survey-level-row {
        padding: 6px 8px !important;
    }
}

/* Post-survey success: full-page replace (no MudAlert below the grid).
   Centred card, large green checkmark with single scale-in pulse. The
   blanket `prefers-reduced-motion` rule in app.css clamps the animation
   duration to 0.01ms for users who opt out, so honour-by-default works
   without an extra @media check here. */
.survey-success-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(var(--dvh, 1vh) * 70);
    padding: 24px 16px;
}
.survey-success-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 520px;
    padding: 32px;
}
.survey-success-mark {
    animation: survey-success-pulse 600ms ease-out 1;
    transform-origin: center;
}
@keyframes survey-success-pulse {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.10); opacity: 1; }
    80%  { transform: scale(0.96); }
    100% { transform: scale(1.00); opacity: 1; }
}

/* Desktop landscape: gentle survey-flow scale-up so the rate-grid + chip
   list + namecard fill the wider viewport without leaving the centred
   max-width:700px panel looking lonely on a 1920px monitor. ROADMAP item
   #20 — original CSS-zoom approach was reverted because Firefox Android
   doesn't implement `zoom`, leaving Android FF users with a layout broken
   into off-grid pixel offsets. Solution: gate the rule on
   `@supports (zoom: 1.25)` so non-supporting browsers (FF Android) skip
   it entirely and stay at the natural 1.0 scale. The min-width gate
   ensures phones in landscape don't accidentally scale up either. */
@media (min-width: 1200px) and (orientation: landscape) {
    @supports (zoom: 1.25) {
        .survey-flow { zoom: 1.10; }
    }
}
