/* CastleCam local viewer — shared styles
 * Mirrors the cloud PWA's brand system (pwa/app/globals.css):
 *   - amber accent (#ff8b2a), warm off-white text (#f1ebdf)
 *   - Fraunces serif for display/wordmark (self-hosted under /fonts/)
 *   - system mono for body/labels (no font download)
 *   - dark navy-ink surfaces, hairline borders
 * Self-hosted fonts so the viewer works fully offline.
 */

/* ============================================================
 * Fonts — self-hosted Fraunces variable (italic + roman)
 * ============================================================ */
@font-face {
    font-family: "Fraunces";
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url("/fonts/fraunces-italic.woff2") format("woff2");
}
@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("/fonts/fraunces.woff2") format("woff2");
}

/* ============================================================
 * Brand tokens — same as pwa/app/globals.css
 * ============================================================ */
:root {
    --bg:          #0a0c0f;
    --surface-1:   #11141a;
    --surface-2:   #161a22;
    --ink:         #f1ebdf;
    --ink-soft:    #b8b1a3;
    --ink-muted:   #76726a;
    --ink-faint:   #36342f;
    --line:        #1d222a;
    --line-bold:   #262d37;

    --amber:       #ff8b2a;
    --vermillion:  #ff3d2e;
    --teal:        #43e5c8;

    --mono: ui-monospace, "SF Mono", "Menlo", "Monaco", monospace;
    --display: "Fraunces", "Times New Roman", serif;
}

/* ============================================================
 * Base
 * ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-family: var(--mono);
    font-feature-settings: "ss01", "ss02";
    color-scheme: dark;
}

body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 12% -10%, rgba(255, 139, 42, 0.04), transparent 55%),
        radial-gradient(ellipse at 92% 110%, rgba(67, 229, 200, 0.03), transparent 55%);
    background-attachment: fixed;
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--display);
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--ink);
}
h1 { font-size: 26px; line-height: 1.1; margin-bottom: 8px; }
h2 { font-size: 19px; line-height: 1.2; margin-bottom: 12px; }
h3 {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-bottom: 8px;
}

p {
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 12px;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Label / stamp / pill atoms (same names as cloud PWA) */
.cc-label {
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--ink-muted);
}
.cc-stamp {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-soft);
    letter-spacing: 0.04em;
}
.cc-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-family: var(--mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--ink-soft);
    border: 1px solid var(--line-bold);
    border-radius: 999px;
}
.cc-pill-amber {
    color: var(--amber);
    border-color: rgba(255, 139, 42, 0.4);
    background: rgba(255, 139, 42, 0.06);
}
.cc-pill-rec {
    color: var(--vermillion);
    border-color: rgba(255, 61, 46, 0.4);
    background: rgba(255, 61, 46, 0.08);
}
.cc-pill-rec::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: var(--vermillion);
    box-shadow: 0 0 8px var(--vermillion);
    animation: cc-pulse 1.4s ease-in-out infinite;
}
@keyframes cc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ============================================================
 * Layout
 * ============================================================ */
.shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 80px;
}
.shell.narrow { max-width: 420px; }

/* ============================================================
 * Top nav (multi-page)
 * ============================================================ */
.nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(10, 12, 15, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.nav-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px;
}

/* CastleCam wordmark — italic 'Castle' + amber bold 'Cam.' (matches cloud PWA) */
.nav-brand {
    font-family: var(--display);
    font-size: 22px;
    line-height: 1;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font-feature-settings: "ss01";
}
.nav-brand .b-italic {
    font-style: italic;
    font-variation-settings: "opsz" 96, "SOFT" 60;
}
.nav-brand .b-amber {
    color: var(--amber);
    font-style: normal;
    font-weight: 600;
    font-variation-settings: "opsz" 96, "SOFT" 0;
}

.nav-tabs {
    display: flex;
    gap: 0;
    margin-left: 12px;
}
.nav-tab {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    padding: 8px 12px;
    border-radius: 0;
    text-decoration: none;
    position: relative;
}
.nav-tab:hover { color: var(--ink-soft); text-decoration: none; }
.nav-tab.active { color: var(--amber); }
.nav-tab.active::after {
    content: "";
    position: absolute;
    left: 12px; right: 12px;
    bottom: 0;
    height: 1px;
    background: var(--amber);
}

.nav-peers {
    margin-left: auto;
}
.peer-select {
    background: var(--surface-2);
    border: 1px solid var(--line-bold);
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    color-scheme: dark;
}
.peer-select:hover { border-color: var(--ink-muted); color: var(--ink); }

.nav-signout {
    margin-left: 8px;
    background: transparent;
    border: 1px solid var(--line-bold);
    color: var(--ink-muted);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.nav-signout:hover { color: var(--ink); border-color: var(--ink-muted); }

/* ============================================================
 * Cards
 * ============================================================ */
.card {
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}
.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}
.card-title {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.card-meta {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-muted);
    letter-spacing: 0.04em;
}

/* ============================================================
 * Live tile
 * ============================================================ */
.live-tile {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    margin-bottom: 16px;
    border: 1px solid var(--line-bold);
}
.live-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.live-tile .live-pill {
    position: absolute;
    top: 10px;
    left: 10px;
}

/* ============================================================
 * Status grid
 * ============================================================ */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}
.status-cell {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
}
.status-label {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.status-value {
    font-family: var(--display);
    font-size: 18px;
    color: var(--ink);
    margin-top: 4px;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.status-value.mono {
    font-family: var(--mono);
    font-size: 13px;
}
.status-value.warn { color: var(--amber); }
.status-value.bad  { color: var(--vermillion); }

/* ============================================================
 * Clip list / group-by-hour
 * ============================================================ */
.hour-group {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-1);
}
.hour-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}
.hour-header.collapsed { border-bottom-color: transparent; }
.hour-label {
    font-family: var(--display);
    font-size: 16px;
    color: var(--ink);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.hour-meta {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.hour-caret {
    font-family: var(--mono);
    color: var(--ink-muted);
    font-size: 12px;
    margin-left: 8px;
    transition: transform 0.15s ease;
}
.hour-header.collapsed .hour-caret { transform: rotate(-90deg); }

.hour-body { padding: 4px; }
.hour-body.hidden { display: none; }

.clip-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.clip-item:hover { background: var(--bg); }

.clip-thumb {
    width: 80px;
    height: 45px;
    background: #000;
    border-radius: 4px;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--line);
}
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; }

.clip-meta { flex: 1; min-width: 0; }
.clip-time {
    font-family: var(--display);
    font-size: 16px;
    color: var(--ink);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.clip-info {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 2px;
    display: flex;
    gap: 8px;
}

.clip-star {
    background: none;
    border: none;
    color: var(--ink-faint);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.clip-star.starred { color: var(--amber); }

/* ============================================================
 * Date picker
 * ============================================================ */
.date-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.date-bar input[type="date"] {
    background: var(--bg);
    border: 1px solid var(--line-bold);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    color-scheme: dark;
}
.date-bar input[type="date"]:focus { border-color: var(--amber); outline: none; }

/* ============================================================
 * Clip modal
 * ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal {
    background: var(--surface-1);
    border: 1px solid var(--line-bold);
    border-radius: 10px;
    max-width: 720px;
    width: 100%;
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--ink); }
.modal video { width: 100%; display: block; background: #000; }

/* ============================================================
 * Forms
 * ============================================================ */
input[type="text"], input[type="password"], input[type="email"], input[type="number"], select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line-bold);
    border-radius: 6px;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 13px;
    outline: none;
    color-scheme: dark;
}
input:focus, select:focus { border-color: var(--amber); }
input::placeholder { color: var(--ink-faint); }

label {
    display: block;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-bottom: 6px;
}
.field { margin-bottom: 14px; }

.btn {
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    cursor: pointer;
    display: inline-block;
    line-height: 1;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--amber); color: #14110b; }
.btn-primary:hover:not(:disabled) { background: #ff7c10; }
.btn-secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line-bold); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-muted); }
.btn-block { display: block; width: 100%; }
.btn-danger { background: transparent; border-color: rgba(255, 61, 46, 0.4); color: var(--vermillion); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 61, 46, 0.08); }

/* ============================================================
 * Toasts
 * ============================================================ */
.toast {
    padding: 10px 14px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 12px;
    margin-bottom: 12px;
}
.toast-error   { background: rgba(255, 61, 46, 0.08);  border: 1px solid rgba(255, 61, 46, 0.35); color: var(--vermillion); }
.toast-success { background: rgba(67, 229, 200, 0.06); border: 1px solid rgba(67, 229, 200, 0.35); color: var(--teal); }
.toast-info    { background: rgba(255, 139, 42, 0.06); border: 1px solid rgba(255, 139, 42, 0.35); color: var(--amber); }

.empty {
    text-align: center;
    color: var(--ink-muted);
    padding: 40px 16px;
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

/* ============================================================
 * Sign-in
 * ============================================================ */
.signin-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.signin-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 28px;
}
.signin-brand {
    font-family: var(--display);
    font-size: 36px;
    line-height: 1;
    text-align: center;
    margin-bottom: 8px;
    display: inline-flex;
    justify-content: center;
    align-items: baseline;
    gap: 4px;
    width: 100%;
}
.signin-brand .b-italic {
    font-style: italic;
    font-variation-settings: "opsz" 96, "SOFT" 60;
    color: var(--ink);
}
.signin-brand .b-amber {
    color: var(--amber);
    font-style: normal;
    font-weight: 600;
    font-variation-settings: "opsz" 96, "SOFT" 0;
}
.signin-tagline {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--ink-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    margin-bottom: 28px;
}

/* ============================================================
 * Utility
 * ============================================================ */
.hidden { display: none; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row-end { justify-content: flex-end; }
.text-muted { color: var(--ink-muted); }
.text-sm { font-size: 12px; }
