/* ═══════════════════════════════════════════
   HQ Base Styles
   Reset, fonts, body defaults, scrollbar,
   selection, grain overlay, animations, utilities.
   Depends on tokens.css.
   ═══════════════════════════════════════════ */

/* ── Google Fonts ──────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

/* ── Touch / tap behavior ──────────────────── */
/* Suppress the default blue/grey tap-highlight flash on all interactive
   elements. We provide our own :active styles per component. */
button,
a,
input,
textarea,
select,
[role="button"],
[role="tab"],
.agent-item,
.team-card,
.task-card,
.project-card,
.server-card,
.tab-nav__tab,
.filter-btn,
.tasks-filter-btn,
.roadmap-project-btn {
  -webkit-tap-highlight-color: transparent;
}

/* ── Body defaults ─────────────────────────── */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Custom scrollbar ──────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-muted);
}

/* ── Selection ─────────────────────────────── */
::selection {
  background: var(--color-amber);
  color: var(--color-bg);
}

/* ── Placeholder ───────────────────────────── */
::placeholder {
  color: var(--color-muted);
}

/* ── Grain texture overlay ─────────────────── */
/* SVG noise at low opacity creates the warm, industrial film-grain feel */
#grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ── Animations ────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 4px currentColor; }
  50%       { box-shadow: 0 0 10px currentColor; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

/* ── Utility classes ───────────────────────── */
.mono    { font-family: var(--font-mono); }
.display { font-family: var(--font-display); }
.dim     { color: var(--color-dim); }
.muted   { color: var(--color-muted); }
.text    { color: var(--color-text); }
.amber   { color: var(--color-amber); }
.green   { color: var(--color-green); }
.red     { color: var(--color-red); }
.orange  { color: var(--color-orange); }

.uppercase    { text-transform: uppercase; }
.truncate     {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1        { gap: var(--space-1); }
.gap-2        { gap: var(--space-2); }
.gap-3        { gap: var(--space-3); }
.flex-1       { flex: 1; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ═══════════════════════════════════════════
   Phone-size defaults (≤480px)
   - Bump input/textarea base size to 16px so iOS
     Safari does NOT auto-zoom when focusing a field.
   - Bump body min size to 14px for readability.
   - Contain overscroll to prevent rubber-band of parent
     scrollers (chat messages, feed list, etc.).
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  /* iOS auto-zooms focused inputs when their font-size is < 16px.
     Apply the minimum here so every future form control inherits it. */
  input,
  textarea,
  select {
    font-size: 16px;
  }
}

/* Any scrollable view inside the app shell should contain its
   overscroll so the whole page doesn't bounce on iOS. Each view
   sets overflow:auto; this centralizes the behavior. */
.dashboard-view,
.feed-view,
.tasks-view,
.team-view,
.servers-view,
.roadmap-view,
.chat-messages,
.chat-directory,
.chief-messages {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
