/* ================================================
   SHADOW CODEX — Design System
   Wiki immersif dark fantasy
   ================================================ */

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

/* --- Variables --- */
:root {
  /* Surfaces */
  --bg: #0b0b0b;
  --surface: #131313;
  --surface-2: #1a1a1a;
  --surface-3: #222222;
  --border: #2a2a2a;

  /* Accents */
  --accent: #c4503a;
  --accent-dim: #8b3828;
  --accent-bg: #c4503a12;
  --accent-gold: #d4a23a;
  --accent-gold-dim: #8b7328;

  /* Text */
  --text: #d4d4d4;
  --text-soft: #888888;
  --text-fade: #555555;
  --white: #eeeeee;

  /* Ranks */
  --rank-dormant: #666666;
  --rank-awakened: #5b8dd9;
  --rank-ascended: #9b6cd4;
  --rank-transcendent: #d4a23a;
  --rank-supreme: #d44a4a;
  --rank-sovereign: #d44a8b;

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Libre Franklin', sans-serif;
  --font-data: 'DM Mono', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 4rem;
  --space-2xl: 8rem;

  /* Layout */
  --content-width: 1200px;
  --content-narrow: 800px;
}

/* --- Base --- */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
}

/* --- Grain Overlay --- */
.grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.04;
}

.grain::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--white);
}

h1 {
  font-size: 3rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.125rem;
}

p {
  margin-bottom: var(--space-md);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* --- Labels (data style) --- */
.label {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
}

.label--accent {
  color: var(--accent);
}

.label--gold {
  color: var(--accent-gold);
}

/* --- Separators --- */
.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-lg) 0;
}

.divider--ornament {
  position: relative;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border) 20%,
    var(--accent-dim) 50%,
    var(--border) 80%,
    transparent 100%
  );
}

.divider--ornament::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 6px;
  height: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(180deg, var(--bg) 0%, transparent 100%);
  backdrop-filter: blur(8px);
}

.nav__logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.02em;
}

.nav__logo:hover {
  color: var(--accent);
}

.nav__links {
  display: flex;
  gap: var(--space-lg);
}

.nav__link {
  color: var(--text-soft);
  transition: color 0.2s ease;
}

.nav__link:hover {
  color: var(--white);
}

.nav__label {
  font-family: var(--font-data);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav__lang {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-data);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav__lang a {
  color: var(--text-fade);
  transition: color 0.2s ease;
}

.nav__lang a:hover,
.nav__lang a.active {
  color: var(--white);
}

.nav__sep {
  color: var(--text-fade);
}

/* --- Hero (cinematic) --- */
.hero {
  position: relative;
  width: 100%;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.hero__bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.hero__overlay {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(11, 11, 11, 0.3) 40%,
    rgba(11, 11, 11, 0.8) 70%,
    var(--bg) 100%
  );
}

.hero__glow {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 200px;
  background: radial-gradient(ellipse, var(--accent-bg) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

.hero__content {
  position: relative;
  max-width: var(--content-width);
  margin: 0 auto;
  width: 100%;
}

.hero__name {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
  margin-bottom: var(--space-sm);
  text-shadow: 0 0 40px rgba(196, 80, 58, 0.15);
}

.hero__titles {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.125rem;
  color: var(--text-soft);
  margin-bottom: var(--space-lg);
}

/* --- Quick Stats Grid (hero) --- */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  max-width: 600px;
}

.quick-stats__item {
  background: var(--surface);
  padding: var(--space-md);
}

.quick-stats__label {
  font-family: var(--font-data);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-fade);
  margin-bottom: var(--space-xs);
}

.quick-stats__value {
  font-family: var(--font-data);
  font-size: 0.875rem;
  color: var(--white);
  font-weight: 500;
}

/* --- Rank Colors (applied via data attribute) --- */
[data-rank="dormant"] { color: var(--rank-dormant); }
[data-rank="awakened"] { color: var(--rank-awakened); }
[data-rank="ascended"] { color: var(--rank-ascended); }
[data-rank="transcendent"] { color: var(--rank-transcendent); }
[data-rank="supreme"] { color: var(--rank-supreme); }
[data-rank="sovereign"] { color: var(--rank-sovereign); }

.rank-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--space-xs);
  vertical-align: middle;
}

.rank-dot[data-rank="dormant"] { background: var(--rank-dormant); }
.rank-dot[data-rank="awakened"] { background: var(--rank-awakened); }
.rank-dot[data-rank="ascended"] { background: var(--rank-ascended); }
.rank-dot[data-rank="transcendent"] { background: var(--rank-transcendent); }
.rank-dot[data-rank="supreme"] { background: var(--rank-supreme); }
.rank-dot[data-rank="sovereign"] { background: var(--rank-sovereign); }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

.tabs__item {
  font-family: var(--font-data);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-fade);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tabs__item:hover {
  color: var(--text);
}

.tabs__item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Tags / Attributes --- */
.tag {
  display: inline-block;
  font-family: var(--font-data);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-soft);
  background: var(--surface);
  transition: border-color 0.2s ease;
}

.tag--active {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-bg);
}

.tag--lost {
  text-decoration: line-through;
  color: var(--text-fade);
  border-color: transparent;
}

/* --- Content Layout --- */
.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.content--narrow {
  max-width: var(--content-narrow);
}

/* --- Data Table --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.data-table th {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-fade);
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.data-table tr:hover td {
  background: var(--surface);
}

/* --- Timeline (vertical) --- */
.timeline {
  position: relative;
  padding-left: var(--space-xl);
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  left: 15px;
  width: 1px;
  height: 100%;
  background: var(--border);
}

.timeline__event {
  position: relative;
  padding-bottom: var(--space-xl);
}

.timeline__dot {
  position: absolute;
  left: calc(-1 * var(--space-xl) + 10px);
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
}

.timeline__dot--active {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 12px rgba(196, 80, 58, 0.4);
}

.timeline__chapter {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-fade);
  margin-bottom: var(--space-xs);
}

.timeline__title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--white);
  margin-bottom: var(--space-xs);
}

.timeline__desc {
  font-size: 0.875rem;
  color: var(--text-soft);
  line-height: 1.5;
}

/* --- Character Card (list page) --- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.char-card {
  position: relative;
  background: var(--surface);
  padding: var(--space-md);
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: var(--space-md);
  align-items: center;
  transition: background 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.char-card:hover {
  background: var(--surface-2);
  color: inherit;
}

.char-card__portrait {
  width: 60px;
  height: 80px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}

.char-card__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-card__info {
  min-width: 0;
}

.char-card__name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 2px;
}

.char-card__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.8125rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-xs);
}

.char-card__meta {
  font-family: var(--font-data);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-fade);
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--space-xl) var(--space-lg);
  margin-top: var(--space-2xl);
}

.footer__inner {
  max-width: var(--content-width);
  margin: 0 auto;
  text-align: center;
}

.footer__text {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: var(--space-sm);
}

.footer__text--fade {
  color: var(--text-fade);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero__name {
    font-size: 2.5rem;
  }

  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav__links {
    display: none;
  }

  h1 {
    font-size: 2rem;
  }

  .content {
    padding: 0 var(--space-md);
  }
}

@media (max-width: 480px) {
  .hero {
    min-height: 60vh;
  }

  .hero__name {
    font-size: 2rem;
  }
}
