/* ===== UTILITY CLASSES & LAYOUT HELPERS ===== */
:root {
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== LAYOUT HELPERS ===== */
.container {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.section {
  padding-block: var(--space-12);
}

.section:last-of-type {
  padding-bottom: 0;
}

.mt-24 {
  margin-top: 24px;
}

.center {
  text-align: center;
}

/* ===== ACCESSIBILITY ===== */
.visually-hidden {
  position: absolute;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
  width: auto;
  height: auto;
  z-index: 1000;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: var(--shadow-soft);
}

/* Dark mode skip link enhancement */
html[data-theme="dark"] .skip-link:focus {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== GRID HELPERS ===== */
.card-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-6);
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
  align-items: stretch;
}

/* ===== ANIMATIONS ===== */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.2s ease, background 0.3s ease, border-color 0.3s ease;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}

/* Ensure button text is always readable */
.btn-primary:hover {
  background: var(--accent);
  color: var(--on-accent);
  opacity: 0.9;
}

.btn-secondary:hover {
  background: var(--icon-bg);
  color: var(--text-primary);
}

/* Additional button enhancements for better visibility */
.btn-primary:active {
  transform: translateY(0);
  opacity: 0.8;
}

.btn-secondary:active {
  transform: translateY(0);
  background: var(--icon-bg);
}

/* Ensure button text contrast in both themes */
.btn {
  font-weight: 500;
  letter-spacing: 0.025em;
}

.btn-primary {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
  border-width: 1px;
}

/* ===== BADGES ===== */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.badges li {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark mode badge text enhancement */
html[data-theme="dark"] .badges li {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== FORMS ===== */
.form-field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-field input,
.form-field textarea {
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark mode form field text enhancement */
html[data-theme="dark"] .form-field input,
html[data-theme="dark"] .form-field textarea {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 203, 225, 0.1);
}

.error {
  font-size: 0.875rem;
  color: var(--danger);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark mode error text enhancement */
html[data-theme="dark"] .error {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== BACK TO TOP ===== */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 50;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  color: var(--text-primary);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark mode back-to-top text enhancement */
html[data-theme="dark"] .back-to-top {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.back-to-top.show {
  opacity: 1;
  pointer-events: auto;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-soft);
  color: var(--text-primary);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark mode toast text enhancement */
html[data-theme="dark"] .toast {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== TYPOGRAPHY ===== */
.display {
  font-family: Poppins, system-ui, Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3rem);
  margin: 0 0 0.5rem;
  line-height: 1.1;
  color: var(--text-primary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.lead {
  font-size: clamp(1.1rem, 3.5vw, 1.4rem);
  margin: 0.25rem 0;
  line-height: 1.4;
  color: var(--text-primary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark mode display and lead text enhancement */
html[data-theme="dark"] .display,
html[data-theme="dark"] .lead {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.section-title {
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
  color: var(--text-primary);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Dark mode section title enhancement */
html[data-theme="dark"] .section-title {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Ensure section titles are always readable */
.section-title {
  position: relative;
  z-index: 1;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .container {
    padding-inline: var(--space-3);
  }
  
  .section {
    padding-block: var(--space-8);
  }
  
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  
  .btn {
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
  }
  
  .badges li {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
  }
  
  .form-field input,
  .form-field textarea {
    padding: 0.625rem 0.75rem;
    font-size: 0.95rem;
  }
  
  .back-to-top {
    right: 12px;
    bottom: 12px;
    padding: 0.5rem 0.7rem;
  }
  
  .toast {
    left: 16px;
    right: 16px;
    transform: translateX(0) translateY(20px);
    bottom: 16px;
  }
  
  .toast.show {
    transform: translateX(0) translateY(0);
  }
  
  .display {
    font-size: clamp(1.75rem, 8vw, 2.5rem);
    margin: 0 0 0.4rem;
  }
  
  .lead {
    font-size: clamp(1rem, 4vw, 1.25rem);
    margin: 0.2rem 0;
  }
  
  .section-title {
    font-size: 1.125rem;
    margin: 0 0 0.625rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding-inline: var(--space-2);
  }
  
  .section {
    padding-block: var(--space-6);
  }
  
  .card-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  .btn {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    width: 100%;
    justify-content: center;
  }
  
  .display {
    font-size: clamp(1.5rem, 9vw, 2rem);
  }
  
  .lead {
    font-size: clamp(0.95rem, 4.5vw, 1.1rem);
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
  .btn:hover,
  .whatsapp-float:hover,
  .social a:hover {
    transform: none;
  }
  
  .reveal {
    transition: none;
  }
}

/* ===== HIGH CONTRAST MODE SUPPORT ===== */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }
  
  .card {
    border-width: 2px;
  }
  
  .skill {
    border-width: 2px;
  }
}
