/**
 * Casa de Jardim - CSS Reset
 * Modern CSS reset for consistent cross-browser styling
 * Mobile-first approach with accessibility considerations
 */

/* ==========================================================================
   Box Model Reset
   ========================================================================== */

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

/* ==========================================================================
   Document Setup
   ========================================================================== */

html {
  /* Prevent font size inflation on mobile */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  
  /* Smooth scrolling for in-page anchors */
  scroll-behavior: smooth;
  
  /* Prevent horizontal overflow */
  overflow-x: hidden;
  max-width: 100%;
  
  /* Better text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  
  /* Set base font size for rem calculations */
  font-size: 16px;
  
  /* Prevent horizontal scroll */
  overflow-x: hidden;
}

/* Focus visible only for keyboard navigation */
html:focus-within {
  scroll-behavior: smooth;
}

/* ==========================================================================
   Body Defaults
   ========================================================================== */

body {
  min-height: 100vh;
  line-height: var(--leading-normal, 1.5);
  font-family: var(--font-system);
  color: var(--color-text);
  background-color: var(--color-bg);

  /* Improve text rendering */
  text-rendering: optimizeSpeed;

  /* Prevent horizontal scroll and center on wide screens */
  overflow-x: hidden;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}

/* ==========================================================================
   Typography Reset
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold, 700);
  line-height: var(--leading-tight, 1.25);
  overflow-wrap: break-word;
}

/* Explicit heading sizes to override deprecated user-agent behavior */
h1 {
  font-size: var(--text-4xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

h5 {
  font-size: var(--text-lg);
}

h6 {
  font-size: var(--text-base);
}

p, li, td, th, dd, dt {
  line-height: var(--leading-normal, 1.5);
  overflow-wrap: break-word;
}

/* Remove default list styles */
ul, ol {
  list-style: none;
}

/* ==========================================================================
   Links & Interactive Elements
   ========================================================================== */

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

/* Better focus styles for accessibility */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--color-primary, #fd7014);
  outline-offset: 2px;
}

/* Remove focus for mouse users */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Disabled state */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 0.25rem);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  max-width: 100%;
}

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

/* Remove default search styling */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Textarea resize control */
textarea {
  resize: vertical;
  min-height: 100px;
}

/* Select dropdown arrow consistency */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23393e46' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

/* ==========================================================================
   Media Elements
   ========================================================================== */

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

/* Maintain aspect ratio */
img {
  font-style: italic;
  vertical-align: middle;
  shape-margin: 0.75rem;
}

/* SVG fill color inheritance */
svg {
  fill: currentColor;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th {
  text-align: left;
  font-weight: var(--font-semibold, 600);
}

/* ==========================================================================
   Utility Elements
   ========================================================================== */

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

details > summary {
  cursor: pointer;
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

dialog {
  max-width: min(90vw, var(--container-2xl));
  max-height: min(90vh, 600px);
  margin: auto;
  padding: var(--space-6);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
}

dialog::backdrop {
  background-color: rgba(34, 37, 42, 0.5);
  backdrop-filter: blur(4px);
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Hide visually but keep available for screen readers */
.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 main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: var(--color-white);
  padding: var(--space-2) var(--space-4);
  z-index: var(--z-tooltip);
  text-decoration: none;
  border-radius: var(--radius-md);
}

.skip-link:focus {
  top: var(--space-2);
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  * {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a,
  a:visited {
    text-decoration: underline;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
  
  abbr[title]::after {
    content: " (" attr(title) ")";
  }
  
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }
  
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
  
  h2,
  h3 {
    page-break-after: avoid;
  }
}