/* app.css — webapp Surface 2 (mobile-first /app/* shell + page primitives).
   Plan 04-07 Task 1: fills the empty stub created in 04-03. Per BLOCKER 2 fix
   App.razor's <link> tag is already in place — this plan only fills CSS content.

   Tokens (--color-*, --font-*, --radius-*) come from default.css.
   Per CONTEXT D-18..D-21:
     - Mobile-first 480/640px shell (no desktop sidebar — phone-shaped surface).
     - Status badges follow Aquatic tokens (uploading/processing/done).
     - Polling lifecycle owned by SessionDetail.razor + WebappStatusPoller.

   Surface composition mirrors sketch-findings-arapaima/references/surfaces.md
   "Surface 2 — webapp shell, mobile-first capture flow". */

/* === App shell — mobile-first === */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    display: flex;
    flex-direction: column;
}

@media (min-width: 600px) {
    .app-shell { max-width: 640px; }
}

/* === Topbar (sticky brand + email + logout pill) === */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 56px;
    padding: 0 16px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-topbar .aq-wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: var(--color-text);
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    letter-spacing: -0.02em;
}

.app-topbar .aq-wordmark .fin-glyph {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    transform: translateY(0) skewX(-20deg);
    box-shadow: 0 0 12px var(--color-accent-glow);
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-pill {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: lowercase;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-form { display: inline; }

.btn-logout-app {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--duration-base) ease;
}

.btn-logout-app:hover {
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

/* === Content area === */
.app-content {
    padding: 20px 16px;
    flex: 1;
}

.app-page-header {
    margin-bottom: 24px;
}

.app-page-header h1 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.app-page-header .eyebrow {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    display: block;
    margin-bottom: 4px;
}

/* === Session card list (Dashboard) === */
.session-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.session-card {
    background: var(--color-bg-elev);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color var(--duration-base) ease;
    display: flex;
    align-items: center;
    gap: 14px;
}

.session-card:hover {
    border-color: var(--color-accent);
}

.session-card .icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-accent-soft);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.session-card .body { flex: 1; min-width: 0; }

.session-card .title {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
}

.session-card .sub {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* === Object type chooser (CreateSession) === */
.object-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.object-type-tile {
    background: var(--color-bg-elev);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--duration-base) ease;
}

.object-type-tile.selected,
.object-type-tile:hover {
    border-color: var(--color-accent);
    box-shadow: 0 8px 24px rgba(164, 255, 60, 0.16);
}

.object-type-tile .icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.object-type-tile .label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--color-text);
}

/* === Background grid (ChooseBackground) === */
.bg-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.bg-tile {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--duration-base) ease;
    background: var(--color-bg-elev);
}

.bg-tile.selected {
    border-color: var(--color-accent);
    box-shadow: 0 8px 24px rgba(164, 255, 60, 0.16);
}

.bg-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-tile .name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: var(--color-text);
    padding: 18px 8px 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* === Photo grid + status badges (SessionDetail) === */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.photo-tile {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--color-bg-elev);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.photo-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-tile .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-dim);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.photo-tile .status-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* Per CONTEXT D-19 — status-badges follow Aquatic tokens */
.status-badge.uploading  { background: rgba(255, 255, 255, 0.08); color: var(--color-text-muted); }
.status-badge.queued     { background: rgba(255, 255, 255, 0.08); color: var(--color-text-muted); }
.status-badge.processing { background: rgba(255, 154, 60, 0.14);  color: var(--color-warning); }
.status-badge.done {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    box-shadow: 0 0 12px rgba(164, 255, 60, 0.4);
}
.status-badge.failed     { background: rgba(255, 94, 94, 0.14);   color: var(--color-danger); }

/* === Login-shell on /app fallback (NotAuthorized) === */
.app-shell .login-shell {
    margin: 80px auto;
    padding: 32px;
    max-width: 360px;
    background: var(--color-bg-elev);
    border-radius: var(--radius-lg);
    text-align: center;
}

/* === Plan 04-08 — Capture surface (full-bleed mobile camera viewport) ===
   Surface 2 capture composition per sketch-findings-arapaima/references/surfaces.md
   line 96 (Webapp capture). Corner-bracket motif unifies hero ↔ capture (line 49,
   126). Shutter button is the only glowing element (line 129). The whole shell
   escapes the .app-shell max-width container by being position:fixed full-viewport. */
.capture-shell {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    z-index: 100;
    color: var(--color-text);
    font-family: var(--font-sans);
}

.capture-shell .capture-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 5;
    height: 56px;
    padding: 0 16px;
    background: linear-gradient(rgba(0,0,0,0.7), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.capture-shell .capture-topbar .session-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.capture-shell .capture-topbar a.close-btn {
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    color: var(--color-text);
    text-decoration: none;
    font-size: 22px;
    line-height: 1;
}

.capture-shell .capture-stage {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.capture-shell video.capture-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.capture-shell svg.capture-ghost {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.55;
    fill: var(--color-accent);
    pointer-events: none;
    mix-blend-mode: screen;
}

/* Corner-bracket frame motif — same as hero visual (sketch surfaces.md line 49). */
.capture-shell .capture-frame-corners {
    position: absolute;
    inset: 80px 16px 140px 16px;
    pointer-events: none;
}
.capture-shell .capture-frame-corners::before,
.capture-shell .capture-frame-corners::after {
    content: "";
    position: absolute;
    width: 28px; height: 28px;
    border: 2px solid var(--color-accent);
    opacity: 0.6;
}
.capture-shell .capture-frame-corners::before {
    top: 0; left: 0;
    border-right: none;
    border-bottom: none;
}
.capture-shell .capture-frame-corners::after {
    bottom: 0; right: 0;
    border-left: none;
    border-top: none;
}

.capture-shell .angle-pill {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    background: rgba(0,0,0,0.5);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent);
    z-index: 5;
}

.capture-shell .capture-bottombar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 5;
    padding: 16px 16px 24px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.capture-shell .thumb-strip {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    align-items: center;
    min-height: 48px;
}

.capture-shell .thumb-strip::-webkit-scrollbar { display: none; }

.capture-shell .thumb-strip .thumb {
    position: relative;
    width: 48px; height: 48px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background: var(--color-bg-elev);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.capture-shell .thumb-strip .thumb img {
    width: 100%; height: 100%; object-fit: cover;
}

.capture-shell .thumb-strip .thumb .status-dot-corner {
    position: absolute;
    top: 2px; right: 2px;
    width: 8px; height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.6);
}
.thumb .status-dot-corner.uploading  { background: var(--color-text-muted); }
.thumb .status-dot-corner.processing { background: var(--color-warning); }
.thumb .status-dot-corner.done {
    background: var(--color-accent);
    box-shadow: 0 0 6px var(--color-accent);
}
.thumb .status-dot-corner.failed     { background: var(--color-danger); }

.capture-shell .shutter-btn {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 4px solid rgba(255,255,255,0.18);
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 0 32px rgba(164, 255, 60, 0.6);
    transition: transform 100ms ease;
    padding: 0;
}

.capture-shell .shutter-btn:active { transform: scale(0.92); }
.capture-shell .shutter-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.capture-shell .done-link {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text);
    text-decoration: none;
    background: rgba(0,0,0,0.5);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

/* === Capture error overlay (UNSUPPORTED, NotAllowedError, etc) ===
   Plan 04-08 SPEC §3.4: NO <input type="file" capture> fallback — user sees a
   Swedish error card explaining what happened and how to recover. */
.capture-error-shell {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    z-index: 100;
}

.capture-error-shell .err-card {
    max-width: 360px;
    background: var(--color-bg-elev);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
}

.capture-error-shell .err-card h2 {
    font-family: var(--font-display);
    font-size: 22px;
    margin: 0 0 12px;
    color: var(--color-warning);
}

.capture-error-shell .err-card p {
    color: var(--color-text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

.capture-error-shell .err-card .err-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
