/* 
==============================================================================
 BLACK ELM COFFEE - CSS RESET & BASE STYLES
 Modern CSS reset and foundational typography
==============================================================================
*/

/* 
 * ===== MODERN CSS RESET =====
 * Based on modern best practices for consistent cross-browser rendering
 */

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

/* Remove default margin and padding */
* {
  margin: 0;
  padding: 0;
}

/* Improve media defaults */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* Remove built-in form typography styles */
input,
button,
textarea,
select {
  font: inherit;
}

/* Avoid text overflows */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

/* 
 * ===== BASE TYPOGRAPHY =====
 */

/* Root font size for rem calculations */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

/* Body defaults */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 
 * ===== HEADINGS =====
 */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  margin-bottom: var(--spacing-3);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--spacing-6);
}

h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--spacing-5);
}

h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--spacing-4);
}

h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--spacing-3);
}

h5 {
  font-size: var(--text-base);
  margin-bottom: var(--spacing-3);
}

h6 {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-2);
}

/* 
 * ===== TEXT ELEMENTS =====
 */
p {
  margin-bottom: var(--spacing-4);
  color: var(--text-primary);
}

/* Links */
a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: all var(--transition-base);
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  text-decoration: none;
}

/* Remove link styling for buttons */
a.btn {
  text-decoration: none;
}

/* Strong and emphasis */
strong,
b {
  font-weight: var(--font-semibold);
}

em,
i {
  font-style: italic;
}

/* Small text */
small {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Code elements */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
}

code {
  background-color: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-base);
  padding: var(--spacing-1) var(--spacing-2);
  font-size: 0.875em;
  color: var(--text-primary);
}

pre {
  background-color: var(--surface-1);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--spacing-4);
  overflow-x: auto;
  margin-bottom: var(--spacing-4);
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* 
 * ===== LISTS =====
 */
ul,
ol {
  margin-bottom: var(--spacing-4);
  padding-left: var(--spacing-6);
}

li {
  margin-bottom: var(--spacing-1);
}

/* Remove list styling for navigation */
nav ul,
nav ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

nav li {
  margin: 0;
}

/* Definition lists */
dl {
  margin-bottom: var(--spacing-4);
}

dt {
  font-weight: var(--font-semibold);
  margin-bottom: var(--spacing-1);
}

dd {
  margin-bottom: var(--spacing-3);
  margin-left: var(--spacing-4);
}

/* 
 * ===== HORIZONTAL RULE =====
 */
hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: var(--spacing-8) 0;
}

/* 
 * ===== QUOTES =====
 */
blockquote {
  border-left: 4px solid var(--accent-primary);
  padding-left: var(--spacing-4);
  margin: var(--spacing-6) 0;
  font-style: italic;
  color: var(--text-secondary);
}

blockquote p {
  margin-bottom: var(--spacing-2);
}

blockquote cite {
  display: block;
  margin-top: var(--spacing-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: normal;
}

blockquote cite::before {
  content: "— ";
}

/* 
 * ===== MEDIA ELEMENTS =====
 */
img {
  height: auto;
  border-radius: var(--radius-base);
}

figure {
  margin: var(--spacing-6) 0;
}

figcaption {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--spacing-2);
}

/* 
 * ===== TABLE BASICS =====
 */
table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: var(--spacing-4);
}

/* 
 * ===== SELECTION STYLING =====
 */
::selection {
  background-color: var(--accent-primary);
  color: var(--bg-primary);
}

::-moz-selection {
  background-color: var(--accent-primary);
  color: var(--bg-primary);
}

/* 
 * ===== FOCUS MANAGEMENT =====
 */
/* Hide focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Show focus outline for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* 
 * ===== SCROLLBAR STYLING =====
 */
/* Webkit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-1);
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) var(--surface-1);
}

/* 
 * ===== PRINT STYLES =====
 */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: black !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) ")";
  }

  pre {
    white-space: pre-wrap !important;
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}

/* 
 * ===== RESPONSIVE IMAGES =====
 */
img {
  max-width: 100%;
  height: auto;
}

/* 
 * ===== SCREEN READER ONLY CONTENT =====
 */
.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 LINK =====
 */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent-primary);
  color: var(--bg-primary);
  padding: 8px;
  text-decoration: none;
  z-index: var(--z-tooltip);
  border-radius: var(--radius-base);
}

.skip-link:focus {
  top: 6px;
}

/* 
 * ===== UNIVERSAL PAGE ENHANCEMENT =====
 * Copy this script to any page's <head> for automatic icon detection:
 * 
 * <script>
 * (function(){
 *   const path = location.pathname.toLowerCase();
 *   const pageType = 
 *     path.includes('employee') || path.includes('directory') ? 'employee' :
 *     path.includes('applicant') ? 'applicant' :
 *     path.includes('coffee-cart') || path.includes('cart') ? 'cart' :
 *     path.includes('inventory') || path.includes('stock') ? 'inventory' :
 *     path.includes('roast') ? 'roast' :
 *     path.includes('analytics') ? 'analytics' :
 *     path.includes('dashboard') ? 'dashboard' :
 *     path.includes('maintenance') ? 'maintenance' :
 *     path.includes('schedule') ? 'schedule' : 'default';
 *   document.body.setAttribute('data-page', pageType);
 * })();
 * </script>
 * 
 * This enables automatic page-specific icons in headers!
 */