/* ==========================================
   Variables
   ========================================== */
:root {
  /* Color scheme */
  color-scheme: dark;
  accent-color: #6b2b1a;

  /* Core brand & theme palette (moody, elegant) */
  --color-background: #0a0d14; /* midnight base */
  --color-surface-1: #0e1424; /* deep panel */
  --color-surface-2: #121a2d; /* elevated panel */
  --color-surface-3: #162238; /* highest surface */

  /* Neutral grays tuned for dark UI */
  --gray-900: #0a0d14;
  --gray-800: #121826;
  --gray-700: #1a2236;
  --gray-600: #243049;
  --gray-500: #394b6a;
  --gray-400: #66718a;
  --gray-300: #8f98ad;
  --gray-200: #b7becd;
  --gray-100: #d9dee7;
  --gray-50:  #eef1f7;

  /* Text & brand accents */
  --color-text: var(--gray-100);
  --color-text-muted: var(--gray-300);
  --color-primary-700: #4d1f14; /* dark mahogany */
  --color-primary:     #6b2b1a; /* rich mahogany */
  --color-primary-400: #8f3c29; /* lighter */
  --color-success: #2ea44f;
  --color-warning: #d89614;
  --color-danger:  #e03a3a;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Helvetica, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  --font-serif: "Cinzel", "Trajan Pro", Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --fs-xs: 0.75rem;   /* 12px */
  --fs-sm: 0.875rem;  /* 14px */
  --fs-md: 1rem;      /* 16px */
  --fs-lg: 1.125rem;  /* 18px */
  --fs-xl: 1.25rem;   /* 20px */
  --fs-2xl: 1.5rem;   /* 24px */
  --fs-3xl: clamp(1.75rem, 1.4rem + 1.5vw, 2rem); /* ~28-32px */
  --fs-4xl: clamp(2.125rem, 1.6rem + 2.2vw, 2.5rem); /* ~34-40px */
  --fs-5xl: clamp(2.5rem, 1.8rem + 3vw, 3.5rem);     /* ~40-56px */

  --lh-tight: 1.2;
  --lh-normal: 1.6;
  --lh-relaxed: 1.8;

  /* Spacing scale (0–96px in 4px increments) */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;
  --space-13: 52px;
  --space-14: 56px;
  --space-15: 60px;
  --space-16: 64px;
  --space-17: 68px;
  --space-18: 72px;
  --space-19: 76px;
  --space-20: 80px;
  --space-21: 84px;
  --space-22: 88px;
  --space-23: 92px;
  --space-24: 96px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows (moody, atmospheric) */
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.30);
  --shadow-sm: 0 2px 6px rgb(0 0 0 / 0.35);
  --shadow-md: 0 6px 16px rgb(0 0 0 / 0.38), 0 2px 6px rgb(0 0 0 / 0.28);
  --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.45), 0 3px 10px rgb(0 0 0 / 0.25);

  /* Transitions */
  --transition-fast: 120ms;
  --transition-normal: 220ms;
  --transition-slow: 420ms;

  /* Layout */
  --container-max: 72rem; /* ~1152px */
  --container-pad: var(--space-6);

  /* Focus */
  --focus-outline: 2px solid var(--color-primary-400);
  --focus-ring: 0 0 0 3px rgb(143 60 41 / 0.45);
}

/* ==========================================
   Reset / Normalize
   ========================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html:focus-within {
  scroll-behavior: smooth;
}

html,
body {
  height: 100%;
}

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

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

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

/* Improve text rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Remove default button/input styles where appropriate */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ==========================================
   Base Styles
   ========================================== */
body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background-color: var(--color-background);
  background-image: radial-gradient(1200px 800px at -10% -20%, rgb(22 34 56 / 0.35), transparent 60%), radial-gradient(1000px 600px at 110% -10%, rgb(75 36 26 / 0.20), transparent 55%);
  min-height: 100vh;
}

main {
  display: block;
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--gray-50);
}

h1 { font-size: var(--fs-5xl); margin-block: var(--space-8) var(--space-4); }
h2 { font-size: var(--fs-4xl); margin-block: var(--space-7) var(--space-4); }
h3 { font-size: var(--fs-3xl); margin-block: var(--space-6) var(--space-3); }
h4 { font-size: var(--fs-2xl); margin-block: var(--space-5) var(--space-3); }
h5 { font-size: var(--fs-xl);  margin-block: var(--space-4) var(--space-2); }
h6 { font-size: var(--fs-lg);  margin-block: var(--space-3) var(--space-2); }

/* Paragraphs and content rhythm */
p {
  max-width: 70ch;
  margin-block: 0 var(--space-4);
  color: var(--color-text);
}

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

/* Links */
a {
  color: var(--color-primary-400);
  text-decoration: none;
  text-underline-offset: 2px;
}

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

a:active { color: var(--color-primary-700); }

/* Lists spacing */
ul, ol {
  padding-inline-start: var(--space-6);
  margin-block: 0 var(--space-4);
}

/* Horizontal rule */
hr {
  border: 0;
  border-top: 1px solid var(--gray-700);
  margin-block: var(--space-8);
}

/* Blockquotes */
blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  background: linear-gradient(180deg, rgb(18 26 45 / 0.6), rgb(18 26 45 / 0.3));
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-md);
  color: var(--gray-100);
}

/* ==========================================
   Accessibility
   ========================================== */
:where(a, button, input, textarea, select, summary, [tabindex])::selection {
  background: rgb(143 60 41 / 0.35);
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

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

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

/* ==========================================
   Utilities
   ========================================== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.center {
  margin-inline: auto;
}

/* Flex helpers */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.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; }
.gap-sm { gap: var(--space-3); }
.gap-md { gap: var(--space-5); }
.gap-lg { gap: var(--space-8); }

/* Grid helpers */
.grid { display: grid; gap: var(--space-6); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-6); }
.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); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6); }

/* Text utilities */
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }

/* ==========================================
   Components
   ========================================== */
/* Buttons */
.btn {
  --_bg: var(--color-primary);
  --_bg-hover: var(--color-primary-400);
  --_bg-active: var(--color-primary-700);
  --_border: transparent;
  --_color: #ffffff;

  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: calc(var(--space-3) + 2px) var(--space-5);
  border: 1px solid var(--_border);
  border-radius: var(--radius-md);
  background-color: var(--_bg);
  color: var(--_color);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, transform var(--transition-fast) ease;
  text-decoration: none;
}

.btn:hover { background-color: var(--_bg-hover); }
.btn:active { background-color: var(--_bg-active); transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.6; cursor: not-allowed; }

/* Button variants */
.btn--secondary { --_bg: var(--gray-700); --_bg-hover: var(--gray-600); --_bg-active: var(--gray-800); --_border: var(--gray-600); --_color: var(--gray-50); }
.btn--ghost {
  --_bg: transparent;
  --_bg-hover: rgb(143 60 41 / 0.12);
  --_bg-active: rgb(143 60 41 / 0.22);
  --_border: var(--color-primary);
  --_color: var(--color-primary-400);
}
.btn--success { --_bg: var(--color-success); --_bg-hover: #31b257; --_bg-active: #239a45; --_border: transparent; }
.btn--warning { --_bg: var(--color-warning); --_bg-hover: #e0a626; --_bg-active: #b88210; --_border: transparent; }
.btn--danger  { --_bg: var(--color-danger);  --_bg-hover: #ef4a4a; --_bg-active: #c23333; --_border: transparent; }

/* Inputs */
:where(input[type='text'], input[type='email'], input[type='password'], input[type='search'], input[type='url'], input[type='number'], input[type='tel'], select, textarea) {
  width: 100%;
  padding: calc(var(--space-3) + 2px) var(--space-4);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, background-color var(--transition-normal) ease;
}

:where(input, select, textarea)::placeholder { color: var(--gray-400); }

:where(input, select, textarea):focus-visible {
  border-color: var(--color-primary-400);
  box-shadow: var(--focus-ring);
}

:where(input, select, textarea):disabled { opacity: 0.6; cursor: not-allowed; }

/* Checkboxes & radios */
:where(input[type='checkbox'], input[type='radio']) {
  width: 1.1em; height: 1.1em; accent-color: var(--color-primary);
}

/* Card */
.card {
  background-color: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.card--elevated { background-color: var(--color-surface-3); box-shadow: var(--shadow-lg); }

.card__header { margin-bottom: var(--space-4); }
.card__footer { margin-top: var(--space-4); border-top: 1px solid var(--gray-700); padding-top: var(--space-4); }

/* Media wrappers */
.media-rounded img, .media-rounded video, .media-rounded picture { border-radius: var(--radius-md); }
.media-shadow img, .media-shadow video, .media-shadow picture { box-shadow: var(--shadow-sm); }

/* ==========================================
   Helpers for Interactive Elements
   ========================================== */
.button-reset { appearance: none; background: none; border: 0; padding: 0; color: inherit; font: inherit; }
.link-underline { text-decoration: underline; text-decoration-color: rgb(143 60 41 / 0.6); text-underline-offset: 3px; }

/* ==========================================
   Print adjustments
   ========================================== */
@media print {
  .btn, .card { box-shadow: none !important; }
  a { text-decoration: underline; color: black; }
}
