/* ============================================================================
   LUMENARY GALLERY - BASE STYLES
   Global resets and foundational styles
   ============================================================================ */

/* ========================================
   CSS RESET & NORMALIZATION
   ======================================== */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-neutral-80);
  background-color: var(--color-void-black);
  overflow-x: hidden;
  min-height: 100vh;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-neutral-100);
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-black);
  letter-spacing: var(--letter-spacing-tight);
}

h2 {
  font-size: var(--font-size-4xl);
}

h3 {
  font-size: var(--font-size-2xl);
}

h4 {
  font-size: var(--font-size-xl);
}

h5 {
  font-size: var(--font-size-lg);
}

h6 {
  font-size: var(--font-size-base);
}

p {
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

p:last-child {
  margin-bottom: 0;
}

/* ========================================
   LINKS & INTERACTIVE ELEMENTS
   ======================================== */

a {
  color: var(--color-primary-100);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--color-primary-90);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary-100);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

button:focus-visible {
  outline: 2px solid var(--color-primary-100);
  outline-offset: 2px;
}

/* ========================================
   LISTS
   ======================================== */

ul, ol {
  list-style-position: inside;
  margin-bottom: var(--space-4);
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

li {
  margin-bottom: var(--space-2);
}

/* ========================================
   MEDIA ELEMENTS
   ======================================== */

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

svg {
  fill: currentColor;
  vertical-align: middle;
}

/* ========================================
   FORMS
   ======================================== */

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-primary-100);
  outline-offset: 2px;
}

/* Remove default input styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* Remove arrows from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ========================================
   TABLES
   ======================================== */

table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: var(--space-4);
}

th,
td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: var(--border-1) solid var(--glass-white-10);
}

th {
  font-weight: var(--font-weight-semibold);
  color: var(--color-neutral-100);
}

/* ========================================
   CODE BLOCKS
   ======================================== */

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: var(--space-1) var(--space-2);
  background: var(--bg-glass-light);
  border-radius: var(--radius-sm);
  color: var(--color-primary-100);
}

pre {
  padding: var(--space-4);
  background: var(--bg-glass-dark);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border-radius: var(--radius-lg);
  border: var(--border-1) solid var(--glass-white-10);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  padding: 0;
  background: none;
  border-radius: 0;
  color: var(--color-neutral-90);
}

/* ========================================
   HORIZONTAL RULE
   ======================================== */

hr {
  border: none;
  height: var(--border-1);
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--glass-white-10) 50%,
    transparent 100%
  );
  margin: var(--space-12) 0;
}

/* ========================================
   SELECTION
   ======================================== */

::selection {
  background-color: var(--color-primary-100);
  color: var(--color-void-black);
  text-shadow: none;
}

::-moz-selection {
  background-color: var(--color-primary-100);
  color: var(--color-void-black);
  text-shadow: none;
}

/* ========================================
   SCROLLBAR STYLING (Webkit browsers)
   ======================================== */

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-glass-medium);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-void-black);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-100);
  box-shadow: var(--glow-primary-sm);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-glass-medium) var(--color-void-black);
}

/* ========================================
   CANVAS CONTAINER (WebGL Background)
   ======================================== */

#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-background);
  pointer-events: none;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ========================================
   LOADING STATE
   ======================================== */

#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-void-black);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.loader__spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--glass-white-10);
  border-top-color: var(--color-primary-100);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: var(--glow-primary-md);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   MAIN LAYOUT
   ======================================== */

main {
  position: relative;
  z-index: var(--z-base);
  min-height: 100vh;
}

section {
  position: relative;
}

/* ========================================
   UTILITY PATTERNS
   ======================================== */

/* Prevent text selection on interactive elements */
button,
.btn,
.nav__link {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

/* Improve text rendering */
p,
h1, h2, h3, h4, h5, h6,
li {
  text-rendering: optimizeLegibility;
}

/* Prevent layout shift from scrollbars */
html {
  overflow-y: scroll;
}

/* Focus visible polyfill */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !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,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

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

  img {
    max-width: 100% !important;
  }

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

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

  #canvas-container,
  .nav,
  .footer {
    display: none;
  }
}

/* ========================================
   RESPONSIVE FONT SIZING
   ======================================== */

@media (max-width: 768px) {
  body {
    font-size: var(--font-size-sm);
  }

  h1 {
    font-size: var(--font-size-3xl);
  }

  h2 {
    font-size: var(--font-size-2xl);
  }

  h3 {
    font-size: var(--font-size-xl);
  }

  h4 {
    font-size: var(--font-size-lg);
  }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary-100);
  color: var(--color-void-black);
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  z-index: 9999;
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus {
  top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-primary-100: #00ffff;
    --color-secondary-100: #ff00ff;
  }

  a,
  button,
  .btn {
    text-decoration: underline;
  }
}

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
  a {
    text-decoration: underline;
  }

  button,
  .btn {
    border: 2px solid currentColor;
  }
}
