/*
 * Base styles - resets and foundational elements
 * Wrapped in @layer base to work with Tailwind v4's cascade layers
 */

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

  /* Document - App-like behavior on mobile */
  html {
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent overscroll bounce */
    overscroll-behavior: none;
    /* Prevent text size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Prevent horizontal scroll/shift */
    overflow-x: hidden;
  }

  body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    background: var(--color-bg-base);
    min-height: 100vh;
    /* Prevent double-tap zoom on interactive elements */
    touch-action: manipulation;
    /* Prevent overscroll bounce and pull-to-refresh */
    overscroll-behavior-y: contain;
    /* Prevent horizontal scroll/shift */
    overflow-x: hidden;
  }

  /* Prevent iOS rubber-banding/overscroll when modal/sheet is open */
  body.no-overscroll {
    overscroll-behavior: none;
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  /* Typography - default styles, can be overridden by Tailwind utilities */
  h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
  }

  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }
  h3 { font-size: var(--text-md); }

  p {
    margin-bottom: var(--space-3);
  }

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

  a:hover {
    color: var(--color-status-info);
  }

  /* Code */
  code, pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
  }

  code {
    background: var(--color-bg-elevated);
    padding: 2px var(--space-1);
    border-radius: var(--radius-sm);
  }

  pre {
    background: var(--color-bg-surface);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    overflow-x: auto;
  }

  /* Lists */
  ul, ol {
    list-style: none;
  }

  /* Focus states - keyboard accessibility */
  :focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(64, 87, 131, 0.5);
    border-radius: var(--radius-sm);
  }

  /* Selection */
  ::selection {
    background: var(--color-interactive-default);
    color: var(--color-text-primary);
  }

  /* Scrollbar styling (Webkit) */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

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

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

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

  /* Firefox scrollbar */
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-default) transparent;
  }

  /* Utility: visually hidden but accessible */
  .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;
  }

  /* Skip to content link - visible only when focused */
  .skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-bg-elevated);
    color: var(--color-text-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-default);
    font-size: var(--text-sm);
    z-index: 1000;
    transition: top 0.2s ease;
  }

  .skip-link:focus {
    top: var(--space-2);
    outline: none;
    box-shadow: 0 0 0 2px var(--color-interactive-default);
  }
}
