/* ==========================================================================
   RLS Dock — application stylesheet
   Built on the RLS design system (docs/DESIGN-SYSTEM.md from RLS.Engaged).
   Warm paper canvas, green as the only chromatic color, numbers in mono.
   ========================================================================== */

/* ---- fonts: self-hosted variable woff2 (no CDN, offline-safe) ------------- */
@font-face {
    font-family: 'Hanken Grotesk';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('lib/fonts/hanken-grotesk-var.woff2') format('woff2');
}
@font-face {
    font-family: 'Spline Sans Mono';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('lib/fonts/spline-sans-mono-var.woff2') format('woff2');
}

/* ---- tokens (official RLS standard, doc MM-0055) -------------------------- */
:root {
    --rls-green:       #08713d;
    --rls-green-dark:  #004623;
    --rls-green-light: #85c989;
    --rls-green-50:    #eaf4ea;

    --rls-paper:     #f4f2ea;
    --rls-card:      #ffffff;
    --rls-ink:       #0c1a14;
    --rls-text:      #1A1A1A;
    --rls-muted:     #6C757D;
    --rls-line:      rgba(12, 26, 20, .10);
    --rls-line-soft: rgba(12, 26, 20, .06);
    --rls-signal:    #df7a39;

    --rls-mono: 'Spline Sans Mono', ui-monospace, 'Cascadia Mono', monospace;

    --rls-sh-sm: 0 1px 2px rgba(12,26,20,.05), 0 1px 3px rgba(12,26,20,.05);
    --rls-sh-md: 0 2px 6px rgba(12,26,20,.04), 0 14px 32px -14px rgba(12,26,20,.16);
    --rls-radius: 13px;
}

/* ---- base ----------------------------------------------------------------- */
html, body {
    font-family: 'Hanken Grotesk', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--rls-text);
    letter-spacing: -.006em;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
body { background-color: var(--rls-paper); min-height: 100vh; }

h1,h2,h3,h4,h5,.h1,.h2,.h3,.h4,.h5 { letter-spacing: -.022em; }
h1, .h1 { font-weight: 800; color: var(--rls-ink); }
h2,.h2,h3,.h3 { font-weight: 700; color: var(--rls-ink); }

a { color: var(--rls-green); text-underline-offset: 2px; }
a:hover { color: var(--rls-green-dark); }

/* Bootstrap 5.1 has no .fw-semibold (arrived in 5.2) — polyfill it. */
.fw-semibold { font-weight: 600; }

/* ---- type utilities ------------------------------------------------------- */
.rls-mono   { font-family: var(--rls-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rls-metric { font-family: var(--rls-mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; font-weight: 600; color: var(--rls-ink); }
.rls-label  { font-family: var(--rls-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--rls-muted); }

/* ---- cards / surfaces ----------------------------------------------------- */
.card {
    background-color: var(--rls-card);
    border: 1px solid var(--rls-line);
    border-radius: var(--rls-radius);
    box-shadow: var(--rls-sh-sm);
}
.card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--rls-line-soft);
    font-weight: 600;
    letter-spacing: -.01em;
}
.modal-content, .dropdown-menu { border-radius: var(--rls-radius); border-color: var(--rls-line); }
.dropdown-menu { box-shadow: var(--rls-sh-md); }

/* ---- buttons -------------------------------------------------------------- */
.btn { border-radius: 9px; transition: background-color .16s, border-color .16s, transform .16s, box-shadow .16s; font-weight: 600; }
.btn-primary { color:#fff; background-color: var(--rls-green); border-color: var(--rls-green-dark); box-shadow: var(--rls-sh-sm); }
.btn-primary:hover, .btn-primary:focus { color:#fff; background-color: var(--rls-green-dark); border-color: var(--rls-green-dark); transform: translateY(-1px); }
.btn-outline-primary { color: var(--rls-green); border-color: var(--rls-green); }
.btn-outline-primary:hover { color:#fff; background-color: var(--rls-green); border-color: var(--rls-green); }
.btn-lg { border-radius: 11px; }

/* ---- forms ---------------------------------------------------------------- */
.form-control, .form-select {
    border-radius: 9px;
    border-color: var(--rls-line);
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--rls-green);
    box-shadow: 0 0 0 3px rgba(8,113,61,.14);
}
.form-label { font-weight: 600; color: var(--rls-ink); margin-bottom: .35rem; }

/* ---- status pills / badges ------------------------------------------------ */
.badge { font-weight: 600; letter-spacing: -.004em; padding: .36em .62em; font-size: .74rem; }
.badge:not(.rounded-pill) { border-radius: 7px; }
.badge.bg-light     { background:#fff !important; border:1px solid var(--rls-line); color:#44524a !important; }
.badge.bg-success   { background: var(--rls-green) !important; }
.badge.bg-signal    { background: rgba(223,122,57,.12) !important; color: #b4551d !important; }

/* ---- ledger grid (dense, instrument headers) ----------------------------- */
.table { font-variant-numeric: tabular-nums; }
.dock-grid { --bs-table-hover-bg: var(--rls-green-50); }
.dock-grid thead th {
    font-family: var(--rls-mono); font-size: 10.5px; font-weight: 600;
    letter-spacing: .07em; text-transform: uppercase; color: var(--rls-muted);
    border-bottom: 1px solid var(--rls-line) !important;
    padding: 11px 14px; white-space: nowrap; background: var(--rls-card);
    position: sticky; top: 0; z-index: 1;
}
.dock-grid tbody td { padding: 9px 14px; border-bottom-color: var(--rls-line-soft); vertical-align: middle; }
.dock-grid tbody tr:hover { background: var(--rls-green-50); }

/* A small mono data chip, e.g. "22 pallets" */
.rls-chip {
    display: inline-flex; align-items: center; gap: .35em;
    font-family: var(--rls-mono); font-variant-numeric: tabular-nums;
    font-size: .78rem; font-weight: 500;
    padding: .22em .55em; border-radius: 7px;
    background: var(--rls-green-50); color: var(--rls-green-dark);
}
.rls-chip.frozen { background: rgba(223,122,57,.12); color: #b4551d; }

/* ==========================================================================
   Portal / public shell — the surfaces external customers & carriers see.
   Calm, centered, warm paper. No staff sidebar.
   ========================================================================== */
.portal-shell { min-height: 100vh; display: flex; flex-direction: column; }

.dock-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px clamp(20px, 5vw, 56px);
    border-bottom: 1px solid var(--rls-line);
    background: rgba(244,242,234,.86);
    backdrop-filter: saturate(1.1) blur(8px);
    position: sticky; top: 0; z-index: 20;
}
.dock-topbar .brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.dock-topbar .brand img { height: 30px; display: block; }
.dock-topbar .brand-name { font-weight: 800; color: var(--rls-ink); letter-spacing: -.03em; font-size: 1.15rem; }
.dock-topbar .brand-name .accent { color: var(--rls-green); }

.portal-main { flex: 1; padding: clamp(28px, 5vw, 64px) clamp(20px, 5vw, 56px); }
.portal-narrow { max-width: 460px; margin: 0 auto; }
.portal-wide { max-width: 1040px; margin: 0 auto; }

.dock-footer {
    padding: 20px clamp(20px,5vw,56px);
    border-top: 1px solid var(--rls-line);
    color: var(--rls-muted); font-size: .8rem;
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ---- hero (landing) ------------------------------------------------------- */
.dock-hero { position: relative; padding: clamp(40px,7vw,88px) 0 clamp(28px,4vw,44px); }
.dock-hero .eyebrow { margin-bottom: 18px; }
.dock-hero h1 {
    font-size: clamp(2.2rem, 5.2vw, 3.7rem); line-height: 1.02; font-weight: 800;
    max-width: 16ch; margin: 0 0 18px;
}
.dock-hero h1 .accent { color: var(--rls-green); }
.dock-hero p.lead { font-size: 1.12rem; color: var(--rls-muted); max-width: 52ch; margin: 0; }

/* faint cold-chain gridlines behind the hero — atmosphere, not decoration */
.dock-hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image:
        linear-gradient(var(--rls-line-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--rls-line-soft) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(120% 80% at 15% 0%, #000 25%, transparent 72%);
    -webkit-mask-image: radial-gradient(120% 80% at 15% 0%, #000 25%, transparent 72%);
    opacity: .7;
}

/* ---- role cards (choose Customer / Carrier / Staff) ----------------------- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 38px; }
.role-card {
    display: flex; flex-direction: column; gap: 12px;
    padding: 24px; border-radius: var(--rls-radius);
    background: var(--rls-card); border: 1px solid var(--rls-line);
    box-shadow: var(--rls-sh-sm); text-decoration: none; color: var(--rls-text);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.role-card:hover { transform: translateY(-3px); box-shadow: var(--rls-sh-md); border-color: rgba(8,113,61,.4); color: var(--rls-text); }
.role-card .role-icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: grid; place-items: center;
    background: var(--rls-green-50); color: var(--rls-green-dark);
}
.role-card h3 { font-size: 1.12rem; margin: 0; }
.role-card p { color: var(--rls-muted); font-size: .9rem; margin: 0; flex: 1; }
.role-card .go { color: var(--rls-green); font-weight: 700; font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; }
.role-card:hover .go { gap: 10px; }

/* ---- auth card ------------------------------------------------------------ */
.auth-card { padding: 30px; border-radius: var(--rls-radius); background: var(--rls-card); border: 1px solid var(--rls-line); box-shadow: var(--rls-sh-md); }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 6px; }
.auth-note { font-size: .86rem; color: var(--rls-muted); }
.role-toggle { display: inline-flex; padding: 3px; gap: 3px; background: var(--rls-green-50); border-radius: 10px; }
.role-toggle button {
    border: 0; background: transparent; border-radius: 8px;
    padding: 7px 16px; font-weight: 600; font-size: .88rem; color: var(--rls-green-dark);
    cursor: pointer; transition: background .14s;
}
.role-toggle button.active { background: #fff; box-shadow: var(--rls-sh-sm); color: var(--rls-green); }

.alert-soft { border-radius: 10px; border: 1px solid var(--rls-line); background: #fff; padding: 12px 14px; font-size: .88rem; }
.alert-soft.ok { border-color: rgba(8,113,61,.3); background: var(--rls-green-50); color: var(--rls-green-dark); }
.alert-soft.err { border-color: rgba(223,122,57,.4); background: rgba(223,122,57,.08); color: #b4551d; }

/* ==========================================================================
   Staff shell — deep green sidebar rail (matches Engaged)
   ========================================================================== */
.staff-page { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex-shrink: 0; color: #fff;
    background-image: linear-gradient(165deg, #0a7a45 0%, #08713d 30%, #004623 100%);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .sidebar-brand { padding: 22px 20px 14px; display: flex; align-items: center; gap: 10px; }
.sidebar .sidebar-brand img { height: 28px; }
.sidebar .sidebar-brand .brand-name { font-weight: 800; letter-spacing: -.03em; font-size: 1.1rem; }
.nav-scrollable { overflow-y: auto; padding: 8px 12px; flex: 1; }
.sidebar .nav-section {
    font-family: var(--rls-mono); font-size: 10px; font-weight: 600; letter-spacing: .14em;
    text-transform: uppercase; color: rgba(255,255,255,.45);
    padding: 16px 12px 6px; margin-top: 6px; border-top: 1px solid rgba(255,255,255,.10);
}
.sidebar .nav-link {
    color: rgba(255,255,255,.85); border-left: 3px solid transparent; border-radius: 8px;
    padding: 9px 12px; display: flex; align-items: center; gap: 11px; font-weight: 600; font-size: .92rem;
    margin-bottom: 3px;
}
.sidebar .nav-link:hover { color:#fff; background: rgba(255,255,255,.07); }
.sidebar .nav-link.active {
    background-color: rgba(133,201,137,.16); color:#fff;
    border-left: 3px solid var(--rls-green-light);
    box-shadow: inset 2px 0 14px -6px rgba(133,201,137,.7);
}
.sidebar .nav-link svg { opacity: .8; }
.sidebar .nav-link.active svg { opacity: 1; }
.sidebar .sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: .82rem; color: rgba(255,255,255,.75); }

.staff-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.staff-topbar {
    height: 62px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 26px; border-bottom: 1px solid var(--rls-line); background: rgba(244,242,234,.86);
    backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10;
}
.staff-main { padding: 28px 26px; flex: 1; }

/* ---- scrollbars ----------------------------------------------------------- */
.nav-scrollable { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; }
.nav-scrollable::-webkit-scrollbar { width:10px; }
.nav-scrollable::-webkit-scrollbar-track { background:transparent; }
.nav-scrollable::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,.16); border-radius:99px; border:3px solid transparent; background-clip:padding-box; }
.nav-scrollable::-webkit-scrollbar-thumb:hover { background-color: rgba(133,201,137,.6); }
html { scrollbar-width: thin; scrollbar-color: rgba(12,26,20,.24) transparent; }
html::-webkit-scrollbar { width:12px; height:12px; }
html::-webkit-scrollbar-track { background:transparent; }
html::-webkit-scrollbar-thumb { background-color: rgba(12,26,20,.18); border-radius:99px; border:3px solid transparent; background-clip:padding-box; }
html::-webkit-scrollbar-thumb:hover { background-color: rgba(12,26,20,.34); }

/* ---- staggered page-load reveal (one orchestrated moment) ----------------- */
@keyframes rls-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rls-rise .5s cubic-bezier(.2,.7,.2,1) both; }
.rise-1 { animation-delay: .04s; } .rise-2 { animation-delay: .1s; }
.rise-3 { animation-delay: .16s; } .rise-4 { animation-delay: .22s; }
@media (prefers-reduced-motion: reduce) { .rise { animation: none; } }

/* ---- Blazor error UI ------------------------------------------------------ */
#blazor-error-ui {
    background: #fff; border-top: 1px solid var(--rls-signal);
    box-shadow: 0 -1px 10px rgba(12,26,20,.1);
    display: none; left: 0; bottom: 0; padding: 10px 16px; position: fixed; width: 100%; z-index: 1000;
    font-size: .88rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 8px; }
.blazor-error-boundary { background: rgba(223,122,57,.1); padding: 12px 16px; border-radius: 10px; color: #b4551d; }
