/* ==========================================================================
   /cam — Live Camera Translator
   Reuses the YKR Agency design system: Outfit, #0D1A1C ink, #ff481f accent,
   Bootstrap form controls. Scoped entirely under .cam-page so no other page
   is affected.
   ========================================================================== */

.cam-page {
    --cam-ink: #0D1A1C;
    --cam-accent: #ff481f;
    --cam-line: rgba(13, 26, 28, 0.12);
    --cam-muted: #64748b;
    background: #f8fafb;
    padding: 2.5rem 0 3.5rem;
}

.cam-shell {
    max-width: 780px;
    margin: 0 auto;
}

/* ---------- Header ---------- */
.cam-head {
    text-align: center;
    margin-bottom: 1.75rem;
}

.cam-kicker {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cam-accent);
    background: rgba(255, 72, 31, 0.1);
    border: 1px solid rgba(255, 72, 31, 0.22);
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    margin-bottom: 0.85rem;
}

.cam-title {
    font-size: clamp(1.75rem, 5vw, 2.6rem);
    font-weight: 600;
    color: var(--cam-ink);
    margin-bottom: 0.6rem;
    line-height: 1.2;
}

.cam-lead {
    font-size: 1rem;
    color: #475569;
    max-width: 40rem;
    margin: 0 auto;
}

/* ---------- Stage ---------- */
.cam-stage {
    background: #fff;
    border: 1px solid var(--cam-line);
    border-radius: 18px;
    padding: 1rem;
    box-shadow: 0 18px 44px rgba(13, 26, 28, 0.08);
}

.cam-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--cam-ink);
    border-radius: 12px;
    overflow: hidden;
}

.cam-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* No mirror by default: pointing at text must feel natural. */
    transform: none;
}

/* Front camera only — set by JS when the active track faces the user. */
.cam-video.is-mirrored {
    transform: scaleX(-1);
}

/* Reticle */
.cam-reticle {
    position: absolute;
    inset: 8%;
    pointer-events: none;
}

.cam-reticle__corner {
    position: absolute;
    width: 26px;
    height: 26px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.cam-reticle__corner--tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.cam-reticle__corner--tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.cam-reticle__corner--bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.cam-reticle__corner--br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }

/* ---------- Gate (permission / errors) ---------- */
.cam-gate {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1.5rem;
    text-align: center;
    background: linear-gradient(160deg, #0D1A1C 0%, #16292c 100%);
    color: #fff;
    z-index: 5;
}

.cam-gate[hidden] {
    display: none;
}

.cam-gate__icon {
    font-size: 2.5rem;
    color: var(--cam-accent);
    line-height: 1;
}

.cam-gate__title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
}

.cam-gate__body {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.72);
    margin: 0;
    max-width: 24rem;
}

/* ---------- Buttons ---------- */
.cam-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border-radius: 999px;
    border: 0;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cam-btn--primary {
    background: var(--cam-accent);
    color: #fff;
    box-shadow: 0 8px 20px rgba(255, 72, 31, 0.32);
}

.cam-btn--primary:hover,
.cam-btn--primary:focus-visible {
    background: #e63c14;
    color: #fff;
    transform: translateY(-1px);
}

.cam-btn--primary:focus-visible {
    outline: 3px solid rgba(13, 26, 28, 0.6);
    outline-offset: 2px;
}

/* ---------- Status row ---------- */
.cam-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
}

.cam-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--cam-ink);
    margin: 0;
}

.cam-status__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}

.cam-status__dot.is-ready { background: #16a34a; }
.cam-status__dot.is-processing { background: #f59e0b; animation: cam-pulse 1.4s ease-in-out infinite; }
.cam-status__dot.is-error { background: #dc2626; }

@keyframes cam-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.cam-privacy {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: var(--cam-muted);
    margin: 0;
}

.cam-privacy i { color: #16a34a; }

/* ---------- Model download progress ---------- */
.cam-progress { margin-top: 0.75rem; }

.cam-progress[hidden] { display: none; }

.cam-progress__track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.cam-progress__fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--cam-accent);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.cam-progress__text {
    font-size: 0.8125rem;
    color: var(--cam-muted);
    margin: 0.4rem 0 0;
}

/* ---------- Language controls ---------- */
.cam-controls {
    margin-top: 1.25rem;
    background: #fff;
    border: 1px solid var(--cam-line);
    border-radius: 18px;
    padding: 1.25rem;
}

.cam-controls[hidden] { display: none; }

.cam-controls__grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 0.85rem;
}

.cam-field__label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cam-muted);
    margin-bottom: 0.4rem;
}

.cam-field__help {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0.4rem 0 0;
}

.cam-select { position: relative; }

.cam-select .form-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: 0.7rem 2.5rem 0.7rem 0.9rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--cam-ink);
    background-color: #fff;
    border: 1px solid var(--cam-line);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cam-select .form-select:focus {
    border-color: var(--cam-accent);
    box-shadow: 0 0 0 3px rgba(255, 72, 31, 0.16);
}

.cam-select__arrow {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #94a3b8;
    font-size: 0.8rem;
}

.cam-swap {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--cam-line);
    border-radius: 12px;
    color: var(--cam-ink);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cam-swap:hover:not(:disabled) {
    border-color: var(--cam-accent);
    color: var(--cam-accent);
    transform: rotate(180deg);
}

.cam-swap:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cam-swap:focus-visible {
    outline: 3px solid rgba(255, 72, 31, 0.35);
    outline-offset: 2px;
}

/* ---------- Results ---------- */
.cam-results { margin-top: 1.25rem; }

.cam-results[hidden] { display: none; }

.cam-card {
    background: #fff;
    border: 1px solid var(--cam-line);
    border-radius: 16px;
    padding: 1.1rem 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cam-card--result {
    border-color: rgba(255, 72, 31, 0.35);
    box-shadow: 0 10px 26px rgba(255, 72, 31, 0.1);
}

.cam-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.cam-card__label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cam-muted);
    margin: 0;
}

.cam-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cam-accent);
    background: rgba(255, 72, 31, 0.1);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
}

.cam-badge.is-low-confidence {
    color: #b45309;
    background: rgba(245, 158, 11, 0.14);
    cursor: help;
}

.cam-card__text {
    font-family: inherit;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #1e293b;
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-height: 1.6em;
}

.cam-card__text--result {
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--cam-ink);
}

.cam-arrow {
    text-align: center;
    color: #cbd5e1;
    font-size: 1.1rem;
    padding: 0.35rem 0;
}

.cam-hint {
    font-size: 0.85rem;
    color: var(--cam-muted);
    margin: 0.85rem 0 0;
    text-align: center;
}

.cam-debug {
    font-size: 0.72rem;
    color: #b6c0cc;
    margin: 0.4rem 0 0;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---------- Notes ---------- */
.cam-notes {
    margin-top: 2rem;
    background: #fff;
    border: 1px solid var(--cam-line);
    border-radius: 18px;
    padding: 1.5rem;
}

.cam-notes__title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--cam-ink);
    margin-bottom: 1rem;
}

.cam-notes__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.1rem;
}

.cam-notes__list li {
    display: flex;
    gap: 0.7rem;
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.6;
}

.cam-notes__list i {
    font-size: 1.1rem;
    color: var(--cam-accent);
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.cam-notes__list strong { color: var(--cam-ink); }

.cam-notes__caveat {
    font-size: 0.8rem;
    color: var(--cam-muted);
    background: #f8fafb;
    border-left: 3px solid rgba(255, 72, 31, 0.4);
    padding: 0.75rem 0.9rem;
    border-radius: 0 8px 8px 0;
    margin: 1.25rem 0 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
    .cam-page { padding: 1.5rem 0 2.5rem; }
    .cam-stage { padding: 0.75rem; }
    .cam-controls__grid {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }
    .cam-swap { justify-self: center; transform: rotate(90deg); }
    .cam-swap:hover:not(:disabled) { transform: rotate(270deg); }
    .cam-card__text { font-size: 1rem; }
    .cam-card__text--result { font-size: 1.05rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .cam-status__dot.is-processing { animation: none; }
    .cam-swap:hover:not(:disabled),
    .cam-swap { transition: none; }
    .cam-btn,
    .cam-progress__fill { transition: none; }
}
