/* S100 — /evaluate public page. Standalone stylesheet (no Filament, no Tailwind).
   Navy/teal palette from pilotlink.net. Mobile-first — dispatchers open this
   on phones at 2 AM. */

:root {
    --ev-navy: #0b2545;
    --ev-navy-2: #13315c;
    --ev-teal: #0d9488;
    --ev-teal-dark: #0f766e;
    --ev-teal-light: #2dd4bf;
    --ev-ink: #1e293b;
    --ev-muted: #64748b;
    --ev-line: #e2e8f0;
    --ev-red: #dc2626;
    --ev-font: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

.ev-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--ev-font);
    color: var(--ev-ink);
    /* S106 — navy gradient is the no-flash placeholder. The bg-layer image
       fades in over this once decoded; if the image fails to load the page
       still looks intentional, not broken. */
    background: linear-gradient(160deg, var(--ev-navy) 0%, var(--ev-navy-2) 55%, #164e63 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* S106 — full-bleed nautical background image behind the card.
   Position: fixed so it doesn't jump on scroll/iOS rubber-band; covers the
   viewport; centered. The dark navy gradient overlay (rgba) guarantees text
   contrast on any photo — we never depend on the photo's own brightness. */
.ev-bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.ev-bg-layer img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transform: scale(1.04);
    transition: opacity 0.6s ease, transform 0.6s ease;
    /* Compose the photo with the navy gradient so the brand palette still
       reads and the white card always has contrast. Two stacked overlays
       (gradient + photo) blend to the intended "homey but legible" tone. */
}

/* The image is lazy-loaded; once it decodes the browser sets visibility.
   We drive opacity from img.complete via a tiny inline load handler would
   be JS — simpler: rely on the CSS :network-prompt not existing, so use
   a transition on opacity from 0 -> 1 via the `onload`-set attribute. */
.ev-bg-layer img.is-loaded { opacity: 1; transform: scale(1); }

/* Per-step tint: each step's photo is paired with a slightly different
   gradient so the page feels alive as the visitor advances. The gradient
   also enforces the navy brand on the bottom (where the footer sits). */
.ev-body[data-bg="intro"]   .ev-bg-layer::after,
.ev-body[data-bg="step1"]   .ev-bg-layer::after,
.ev-body[data-bg="step2"]   .ev-bg-layer::after,
.ev-body[data-bg="step3"]   .ev-bg-layer::after,
.ev-body[data-bg="step4"]   .ev-bg-layer::after,
.ev-body[data-bg="step5"]   .ev-bg-layer::after,
.ev-body[data-bg="confirm"] .ev-bg-layer::after,
.ev-body[data-bg="mira"]    .ev-bg-layer::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(11, 37, 69, 0.55) 0%, rgba(19, 49, 92, 0.78) 60%, rgba(11, 37, 69, 0.92) 100%);
}

/* The card sits above the background layer. */
.ev-wrap { position: relative; z-index: 1; }

/* High-DPI / large screens: swap to the 1080w variant. Done via the
   picture-source swap would require <picture>; simpler here is a CSS
   background-image swap, but we're using <img> for lazy + decoding hints.
   The 640w <img> scales acceptably up to ~720px viewport; beyond that we
   bump the src via a tiny JS swap (set in the layout). For now the 640w
   image is fine on desktop too at this card width (560px max). */
@media (min-width: 720px) {
    .ev-bg-layer img { object-position: center 30%; }
}

@media (prefers-reduced-motion: reduce) {
    .ev-bg-layer img { transition: none; transform: none; }
    .ev-bg-layer img.is-loaded { transform: none; }
}

.ev-wrap {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ev-brand {
    text-align: center;
    color: #fff;
    letter-spacing: 0.02em;
}

.ev-brand-name {
    font-size: 22px;
    font-weight: 700;
}

.ev-brand-name sup {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.7;
}

.ev-card {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 40px 28px 28px;
    box-shadow: 0 20px 50px rgba(2, 12, 27, 0.45);
    overflow: hidden;
}

/* Subtle nautical wave along the card top (marketing-site accent) */
.ev-wave {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    color: rgba(13, 148, 136, 0.12);
    transform: scaleY(-1);
    pointer-events: none;
}

.ev-wave svg { width: 100%; height: 100%; display: block; }

/* Honeypot — off-screen, not display:none (some bots skip hidden inputs) */
.ev-hp {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Progress dots */
.ev-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.ev-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ev-line);
    transition: background 0.25s, transform 0.25s;
}

.ev-dot.is-done { background: var(--ev-teal-light); }

.ev-dot.is-active {
    background: var(--ev-teal);
    transform: scale(1.35);
}

/* Step slide + fade on insert */
.ev-step { animation: ev-in 0.35s ease both; }

@keyframes ev-in {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

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

h1 {
    font-size: 24px;
    line-height: 1.25;
    margin: 0 0 12px;
    color: var(--ev-navy);
}

h2 {
    font-size: 20px;
    line-height: 1.3;
    margin: 0 0 10px;
    color: var(--ev-navy);
}

.ev-lead {
    font-size: 16px;
    line-height: 1.6;
    color: var(--ev-ink);
    margin: 0 0 8px;
}

.ev-micro {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ev-muted);
    margin: 0 0 14px;
}

.ev-sig {
    color: var(--ev-muted);
    font-style: italic;
    margin: 0 0 20px;
}

.ev-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ev-navy);
    margin: 16px 0 6px;
}

.ev-input {
    width: 100%;
    font-family: var(--ev-font);
    font-size: 16px; /* 16px+ prevents iOS focus zoom */
    color: var(--ev-ink);
    padding: 12px 14px;
    border: 1.5px solid var(--ev-line);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}

.ev-input:focus {
    border-color: var(--ev-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.ev-textarea { resize: vertical; min-height: 96px; }

.ev-input::placeholder { color: #94a3b8; }

/* Chips — tap-select, typing is the enemy on mobile */
.ev-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.ev-chip {
    font-family: var(--ev-font);
    font-size: 14.5px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--ev-line);
    background: #fff;
    color: var(--ev-ink);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.ev-chip:hover { border-color: var(--ev-teal-light); }

.ev-chip.is-selected {
    background: var(--ev-teal);
    border-color: var(--ev-teal);
    color: #fff;
    font-weight: 600;
}

.ev-btn {
    display: block;
    width: 100%;
    font-family: var(--ev-font);
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--ev-teal);
    border: none;
    border-radius: 8px;
    padding: 14px 20px;
    margin-top: 22px;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.ev-btn:hover { background: var(--ev-teal-dark); }

.ev-btn:disabled { opacity: 0.6; cursor: wait; }

.ev-back {
    display: inline-block;
    margin-top: 16px;
    background: none;
    border: none;
    font-family: var(--ev-font);
    font-size: 14px;
    color: var(--ev-muted);
    cursor: pointer;
    padding: 4px 0;
}

.ev-back:hover { color: var(--ev-navy); }

.ev-error {
    font-size: 13px;
    color: var(--ev-red);
    margin: 6px 0 0;
}

.ev-error-block {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 14px;
}

.ev-turnstile { margin-top: 16px; min-height: 65px; }

/* Confirmation screen */
.ev-done { text-align: center; padding: 12px 0; }

.ev-check {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--ev-teal);
}

.ev-check svg { width: 100%; height: 100%; }

.ev-footer {
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.55);
}

@media (min-width: 640px) {
    .ev-card { padding: 48px 44px 32px; }
    h1 { font-size: 27px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   S107 — the live-filling request sheet (.gf-*). S133 moved it out of the
   voice panel's <style> block: the text chat renders the same sheet, and that
   block only ships when the voice panel is on screen.
   ───────────────────────────────────────────────────────────────────────── */

.gf-sheet {
    border: 1px solid var(--ev-border, #e2e8f0);
    border-radius: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
}
.gf-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ev-navy-2, #1e3a5f);
    margin-bottom: 8px;
}
.gf-sub { font-weight: 400; color: var(--ev-muted); }
.gf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--ev-border, #e2e8f0);
    font-size: 13.5px;
}
.gf-row:last-child { border-bottom: none; }
.gf-label { color: var(--ev-muted); white-space: nowrap; }
.gf-value { color: var(--ev-muted); text-align: right; overflow-wrap: anywhere; }
.gf-row--filled .gf-value {
    color: var(--ev-navy-2, #1e3a5f);
    font-weight: 600;
    animation: gf-fill-in 0.5s ease-out;
}
@keyframes gf-fill-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Review mode (S109) + the per-row ⋮ edit affordance (S133) */
.gf-sheet--review { border-color: var(--ev-teal, #0d9488); }
.gf-menu {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--ev-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.gf-menu:hover { background: rgba(13, 148, 136, 0.1); color: var(--ev-teal-dark, #0f766e); }
.gf-input {
    font-family: var(--ev-font);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ev-navy-2, #1e3a5f);
    text-align: right;
    border: none;
    border-bottom: 1px solid var(--ev-border, #e2e8f0);
    background: transparent;
    padding: 2px 0;
    flex: 1;
    min-width: 0;
    outline: none;
}
.gf-input:focus { border-bottom-color: var(--ev-teal, #0d9488); }

/* The text chat's copy of the sheet sits between the composer and the back link. */
.mc-sheet { margin-top: 14px; }

/* S133c — "I couldn't fill these in automatically" notice inside the sheet */
.gf-warn {
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 12.5px;
    line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
    .gf-row--filled .gf-value { animation: none; }
}

/* S133 — the voice door earns a wider card on a desktop screen: Mira's
   controls + the request sheet on the left, the conversation full-height on
   the right (the panel's own container query does the split). Scoped with
   :has() so ONLY the voice panel widens — the quick form and the text chat
   keep the 560px reading width. Browsers without :has() simply keep the
   narrow card, and the panel falls back to its single-column layout. */
@media (min-width: 1024px) {
    .ev-wrap:has(.mv-wrap) { max-width: 1060px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   S104 — Mira chat (Path B). Same palette tokens as the form (.ev-*).
   Bubble prefix is .mc-* to avoid collisions. Mobile-first, max-width 560px
   inherited from .ev-card.
   ───────────────────────────────────────────────────────────────────────── */

.mc-wrap { display: flex; flex-direction: column; }

/* Secondary "Or talk to Mira" / "Switch to the form" button on the intro + degraded states */
.ev-link-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    background: transparent;
    border: none;
    color: var(--ev-teal-dark);
    font-family: var(--ev-font);
    font-size: 14.5px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 8px 0;
    -webkit-tap-highlight-color: transparent;
}

.ev-btn--solid { margin-top: 14px; }

.mc-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
}

.mc-header h2 { margin: 0; }

.mc-count {
    font-size: 12px;
    color: var(--ev-muted);
    font-variant-numeric: tabular-nums;
}

.mc-thread {
    max-height: 340px;
    overflow-y: auto;
    padding: 4px 2px 8px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.mc-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.5;
    animation: ev-in 0.25s ease both;
}

.mc-bubble p { margin: 0; word-wrap: break-word; overflow-wrap: anywhere; }

.mc-author {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
    opacity: 0.7;
}

/* Mira = left, light */
.mc-bubble--assistant {
    align-self: flex-start;
    background: #f1f5f9;
    color: var(--ev-ink);
    border-bottom-left-radius: 4px;
}

/* User = right, teal */
.mc-bubble--user {
    align-self: flex-end;
    background: var(--ev-teal);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.mc-bubble--user .mc-author { color: rgba(255, 255, 255, 0.8); }

/* Typing indicator */
.mc-typing p { display: flex; gap: 4px; align-items: center; padding-top: 2px; }

.mc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ev-muted);
    opacity: 0.5;
    animation: mc-bounce 1.2s infinite ease-in-out;
}

.mc-dot:nth-child(2) { animation-delay: 0.15s; }
.mc-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes mc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 0.9; }
}

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

.mc-degraded {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 8px 0 12px;
    font-size: 13.5px;
    line-height: 1.5;
    color: #92400e;
}

.mc-degraded p { margin: 0 0 6px; }
.mc-degraded .ev-link-btn { margin-top: 4px; color: #92400e; text-align: left; }

.mc-composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 4px;
}

.mc-input {
    flex: 1;
    min-height: 48px;
    max-height: 140px;
    resize: none;
}

.mc-send {
    width: auto;
    margin-top: 0;
    padding: 12px 20px;
    white-space: nowrap;
}

.mc-finish {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed var(--ev-line);
}

.mc-finish .ev-input { margin-bottom: 6px; }

.mc-offline {
    opacity: 0.55;
    pointer-events: none;
}

.mc-step { animation: ev-in 0.35s ease both; }

@media (min-width: 640px) {
    .mc-thread { max-height: 420px; }
    .mc-bubble { font-size: 15.5px; }
}
