/**
 * Base styles for consistent UI across browsers, OS, and devices.
 * Load this first (after polyfills) on every page.
 */

/* ============================================
   Box model
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ============================================
   HTML root – viewport, scroll, safe-area
   ============================================ */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* Viewport height that works on mobile (address bar, notches) */
@supports (height: 100dvh) {
  :root {
    --viewport-height: 100dvh;
    --viewport-height-dynamic: 100dvh;
  }
}

@supports (height: 100svh) {
  :root {
    --viewport-height-small: 100svh;
  }
}

:root {
  --viewport-height: 100vh;
  --viewport-height-dynamic: 100vh;
  --viewport-height-small: 100vh;
  /* Safe area for notched devices (phones, tablets) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* ============================================
   Body baseline
   ============================================ */
html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: var(--viewport-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Tap highlight & selection (cross-browser)
   ============================================ */
a,
button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"] {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

::selection {
  background-color: rgba(59, 130, 246, 0.25);
  color: inherit;
}

::-moz-selection {
  background-color: rgba(59, 130, 246, 0.25);
  color: inherit;
}

/* ============================================
   Media & embedded content
   ============================================ */
img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

img,
video {
  vertical-align: middle;
}

/* ============================================
   Form controls – prevent iOS zoom, consistent look
   ============================================ */
input,
button,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}

/* 16px minimum on focus prevents iOS from zooming on inputs */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============================================
   Focus visible (keyboard users, not mouse)
   ============================================ */
:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ============================================
   Scrollbar (optional consistency on WebKit/Blink)
   ============================================ */
@media (hover: hover) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
  }
}
