/* ==========================================================================
   SecurApp Design System — Modern CSS Reset (reset.css)
   Normalises browser defaults & establishes base typography
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BOX MODEL
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   2. ROOT & DOCUMENT
   -------------------------------------------------------------------------- */
html {
  /* Prevent font-size inflation on mobile */
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;

  /* scroll-behavior: managed by Lenis — do NOT set smooth here */

  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* Prevent scroll on body overflow */
  overflow-x: hidden;

  /* Tab size for code blocks */
  tab-size: 4;
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport for mobile */
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY RESETS
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--fw-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  text-wrap: balance;
}

h1 { font-size: var(--text-hero); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  text-wrap: pretty;
}

small {
  font-size: var(--text-sm);
  font-weight: var(--fw-light);
  color: var(--text-tertiary);
}

strong, b {
  font-weight: var(--fw-semibold);
}

/* --------------------------------------------------------------------------
   4. LINKS
   -------------------------------------------------------------------------- */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

/* --------------------------------------------------------------------------
   5. IMAGES & MEDIA
   -------------------------------------------------------------------------- */
img,
picture,
video,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

svg {
  display: block;
}

/* Avoid overflow for iframes and embeds */
iframe,
embed,
object {
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   6. FORM ELEMENTS
   -------------------------------------------------------------------------- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Remove default appearance */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

textarea {
  resize: vertical;
}

/* Remove spinner for number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* --------------------------------------------------------------------------
   7. LISTS
   -------------------------------------------------------------------------- */
ul, ol {
  list-style: none;
}

/* --------------------------------------------------------------------------
   8. TABLES
   -------------------------------------------------------------------------- */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* --------------------------------------------------------------------------
   9. SELECTION
   -------------------------------------------------------------------------- */
::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

::-moz-selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

/* --------------------------------------------------------------------------
   10. FOCUS — Accessible focus-visible ring
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Special focus for buttons */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   11. SCROLLBAR — Custom styling
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* --------------------------------------------------------------------------
   12. CODE
   -------------------------------------------------------------------------- */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  overflow-x: auto;
  white-space: pre;
}

code {
  padding: 0.125em 0.375em;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

pre code {
  padding: 0;
  background-color: transparent;
  border-radius: 0;
}

/* --------------------------------------------------------------------------
   13. HORIZONTAL RULE
   -------------------------------------------------------------------------- */
hr {
  border: none;
  height: 1px;
  background-color: var(--border-default);
  margin: var(--space-8) 0;
}

/* --------------------------------------------------------------------------
   14. MISC
   -------------------------------------------------------------------------- */

/* Remove built-in dialog styles */
dialog {
  padding: 0;
  border: none;
  background: none;
}

/* Hidden utility */
[hidden] {
  display: none !important;
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --------------------------------------------------------------------------
   15. REDUCED MOTION — Disable animations for users who prefer it
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
