/* ================================================================
   portal-chrome.css  --  First Light Agency Strategy Portal shared chrome
   Apple-dark OS-Design language, token-identical with the ops
   cockpit (ops.firstlightfilms.org). Source of truth:
   ~/OS Design/Apple Dark DESIGN.md + the --ck-* set in
   Ops-Brain/web/app/globals.css.

   Legacy --portal-* names are kept as aliases so older pages keep
   working; they now resolve to the ck values. Client deliverables
   and decks never load this file (they keep the First Light presentation
   identity via PRESENTATION_SPEC.md + portal-chrome.js).
   ================================================================ */

:root {
  /* ck Apple-dark tokens */
  --ck-canvas: #0f1a28;
  --ck-deep: #182838;
  --ck-graphite: #243447;
  --ck-elevated: #324355;
  --ck-smoke: #40556a;
  --ck-pearl: #fbf6ec;
  --ck-fog: #b1c4cc;
  --ck-fog-2: #c2dede;      /* muted on graphite: holds 4.5:1 */
  --ck-platinum: #d7e9e9;
  --ck-slate: #98afbc;      /* never for small text */
  --ck-magenta: #f8b818;
  --ck-magenta-bright: #ffd466;
  --ck-magenta-dim: #e86808;
  --ck-lime: #98c8c8;
  --ck-amber: #f59e0b;
  --ck-blue: #2997ff;
  --ck-red: #ef4444;
  --ck-rose: #e0607e;
  --ck-magenta-glow: rgba(248,184,24, 0.14);
  --ck-lime-glow: rgba(152,200,200, 0.12);
  --ck-hair: rgba(255, 255, 255, 0.07);
  --ck-hair-2: rgba(255, 255, 255, 0.12);
  --ck-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ck-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;

  /* Legacy aliases (older pages reference these names) */
  --portal-bg: var(--ck-canvas);
  --portal-surface: var(--ck-deep);
  --portal-surface-light: var(--ck-graphite);
  --portal-surface-hover: var(--ck-graphite);
  --portal-card: var(--ck-graphite);
  --portal-card-hover: var(--ck-elevated);
  --portal-accent: var(--ck-magenta);
  --portal-accent-bright: var(--ck-magenta-bright);
  --portal-accent-dim: rgba(248,184,24, 0.10);
  --portal-accent-glow: var(--ck-magenta-glow);
  --portal-accent-border: rgba(248,184,24, 0.28);
  --portal-pink: var(--ck-magenta);
  --portal-pink-dim: rgba(248,184,24, 0.12);
  --portal-gradient: var(--ck-magenta); /* flat fill; the gold gradient is retired */
  --portal-border: var(--ck-hair);
  --portal-border-hover: var(--ck-hair-2);
  --portal-green: var(--ck-lime);
  --portal-green-dim: var(--ck-lime-glow);
  --portal-amber: var(--ck-amber);
  --portal-amber-dim: rgba(245, 158, 11, 0.12);
  --portal-red: var(--ck-red);
  --portal-red-dim: rgba(239, 68, 68, 0.12);
  --portal-blue: var(--ck-blue);
  --portal-blue-dim: rgba(41, 151, 255, 0.12);
  --portal-purple: var(--ck-magenta-bright);
  --portal-text: var(--ck-pearl);
  --portal-text-secondary: var(--ck-fog-2);
  --portal-text-muted: var(--ck-fog);
  --portal-muted: var(--ck-fog);
  --portal-sidebar-w: 240px;
  --portal-sidebar-collapsed-w: 56px;
  --portal-topbar-h: 48px;
  --portal-status-h: 28px;
  --portal-radius-sm: 6px;
  --portal-radius: 10px;
  --portal-radius-lg: 14px;
  --portal-nav-height: 48px;
  --portal-font: var(--ck-font);
  --portal-font-mono: var(--ck-mono);
}

/* Retired JARVIS effects (class names kept so older pages don't break) */
.jarvis-grid-bg::before { content: none; }
.jarvis-scanlines::after { content: none; }
.status-breathe { animation: none; box-shadow: none; }
.status-pulse { animation: none; }
.text-glow { text-shadow: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp 0.4s ease forwards; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .fade-up { animation: none; opacity: 1; }
}

/* Shell */
.portal-shell { display: flex; height: 100vh; overflow: hidden; position: relative; z-index: 1; }
.portal-shell__main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; z-index: 10; }
.portal-shell__content { flex: 1; overflow-y: auto; padding: 1rem; background: var(--ck-canvas); }
@media (min-width: 769px) { .portal-shell__content { padding: 1.5rem; } }

/* Sidebar */
.portal-sidebar { width: var(--portal-sidebar-w); background: var(--ck-canvas); border-right: 1px solid var(--ck-hair); display: flex; flex-direction: column; overflow: hidden; position: relative; flex-shrink: 0; transition: width 0.2s ease; }
.portal-sidebar.collapsed { width: var(--portal-sidebar-collapsed-w); }
.portal-sidebar__glow { display: none; }
.portal-sidebar__header { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 12px; border-bottom: 1px solid var(--ck-hair); flex-shrink: 0; }
.portal-sidebar__logo { height: 22px; width: auto; max-width: 100%; object-fit: contain; flex-shrink: 0; }
.portal-sidebar.collapsed .portal-sidebar__logo { display: none; }
.portal-sidebar__label { margin-left: 8px; font-family: var(--ck-mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0; color: var(--ck-fog); }
.portal-sidebar__toggle { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--ck-fog); padding: 4px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: color 0.15s; }
.portal-sidebar__toggle:hover { color: var(--ck-pearl); }
.portal-sidebar.collapsed .portal-sidebar__label { display: none; }
.portal-sidebar__nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; }
.portal-sidebar__nav-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--ck-fog); text-decoration: none; transition: background 0.15s, color 0.15s; }
.portal-sidebar__nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--ck-pearl); }
.portal-sidebar__nav-item.active { background: rgba(248,184,24, 0.10); color: var(--ck-magenta-bright); box-shadow: inset 0 0 0 1px rgba(248,184,24, 0.28); }
.portal-sidebar__nav-item.active::before { content: none; }
.portal-sidebar__nav-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.portal-sidebar__nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-sidebar.collapsed .portal-sidebar__nav-item span { display: none; }
.portal-sidebar__section { padding: 0 8px; margin-bottom: 12px; }
.portal-sidebar__section-label { display: flex; align-items: center; gap: 6px; padding: 0 8px 6px; font-family: var(--ck-mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0; color: var(--ck-fog); }
.portal-sidebar.collapsed .portal-sidebar__section { display: none; }
.portal-sidebar__deliv-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 12px; letter-spacing: 0; color: var(--ck-fog); text-decoration: none; transition: background 0.15s, color 0.15s; }
.portal-sidebar__deliv-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--ck-pearl); }
.portal-sidebar__deliv-item.active { background: rgba(255, 255, 255, 0.06); color: var(--ck-pearl); }
.portal-sidebar__deliv-item .status-dot, .portal-sidebar__deliv-item .portal-sidebar__status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.portal-sidebar__deliv-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-sidebar__scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.portal-sidebar__client-toggle { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px; border: none; background: none; cursor: pointer; font-family: var(--ck-mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0; color: var(--ck-fog); border-radius: 6px; text-align: left; transition: background 0.15s, color 0.15s; }
.portal-sidebar__client-toggle:hover { background: rgba(255, 255, 255, 0.04); color: var(--ck-pearl); }
.portal-sidebar__client-toggle.open { color: var(--ck-pearl); }
.portal-sidebar__client-chevron { display: flex; align-items: center; transition: transform 0.2s ease; flex-shrink: 0; }
.portal-sidebar__client-chevron svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.portal-sidebar__client-toggle.open .portal-sidebar__client-chevron { transform: rotate(90deg); }
.portal-sidebar__client-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-sidebar__client-count { font-family: var(--ck-mono); font-size: 10px; color: var(--ck-fog); background: rgba(255, 255, 255, 0.06); padding: 1px 6px; border-radius: 999px; flex-shrink: 0; }
.portal-sidebar__client-items { padding-left: 12px; margin-bottom: 4px; }
.portal-sidebar__placeholder { padding: 12px 8px; font-size: 12px; color: var(--ck-fog); }

/* Mobile sidebar */
.portal-sidebar-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 9998; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.portal-sidebar-overlay.visible { opacity: 1; pointer-events: auto; }
@media (max-width: 768px) {
  .portal-sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 9999; width: 280px !important; transform: translateX(-100%); transition: transform 0.25s ease; }
  .portal-sidebar.open { transform: translateX(0); }
  .portal-sidebar.collapsed { width: 280px !important; }
  .portal-sidebar.collapsed .portal-sidebar__label, .portal-sidebar.collapsed .portal-sidebar__section, .portal-sidebar.collapsed .portal-sidebar__nav-item span { display: flex; }
}

/* Topbar */
.portal-topbar { display: flex; align-items: center; justify-content: space-between; height: var(--portal-topbar-h); padding: 0 12px; background: var(--ck-canvas); border-bottom: 1px solid var(--ck-hair); flex-shrink: 0; }
@media (min-width: 769px) { .portal-topbar { padding: 0 16px; } }
.portal-topbar__left { display: flex; align-items: center; gap: 8px; }
.portal-topbar__hamburger { display: flex; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; color: var(--ck-fog); padding: 8px; min-width: 44px; min-height: 44px; }
@media (min-width: 769px) { .portal-topbar__hamburger { display: none; } }
.portal-topbar__brand { display: flex; align-items: center; gap: 8px; }
.portal-topbar__brand img { height: 22px; width: auto; max-width: 100%; object-fit: contain; }
.portal-topbar__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ck-magenta); color: var(--ck-magenta); }
.portal-topbar__brand-label { font-family: var(--ck-mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0; color: var(--ck-fog); }
.portal-topbar__breadcrumb { display: none; align-items: center; gap: 6px; font-size: 13px; letter-spacing: 0; margin-left: 8px; }
@media (min-width: 769px) { .portal-topbar__breadcrumb { display: flex; } }
.portal-topbar__breadcrumb-link { color: var(--ck-fog); font-weight: 500; text-decoration: none; transition: color 0.15s; }
.portal-topbar__breadcrumb-link:hover { color: var(--ck-pearl); }
.portal-topbar__breadcrumb-sep { color: var(--ck-fog); font-size: 11px; }
.portal-topbar__breadcrumb-current { color: var(--ck-pearl); font-weight: 400; }
.portal-topbar__breadcrumb-muted { color: var(--ck-fog-2); font-weight: 400; }
.portal-topbar__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.portal-topbar__btn { font-size: 13px; font-family: var(--ck-font); font-weight: 500; letter-spacing: 0; padding: 6px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: color 0.15s, background 0.15s, border-color 0.15s; }
.portal-topbar__btn--ghost { background: var(--ck-graphite); border: 1px solid var(--ck-hair-2); color: var(--ck-pearl); }
.portal-topbar__btn--ghost:hover { border-color: rgba(255, 255, 255, 0.2); color: var(--ck-pearl); }

/* Status strip */
.portal-status-strip { display: flex; align-items: center; justify-content: space-between; height: var(--portal-status-h); padding: 0 16px; background: var(--ck-canvas); border-top: 1px solid var(--ck-hair); font-family: var(--ck-mono); font-size: 11px; letter-spacing: 0; color: var(--ck-fog); flex-shrink: 0; }
.portal-status-strip__group { display: flex; align-items: center; gap: 16px; }
.portal-status-strip .highlight { color: var(--ck-magenta-bright); }

/* Brand rail (presentation identity; injected by portal-chrome.js on decks
   only, never on portal chrome pages) */
.brand-rail { position: fixed; left: 0; top: 0; bottom: 0; width: 36px; z-index: 9000; background: #ffffff; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.brand-rail-text { writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 0.6rem; font-weight: 600; letter-spacing: 0; color: #0f1a28; white-space: nowrap; }
.brand-rail-dot { width: 7px; height: 7px; border-radius: 50%; background: #e86808; flex-shrink: 0; margin-top: 0.5rem; }
@media (max-width: 768px) { .brand-rail { display: none; } }

/* Grid bg (legacy class, retired) */
.portal-grid-bg::before { content: none; }

/* Base typography */
.portal-body { font-family: var(--ck-font); background: var(--ck-canvas); color: var(--ck-pearl); letter-spacing: 0; margin: 0; padding: 0; min-height: 100vh; -webkit-font-smoothing: antialiased; }
.portal-heading { font-weight: 600; line-height: 1.2; letter-spacing: 0; color: var(--ck-pearl); }
.portal-heading--pink { background: none; -webkit-background-clip: initial; -webkit-text-fill-color: currentColor; background-clip: initial; color: var(--ck-magenta-bright); }
.portal-muted { color: var(--ck-fog); }
.portal-label { font-family: var(--ck-mono); color: var(--ck-fog); font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: uppercase; }
.portal-gradient-line { width: 60px; height: 2px; background: var(--ck-magenta); border-radius: 2px; }

/* Cards */
.portal-card { position: relative; background: var(--ck-graphite); border: 1px solid var(--ck-hair); border-radius: var(--portal-radius-lg); padding: 1.25rem 1.5rem; text-decoration: none; color: var(--ck-pearl); display: block; transition: border-color 0.15s ease; }
.portal-card:hover { border-color: rgba(255, 255, 255, 0.14); }
.portal-card__label { font-family: var(--ck-mono); color: var(--ck-fog-2); font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: uppercase; margin-bottom: 0.35rem; }
.portal-card__title { font-size: 16px; font-weight: 600; letter-spacing: 0; line-height: 1.35; margin-bottom: 0.3rem; }
.portal-card__desc { font-size: 13px; font-weight: 400; color: var(--ck-fog-2); line-height: 1.5; }

/* Badges */
.portal-badge { display: inline-flex; align-items: center; gap: 0.35rem; font-family: var(--ck-mono); font-size: 10px; font-weight: 500; letter-spacing: 0; padding: 0.2rem 0.55rem; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.portal-badge--type { background: var(--ck-deep); border: 1px solid var(--ck-hair); color: var(--ck-fog-2); }
.portal-badge--draft { background: var(--portal-amber-dim); color: var(--ck-amber); }
.portal-badge--review { background: var(--portal-blue-dim); color: var(--ck-blue); }
.portal-badge--final { background: var(--ck-lime-glow); color: var(--ck-lime); }
.portal-badge__dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.portal-badge--draft .portal-badge__dot { background: var(--ck-amber); }
.portal-badge--review .portal-badge__dot { background: var(--ck-blue); }
.portal-badge--final .portal-badge__dot { background: var(--ck-lime); }

/* Buttons */
.portal-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.6rem 1.25rem; border-radius: 999px; font-family: var(--ck-font); font-weight: 500; font-size: 14px; letter-spacing: 0; cursor: pointer; border: none; text-decoration: none; transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease; }
.portal-btn--primary { background: var(--ck-magenta); color: #ffffff; box-shadow: 0 0 22px var(--ck-magenta-glow); }
.portal-btn--primary:hover { opacity: 0.92; }
.portal-btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.portal-btn--ghost { background: var(--ck-graphite); border: 1px solid var(--ck-hair-2); color: var(--ck-pearl); font-size: 13px; }
.portal-btn--ghost:hover { border-color: rgba(255, 255, 255, 0.2); color: var(--ck-pearl); }
.portal-btn--outline { background: none; border: 1px solid rgba(248,184,24, 0.28); color: var(--ck-magenta-bright); font-size: 13px; }
.portal-btn--outline:hover { background: rgba(248,184,24, 0.10); }

/* Focus visibility (ops uses the blue ring everywhere) */
.portal-body a:focus-visible,
.portal-body button:focus-visible,
.portal-body [tabindex]:focus-visible { outline: 2px solid var(--ck-blue); outline-offset: 2px; }

/* Toasts */
.portal-toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 10000; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.portal-toast { pointer-events: auto; background: var(--ck-graphite); border: 1px solid var(--ck-hair); border-radius: var(--portal-radius-lg); padding: 0.75rem 1.25rem; font-family: var(--ck-font); font-size: 13px; letter-spacing: 0; color: var(--ck-pearl); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); transform: translateX(120%); transition: transform 0.3s ease, opacity 0.3s ease; max-width: 360px; }
.portal-toast--visible { transform: translateX(0); }
.portal-toast--success { border-left: 3px solid var(--ck-lime); }
.portal-toast--error { border-left: 3px solid var(--ck-red); }
.portal-toast--info { border-left: 3px solid var(--ck-blue); }

/* Section headers */
.portal-section-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; margin-top: 2rem; }
.portal-section-header__line { flex: 1; height: 1px; background: var(--ck-hair); }
.portal-section-header__text { font-family: var(--ck-mono); font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: uppercase; color: var(--ck-fog); white-space: nowrap; }

/* Grid */
.portal-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .portal-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .portal-grid { grid-template-columns: repeat(3, 1fr); } }

/* Responsive helpers */
@media (max-width: 768px) { .portal-hide-mobile { display: none !important; } }
@media (min-width: 769px) { .portal-hide-desktop { display: none !important; } }
