/* ==========================================================================
   Tapitt Talks Companion — main.css
   Global variables, reset, typography, base layout.
   Mobile-first: base rules target small screens, min-width queries scale up.
   ========================================================================== */

:root {
  /* Colors */
  --color-bg: #FFFFFF;
  --color-surface: #F8F8F8;
  --color-border: #E8E8E8;
  --color-text-primary: #0A0A0A;
  --color-text-secondary: #6B6B6B;
  --color-text-muted: #A0A0A0;
  --color-accent: #5B5BD6;
  --color-accent-light: #EEEEFF;
  --color-accent-hover: #4A4AC4;
  --color-success: #16A34A;
  --color-success-light: #DCFCE7;
  --color-error: #DC2626;
  --color-error-light: #FEE2E2;
  --color-warning: #D97706;
  --color-warning-light: #FEF3C7;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);

  /* Fonts */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  --spacing-3xl: 64px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: light;
}

/* ---------------------------------------------------------------------- */
/* Reset                                                                   */
/* ---------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, canvas, video {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

::selection {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

/* ---------------------------------------------------------------------- */
/* Typography scale                                                        */
/* ---------------------------------------------------------------------- */

.text-display {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.text-heading {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.text-subheading {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.text-body {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
}

.text-caption {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.45;
}

.text-micro {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------- */
/* Layout primitives                                                       */
/* ---------------------------------------------------------------------- */

.app-root {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-md) var(--spacing-3xl);
}

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  background: var(--color-bg);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.screen.is-active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  position: relative;
}

.screen.is-transitioning-out {
  animation: screenFadeOut var(--transition-fast) ease forwards;
}

.screen.is-transitioning-in {
  animation: screenFadeIn var(--transition-base) ease forwards;
}

/* ---------------------------------------------------------------------- */
/* Screen header                                                           */
/* ---------------------------------------------------------------------- */

.screen-header {
  padding: var(--spacing-xl) 0 var(--spacing-lg);
}

.screen-header--with-back {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
}

.screen-header__title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.screen-header__subtitle {
  margin-top: var(--spacing-xs);
  font-size: 1rem;
  color: var(--color-accent);
  font-weight: 500;
}

/* ---------------------------------------------------------------------- */
/* Global loader                                                           */
/* ---------------------------------------------------------------------- */

.global-loader {
  position: fixed;
  top: var(--spacing-md);
  right: var(--spacing-md);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.global-loader.is-visible {
  opacity: 1;
}

.global-loader__spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--color-accent-light);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

/* ---------------------------------------------------------------------- */
/* Toasts                                                                   */
/* ---------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: var(--spacing-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  width: calc(100% - var(--spacing-xl));
  max-width: 420px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--color-text-primary);
  color: #fff;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp var(--transition-base) ease;
}

.toast--error {
  background: var(--color-error);
}

.toast--success {
  background: var(--color-success);
}

/* ---------------------------------------------------------------------- */
/* Utility                                                                  */
/* ---------------------------------------------------------------------- */

.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;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------------------------------------------------------------------- */
/* 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;
  }
}

/* ---------------------------------------------------------------------- */
/* Desktop scale-up                                                         */
/* ---------------------------------------------------------------------- */

@media (min-width: 640px) {
  .container {
    padding: var(--spacing-xl) var(--spacing-lg) var(--spacing-3xl);
  }

  .text-display {
    font-size: 2.25rem;
  }
}
