/* ERVISM - Consciousness Knowledge Archive Styles */
:root {
  /* Dark Mode (Default) */
  --bg-color: #0A0A0A;
  --text-color: #E8E8E8;
  --accent-color: #FFD700;
  --warning-color: #DC143C;
  --secondary-bg: #1A1A1A;
  --border-color: #333333;
  --shadow-color: rgba(255, 215, 0, 0.2);
  --wave-color: rgba(255, 215, 0, 0.1);
}

/* Safari-specific fallbacks for CSS custom properties */
@supports not (color: var(--bg-color)) {
  body {
    background-color: #0A0A0A;
    color: #E8E8E8;
  }
  
  [data-theme="light"] body {
    background-color: #F5F5F5;
    color: #1A1A1A;
  }
}

[data-theme="light"] {
  --bg-color: #F5F5F5;
  --text-color: #1A1A1A;
  --accent-color: #B8860B;
  --warning-color: #8B0000;
  --secondary-bg: #FFFFFF;
  --border-color: #CCCCCC;
  --shadow-color: rgba(184, 134, 11, 0.2);
  --wave-color: rgba(184, 134, 11, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  
  /* Safari CSS variable refresh fix */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Safari-specific theme enforcement */
[data-theme="dark"] body {
  background-color: #0A0A0A !important;
  color: #E8E8E8 !important;
}

[data-theme="light"] body {
  background-color: #F5F5F5 !important;
  color: #1A1A1A !important;
}

/* Typography */
h1, h2, h3 {
  font-family: Georgia, 'Playfair Display', serif;
  font-weight: 400;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.5rem;
  text-align: center;
  letter-spacing: 2px;
}

h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--accent-color);
}

h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

p {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.cipher-text {
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-container {
  min-height: 100vh;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  position: relative;
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--secondary-bg);
  border: 2px solid var(--accent-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  box-shadow: 0 0 20px var(--shadow-color);
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}

.theme-toggle span {
  font-size: 24px;
}

/* Buttons */
.btn {
  background: -webkit-linear-gradient(45deg, var(--accent-color), #FFA500);
  background: linear-gradient(45deg, var(--accent-color), #FFA500);
  color: var(--bg-color);
  padding: 15px 30px;
  border: none;
  border-radius: 5px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn:hover {
  -webkit-transform: translateY(-2px);
  transform: translateY(-2px);
  box-shadow: 0 10px 25px var(--shadow-color);
}

.btn:active {
  -webkit-transform: translateY(0);
  transform: translateY(0);
}

/* Animations */
@-webkit-keyframes frequency-wave {
  0%, 100% { -webkit-transform: scaleX(1); opacity: 0.3; }
  50% { -webkit-transform: scaleX(1.5); opacity: 0.6; }
}

@keyframes frequency-wave {
  0%, 100% { transform: scaleX(1); opacity: 0.3; }
  50% { transform: scaleX(1.5); opacity: 0.6; }
}

.wave-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.wave-bg::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  width: 200%;
  height: 2px;
  background: -webkit-linear-gradient(90deg, transparent, var(--wave-color), transparent);
  background: linear-gradient(90deg, transparent, var(--wave-color), transparent);
  -webkit-animation: frequency-wave 4s ease-in-out infinite;
  animation: frequency-wave 4s ease-in-out infinite;
}

.wave-bg::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%) rotate(90deg);
  transform: translate(-50%, -50%) rotate(90deg);
  width: 200%;
  height: 1px;
  background: -webkit-linear-gradient(90deg, transparent, var(--wave-color), transparent);
  background: linear-gradient(90deg, transparent, var(--wave-color), transparent);
  -webkit-animation: frequency-wave 6s ease-in-out infinite reverse;
  animation: frequency-wave 6s ease-in-out infinite reverse;
}

/* Sacred Symbol */
.sacred-symbol {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 2rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pyramid {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 150px solid var(--accent-color);
  opacity: 0.3;
}

.eye {
  position: absolute;
  width: 60px;
  height: 40px;
  background: var(--text-color);
  border-radius: 50%;
  z-index: 2;
}

.eye::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: var(--bg-color);
  border-radius: 50%;
}

.tuning-fork {
  position: absolute;
  width: 4px;
  height: 120px;
  background: var(--accent-color);
  z-index: 3;
}

.tuning-fork::before,
.tuning-fork::after {
  content: '';
  position: absolute;
  top: 0;
  width: 3px;
  height: 40px;
  background: var(--accent-color);
}

.tuning-fork::before {
  left: -10px;
}

.tuning-fork::after {
  right: -10px;
}

/* Glow Effects */
.glow-text {
  text-shadow: 0 0 10px var(--accent-color);
  transition: text-shadow 0.3s ease;
}

.glow-text:hover {
  text-shadow: 0 0 20px var(--accent-color), 0 0 30px var(--accent-color);
}

/* Archive Page Styles */
.ancient-door {
  width: 300px;
  height: 400px;
  background: var(--secondary-bg);
  border: 3px solid var(--accent-color);
  border-radius: 10px;
  position: relative;
  margin: 2rem auto;
  box-shadow: 0 0 30px var(--shadow-color);
}

.geometric-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border: 2px solid var(--accent-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.geometric-lock::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 2px solid var(--accent-color);
  transform: rotate(45deg);
}

.cipher-input {
  width: 100%;
  max-width: 400px;
  padding: 15px;
  margin: 2rem auto;
  background: var(--secondary-bg);
  border: 2px solid var(--accent-color);
  border-radius: 5px;
  color: var(--text-color);
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 2px;
  display: block;
}

.cipher-input:focus {
  outline: none;
  box-shadow: 0 0 20px var(--shadow-color);
}

/* Downloads Grid */
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
  /* Safari Grid fallback */
  display: -webkit-grid;
  -webkit-grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  -webkit-grid-gap: 2rem;
}

.download-item {
  background: var(--secondary-bg);
  padding: 2rem;
  border-radius: 10px;
  border: 2px solid var(--accent-color);
  transition: all 0.3s ease;
  position: relative;
}

.download-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px var(--shadow-color);
}

.download-item.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.download-item.locked::after {
  content: '🔒';
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
}

.download-item h3 {
  margin-bottom: 1rem;
}

.download-item p {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 1.5rem;
}

.download-link {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: bold;
  border-bottom: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.download-link:hover {
  border-bottom-color: var(--accent-color);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--secondary-bg);
  padding: 2rem;
  border-radius: 10px;
  border: 2px solid var(--warning-color);
  max-width: 500px;
  text-align: center;
}

.modal-close {
  background: var(--warning-color);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 1rem;
}

/* Enhanced Responsive Design */

/* Tablets Portrait */
@media (max-width: 1024px) {
  .container {
    padding: 0 20px;
  }
  
  .downloads-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
  }
  
  .page-container {
    padding: 1.5rem 0;
  }
  
  h1 {
    font-size: 2.2rem;
  }
  
  h2 {
    font-size: 1.8rem;
  }
  
  .btn {
    padding: 14px 28px;
    font-size: 1.1rem;
  }
}

/* Tablets and Small Laptops */
@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }
  
  h1 {
    font-size: 2rem;
    letter-spacing: 1px;
  }
  
  h2 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
  }
  
  h3 {
    font-size: 1.3rem;
  }
  
  p {
    font-size: 1rem;
  }
  
  .sacred-symbol {
    width: 150px;
    height: 150px;
    margin: 1.5rem auto;
  }
  
  .pyramid {
    border-left-width: 75px;
    border-right-width: 75px;
    border-bottom-width: 112px;
  }
  
  .ancient-door {
    width: 250px;
    height: 320px;
    margin: 1.5rem auto;
  }
  
  .downloads-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .download-item {
    padding: 1.5rem;
  }
  
  .cipher-input {
    max-width: 100%;
    font-size: 1rem;
    padding: 12px;
  }
  
  .btn {
    padding: 12px 24px;
    font-size: 1rem;
  }
  
  .modal-content {
    margin: 1rem;
    padding: 1.5rem;
  }
  
  /* Navigation improvements */
  nav {
    margin-bottom: 1rem !important;
  }
  
  nav a {
    font-size: 0.9rem !important;
  }
}

/* Mobile Phones */
@media (max-width: 480px) {
  .container {
    padding: 0 10px;
  }
  
  .theme-toggle {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
  }
  
  .theme-toggle span {
    font-size: 18px;
  }
  
  h1 {
    font-size: 1.8rem;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
  }
  
  h2 {
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
  }
  
  h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
  }
  
  p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.8rem;
  }
  
  .btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    letter-spacing: 1px;
    width: 100%;
    max-width: 280px;
  }
  
  .sacred-symbol {
    width: 120px;
    height: 120px;
    margin: 1rem auto;
  }
  
  .pyramid {
    border-left-width: 60px;
    border-right-width: 60px;
    border-bottom-width: 90px;
  }
  
  .eye {
    width: 45px;
    height: 30px;
  }
  
  .eye::before {
    width: 15px;
    height: 15px;
  }
  
  .tuning-fork {
    height: 90px;
    width: 3px;
  }
  
  .ancient-door {
    width: 200px;
    height: 260px;
  }
  
  .geometric-lock {
    width: 60px;
    height: 60px;
  }
  
  .geometric-lock::before {
    width: 30px;
    height: 30px;
  }
  
  .cipher-input {
    font-size: 0.9rem;
    padding: 10px;
    letter-spacing: 1px;
  }
  
  .download-item {
    padding: 1.2rem;
    margin-bottom: 1rem;
  }
  
  .download-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
  }
  
  .download-item p {
    font-size: 0.85rem;
  }
  
  .modal-content {
    margin: 0.5rem;
    padding: 1.2rem;
    max-width: calc(100vw - 1rem);
  }
  
  /* Improve touch targets */
  .download-link {
    display: inline-block;
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: 4px;
    background: rgba(255, 215, 0, 0.1);
    transition: all 0.3s ease;
  }
  
  .download-link:hover {
    background: rgba(255, 215, 0, 0.2);
  }
}

/* Small Mobile Phones */
@media (max-width: 360px) {
  .container {
    padding: 0 8px;
  }
  
  h1 {
    font-size: 1.6rem;
  }
  
  .ancient-door {
    width: 180px;
    height: 240px;
  }
  
  .download-item {
    padding: 1rem;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

/* Large Screens */
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
  }
  
  .downloads-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2.5rem;
  }
  
  .page-container {
    padding: 3rem 0;
  }
}

/* Ultra Wide Screens */
@media (min-width: 1600px) {
  .container {
    max-width: 1600px;
  }
  
  .downloads-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 3rem;
  }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .page-container {
    justify-content: flex-start;
    padding: 1rem 0;
  }
  
  .sacred-symbol {
    width: 100px;
    height: 100px;
    margin: 0.5rem auto;
  }
  
  .pyramid {
    border-left-width: 50px;
    border-right-width: 50px;
    border-bottom-width: 75px;
  }
  
  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }
  
  .ancient-door {
    width: 150px;
    height: 200px;
  }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  h1, h2, h3 {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  .btn {
    -webkit-font-smoothing: antialiased;
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .wave-bg::before,
  .wave-bg::after {
    animation: none;
  }
  
  .meditation-symbol {
    animation: none;
  }
}

/* Print Styles */
@media print {
  .theme-toggle,
  .wave-bg,
  .modal {
    display: none;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .btn {
    border: 2px solid black;
    background: white;
    color: black;
  }
}

/* Mobile Touch Optimizations */
.touch-active {
  transform: scale(0.95) !important;
  opacity: 0.8 !important;
  transition: all 0.1s ease !important;
}

/* Mobile-optimized styles */
.mobile-optimized * {
  -webkit-tap-highlight-color: rgba(255, 215, 0, 0.3);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.mobile-optimized input,
.mobile-optimized textarea {
  -webkit-user-select: text;
  -khtml-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Viewport height handling for mobile browsers */
:root {
  --vh: 1vh;
}

.page-container {
  min-height: calc(var(--vh, 1vh) * 100);
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .page-container {
    min-height: -webkit-fill-available;
  }
}

/* Safari transform 3D acceleration */
.theme-toggle,
.btn,
.download-item {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Safari border-radius and overflow fixes */
.theme-toggle {
  -webkit-border-radius: 50%;
  border-radius: 50%;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

.btn {
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

.download-item {
  -webkit-border-radius: 10px;
  border-radius: 10px;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

/* Android Chrome specific fixes */
@media screen and (max-width: 767px) {
  .page-container {
    min-height: calc(100vh - env(safe-area-inset-bottom));
  }
}

/* Improved focus styles for accessibility */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Better contrast for WCAG compliance */
@media (prefers-contrast: high) {
  :root {
    --text-color: #FFFFFF;
    --bg-color: #000000;
    --accent-color: #FFFF00;
  }
  
  [data-theme="light"] {
    --text-color: #000000;
    --bg-color: #FFFFFF;
    --accent-color: #0066CC;
  }
}

/* Reduced animation for users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .touch-active {
    transform: none !important;
    transition: opacity 0.1s ease !important;
  }
}

/* Konami Code notification animation */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Special Effects */
.parallax-container {
  overflow-x: hidden;
  overflow-y: auto;
  height: 100vh;
  perspective: 1px;
}

.parallax-element {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.parallax-back {
  transform: translateZ(-1px) scale(2);
}

.parallax-base {
  transform: translateZ(0);
}

/* Archive hover effect */
.archive-link {
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
}

.archive-link:hover {
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-color);
}

/* Frequency meditation visual */
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.meditation-symbol {
  display: inline-block;
  animation: pulse 3s ease-in-out infinite;
}