/* Modern CSS with Advanced Features */

/* Root Variables for Theme */
:root {
  --primary-color: #4a90e2;
  --secondary-color: #50e3c2;
  --accent-color: #ff6b6b;
  --text-color: #2c3e50;
  --background-color: #ffffff;
  --button-gradient: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  --glow-color: rgba(74, 144, 226, 0.5);
  --spacing-unit: 1rem;
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #64b5f6;
    --secondary-color: #66ffcc;
    --accent-color: #ff7b7b;
    --text-color: #e0e0e0;
    --background-color: #1a1a1a;
    --glow-color: rgba(100, 181, 246, 0.5);
  }
}

/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

/* Document Setup */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
  text-align: center;
  padding: var(--spacing-unit);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: calc(var(--spacing-unit) * 2) 0;
  font-weight: 700;
  letter-spacing: -0.5px;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1.1rem; }

/* Paragraphs and Text Content */
p, li, dt, dd {
  font-size: 1.125rem;
  margin-bottom: var(--spacing-unit);
  max-width: 70ch;
  margin-left: auto;
  margin-right: auto;
}

/* Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  position: relative;
}

a:hover {
  color: var(--secondary-color);
  text-shadow: 0 0 8px var(--glow-color);
}

a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: var(--secondary-color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

a:hover::after {
  transform: scaleX(1);
}

/* Lists */
ul, ol {
  list-style: none;
  padding: var(--spacing-unit) 0;
  max-width: 800px;
  margin: 0 auto;
}

li {
  background: var(--background-color);
  margin: calc(var(--spacing-unit) * 0.5) 0;
  padding: calc(var(--spacing-unit) * 1.5);
  border-radius: 8px;
  color: var(--text-color);
  font-weight: 500;
  border: 2px solid var(--primary-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--button-gradient);
  opacity: 0.1;
  transition: opacity 0.3s ease;
}

li:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15),
              0 0 15px var(--glow-color);
}

li:hover::before {
  opacity: 0.2;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: var(--spacing-unit) 0;
}

img:hover {
  transform: scale(1.02);
  box-shadow: 0 0 20px var(--glow-color);
}

/* Form Elements */
input, textarea, select, button {
  font-family: inherit;
  font-size: 1rem;
  padding: calc(var(--spacing-unit) * 0.75);
  border: 2px solid var(--primary-color);
  border-radius: 4px;
  background-color: var(--background-color);
  color: var(--text-color);
  margin: calc(var(--spacing-unit) * 0.5) 0;
}

button {
  background: var(--background-color);
  color: var(--text-color);
  border: 2px solid var(--primary-color);
  padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1.5);
  cursor: pointer;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--button-gradient);
  opacity: 0.1;
  transition: opacity 0.3s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 15px var(--glow-color);
}

button:hover::before {
  opacity: 0.2;
}

/* Tables */
table {
  width: 100%;
  max-width: 1000px;
  margin: var(--spacing-unit) auto;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  padding: calc(var(--spacing-unit) * 0.75);
  border-bottom: 1px solid var(--primary-color);
  text-align: left;
}

th {
  background: var(--background-color);
  color: var(--text-color);
  font-weight: 600;
  border: 2px solid var(--primary-color);
  position: relative;
  overflow: hidden;
}

th::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--button-gradient);
  opacity: 0.1;
  transition: opacity 0.3s ease;
}

th:hover::before {
  opacity: 0.15;
}

tr:hover {
  background-color: rgba(74, 144, 226, 0.1);
}

/* Code Blocks */
pre, code {
  font-family: 'Fira Code', 'Consolas', monospace;
  background-color: rgba(0, 0, 0, 0.1);
  padding: calc(var(--spacing-unit) * 0.5);
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: var(--spacing-unit);
  margin: var(--spacing-unit) 0;
  font-style: italic;
}

/* Article and Section */
article, section {
  margin: calc(var(--spacing-unit) * 2) auto;
  padding: var(--spacing-unit);
  max-width: 1200px;
}

/* Header and Footer */
header, footer {
  padding: calc(var(--spacing-unit) * 2);
  background: var(--background-color);
  color: var(--text-color);
  margin: calc(var(--spacing-unit) * -1);
  margin-bottom: var(--spacing-unit);
  border-top: 2px solid var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
  position: relative;
  overflow: hidden;
}

header::before, footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--button-gradient);
  opacity: 0.1;
  transition: opacity 0.3s ease;
}

header:hover::before, footer:hover::before {
  opacity: 0.15;
}

/* Navigation */
nav {
  padding: var(--spacing-unit);
}

nav ul {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--spacing-unit);
}

nav li {
  background: none;
  padding: calc(var(--spacing-unit) * 0.5);
}

/* Media Elements */
video, audio {
  width: 100%;
  max-width: 800px;
  margin: var(--spacing-unit) auto;
  border-radius: 8px;
}

/* Progress and Meter */
progress, meter {
  width: 100%;
  height: 20px;
  border-radius: 10px;
  margin: var(--spacing-unit) 0;
}

/* Details and Summary */
details {
  margin: var(--spacing-unit) 0;
  padding: var(--spacing-unit);
  border-radius: 8px;
  border: 2px solid var(--primary-color);
}

summary {
  cursor: pointer;
  font-weight: 600;
}

summary:hover {
  color: var(--primary-color);
}

/* Focus States */
:focus {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background-color: var(--primary-color);
  color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--button-gradient);
  border-radius: 6px;
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Utility Classes */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Responsive Design */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  .container {
    padding: 0 calc(var(--spacing-unit) * 0.5);
  }
  
  nav ul {
    flex-direction: column;
  }
}

/* Print Styles */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
}
