/* ============================================================================
   Octopus BOS — Accessible Brand Design System (Pink)
   One brain. Eight arms. Unlimited agents.

   Single source of truth for the Pink brand identity, tuned to WCAG 2.1 AA.
   Brand source: Idea/branding/pink — Space Grotesk + JetBrains Mono,
   near-black ink, Octo Pink primary, Brain Cyan + Sucker Teal accents.

   CONTRAST RULES baked into the tokens below (measured on --ink #0E0810):
     - Body/small text  : --text 16.4:1, --muted 7.6:1            (AA normal OK)
     - Small pink text  : use --pink-text (#F0A6DD) 10.6:1         (NOT raw pink)
     - Raw --pink       : 4.58:1 on ink -> headings/large or FILLS only
     - --pink-deep      : 2.0:1  -> FILLS / gradient stops only, never text
     - --faint          : 3.7:1  -> large text / decorative only
     - Pink/teal FILLS  : take ink text (--on-accent), never white
     - Focus ring       : --cyan 8.4:1, always visible
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* ---- Ink scale (backgrounds) -------------------------------------------- */
  --ink:        #0E0810;   /* page background          */
  --bg2:        #120A14;   /* deep panels              */
  --surface:    #1A121C;   /* card surface             */
  --raised:     #241828;   /* raised / hover surface   */
  --line:       #2E2030;   /* borders                  */
  --line-soft:  rgba(255,255,255,.07);

  /* ---- Text (AA-verified on ink) ------------------------------------------ */
  --text:       #ECE8F4;   /* primary  16.4:1          */
  --muted:      #A39DB4;   /* secondary 7.6:1          */
  --faint:      #6E6880;   /* 3.7:1 — LARGE/decorative only */

  /* ---- Brand accents ------------------------------------------------------ */
  --pink:       #D6359E;   /* primary brand — fills + large text */
  --pink-text:  #F0A6DD;   /* 10.6:1 — small pink TEXT on dark   */
  --pink-deep:  #7A1860;   /* FILL/gradient stop only            */
  --cyan:       #68AEF0;   /* intelligence + focus ring 8.4:1    */
  --teal:       #22D3D3;   /* live signal 10.7:1                 */
  --teal-deep:  #0E9E9E;   /* 6.0:1                              */

  /* ---- Text colour to sit ON a bright accent fill ------------------------- */
  --on-accent:  #0E0810;   /* ink on pink 4.58:1 / on teal 10.7:1 */

  /* ---- Status (AA-verified on ink) ---------------------------------------- */
  --danger:     #FB7185;   /* 7.35:1 */
  --success:    #4ADE80;   /* 11.4:1 */
  --warning:    #F5C451;   /* 12.2:1 */

  /* ---- Gradients (decorative; never the only carrier of meaning) ---------- */
  --grad-brand: linear-gradient(135deg, #D6359E 0%, #22D3D3 100%);
  --grad-pink:  linear-gradient(155deg, #E84FB8 0%, #7A1860 100%);

  /* ---- Geometry ----------------------------------------------------------- */
  --maxw:       1120px;
  --radius:     12px;
  --radius-lg:  18px;
  --focus:      var(--cyan);

  --font-sans:  'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;
}

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

/* 100% = 16px (browser default) so rem-based sizing scales cleanly to 200%. */
html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--ink);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 1rem;
  /* avoid forcing horizontal scroll, but allow content to wrap at 200% zoom */
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ---- Typography (rem so 200% zoom never clips) -------------------------- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); letter-spacing: -0.04em; }
h2 { font-size: clamp(1.35rem, 1rem + 1.4vw, 1.75rem); }
h3 { font-size: 1.25rem; }
p  { max-width: 70ch; }
a  { color: var(--pink-text); text-underline-offset: 0.18em; }
a:hover { color: var(--text); }

small, .text-muted { color: var(--muted); }

/* The brand // mono "comment device" for labels, ports, status lines. */
.mono, .eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--muted);           /* 7.6:1 — readable, not --faint */
}

/* ============================================================================
   ACCESSIBILITY PRIMITIVES
   ========================================================================== */

/* Skip link — first focusable element; visible on focus. */
.skip-link {
  position: absolute;
  left: 0; top: -100%;
  z-index: 1000;
  background: var(--pink);
  color: var(--on-accent);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 0; color: var(--on-accent); }

/* Visible focus for EVERY interactive element (keyboard operability). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Keep a fallback ring for browsers without :focus-visible. */
:where(a, button, input, select, textarea):focus { outline-color: var(--focus); }

/* Screen-reader-only utility (use for icon-only control labels). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   LAYOUT LANDMARKS
   ========================================================================== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.brand-lockup { display: flex; align-items: center; gap: 0.625rem; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--grad-brand);
  font-size: 1.1rem;
}
.brand-name { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.02em; }
.brand-sub  {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.16em;
}

main { display: block; }
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding: 2rem 1.5rem; }

.app-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem; text-align: center;
  color: var(--muted); font-family: var(--font-mono); font-size: 0.78rem;
}

/* ============================================================================
   CARDS / TILES
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.875rem;
}
.tile {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.tile:hover { border-color: var(--pink); background: var(--raised); transform: translateY(-2px); color: var(--text); }
.tile .tile-icon { font-size: 1.4rem; }
.tile .tile-name { font-weight: 600; }

/* ============================================================================
   FORMS — every control pairs with an explicit <label for>
   ========================================================================== */
.field { margin-bottom: 1.25rem; }
.field > label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.field .hint { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.375rem; }
.req { color: var(--pink-text); }   /* required marker — has text alt in label */

.input, input[type=text], input[type=password], input[type=email],
input[type=tel], input[type=number], input[type=search], input[type=date],
select, textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;            /* >=16px avoids iOS zoom; scales with rem */
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(104,174,240,0.25);
  outline: none;             /* box-shadow ring is the visible focus here */
}
input:invalid:not(:placeholder-shown) { border-color: var(--danger); }
textarea { resize: vertical; min-height: 6rem; }

/* ============================================================================
   BUTTONS — bright fills carry INK text for AA contrast
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--font-sans); font-weight: 700; font-size: 1rem;
  padding: 0.8rem 1.4rem;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: filter 0.15s, transform 0.12s, background 0.15s;
}
.btn:hover  { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block  { width: 100%; }

.btn-primary   { background: var(--pink); color: var(--on-accent); }   /* 4.58:1 */
.btn-secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--raised); border-color: var(--pink); }
.btn-accent    { background: var(--teal); color: var(--on-accent); }   /* 10.7:1 */

/* ============================================================================
   STATUS / FEEDBACK  (icon + colour + text — never colour alone)
   ========================================================================== */
.alert {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}
.alert-error   { background: rgba(251,113,133,0.08); border-color: rgba(251,113,133,0.4); color: var(--danger); }
.alert-success { background: rgba(74,222,128,0.08);  border-color: rgba(74,222,128,0.4);  color: var(--success); }
.alert-warning { background: rgba(245,196,81,0.08);  border-color: rgba(245,196,81,0.4);  color: var(--warning); }

/* Live "agent working" pill — pairs colour with text + aria-live in markup. */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono); font-size: 0.75rem;
  padding: 0.25rem 0.75rem; border-radius: 999px;
  background: rgba(34,211,211,0.1); color: var(--teal);
  border: 1px solid rgba(34,211,211,0.3);
}
.status-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--teal); }

/* ============================================================================
   RESPONSIVE — supports text scaling / 200% zoom without horizontal scroll
   ========================================================================== */
@media (max-width: 600px) {
  .container { padding: 1.5rem 1rem; }
  .app-header { padding: 0.875rem 1rem; }
}
