/* ==========================================================================
   FastToolsHQ App — app.css
   Design tokens + base layout + theming + navigation shell.
   Everything else (components, tools) inherits from the tokens defined here.
   ========================================================================== */

/* ---- Design tokens -------------------------------------------------------
   Single source of truth. New tools pull from these so the whole app stays
   visually consistent. Dark theme is the default; light theme overrides below.
--------------------------------------------------------------------------- */
:root {
  /* Brand */
  --brand: #4f7cff;
  --brand-strong: #3a63e0;
  --brand-soft: rgba(79, 124, 255, 0.14);
  --accent: #22d3a6;

  /* Status */
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Surfaces (dark default) */
  --bg: #0e1116;
  --surface: #161a22;
  --surface-2: #1d222c;
  --surface-3: #262c38;
  --on-surface: #e8ecf3;
  --on-surface-muted: #9aa4b2;
  --on-surface-faint: #6b7480;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --overlay: rgba(0, 0, 0, 0.6);

  /* On-brand text */
  --on-brand: #ffffff;

  /* Typography */
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.85rem;
  --fs-md: 0.95rem;
  --fs-lg: 1.1rem;
  --fs-xl: 1.35rem;
  --fs-2xl: 1.75rem;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, 0.45);

  /* Motion tokens — one language for the whole app */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1.2);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --dur-fast: 120ms;
  --dur-med: 220ms;
  --dur-slow: 360ms;

  /* Layout */
  --nav-height: 64px;
  --header-height: 56px;
  --content-max: 720px;

  /* Safe-area insets (TWA / notched phones) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light theme — applied when the user (or system) chooses light. */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --surface-3: #e6ebf4;
  --on-surface: #131720;
  --on-surface-muted: #55606f;
  --on-surface-faint: #8a94a3;
  --border: rgba(16, 22, 34, 0.08);
  --border-strong: rgba(16, 22, 34, 0.16);
  --brand-soft: rgba(79, 124, 255, 0.12);
  --overlay: rgba(20, 24, 32, 0.45);
  --shadow-1: 0 1px 2px rgba(16, 22, 34, 0.08);
  --shadow-2: 0 4px 14px rgba(16, 22, 34, 0.1);
  --shadow-3: 0 12px 32px rgba(16, 22, 34, 0.16);
}

/* ---- Reset / base -------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  /* Prevent text scaling weirdness inside a TWA */
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }

/* Themed color transition when toggling light/dark */
body,
.app-header,
.bottom-nav,
.card,
.chip,
.search-bar {
  transition: background-color var(--dur-med) var(--ease-standard),
              color var(--dur-med) var(--ease-standard),
              border-color var(--dur-med) var(--ease-standard);
}

/* ---- App layout shell ---------------------------------------------------- */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Top app bar — compact, not a website header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: calc(var(--header-height) + var(--safe-top));
  padding: var(--safe-top) var(--sp-4) 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.app-header__logo {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
}

.app-header__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
}

.app-header__title span { color: var(--brand); }

.app-header__spacer { flex: 1; }

/* Main scroll region sits between header and bottom nav */
.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4)
           calc(var(--nav-height) + var(--safe-bottom) + var(--sp-6));
}

/* Views are swapped by navigation.js; only one is active at a time */
.view { display: none; animation: view-in var(--dur-med) var(--ease-standard); }
.view.is-active { display: block; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-4);
}

/* Section grouping on the home screen */
.section { margin-bottom: var(--sp-8); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.section__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}

.section__link {
  font-size: var(--fs-sm);
  color: var(--brand);
  font-weight: var(--fw-medium);
}

/* Empty-state block reused across Favourites / Recent */
.empty {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--on-surface-muted);
}
.empty__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-4);
  opacity: 0.5;
}
.empty__title { font-weight: var(--fw-semibold); color: var(--on-surface); margin-bottom: var(--sp-1); }

/* Utility */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Reduced 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;
  }
}
