/* ===================================================================
   AdsNine member portal -- stylesheet (warm light edition)

   Same visual system as the landing at the repo root: warm cream
   canvas, near-black ink, a three-stop brand gradient used sparingly
   as an accent. The side-rail shell, card grids and responsive
   breakpoints are unchanged from the previous (dark terminal) build;
   only colour, type and component surface changed.

   Sections:
     1. Font
     2. Design tokens (copied verbatim from the landing root styles.css)
     3. App tokens (spacing, type scale, radii -- the landing has no
        equivalent, this portal needs a denser UI than a marketing page)
     4. Reset + base
     5. Buttons
     6. Shell -- side rail + content
     7. Gate
     8. Dashboard -- progress row, cards, badges, org chart
     9. Agent page -- commands, knowledge, prompts, install
    10. Setup steps
    11. Memory / changelog
    12. Mobile
   =================================================================== */


/* 1. FONT -------------------------------------------------------------
   Cloudflare Pages deploys only portal/, so the font file is copied
   into portal/assets/fonts/ rather than pointing at the root assets/
   folder the landing ships from. */

@font-face {
  font-family: 'General Sans';
  src: url('assets/fonts/GeneralSans-Variable.woff2') format('woff2-variations');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}


/* 2. DESIGN TOKENS ------------------------------------------------------
   Copied verbatim from the landing's root :root block. */

:root {
  --canvas: #FBF8F3;
  --canvas-2: #F4EEE4;
  --surface: #FFFFFF;
  --hairline: rgba(26,23,20,.13);
  --ink: #1A1714;
  --ink-dim: rgba(26,23,20,.68);
  --ink-faint: rgba(26,23,20,.44);
  --violet: #A855F7;
  --magenta: #FF3D9A;
  --orange: #FF6B35;
  --brand-grad: linear-gradient(100deg, #A855F7 0%, #FF3D9A 52%, #FF6B35 100%);
  --radius: 14px;
}


/* 3. APP TOKENS -----------------------------------------------------------
   Spacing, type scale and the monospace stack. The spacing and text
   sizes are unchanged from the previous build, so the shell keeps
   every measurement it had; --font-mono is new, used only where
   content reads as code (license keys, terminal commands). Note that
   --ink-faint above is part of the copied token block but nothing
   below sets it on text -- body copy stays --ink or --ink-dim per the
   brief's contrast rule. */

:root {
  --font-display: 'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px;
  --space-lg: 24px; --space-xl: 32px; --space-2xl: 48px; --space-3xl: 72px;

  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.5rem; --text-2xl: 2rem; --text-3xl: 2.75rem;

  --radius-sm: 8px; --radius-md: 12px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-fast: 160ms;

  /* Not part of the landing palette, it has no error state. Warm
     enough to sit on --canvas without fighting the gradient's orange
     leg, used only for the gate's "key not recognized" message. */
  --error: #C0392B;
}


/* 4. RESET + BASE ----------------------------------------------------- */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: clip; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { font-style: normal; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }

/* Every focusable element gets this, :focus-visible only ever matches
   elements that can take focus, so there is no need to enumerate
   selectors here. */
:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

.cursor { color: var(--violet); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  * { transition-duration: 0ms !important; }
}


/* 5. BUTTONS -----------------------------------------------------------
   Base is a white outline pill so it reads as secondary next to the
   two accented variants below it. */

.btn {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: 999px;
  border: 1.5px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--canvas-2); border-color: rgba(26,23,20,.3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }

.btn-buy { background: var(--brand-grad); border-color: transparent; color: #fff; font-weight: 700; }
.btn-buy:hover { filter: brightness(1.06); }

.btn-wide { width: 100%; text-align: center; }


/* 6. SHELL -- SIDE RAIL + CONTENT --------------------------------------- */

.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--canvas-2);
  border-right: 1px solid var(--hairline);
  padding: var(--space-lg) var(--space-md);
  display: flex; flex-direction: column; gap: var(--space-lg);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail-logo { font-weight: 600; font-size: var(--text-md); }
.rail-logo a {
  text-decoration: none;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.rail-label {
  font-size: var(--text-xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: var(--space-xs);
}
.rail-link {
  display: block; padding: var(--space-2xs) var(--space-xs); border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  font-size: var(--text-sm); color: var(--ink-dim); text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.rail-link:hover { background: var(--surface); color: var(--ink); }
.rail-link.active { background: var(--surface); color: var(--ink); border-left-color: var(--violet); font-weight: 500; }
.rail-link .mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.rail-foot { margin-top: auto; border-top: 1px solid var(--hairline); padding-top: var(--space-md); }
.rail-key { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-dim); overflow-wrap: anywhere; }
.rail-signout {
  margin-top: var(--space-xs); background: none; border: none; color: var(--ink-dim);
  font-size: var(--text-xs); cursor: pointer; padding: 0; font-family: var(--font-body);
}
.rail-signout:hover { color: var(--ink); text-decoration: underline; }

.content { padding: var(--space-2xl) var(--space-2xl) var(--space-3xl); max-width: 980px; }


/* 7. GATE ---------------------------------------------------------------
   A centred white card on the canvas. The wordmark is the one accent
   word on this screen, set with the brand gradient clipped to its
   text; everything else stays ink or ink-dim. */

.gate {
  min-height: 100vh; display: grid; place-items: center; padding: var(--space-lg);
}
.gate-box {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: var(--space-2xl) var(--space-xl);
  box-shadow: 0 1px 2px rgba(26,23,20,.05), 0 20px 44px rgba(26,23,20,.07);
}
.gate-logo {
  font-size: var(--text-lg); font-weight: 600;
  margin-bottom: var(--space-2xl);
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gate-logo-mark { vertical-align: -6px; margin-right: 8px; }
.rail-logo-mark { vertical-align: -5px; margin-right: 7px; }
.gate-title { font-weight: 500; font-size: var(--text-xl); margin-bottom: var(--space-sm); color: var(--ink); }
.gate-sub { color: var(--ink-dim); font-size: var(--text-sm); margin-bottom: var(--space-lg); }
.key-input {
  width: 100%; padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono); font-size: var(--text-md); letter-spacing: .04em;
  background: var(--canvas-2); color: var(--ink);
  border: 1.5px solid var(--hairline); border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.key-input::placeholder { color: var(--ink-dim); }
.key-input:hover { border-color: rgba(26,23,20,.3); }
.key-input:focus-visible { border-color: var(--violet); }
.gate-error { color: var(--error); font-size: var(--text-sm); margin-bottom: var(--space-sm); }
.gate-hint { color: var(--ink-dim); font-size: var(--text-xs); margin-top: var(--space-lg); }


/* 8. DASHBOARD -- PROGRESS, CARDS, BADGES, ORG CHART --------------------- */

.page-eyebrow { font-size: var(--text-xs); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: var(--space-xs); }
.page-title { font-weight: 600; font-size: var(--text-2xl); line-height: 1.2; letter-spacing: -.01em; margin-bottom: var(--space-sm); }
.page-sub { color: var(--ink-dim); max-width: 60ch; margin-bottom: var(--space-xl); }

.progress-row {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md); border: 1px solid var(--hairline); border-radius: var(--radius-md);
  margin-bottom: var(--space-xl); background: var(--surface);
  flex-wrap: wrap;
}
.progress-count {
  font-size: var(--text-lg); font-weight: 700; color: var(--ink);
  padding: 3px var(--space-sm);
  background: rgba(168,85,247,.12);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}
.progress-note { color: var(--ink-dim); font-size: var(--text-sm); flex: 1; min-width: 200px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: var(--space-md); }
.card {
  background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-sm);
  box-shadow: 0 1px 2px rgba(26,23,20,.05);
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.card:hover { border-color: rgba(26,23,20,.3); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(26,23,20,.08); }

.card-locked { opacity: .75; background: var(--canvas-2); }
.card-locked .card-name, .card-locked .card-tag { color: var(--ink-dim); }
.card-locked:hover { transform: none; box-shadow: 0 1px 2px rgba(26,23,20,.05); }

.card-cmo { border-color: rgba(168,85,247,.35); background: linear-gradient(180deg, rgba(168,85,247,.07), var(--surface) 60%); }
.card-cmo.card-locked { background: var(--canvas-2); }

.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-sm); flex-wrap: wrap; }
.card-name { font-weight: 600; font-size: var(--text-md); }
.card-name a { text-decoration: none; }
.card-name a:hover { text-decoration: underline; }
.card-price { font-size: var(--text-xs); color: var(--ink-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.card-tag { color: var(--ink-dim); font-size: var(--text-sm); flex: 1; }

.badge {
  display: inline-block; font-size: var(--text-xs); font-weight: 500;
  padding: 2px var(--space-xs); border-radius: 999px; border: 1px solid var(--hairline);
  /* Always --surface, not --canvas-2: badges sit on both unlocked
     (surface) and locked (canvas-2) cards, and a canvas-2 fill would
     disappear into the locked card's own background. */
  background: var(--surface);
  color: var(--ink-dim); width: fit-content;
}
.badge-installed { color: var(--ink); border-color: rgba(168,85,247,.35); background: rgba(168,85,247,.12); }
.badge-boss { color: #fff; background: var(--brand-grad); border-color: transparent; font-weight: 600; }

.card-actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.card-actions .btn { padding: var(--space-2xs) var(--space-sm); font-size: var(--text-xs); }

/* Org chart on the dashboard: CMO card, a connector line, the team. */
.lead-card {
  flex-direction: row; align-items: center; justify-content: space-between;
  gap: var(--space-lg); flex-wrap: wrap;
}
.lead-card:hover { transform: none; }
.lead-main { flex: 1; min-width: 240px; }
.lead-card .card-top { justify-content: flex-start; margin-bottom: var(--space-xs); }
.lead-card .card-actions { align-items: center; flex-wrap: wrap; }
.lead-prompt { margin-bottom: 0; padding: var(--space-2xs) var(--space-sm); }
.org-line { width: 1px; height: 28px; background: var(--violet); margin: 0 auto; opacity: .5; }
.team-label { font-size: var(--text-xs); color: var(--ink-dim); text-align: center; margin: var(--space-xs) 0 var(--space-md); }


/* 9. AGENT PAGE ----------------------------------------------------------- */

.back-link { font-size: var(--text-xs); color: var(--ink-dim); text-decoration: none; display: inline-block; margin-bottom: var(--space-lg); }
.back-link:hover { color: var(--ink); text-decoration: underline; }
.agent-head { display: flex; align-items: baseline; gap: var(--space-md); flex-wrap: wrap; margin-bottom: var(--space-xs); }
.replaces {
  border-left: 3px solid var(--violet); padding: var(--space-xs) var(--space-md);
  color: var(--ink-dim); font-size: var(--text-sm); margin: var(--space-lg) 0 var(--space-xl);
  background: var(--canvas-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.section-title { font-size: var(--text-md); font-weight: 600; margin: var(--space-xl) 0 var(--space-md); color: var(--ink); }

.cmd-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.cmd-table td { padding: var(--space-sm) var(--space-md); border-top: 1px solid var(--hairline); vertical-align: top; }
.cmd-table tr:last-child td { border-bottom: 1px solid var(--hairline); }
.cmd-table .cmd { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; color: var(--ink); white-space: nowrap; }
.cmd-table .desc { color: var(--ink-dim); }
.table-wrap { overflow-x: auto; }

.kb-list { list-style: none; }
.kb-list li { padding: var(--space-xs) 0; border-top: 1px solid var(--hairline); color: var(--ink-dim); font-size: var(--text-sm); }
.kb-list li::before { content: "\25B8  "; color: var(--ink); }

.prompt-block {
  font-family: var(--font-mono); font-size: var(--text-sm);
  background: var(--canvas-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md); margin-bottom: var(--space-xs);
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-md);
  overflow-wrap: anywhere;
  color: var(--ink);
}
.copy-btn {
  font-family: var(--font-body); font-size: var(--text-xs); color: var(--ink-dim);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 999px;
  padding: 2px var(--space-sm); cursor: pointer; white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.copy-btn:hover { color: var(--ink); border-color: rgba(26,23,20,.3); }
.copy-btn.copied { color: var(--violet); border-color: var(--violet); }

.install-row { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin: var(--space-lg) 0; }
.install-check { display: flex; align-items: center; gap: var(--space-xs); margin-top: var(--space-lg); color: var(--ink-dim); font-size: var(--text-sm); }
.install-check input { accent-color: var(--violet); width: 16px; height: 16px; }


/* 10. SETUP STEPS ----------------------------------------------------------- */

.step {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--space-md);
  padding: var(--space-lg) 0; border-top: 1px solid var(--hairline);
}
.step-num { font-weight: 700; color: var(--ink); font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.step h3 { font-size: var(--text-md); font-weight: 600; margin-bottom: var(--space-xs); }
.step p { color: var(--ink-dim); font-size: var(--text-sm); margin-bottom: var(--space-sm); }
.step code { font-family: var(--font-mono); font-size: .9em; background: var(--canvas-2); padding: 1px 5px; border-radius: 4px; }
.step a:hover { color: var(--ink); }


/* 11. MEMORY / CHANGELOG ----------------------------------------------------- */

.mem-file { margin-bottom: var(--space-lg); }
.mem-file .prompt-block { margin-top: var(--space-xs); }
.log-item { padding: var(--space-md) 0; border-top: 1px solid var(--hairline); }
.log-date { font-size: var(--text-xs); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.log-item p { color: var(--ink-dim); font-size: var(--text-sm); margin-top: var(--space-2xs); }


/* 12. MOBILE ----------------------------------------------------------------- */

/* The top bar only exists on phones; on desktop the side rail is the nav. */
.topbar { display: none; }

@media (max-width: 768px) {
  .shell { display: block; }

  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    padding: var(--space-sm) var(--space-md);
    background: var(--canvas-2);
    border-bottom: 1px solid var(--hairline);
  }
  .topbar-logo {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: var(--text-md); text-decoration: none; color: var(--ink);
  }
  .topbar-toggle {
    width: 44px; height: 44px; flex: none;
    display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
    cursor: pointer;
  }
  /* Three lines that fold into an X when the drawer is open. */
  .bars, .bars::before, .bars::after {
    display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink);
    transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
  }
  .bars::before, .bars::after { content: ""; position: relative; }
  .bars::before { top: -6px; }
  .bars::after { top: 4px; }
  .topbar-toggle[aria-expanded="true"] .bars { background: transparent; }
  .topbar-toggle[aria-expanded="true"] .bars::before { top: -2px; transform: rotate(45deg); }
  .topbar-toggle[aria-expanded="true"] .bars::after { top: -4px; transform: rotate(-45deg); }

  /* --topbar-h is measured in app.js so the drawer sits flush under the bar
     whatever the font or notch does to its height. */
  .rail {
    position: sticky; top: var(--topbar-h, 61px); z-index: 19;
    height: auto; max-height: calc(100vh - var(--topbar-h, 61px)); overflow-y: auto;
    border-right: none; border-bottom: 1px solid var(--hairline);
    padding: var(--space-md);
    gap: var(--space-md);
  }
  .rail[hidden] { display: none; }
  .rail-logo { display: none; }
  .rail-link { padding: var(--space-xs) var(--space-sm); font-size: var(--text-md); }

  .content { padding: var(--space-lg) var(--space-md) var(--space-2xl); }
  .page-title { font-size: var(--text-xl); }

  /* Commands read as stacked blocks; a two-column table forces a pinch-zoom. */
  .cmd-table, .cmd-table tbody, .cmd-table tr, .cmd-table td { display: block; width: 100%; }
  .cmd-table td { padding: 0; border: none; }
  .cmd-table tr { padding: var(--space-sm) 0; border-top: 1px solid var(--hairline); }
  .cmd-table tr:last-child { border-bottom: 1px solid var(--hairline); }
  .cmd-table .cmd { white-space: normal; overflow-wrap: anywhere; margin-bottom: 2px; }

  /* Copy button below the snippet instead of squeezed beside it. */
  .prompt-block { flex-direction: column; align-items: stretch; gap: var(--space-xs); }
  .copy-btn { align-self: flex-start; min-height: 40px; padding: 0 var(--space-lg); font-size: var(--text-sm); }

  .card-actions { gap: var(--space-sm); }
  .card-actions .btn { flex: 1 1 auto; text-align: center; padding: 10px var(--space-sm); font-size: var(--text-sm); }
  /* The CMO card puts a snippet next to Open; side by side they are both too
     narrow to read or hit on a phone. */
  .lead-card .card-actions { flex-direction: column; align-items: stretch; }
  .lead-prompt { width: 100%; }
  .install-row .btn { flex: 1 1 auto; text-align: center; }
  .step { grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-sm); }
}
