/* Sentinel.Web — kiosk-tuned styles with dark / light themes.
   Theme controlled by the `data-bs-theme` attribute on <html>, set early in
   index.html before Blazor boots. Bootstrap 5.3 + Blazorise.Bootstrap5
   auto-adapt their built-in components (cards, modals, form-controls,
   tables, badges); custom classes here read CSS variables so they swap too.

   Default is dark — factory shop-floor lighting + kiosks tend to prefer a
   non-glaring screen. Light is the explicit opt-in. */

:root {
    /* Dark — default. Matches Pulse.Web / RKT.Web palette (near-black,
       not blue) so the Gemini G corner mark reads consistently across
       the suite. */
    --sentinel-bg:           #1a1a1a;
    --sentinel-text:         #f3f4f6;
    --sentinel-muted:        #9ca3af;   /* neutral grey-400 (was slate-400 — had blue cast) */
    --sentinel-card-border:  #2a2a2a;
    --sentinel-divider:      #1f1f1f;
    --sentinel-gold:         #bba96c;   /* identity colour, same in both themes */
}

[data-bs-theme="light"] {
    --sentinel-bg:           #f5f5f5;
    --sentinel-text:         #111827;
    --sentinel-muted:        #6b7280;
    --sentinel-card-border:  #e5e7eb;
    --sentinel-divider:      #e5e7eb;
}

/* Body background — same pattern as Pulse.Web and RKT.Web: the Gemini
   "G" SVG painted into the bottom-right corner of the viewport as a
   fixed background image. Same SVG works in both themes because the
   fill is gold-grey (#b6a88f). The page colour itself comes from
   --sentinel-bg, layered behind the image. */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    color: var(--sentinel-text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 18px;

    background-color: var(--sentinel-bg);
    background-image: url('../images/gemini-g.svg');
    background-repeat: no-repeat;
    background-position: bottom right;
    background-size: 100px 140px;
    background-attachment: fixed;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sentinel-splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--sentinel-muted);
}

.sentinel-splash h1 {
    font-size: 3rem;
    letter-spacing: 0.1em;
    color: var(--sentinel-gold);
}

/* Big-touch primary action — used on "Tap your tag" and "Submit" buttons. */
.btn-tap {
    font-size: 1.5rem;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    min-height: 4rem;
}

/* The header stays dark in both themes — identity element, also reads well
   under shop-floor lighting regardless of which mode the rest of the UI is in.
   Neutral near-black (#0d0d0d), one shade darker than the body's #1a1a1a
   to give the bar visual weight without introducing a blue cast. */
.sentinel-header {
    background: #0d0d0d;
    color: #f9fafb;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sentinel-header .stage-tag {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    flex: 0 0 auto;
}

.sentinel-header .header-middle {
    flex: 1;
    text-align: center;
}

.sentinel-header .header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sentinel-header .operator-name {
    font-size: 1rem;
    opacity: 0.85;
}

/* Theme toggle button in the header — small, icon-only, low-key. */
.sentinel-theme-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f9fafb;
    border-radius: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.15s ease;
}

.sentinel-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sentinel-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    /* Transparent so the body's fixed Gemini-G background shows through. */
    background: transparent;
}

/* Muted text utility — for tag hints, captions, "returning in N seconds" etc.
   Replaces the old inline `style="color:#6b7280"` so it themes correctly. */
.sentinel-muted {
    color: var(--sentinel-muted);
}

/* Sentinel branding — Gemini gold on the Index splash. */
.sentinel-brand {
    margin: 2rem auto 1.5rem;
}

.sentinel-index-title {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 1.75rem;
    letter-spacing: 0.02em;
    color: var(--sentinel-gold);
    margin: 0.75rem 0 0.25rem;
    font-weight: 500;
}

.sentinel-index-tagline {
    font-size: 1.1rem;
    color: var(--sentinel-muted);
    margin: 0 0 1rem;
    letter-spacing: 0.02em;
}

.sentinel-index-scanline {
    animation: sentinel-scan-sweep 2.8s ease-in-out infinite;
    transform-origin: center;
}

.sentinel-index-dot {
    animation: sentinel-dot-pulse 1.6s ease-in-out infinite;
    transform-origin: 60px 60px;
}

@keyframes sentinel-scan-sweep {
    0%   { transform: translateY(-30px); opacity: 0.0; }
    20%  { opacity: 0.9; }
    50%  { transform: translateY( 30px); opacity: 0.9; }
    80%  { opacity: 0.9; }
    100% { transform: translateY(-30px); opacity: 0.0; }
}

@keyframes sentinel-dot-pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.6; }
    50%      { transform: scale(1.4); opacity: 1.0; }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
    .sentinel-index-scanline,
    .sentinel-index-dot {
        animation: none;
    }
}

/* Checklist flow — full-viewport flex column. Header + image + body card +
   nav row all stack vertically. Image card flex-grows to fill any leftover
   space; nav row has margin-top:auto so it sits glued to the bottom even
   when the image is absent (e.g. RKT 404'd the PNG). */
.sentinel-checklist-flow {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0.75rem;
    min-height: 0;  /* allows flex children to shrink below their content size */
}

.sentinel-checklist-header {
    flex: 0 0 auto;
}

.sentinel-checklist-body {
    /* Body card (notes / question / review / transition) sizes to content
       up to the space the image isn't using. If a question card has a long
       memo or a notes step has a lot of text, the body scrolls internally
       rather than pushing the nav off-screen. */
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sentinel-body-card {
    margin: 0;       /* defaults add bottom-margin we don't want */
    flex: 0 1 auto;
}

.sentinel-checklist-nav {
    flex: 0 0 auto;
    margin-top: auto;  /* pin to bottom of the flex column */
}

/* Piece-image card — flex-grows to fill the available space between header
   and body. Image inside uses object-fit:contain so the proportions stay
   right whatever the available height is. Tap to open the lightbox. */
.sentinel-piece-image-card {
    position: relative;
    flex: 1 1 0;
    min-height: 180px;
    border: 1px solid var(--sentinel-card-border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.sentinel-piece-image-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;  /* the piece PNG has a white background — fill */
}

.sentinel-piece-image-card .sentinel-piece-image-hint {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.85rem;
    border-radius: 0.25rem;
}

/* Warning shown when the piece image fetch returns no bytes — the operator
   can still complete the checklist, so the warning is informational, not
   blocking. Sits in the same flex slot as .sentinel-piece-image-card so the
   surrounding layout stays consistent. */
.sentinel-piece-image-missing {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #f59e0b;
    border-left: 4px solid #f59e0b;
    background: rgba(245, 158, 11, 0.08);
    border-radius: 0.5rem;
    color: #92400e;
}

.sentinel-piece-image-missing i {
    font-size: 1.5rem;
    flex: 0 0 auto;
}

.sentinel-piece-image-missing-title {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.sentinel-piece-image-missing-text {
    font-size: 0.9rem;
    color: #78350f;
}

/* Camera capture modal — full-viewport overlay rendered by sentinel.camera
   when the operator hits "Take photo". The shutter is a large round target
   for thick gloves. */
.sentinel-camera-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    flex-direction: column;
}

.sentinel-camera-stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sentinel-camera-preview {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    min-height: 0;
}

.sentinel-camera-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.85);
    gap: 1rem;
}

.sentinel-camera-spacer {
    flex: 0 0 5rem;
}

.sentinel-camera-btn {
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.sentinel-camera-cancel {
    flex: 0 0 5rem;
    height: 3rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.sentinel-camera-cancel:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sentinel-camera-shutter {
    flex: 0 0 auto;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    background: #fff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

.sentinel-camera-shutter:disabled {
    opacity: 0.45;
    cursor: wait;
}

.sentinel-camera-shutter-dot {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #bba96c;  /* Gemini gold */
}

.sentinel-camera-shutter:hover:not(:disabled) .sentinel-camera-shutter-dot {
    background: #a8975e;
}

/* Fullscreen lightbox — covers the viewport when the operator taps the
   piece-image card. The viewport meta is temporarily switched to
   user-scalable=yes (via sentinelViewport.setZoomEnabled in sentinel.js)
   so native pinch-zoom works on the modal image while it's open. */
.sentinel-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
    /* Allow the OS pinch-gesture to land on the image inside, not be eaten
       by the overlay's tap-to-close handler. The image element below uses
       touch-action: pinch-zoom; this container only handles tap dismiss. */
    touch-action: manipulation;
}

.sentinel-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #fff;
    touch-action: pinch-zoom;
}

.sentinel-lightbox .sentinel-lightbox-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.9rem;
    border-radius: 0.25rem;
    pointer-events: none;
}

/* Factory-notes card — a touch more visual weight than a regular question
   card so the operator notices it. */
.sentinel-notes-card {
    border-left: 4px solid var(--sentinel-gold);
}

/* Progress meter — appears under the header in the one-question-at-a-time
   flow so the operator can see how far they are through the checklist. */
.sentinel-progress {
    margin-top: 0.75rem;
    user-select: none;
}

.sentinel-progress-text {
    font-size: 0.85rem;
    color: var(--sentinel-muted);
}

.sentinel-progress-bar {
    margin-top: 0.25rem;
    height: 4px;
    background: var(--sentinel-divider);
    border-radius: 2px;
    overflow: hidden;
}

.sentinel-progress-fill {
    height: 100%;
    background: var(--sentinel-gold);
    transition: width 0.3s ease-out;
}

/* "Answer carried forward from a prior submission" banner — sits inside
   the question card under the inputs so the operator notices the prior
   state is loaded, and knows Forward will skip ahead. */
.sentinel-prior-hint {
    margin-top: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(187, 169, 108, 0.12); /* gold-tinted subtle */
    border-left: 3px solid var(--sentinel-gold);
    border-radius: 0.25rem;
    font-size: 0.85rem;
    color: var(--sentinel-text);
}

.sentinel-prior-hint i {
    margin-right: 0.5rem;
    color: var(--sentinel-gold);
}

/* Sentinel-logo flash between questions — same scanning viewfinder used on
   the Index splash, but one-shot (matches WobbleMs in Checklist.razor) so it
   feels like a quick punctuation rather than an ambient animation. */
.sentinel-transition-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    margin: 1rem 0;
}

.sentinel-transition .sentinel-transition-scanline {
    animation: sentinel-transition-sweep 0.55s ease-in-out;
    transform-origin: center;
}

.sentinel-transition .sentinel-transition-dot {
    animation: sentinel-transition-pulse 0.55s ease-in-out;
    transform-origin: 60px 60px;
}

@keyframes sentinel-transition-sweep {
    0%   { transform: translateY(-30px); opacity: 0.0; }
    25%  { opacity: 1.0; }
    75%  { opacity: 1.0; }
    100% { transform: translateY( 30px); opacity: 0.0; }
}

@keyframes sentinel-transition-pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.4; }
    50%      { transform: scale(2.2); opacity: 1.0; }
}

/* Respect reduced-motion. Collapses to static lines/dot — the operator just
   sees a still Sentinel-logo placeholder for the same 550ms beat. */
@media (prefers-reduced-motion: reduce) {
    .sentinel-transition .sentinel-transition-scanline,
    .sentinel-transition .sentinel-transition-dot {
        animation: none;
    }
}

/* Review page — list of every Q + A, tap a row to jump back to that
   question. Rows are big-touch so the operator can target one with a
   gloved hand. */
.sentinel-review-card .sentinel-review-row {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    margin: 0.25rem 0;
    border: 1px solid var(--sentinel-card-border);
    border-radius: 0.5rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s ease;
}

.sentinel-review-card .sentinel-review-row:hover,
.sentinel-review-card .sentinel-review-row:active {
    background: rgba(187, 169, 108, 0.10);
}

.sentinel-review-card .sentinel-review-q {
    font-weight: 600;
}

.sentinel-review-card .sentinel-review-a {
    margin-top: 0.25rem;
    color: var(--sentinel-muted);
    white-space: pre-wrap;
}

/* Status badges (G/A/R) — colour-blind-safe by including a symbol. Same
   palette in both themes since they're status semantics, not branding. */
.badge-G { background: #16a34a; color: white; }
.badge-A { background: #f59e0b; color: black; }
.badge-R { background: #dc2626; color: white; }

/* Primary buttons (Sign-in, Submit, Next-piece) — Gemini gold instead of
   Bootstrap's default blue, matching the Pulse.Web palette
   (#bba96c bg, #212529 text). Hover / active / disabled / focus all derived
   from the gold to keep one identity colour.
   Applied via Bootstrap 5.3's `--bs-btn-*` CSS variables on the `.btn-primary`
   class — Blazorise's <Button Color="Color.Primary"> renders btn-primary, so
   this catches all of them in one place. */
.btn-primary {
    --bs-btn-color:                 #212529;
    --bs-btn-bg:                    #bba96c;
    --bs-btn-border-color:          #bba96c;
    --bs-btn-hover-color:           #212529;
    --bs-btn-hover-bg:              #a8985d;
    --bs-btn-hover-border-color:    #9f9056;
    --bs-btn-focus-shadow-rgb:      187, 169, 108;
    --bs-btn-active-color:          #212529;
    --bs-btn-active-bg:             #9f9056;
    --bs-btn-active-border-color:   #968855;
    --bs-btn-disabled-color:        #4b5563;
    --bs-btn-disabled-bg:           #d8ccaa;
    --bs-btn-disabled-border-color: #d8ccaa;
}

/* Same treatment for "link" text shown in the primary colour — keeps
   Bootstrap's link-primary etc. on-brand. */
.text-primary,
.link-primary {
    color: var(--sentinel-gold) !important;
}

/* Bootstrap error banner — themed. */
#blazor-error-ui {
    background: var(--sentinel-card-bg, #fef2f2);
    color: var(--sentinel-text);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    border-top: 1px solid var(--sentinel-card-border);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
