/* ══════════════════════════════════════
   FiveHow Design System — Global Tokens
   ══════════════════════════════════════ */

/* ---- Fonts ---- */
@import url('https://api.fontshare.com/v2/css?f[]=general-sans@400,500,600,700&f[]=satoshi@400,500,600,700&display=swap');

/* ---- Design Tokens ---- */
:root {
  --app-vh: 100dvh;

  /* Surface */
  --surface-0: #FAFAF9;
  --surface-1: #FFFFFF;
  --surface-2: #F5F5F4;
  --surface-3: #E7E5E4;

  /* Ink */
  --ink-0: #1C1917;
  --ink-1: #44403C;
  --ink-2: #78716C;
  --ink-3: #A8A29E;
  --ink-4: #D6D3D1;

  /* Primary */
  --primary: #1C1917;
  --hover: #292524;
  --subtle: #F5F5F4;

  /* States */
  --state-green: #10B981;
  --state-yellow: #F59E0B;
  --danger: #EF4444;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(28,25,23,0.04), 0 1px 2px rgba(28,25,23,0.02);
  --shadow-card-hover: 0 20px 60px -15px rgba(28,25,23,0.08), 0 8px 24px -8px rgba(28,25,23,0.04);
  --shadow-modal: 0 25px 50px -12px rgba(0,0,0,0.15);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;

  /* Font families */
  --font-heading: 'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fh-keyboard-inset: 0px;
  --fh-safe-bottom: env(safe-area-inset-bottom);
  --fh-viewport-height: 100dvh;
  --fh-top-nav-offset: 0px;
}

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

html {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-1);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink-0);
  letter-spacing: -0.02em;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%      { transform: translateY(-4px); }
}
@keyframes subtlePulse {
  0%, 100% { opacity: .4; }
  50%      { opacity: .7; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes boardReset {
  0% { opacity: 0; background: white; }
  40% { opacity: 0.8; background: white; }
  100% { opacity: 1; background: transparent; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes toastIn {
  from { transform: translateY(-100%) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to   { transform: translateY(-100%) scale(0.95); opacity: 0; }
}

.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }

/* ---- Animate In Classes ---- */
.animate-fade-in-up {
  animation: fadeInUp 600ms cubic-bezier(0.16,1,0.3,1) both;
}
.animate-scale-in {
  animation: scaleIn 500ms cubic-bezier(0.16,1,0.3,1) both;
}

/* ---- AppCard hover ---- */
.app-card {
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.app-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card-hover);
}
.app-card:hover .card-icon-wrapper {
  background-color: var(--ink-0) !important;
}
.app-card:hover .card-icon-wrapper iconify-icon {
  color: white !important;
}
.app-card .card-arrow {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s;
  opacity: .9;
}
.app-card:hover .card-arrow {
  transform: translateX(4px);
  opacity: 1;
}

/* ---- Channel Item ---- */
.channel-item {
  transition: all 0.15s ease;
}
.channel-item:hover {
  background: var(--surface-2) !important;
}
.channel-item.active {
  background: var(--surface-3) !important;
  border-left: 3px solid var(--ink-0) !important;
  font-weight: 600;
}

/* ---- Message hover ---- */
.message-bubble-wrap:hover .copy-btn {
  opacity: 1;
}

/* ---- Modal overlay ---- */
.modal-overlay {
  transition: opacity 0.2s ease;
}
.modal-content {
  animation: scaleIn 300ms cubic-bezier(0.16,1,0.3,1) both;
}

/* ---- Toast ---- */
.toast-enter { animation: toastIn 300ms cubic-bezier(0.16,1,0.3,1) both; }
.toast-exit  { animation: toastOut 200ms ease-in both; }

/* ---- Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Chess board ---- */
.chess-square-light { background: var(--surface-2); }
.chess-square-dark { background: var(--ink-4); }
.chess-square-selected { background: #bae6fd !important; }
.chess-square-legal { position: relative; }
.chess-square-legal::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
}
.chess-square-illegal {
  animation: shake 0.4s ease-in-out;
  box-shadow: inset 0 0 0 2px var(--danger) !important;
}

/* ---- Drawer ---- */
.drawer-overlay {
  transition: opacity 0.3s ease;
}
.drawer-panel {
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
}

/* ---- Input focus ---- */
.fh-input:focus {
  border-color: var(--ink-0);
  box-shadow: 0 0 0 3px rgba(28,25,23,0.06);
}

/* ---- Status dot border for a11y ---- */
.status-dot-green {
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--state-green);
}
.status-dot-yellow {
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--state-yellow);
}

/* ---- Misc Utilities ---- */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
