/* ==========================================================================
   CODEORBIT — DESIGN TOKENS & BASE STYLES
   Made by Let's Cook. Look: space x Let's Cook x Swiss (docs/DECISIONS.md, D-020),
   dark only (D-025).
   Black and white with one crimson accent, a strict grid, big numbers,
   mono labels, slow decorative motion only.
   ========================================================================== */

/* Fonts are served from this repo (no Google Fonts request). SIL OFL 1.1, see assets/fonts/. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-var.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-500.woff2') format('woff2');
}

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg-main: #0a0a0b;
  --bg-secondary: #0d0d0f;
  --bg-card: #0d0d0f;
  --bg-card-elevated: #121214;
  --bg-card-hover: #17171a;
  --bg-input: #121214;
  --bg-topbar: rgba(10, 10, 11, 0.88);
  --overlay: rgba(0, 0, 0, 0.72);
  --avatar-bg: #121214;
  --tint: rgba(245, 245, 244, 0.06); /* faint white wash, e.g. the focus ring */

  /* Brand: Let's Cook crimson. Fill colour carries white text only;
     on dark backgrounds crimson TEXT uses --accent-text so it stays readable. */
  --primary: #b8002f;
  --primary-hover: #9c0028;
  --primary-subtle: rgba(184, 0, 47, 0.14);
  --accent-text: #ff4d6a;

  /* Status */
  --success: #6fd39b;
  --warning: #e8b04b;
  --danger: #ff4d6a;
  --danger-subtle: rgba(255, 77, 106, 0.12);

  /* Text */
  --text-primary: #ebebea; /* slightly off-white: pure white on black glares */
  --text-secondary: #b9b9be;
  --text-muted: #8f8f95;
  --text-inverse: #0a0a0b;

  /* Lines */
  --border: #2c2c31;
  --border-strong: #3a3a40;
  --border-hover: #4a4a52;
  --border-light: #1e1e22;
  --border-focus: #ff4d6a;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --text-xs: 0.75rem; /* 12px */
  --text-sm: 0.875rem; /* 14px */
  --text-base: 1rem; /* 16px */
  --text-lg: 1.125rem; /* 18px */
  --text-xl: 1.25rem; /* 20px */
  --text-2xl: 1.5rem; /* 24px */
  --label-tracking: 0.16em;

  /* Spacing (8px steps) */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Flat by design: no glows; one shadow for things that float (modals, toasts) */
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

  /* Motion */
  --ease-swiss: cubic-bezier(0.7, 0, 0.3, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --topbar-height: 72px;
  --max-content-width: 1280px;
  --page-gutter: clamp(1.25rem, 4vw, 3rem);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Starfield behind the page (decorative, app.js initStarfield) */
#stars-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--text-primary);
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

img,
svg {
  vertical-align: middle;
  max-width: 100%;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* Accessibility: Focus visible outline */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   APP LAYOUT: TOP BAR + ONE CENTRED COLUMN
   ========================================================================== */
.skip-link {
  position: absolute;
  left: var(--space-md);
  top: -100px;
  z-index: 300;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.skip-link:focus {
  top: var(--space-md);
  color: #ffffff;
}

.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg-topbar);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.brand-link:hover {
  color: var(--text-primary);
}

.brand-logo-img {
  width: 40px;
  height: 25px;
  object-fit: contain;
}

.brand-title {
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
}

.main-nav {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-sm);
  white-space: nowrap;
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.avatar-link {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  display: block;
  flex-shrink: 0;
}

.avatar-link:hover {
  border-color: var(--border-strong);
}

.user-avatar-img {
  width: 100%;
  height: 100%;
}

/* Visually hidden but read by screen readers */
.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;
}

/* CONTENT AREA & VIEWS */
.content-area {
  flex: 1;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--page-gutter) var(--space-3xl);
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.page-header[hidden] {
  display: none;
}

.page-title {
  font-weight: 900;
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
  color: var(--text-primary);
}

.page-subtitle {
  max-width: 560px;
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text-secondary);
}

.view-page {
  display: none;
}

.view-page.active {
  display: block;
  animation: fadeInPage 0.3s var(--ease-swiss) both;
}

@keyframes fadeInPage {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-footer {
  border-top: 1px solid var(--border-light);
}

.app-footer-inner {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--page-gutter);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Mono uppercase label used across pages */
.label-mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.search-hotkey {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
}
