/* Main Styles for Nimbus Code Website */
/* Optimized for performance, accessibility and web standards */

:root {
  /* Color Variables - with improved contrast ratios for accessibility */
  --terminal-bg: #000000;
  --terminal-text: #40ff40; /* Slightly brighter for better contrast */
  --terminal-header: #222222;
  --terminal-border: #444444;
  --terminal-link: #40cfff; /* Improved contrast for accessibility */
  --terminal-link-hover: #ffcc00;
  --terminal-button: #333333;
  --terminal-button-hover: #555555;
  --terminal-input: #111111;
  --terminal-error: #ff5a5a; /* High contrast error color */
  --terminal-success: #56db56; /* High contrast success color */
  --terminal-info: #5bb2ff; /* High contrast info color */
  
  /* Font sizes using rem for better scaling */
  --font-size-small: 0.875rem;
  --font-size-base: 1rem;
  --font-size-large: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-xxl: 2rem;
  
  /* Focus outline for accessibility */
  --focus-outline: 2px solid #80b3ff;
  
  /* Animation timings */
  --transition-fast: 0.2s;
  --transition-normal: 0.3s;
  --transition-slow: 0.5s;
}

/* Modern CSS reset with accessibility improvements */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Improve font rendering */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%; /* Prevent font size inflation on mobile */
  scroll-behavior: smooth; /* Enable smooth scrolling for all browsers that support it */
}

/* Remove focus outlines only if the user is using a mouse/touch, keep them for keyboard navigation */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Screen reader only class */
.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;
}

body {
  font-family: 'Courier New', monospace, system-ui;
  background-color: #111;
  color: var(--terminal-text);
  line-height: 1.6;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Improve text rendering */
  text-rendering: optimizeSpeed;
  /* Improve accessibility */
  font-size: var(--font-size-base);
  /* Better dark mode handling */
  color-scheme: dark;
  /* Ensure proper handling of tap targets on mobile */
  touch-action: manipulation;
}

/* Accessible typography with proper hierarchy and spacing */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 1rem;
  font-weight: normal;
  line-height: 1.3;
  max-width: 70ch; /* Improve readability with max line length */
}

h1 {
  font-size: var(--font-size-xxl);
  margin-top: 0;
}

h2 {
  font-size: var(--font-size-xl);
  margin-top: 1.5rem;
}

h3 {
  font-size: var(--font-size-large);
  margin-top: 1.2rem;
}

h4, h5, h6 {
  margin-top: 1rem;
}

p {
  margin-bottom: 1rem;
  max-width: 70ch; /* Improve readability */
}

/* Accessible link styling with clear hover/focus states */
a {
  color: var(--terminal-link);
  text-decoration: underline; /* Always show underlines for accessibility */
  text-underline-offset: 0.15em; /* Improve underline positioning */
  transition: color var(--transition-normal), text-decoration var(--transition-normal);
  cursor: pointer;
}

a:hover {
  color: var(--terminal-link-hover);
  text-decoration: underline;
}

a:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Remove underline from navigation and button-style links */
nav a,
.terminal-button {
  text-decoration: none;
}

/* Ensure proper focus indication even without outline */
nav a:focus-visible,
.terminal-button:focus-visible {
  text-decoration: underline;
  box-shadow: 0 0 0 2px var(--terminal-link);
}

/* Accessible button styling with improved states */
button,
.terminal-button {
  background: var(--terminal-button);
  color: var(--terminal-text);
  border: 1px solid var(--terminal-border);
  padding: 0.75rem 1.25rem; /* Larger touch target for mobile */
  font-family: 'Courier New', monospace, system-ui;
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: background var(--transition-normal), transform var(--transition-fast);
  border-radius: 2px; /* Slight roundness for modern design */
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  min-height: 44px; /* Ensure minimum touch target size */
}

button:hover,
.terminal-button:hover {
  background: var(--terminal-button-hover);
}

button:focus,
.terminal-button:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

button:active,
.terminal-button:active {
  transform: translateY(1px); /* Subtle feedback for press */
}

/* Accessible button states */
button:disabled,
.terminal-button:disabled,
button[aria-busy="true"],
.terminal-button[aria-busy="true"] {
  opacity: 0.7;
  cursor: not-allowed;
}

button.processing::after,
.terminal-button.processing::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* List styling with improved spacing */
ul, ol {
  list-style-position: outside;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

/* Reset list styling only for navigation and other special lists */
nav ul,
.unstyled-list {
  list-style-type: none;
  padding-left: 0;
}

li {
  margin-bottom: 0.5rem;
}

/* Layout with improved responsive behavior */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(15px, 5%, 30px); /* Responsive padding that scales with viewport */
}

.section {
  margin-bottom: clamp(2rem, 5vh, 3rem); /* Responsive spacing */
  padding: clamp(1rem, 3vh, 2rem);
}

/* Flexbox layout utilities */
.flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.justify-between {
  justify-content: space-between;
}

.items-center {
  align-items: center;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

/* Grid layout utilities */
.grid {
  display: grid;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
}

/* Accessible form styles */
form {
  width: 100%;
}

.form-group {
  margin-bottom: 1.5rem;
  position: relative;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

/* Status indicators for form validation */
.form-group[data-error]::after {
  content: attr(data-error);
  color: var(--terminal-error);
  font-size: var(--font-size-small);
  display: block;
  margin-top: 0.25rem;
}

/* Accessible form message styling */
.form-message {
  padding: 0.75rem;
  margin: 1rem 0;
  border: 1px solid var(--terminal-border);
  border-radius: 2px;
}

.form-message.error {
  border-color: var(--terminal-error);
  color: var(--terminal-error);
  background-color: rgba(255, 90, 90, 0.1);
}

.form-message.success {
  border-color: var(--terminal-success);
  color: var(--terminal-success);
  background-color: rgba(86, 219, 86, 0.1);
}

.form-message.info {
  border-color: var(--terminal-info);
  color: var(--terminal-info);
  background-color: rgba(91, 178, 255, 0.1);
}

.form-message.processing {
  display: flex;
  align-items: center;
}

.form-message.processing::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Accessible form controls with improved states */
input,
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  background: var(--terminal-input);
  border: 2px solid var(--terminal-border);
  color: var(--terminal-text);
  font-family: 'Courier New', monospace, system-ui;
  font-size: var(--font-size-base);
  border-radius: 2px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  line-height: 1.5;
  min-height: 44px; /* Ensure minimum touch target size */
}

/* Style placeholders for better visibility */
::placeholder {
  color: #888;
  opacity: 1;
}

/* Focus states for form controls */
input:focus,
textarea:focus,
select:focus {
  border-color: var(--terminal-link);
  outline: none;
  box-shadow: 0 0 0 1px var(--terminal-link);
}

/* Invalid state for form controls */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--terminal-error);
}

/* Ensure proper sizing for textareas */
textarea {
  min-height: 120px;
  resize: vertical;
}

/* Styling for checkboxes and radio buttons */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  display: inline-block;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Larger interactive area for checkboxes/radios */
input[type="checkbox"] + label,
input[type="radio"] + label {
  display: inline-block;
  padding: 0.25rem 0.5rem 0.25rem 0;
  cursor: pointer;
}

/* Modern responsive approach with fluid typography */

/* Base responsive container */
.responsive-container {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Fluid typography using clamp */
@media screen and (min-width: 320px) {
  :root {
    --font-size-small: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --font-size-base: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
    --font-size-large: clamp(1rem, 0.95rem + 0.25vw, 1.25rem);
    --font-size-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --font-size-xxl: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
  }
}

/* Responsive media queries with modern approach */
@media (max-width: 1024px) {
  .terminal-container {
    width: 90%;
    max-width: 100%;
  }
  
  /* Reduce unnecessary animations on smaller screens to improve performance */
  * {
    transition-duration: 0ms !important;
    animation-duration: 0.5s !important;
  }
}

@media (max-width: 768px) {
  .terminal-container {
    width: 95%;
    max-width: 100%;
  }
  
  /* Convert multi-column layouts to single column */
  .tech-categories,
  .blog-categories,
  .mentor-list {
    flex-direction: column;
  }
  
  .tech-category,
  .blog-post,
  .mentor-card {
    width: 100%;
    margin-bottom: 1.5rem;
  }
  
  /* Adjust spacing for better mobile experience */
  .section {
    padding: 1rem;
  }
  
  /* Improve readability on smaller screens */
  p, li {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }
  
  .terminal-header {
    padding: 5px;
    flex-wrap: wrap;
  }
  
  /* Improve navigation on small screens */
  .main-nav {
    width: 100%;
    margin-top: 0.5rem;
  }
  
  .main-nav ul {
    flex-direction: column;
    width: 100%;
  }
  
  .main-nav li {
    margin-bottom: 5px;
  }
  
  /* Optimize buttons for mobile */
  button,
  .terminal-button {
    width: 100%;
    padding: 0.75rem 1rem;
    justify-content: center;
  }
  
  /* Adjust form layouts */
  .form-group label {
    margin-bottom: 0.25rem;
  }
  
  input, textarea, select {
    padding: 0.5rem;
  }
}

/* Dark mode preferences */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* Reduced motion preferences for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
