/*
  ============================================================================
  Variables
  ============================================================================
*/

:root {
  /* Color palette - Evoland 2 inspired */
  --color-bg: #0b1017;              /* deep slate/steel night */
  --color-surface: #121824;         /* elevated panels */
  --color-surface-soft: #181f2c;    /* softer panels */

  --color-text: #e8edf7;            /* primary text */
  --color-text-muted: #a4b0c8;      /* secondary text */

  --color-primary: #3fb6f5;         /* frost blue accent */
  --color-primary-soft: rgba(63, 182, 245, 0.14);

  --color-accent-ember: #ff8a3c;    /* ember orange */
  --color-accent-ember-soft: rgba(255, 138, 60, 0.15);

  --color-success: #4fd37b;
  --color-warning: #ffd56a;
  --color-danger: #ff5b6b;

  /* Neutral grays (cool / steel) */
  --gray-50:  #f5f7fa;
  --gray-100: #e2e6f0;
  --gray-200: #c3cad8;
  --gray-300: #a4afc4;
  --gray-400: #8592b0;
  --gray-500: #667393;
  --gray-600: #4e5873;
  --gray-700: #383f55;
  --gray-800: #242938;
  --gray-900: #151824;

  /* Parchment accent for retro panels */
  --color-parchment: #f5e4c6;
  --color-parchment-text: #3f2a18;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Press Start 2P", "VT323", "IBM Plex Sans", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --font-size-xs: 0.75rem;  /* 12px */
  --font-size-sm: 0.875rem; /* 14px */
  --font-size-md: 1rem;     /* 16px */
  --font-size-lg: 1.125rem; /* 18px */
  --font-size-xl: 1.25rem;  /* 20px */
  --font-size-2xl: 1.5rem;  /* 24px */
  --font-size-3xl: 1.875rem;/* 30px */
  --font-size-4xl: 2.25rem; /* 36px */
  --font-size-5xl: 3rem;    /* 48px */

  --line-height-tight: 1.2;
  --line-height-snug: 1.35;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.75;

  /* Spacing scale (0–96px) */
  --space-0: 0;
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  --space-20: 5rem;    /* 80px */
  --space-24: 6rem;    /* 96px */

  /* Radii */
  --radius-none: 0;
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Shadows - subtle yet polished */
  --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-soft-glow: 0 0 0 1px rgba(63, 182, 245, 0.3),
    0 0 24px rgba(63, 182, 245, 0.35);

  /* Transitions */
  --transition-fast: 120ms ease-out;
  --transition-normal: 200ms ease-out;
  --transition-slow: 320ms ease-out;

  /* Layout */
  --container-max-width: 1120px;
}

/*
  ============================================================================
  Reset / Normalize
  ============================================================================
*/

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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style-position: outside;
}

img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

textarea {
  resize: vertical;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus {
  outline: none;
}

/*
  ============================================================================
  Base Styles
  ============================================================================
*/

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  background: radial-gradient(circle at top, #182539 0, #0b1017 55%, #05070b 100%);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  min-height: 60vh;
}

/* Heading hierarchy - modern + subtle retro flavor via display font */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: var(--line-height-tight);
  color: var(--gray-50);
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.9rem, 2.6vw + 1.4rem, var(--font-size-4xl));
  margin-bottom: var(--space-4);
}

h2 {
  font-size: clamp(1.5rem, 2vw + 1rem, var(--font-size-3xl));
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: clamp(1.25rem, 1.4vw + 0.9rem, var(--font-size-2xl));
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

h4 {
  font-size: var(--font-size-xl);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

h5 {
  font-size: var(--font-size-lg);
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
}

h6 {
  font-size: var(--font-size-sm);
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
}

p {
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

p + p {
  margin-top: var(--space-1);
}

small {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

strong {
  font-weight: 600;
}

code,
pre {
  font-family: "IBM Plex Mono", SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

a {
  position: relative;
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-normal);
}

a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent-ember));
  transition: width var(--transition-normal);
}

a:hover::after {
  width: 100%;
}

a:hover {
  color: var(--color-accent-ember);
}

hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: var(--space-6) 0;
}

/*
  ============================================================================
  Utilities
  ============================================================================
*/

/* Layout container */

.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--space-6);
  }
}

/* Flex helpers */

.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

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

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

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

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

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

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

.justify-end {
  justify-content: flex-end;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-4 {
  gap: var(--space-4);
}

/* Grid helpers */

.grid {
  display: grid;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
}

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

/* Visually hidden (screen reader only) */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Parchment panel utility for retro lore sections */

.u-parchment-panel {
  background: radial-gradient(circle at top left, #fff8e8 0, #f5e4c6 40%, #e1c9a1 100%);
  color: var(--color-parchment-text);
  border-radius: 10px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
  padding: var(--space-5);
  border: 1px solid rgba(63, 42, 24, 0.25);
}

/*
  ============================================================================
  Components
  ============================================================================
*/

/* Buttons - primary / secondary / ghost */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--transition-normal),
    color var(--transition-normal),
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, #3fb6f5 0%, #46e1ff 50%, #ff8a3c 100%);
  background-size: 180% 180%;
  color: #06131c;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft-glow);
  background-position: 10% 0;
}

.btn-secondary {
  background: rgba(9, 16, 32, 0.95);
  border-color: rgba(109, 136, 196, 0.6);
  color: var(--gray-50);
  box-shadow: 0 0 0 1px rgba(63, 182, 245, 0.25);
}

.btn-secondary:hover {
  background: rgba(18, 30, 60, 0.95);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--color-text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn[disabled],
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Inputs */

.input,
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background-color: rgba(4, 8, 18, 0.92);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  transition:
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    background-color var(--transition-normal);
}

.input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

.input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: rgba(63, 182, 245, 0.9);
  box-shadow: 0 0 0 1px rgba(63, 182, 245, 0.9),
    0 0 0 5px rgba(63, 182, 245, 0.23);
  outline: none;
}

.input[disabled],
select[disabled],
textarea[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

label {
  display: inline-block;
  margin-bottom: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Card - for sections like lore archives, mechanic showcases, character panels */

.card {
  position: relative;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    radial-gradient(circle at top left, rgba(63, 182, 245, 0.16), transparent 56%),
    linear-gradient(145deg, #151c28, #0c1019);
  border: 1px solid rgba(145, 175, 230, 0.22);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      120deg,
      rgba(106, 212, 255, 0.04) 0px,
      transparent 45%,
      transparent 55%,
      rgba(255, 138, 60, 0.04) 100%
    );
  mix-blend-mode: screen;
  pointer-events: none;
}

.card-header {
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-1);
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.card-footer {
  margin-top: var(--space-4);
}

/*
  ============================================================================
  Accessibility & Motion Preferences
  ============================================================================
*/

:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px rgba(63, 182, 245, 0.8);
  border-radius: 6px;
}

button:focus-visible,
.btn:focus-visible,
a.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(63, 182, 245, 0.85),
    0 0 0 6px rgba(14, 25, 46, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/*
  ============================================================================
  Thematic Helpers (Retro / Era-shift Flavor)
  ============================================================================
*/

/* Pixel-border utility for retro frames (e.g., classic era screenshots) */

.u-pixel-frame {
  border-radius: var(--radius-xs);
  box-shadow:
    0 0 0 2px #000,
    0 0 0 4px #f5e4c6,
    0 0 0 6px #000;
  image-rendering: pixelated;
}

/* Soft glow frame for modern 3D & UI elements */

.u-glow-frame {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft-glow);
  overflow: hidden;
}

/* Section divider bar reminiscent of HUD UI */

.section-divider {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg,
      transparent 0,
      rgba(63, 182, 245, 0.65) 18%,
      rgba(255, 138, 60, 0.85) 50%,
      rgba(63, 182, 245, 0.65) 82%,
      transparent 100%);
  opacity: 0.8;
  margin: var(--space-6) 0;
}
