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

:root {
  /* Colors */
  --color-bg: #0c1623; /* deep ocean night */
  --color-bg-elevated: #111b29;
  --color-surface: #182334;
  --color-surface-soft: #202c3f;

  --color-text: #f7f2e9; /* parchment light */
  --color-text-soft: #d7d0c2;
  --color-text-muted: #a6a099;

  --color-primary: #1d7fbf; /* ocean blue */
  --color-primary-soft: rgba(29, 127, 191, 0.14);
  --color-primary-strong: #0f5c8a;

  --color-success: #3e8e4a; /* forest green */
  --color-warning: #d9a437; /* golden wheat */
  --color-danger: #b94132;  /* rustic red/brown */

  --color-sand: #d9c29a;   /* warm sand beige */
  --color-forest: #295538; /* deep forest green */
  --color-wheat: #f0c56c;  /* bright wheat accent */
  --color-stone: #6e747e;  /* stone gray */

  /* Neutral grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2933;
  --gray-900: #111827;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Cinzel", "Cormorant Garamond", "Garamond", "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --font-size-xs: 0.75rem;  /* 12px */
  --font-size-sm: 0.875rem; /* 14px */
  --font-size-base: 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.5;
  --line-height-relaxed: 1.7;

  /* 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 */

  /* Radius */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Shadows (slightly mystical / atmospheric) */
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 35px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 20px 60px rgba(0, 0, 0, 0.6);

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

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

/* Respect user preference: reduced motion */

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0s;
    --transition-base: 0s;
    --transition-slow: 0s;
  }

  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

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

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

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

body {
  margin: 0;
}

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

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

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

input,
button,
textarea,
select {
  font: inherit;
}

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

textarea {
  resize: vertical;
}

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

:where(*) {
  min-width: 0;
}

/* ========================================================================== *
   Base styles
   ========================================================================== */

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  background: radial-gradient(circle at top, #233c5d 0, #0a111a 55%, #05070a 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  display: block;
}

/* Headings: medieval-inspired display type with controlled margins */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: #fdf6e3;
}

h1 {
  font-size: clamp(2.4rem, 2.2rem + 1vw, 3.2rem);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: var(--space-4);
}

h2 {
  font-size: clamp(1.9rem, 1.7rem + 0.8vw, 2.4rem);
  margin-top: var(--space-10);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: clamp(1.4rem, 1.2rem + 0.5vw, 1.75rem);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

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

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

h6 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
}

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

strong, b {
  font-weight: 600;
  color: #fffaf3;
}

em, i {
  font-style: italic;
}

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

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

pre {
  padding: var(--space-3);
  background-color: rgba(6, 10, 16, 0.85);
  border-radius: var(--radius-md);
  overflow: auto;
}

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

/* Links with subtle medieval accent */

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

a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.1em;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-wheat), var(--color-primary));
  transition: width var(--transition-base);
}

a:hover {
  color: #fff3c6;
}

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

a:focus-visible {
  outline: 2px solid var(--color-wheat);
  outline-offset: 2px;
}

/* Lists */

ul, ol {
  padding-left: 1.4rem;
  margin-bottom: var(--space-3);
}

/* ========================================================================== *
   Accessibility & Focus
   ========================================================================== */

:focus-visible {
  outline: 3px solid var(--color-wheat);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Screen-reader only utility */

.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;
}

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

/* Layout container */

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

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

/* Flex helpers */

.flex {
  display: flex;
}

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

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

.gap-xs { gap: var(--space-1); }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-3); }
.gap-lg { gap: var(--space-4); }
.gap-xl { gap: var(--space-6); }

/* Grid helpers */

.grid {
  display: grid;
}

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

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

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

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

/* Spacing utilities (vertical rhythm helpers) */

.space-y-2 > * + * { margin-top: var(--space-2); }
.space-y-3 > * + * { margin-top: var(--space-3); }
.space-y-4 > * + * { margin-top: var(--space-4); }
.space-y-6 > * + * { margin-top: var(--space-6); }

.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

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

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

/* Buttons: adventurous, rounded, tactile */

.btn {
  --btn-bg: var(--color-primary);
  --btn-bg-hover: var(--color-primary-strong);
  --btn-color: #fdfaf3;
  --btn-border: rgba(0, 0, 0, 0.6);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  border: 1px solid var(--btn-border);
  color: var(--btn-color);
  background: radial-gradient(circle at 10% 0, rgba(255, 255, 255, 0.18), transparent 55%), var(--btn-bg);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.7), 0 10px 18px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-base),
    filter var(--transition-base);
  text-decoration: none;
}

.btn:hover {
  background: radial-gradient(circle at 10% 0, rgba(255, 255, 255, 0.25), transparent 55%), var(--btn-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.75), 0 16px 26px rgba(0, 0, 0, 0.6);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.8), 0 6px 12px rgba(0, 0, 0, 0.65);
}

.btn:focus-visible {
  outline: 3px solid var(--color-wheat);
  outline-offset: 3px;
}

.btn--primary {
  --btn-bg: var(--color-primary);
  --btn-bg-hover: var(--color-primary-strong);
}

.btn--secondary {
  --btn-bg: #473625;
  --btn-bg-hover: #5c4129;
}

.btn--ghost {
  --btn-bg: rgba(11, 18, 27, 0.7);
  --btn-bg-hover: rgba(22, 33, 48, 0.95);
  --btn-border: rgba(255, 255, 255, 0.2);
}

.btn--danger {
  --btn-bg: var(--color-danger);
  --btn-bg-hover: #963525;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.7), 0 4px 8px rgba(0, 0, 0, 0.45);
}

/* Form controls: parchment-style inputs inside dark UI */

.input,
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(235, 222, 198, 0.45);
  background-color: rgba(22, 19, 14, 0.9);
  color: #f8f2e5;
  font-size: var(--font-size-sm);
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    background-color var(--transition-base);
}

.input::placeholder,
textarea::placeholder {
  color: rgba(232, 220, 196, 0.55);
}

.input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--color-wheat);
  box-shadow: 0 0 0 1px rgba(240, 197, 108, 0.6), 0 0 0 4px rgba(240, 197, 108, 0.24);
  background-color: rgba(26, 21, 15, 0.98);
}

.input[aria-invalid="true"],
.input--error {
  border-color: var(--color-danger);
}

.label {
  display: inline-block;
  margin-bottom: 0.25rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-soft);
}

.field-help {
  margin-top: 0.25rem;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.field-error {
  margin-top: 0.25rem;
  font-size: var(--font-size-xs);
  color: var(--color-danger);
}

/* Card: for guides, expansions, timelines, etc. */

.card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 60%),
    radial-gradient(circle at top left, rgba(36, 85, 125, 0.32), transparent 55%),
    linear-gradient(160deg, #151c29, #0d131f);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  border: 1px solid rgba(240, 197, 108, 0.08);
  mix-blend-mode: screen;
}

.card--highlight {
  background:
    linear-gradient(135deg, rgba(240, 197, 108, 0.16), transparent 65%),
    linear-gradient(160deg, #191f2e, #101725);
}

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

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

.card-meta {
  font-size: var(--font-size-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.card-body {
  color: var(--color-text-soft);
}

/* Hero helpers for the adventure-themed island intro */

.hero {
  position: relative;
  padding: var(--space-16) 0 var(--space-12);
  color: #fffaf0;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top, rgba(240, 197, 108, 0.15), transparent 60%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.75));
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-kicker {
  font-size: var(--font-size-sm);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(244, 235, 211, 0.8);
  margin-bottom: var(--space-2);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 2.1rem + 1.6vw, 3.4rem);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: var(--space-3);
}

.hero-subtitle {
  max-width: 40rem;
  font-size: var(--font-size-lg);
  color: var(--color-text-soft);
}

/* Badges for resource types, expansions, etc. */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background-color: rgba(3, 8, 16, 0.85);
  color: rgba(250, 245, 235, 0.9);
}

.badge--ocean {
  background: rgba(29, 127, 191, 0.19);
  border-color: rgba(29, 127, 191, 0.6);
}

.badge--forest {
  background: rgba(62, 142, 74, 0.2);
  border-color: rgba(62, 142, 74, 0.7);
}

.badge--wheat {
  background: rgba(240, 197, 108, 0.18);
  border-color: rgba(240, 197, 108, 0.7);
}
