/* =========================================================
   Variables
   WarThrone — dark fantasy, cinematic, immersive base styles
   ========================================================= */
:root {
  /* Colors */
  --color-bg: #0a0b0d;            /* Obsidian */
  --color-surface: #101317;       /* Deep iron */
  --color-surface-2: #151a22;     /* Elevated surface */

  --color-text: #e6e8ec;          /* High contrast on dark */
  --color-text-muted: #b5bcc7;    /* Muted copy */

  --color-primary: #c71f37;       /* Blood red */
  --color-accent: #c9a227;        /* Aged gold */

  --color-success: #2ea043;       /* Victory green */
  --color-warning: #f2b705;       /* Ember gold */
  --color-danger: #e11d48;        /* Crimson */

  /* Neutral grays (iron) */
  --gray-50:  #f4f5f7;
  --gray-100: #e6e8ec;
  --gray-200: #cfd5df;
  --gray-300: #b5bcc7;
  --gray-400: #949cad;
  --gray-500: #747e91;
  --gray-600: #586173;
  --gray-700: #3f4656;
  --gray-800: #2b303c;
  --gray-900: #181c24;
  --gray-950: #0c0f14;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  --font-serif: "Cinzel", "Trajan Pro", "Garamond", Georgia, serif; /* Epic display */

  --text-xs: clamp(0.78rem, 0.75rem + 0.2vw, 0.84rem);
  --text-sm: clamp(0.88rem, 0.84rem + 0.2vw, 0.94rem);
  --text-base: clamp(1rem, 0.96rem + 0.25vw, 1.06rem);
  --text-lg: clamp(1.13rem, 1.05rem + 0.4vw, 1.25rem);
  --text-xl: clamp(1.28rem, 1.18rem + 0.6vw, 1.56rem);
  --text-2xl: clamp(1.5rem, 1.32rem + 1.2vw, 2rem);
  --text-3xl: clamp(1.88rem, 1.56rem + 1.8vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.9rem + 2.4vw, 3.25rem);

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;

  /* Spacing scale (0–96px) */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Shadows (cinematic, layered) */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.6), 0 2px 0 rgba(255, 255, 255, 0.05) inset;

  /* Transitions */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
  --easing-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --focus-ring: 0 0 0 3px rgba(201, 162, 39, 0.45), 0 0 0 1px rgba(201, 162, 39, 0.9) inset;

  /* Layout */
  --container-max: 1200px;
  --container-padding: var(--space-7);
}

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

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

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

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

input, button, textarea, select { font: inherit; color: inherit; }
button, [role="button"] { cursor: pointer; }

/* Remove default link underlines; manage via base styles */
a { text-decoration: none; color: inherit; }

/* Better default line-height and text rendering */
body { line-height: var(--lh-normal); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

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

/* =========================================================
   Base
   ========================================================= */
body {
  background-color: var(--color-bg);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(199, 31, 55, 0.08), transparent 70%),
    radial-gradient(800px 480px at 100% 10%, rgba(201, 162, 39, 0.05), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.18));
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  min-height: 100vh;
  accent-color: var(--color-primary);
}

main { display: block; }

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: var(--lh-tight);
  letter-spacing: 0.02em;
}

h1 { font-size: var(--text-4xl); color: var(--color-accent); margin-block: var(--space-10) var(--space-6); }
h2 { font-size: var(--text-3xl); color: var(--color-accent); margin-block: var(--space-9) var(--space-5); }
h3 { font-size: var(--text-2xl); margin-block: var(--space-8) var(--space-4); }
h4 { font-size: var(--text-xl);  margin-block: var(--space-7) var(--space-3); }
h5 { font-size: var(--text-lg);  margin-block: var(--space-6) var(--space-2); }
h6 { font-size: var(--text-base); margin-block: var(--space-5) var(--space-1); text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray-300); }

p { font-size: var(--text-base); line-height: var(--lh-relaxed); color: var(--color-text); max-width: 68ch; }

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

/* Links */
a { color: var(--color-accent); text-underline-offset: 3px; }
a:hover { color: #e4c978; text-decoration: underline; transition: color var(--duration-base) var(--easing-smooth); }
a:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }

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

/* Horizontal rule */
hr { border: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(201,162,39,0.3), transparent); margin-block: var(--space-8); }

/* Code */
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

/* Selection */
::selection { background: rgba(199, 31, 55, 0.35); color: var(--color-text); }

/* =========================================================
   Utilities
   ========================================================= */
.container { width: 100%; max-width: var(--container-max); margin-inline: auto; padding-inline: var(--container-padding); }
.container.narrow { max-width: 860px; }
.container.wide { max-width: 1400px; }

.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-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.grid { display: grid; gap: var(--space-7); }
.grid-center { display: grid; place-items: center; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.text-center { text-align: center; }
.center { margin-inline: auto; }

/* Vertical rhythm utility */
.stack > * + * { margin-top: var(--space-6); }

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

/* =========================================================
   Components
   ========================================================= */
/* Buttons */
.btn {
  --btn-bg: var(--color-surface-2);
  --btn-fg: var(--color-text);
  --btn-border: rgba(201, 162, 39, 0.18);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  padding: calc(var(--space-3) + 2px) var(--space-6);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.25)) , var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform var(--duration-fast) var(--easing-smooth), box-shadow var(--duration-base) var(--easing-smooth), background-color var(--duration-base) var(--easing-smooth), color var(--duration-base) var(--easing-smooth);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring), var(--shadow-md); }
.btn[disabled], .btn:disabled { opacity: 0.6; cursor: not-allowed; filter: grayscale(20%); }

.btn-primary { --btn-bg: var(--color-primary); --btn-fg: #fff; --btn-border: rgba(199,31,55,0.55); }
.btn-accent  { --btn-bg: var(--color-accent);  --btn-fg: #1a1206; --btn-border: rgba(201,162,39,0.65); }
.btn-success { --btn-bg: var(--color-success); --btn-fg: #06150b; --btn-border: rgba(46,160,67,0.6); }
.btn-danger  { --btn-bg: var(--color-danger);  --btn-fg: #fff; --btn-border: rgba(225,29,72,0.55); }

.btn-ghost {
  --btn-bg: transparent; --btn-fg: var(--color-text);
  border-color: var(--gray-800);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.15));
}
.btn-ghost:hover { background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.22)); }

/* Inputs */
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  color: var(--color-text);
  background-color: var(--color-surface);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs) inset;
  transition: border-color var(--duration-base) var(--easing-smooth), box-shadow var(--duration-base) var(--easing-smooth), background-color var(--duration-base) var(--easing-smooth);
}

input::placeholder, textarea::placeholder { color: var(--gray-500); }

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--color-accent); box-shadow: var(--focus-ring);
}

fieldset { border: none; padding: 0; margin: 0; }
label { display: inline-block; font-weight: 600; margin-bottom: var(--space-2); color: var(--gray-100); }

/* Cards */
.card {
  background-color: var(--color-surface);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.3)),
    radial-gradient(800px 300px at 0% 0%, rgba(201,162,39,0.06), transparent 60%);
  border: 1px solid rgba(201, 162, 39, 0.14);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
}
.card > *:first-child { margin-top: 0; }
.card > * + * { margin-top: var(--space-5); }

/* Elevation helper */
.elevate-sm { box-shadow: var(--shadow-sm); }
.elevate-md { box-shadow: var(--shadow-md); }
.elevate-lg { box-shadow: var(--shadow-lg); }

/* Badges (lightweight) */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); line-height: 1.2; background: rgba(201,162,39,0.14); color: #f1e3b0; border: 1px solid rgba(201,162,39,0.3); }

/* Tables (basic) */
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--gray-800); }
th { text-align: left; color: var(--gray-100); font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* =========================================================
   Accessibility & Interaction
   ========================================================= */
:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Reduce motion adjustments already in Reset */

/* Media prefers color scheme (kept dark by design) */
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; }
}

/* Responsive container padding */
@media (max-width: 640px) {
  :root { --container-padding: var(--space-5); }
  .stack > * + * { margin-top: var(--space-4); }
}

/* =========================================================
   Header & Footer styles
   ========================================================= */

/* Accessibility: Skip link */
.skip-link { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.skip-link:focus { left: 16px; top: 12px; width: auto; height: auto; padding: 10px 14px; background: var(--color-accent); color: #1a1206; border-radius: var(--radius-sm); z-index: 1000; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 500; background: rgba(16,19,23,0.82); backdrop-filter: saturate(120%) blur(8px); border-bottom: 1px solid rgba(201,162,39,0.12); }
.header-inner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-6); min-height: 64px; }
.brand-link { font-family: var(--font-serif); font-size: var(--text-xl); color: var(--gray-100); letter-spacing: 0.04em; }
.brand-link:hover { text-decoration: none; color: #f1e3b0; }

/* Brand logo sizing: desktop 120px, mobile max 80px */
.brand-link .brand-logo {
  width: 120px;
  height: auto;
  display: block;
}
@media (max-width: 900px) {
  .brand-link .brand-logo { width: 80px; max-width: 80px; }
}

.nav-toggle { display: none; position: relative; width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--gray-800); background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.2)); }
.nav-toggle .bar { position: absolute; left: 10px; right: 10px; height: 2px; background: var(--gray-200); border-radius: 2px; transition: transform var(--duration-base) var(--easing-smooth), opacity var(--duration-base) var(--easing-smooth); }
.nav-toggle .bar:nth-child(2) { top: 14px; }
.nav-toggle .bar:nth-child(3) { top: 21px; }
.nav-toggle .bar:nth-child(4) { top: 28px; }
.nav-toggle[aria-expanded="true"] .bar:nth-child(2) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bar:nth-child(3) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .bar:nth-child(4) { transform: translateY(-7px) rotate(-45deg); }

.site-nav { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-6); }
.nav-list { display: flex; gap: var(--space-6); align-items: center; }
.nav-list a { color: var(--gray-100); }
.nav-list a:hover { color: #e4c978; }

.nav-search { display: flex; gap: var(--space-3); align-items: center; width: min(360px, 38vw); }
.nav-search input { min-width: 0; }

@media (max-width: 1024px) {
  .nav-search { display: none; }
}

@media (max-width: 860px) {
  .header-inner { grid-template-columns: auto auto; }
  .nav-toggle { display: inline-flex; justify-content: center; align-items: center; }
  .site-nav { position: absolute; left: 0; right: 0; top: 64px; background: rgba(10,11,13,0.98); border-bottom: 1px solid rgba(201,162,39,0.12); padding: var(--space-6) var(--container-padding); display: none; flex-direction: column; align-items: stretch; gap: var(--space-6); }
  .site-nav.open { display: flex; }
  .nav-list { flex-direction: column; gap: var(--space-4); }
  .nav-search { display: flex; width: 100%; }
}

/* Footer */
.site-footer { border-top: 1px solid rgba(201,162,39,0.12); background: rgba(16,19,23,0.9); }
.footer-inner { display: grid; gap: var(--space-7); grid-template-columns: 1.2fr 1fr 1fr; padding: var(--space-10) 0; }
.footer-brand .brand-link { font-family: var(--font-serif); font-size: var(--text-lg); color: var(--gray-100); }
.footer-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.footer-list a { color: var(--gray-300); }
.footer-list a:hover { color: #e4c978; }
@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr; padding-left: 10px; }
}

/* Prevent horizontal scrolling and ensure child elements fit viewport on small screens */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }

  /* Make the main container responsive and avoid side overflow */
  .container {
    max-width: 100%;
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }

  /* Ensure elements inside containers do not exceed viewport */
  .container, .container * { box-sizing: border-box; }
  img, video, iframe, embed, figure { max-width: 100%; height: auto; display: block; }

  /* Tidy up components that may push layout horizontally */
  .site-nav, .cookie-inner, .footer-inner { padding-left: var(--space-5); padding-right: var(--space-5); }

  /* Prevent elements using 100% width + extra padding from overflowing */
  [class*="-inner"] { max-width: 100%; }
}

/* Ensure all .grid.cols-3 layouts collapse to one column on small screens
   and that their children don't cause horizontal overflow. */
@media (max-width: 900px) {
  .grid.cols-3, .cols-3 {
    grid-template-columns: 1fr !important;
  }

  .grid.cols-3 > *,
  .cols-3 > * {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Defensive: ensure inner elements don't add extra horizontal spacing */
  .grid.cols-3, .cols-3, .grid.cols-3 * , .cols-3 * {
    overflow-wrap: break-word;
    word-wrap: break-word;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
  }
}

/* =========================================================
   Cookie Consent Banner styles
   ========================================================= */
.cookie-banner { position: sticky; bottom: 0; inset-inline: 0; z-index: 600; }
.cookie-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); padding: var(--space-5) var(--container-padding); margin: var(--space-6) auto; background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.25)), var(--color-surface); border: 1px solid rgba(201,162,39,0.18); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.cookie-text { color: var(--gray-200); max-width: 70ch; }
.cookie-actions { display: flex; gap: var(--space-4); flex-wrap: wrap; }
@media (max-width: 680px) { .cookie-inner { flex-direction: column; align-items: stretch; } }
