/**
 * ============================================================================
 * FILE: assets/css/browser-compat.css
 * PURPOSE: Cross-browser compatibility layer — must load before all other CSS
 * TARGETS: Chrome 88+, Firefox 85+, Safari 14+, Edge 88+, Samsung Internet 13+
 * DEPENDS ON: —
 * VERSION: 1.0.0
 * ============================================================================
 */

/* ── SECTION START: Feature Detection ── */
@supports not (aspect-ratio: 1) {
  .ex-layout { min-height: 100vh; }
}

@supports not (gap: 1px) {
  .ex-layout > * + * { margin-inline-start: var(--space-md, 16px); }
}
/* ── SECTION END: Feature Detection ── */

/* ── SECTION START: Scroll Behaviour ── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: var(--radius-full, 9999px); }
::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,0.5); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: rgba(201,168,76,0.3) transparent; }
/* ── SECTION END: Scroll Behaviour ── */

/* ── SECTION START: Focus & Accessibility ── */
:focus-visible {
  outline: 2px solid var(--color-gold, #C9A84C);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* ── SECTION END: Focus & Accessibility ── */

/* ── SECTION START: Safe Area Insets (Notch / Home Bar) ── */
body {
  padding-top:    env(safe-area-inset-top,    0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left:   env(safe-area-inset-left,   0px);
  padding-right:  env(safe-area-inset-right,  0px);
}

.ex-mobile-bottomnav {
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
}
/* ── SECTION END: Safe Area Insets ── */

/* ── SECTION START: Input Normalisation ── */
input, button, textarea, select {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

/* iOS date input fix */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  -webkit-appearance: textfield;
}

/* Prevent iOS zoom on focus */
@media (max-width: 768px) {
  input, select, textarea { font-size: max(16px, 1rem); }
}
/* ── SECTION END: Input Normalisation ── */

/* ── SECTION START: Shadow DOM adoptedStyleSheets Fallback (older Safari) ── */
/* When adoptedStyleSheets is not available, styles injected via <style> inside shadow root */
@supports not (adoptedStyleSheets: []) {
  /* Fallback: components use <style> tag injection */
}
/* ── SECTION END: Shadow DOM Fallback ── */

/* ── SECTION START: Touch Target Enforcement ── */
button, [role="button"], a, input[type="checkbox"], input[type="radio"] {
  min-height: var(--touch-target-min, 44px);
  min-width:  var(--touch-target-min, 44px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Exception: icon-only buttons with explicit override */
button.no-min-size, a.no-min-size {
  min-height: unset;
  min-width: unset;
}
/* ── SECTION END: Touch Target Enforcement ── */

/* ── SECTION START: Print ── */
@media print {
  .ex-sidebar-section,
  .ex-topbar-section,
  .ex-mobile-bottomnav { display: none !important; }
  .ex-main-wrapper { padding: 0 !important; }
}
/* ── SECTION END: Print ── */

/* END OF FILE: browser-compat.css */
