@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=EB+Garamond:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0a0604;
  --panel: rgba(22, 14, 10, 0.95);
  --text: #e8dbcc;
  --muted: #a39481;
  --cyan: #d1a054; /* Gold */
  --pink: #8a2121; /* Crimson */
  --amber: #d1a054; /* Gold */
  --red: #8a2121; /* Crimson */
  --green: #446e37; /* Forest Green */
  --ice: #68798c; /* Steel */
  --accent: var(--cyan);
  --line: rgba(209, 160, 84, 0.15);
  
  --font-title: 'Cinzel', serif;
  --font-body: 'EB Garamond', serif;
}

.accent-amber { --accent: var(--amber); }
.accent-violet { --accent: #6c4675; }
.accent-red { --accent: var(--red); }
.accent-green { --accent: var(--green); }
.accent-ice { --accent: var(--ice); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body.kd-lore-page {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background-color: var(--bg);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(209, 160, 84, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(138, 33, 33, 0.05) 0%, transparent 40%),
    url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
  font-family: var(--font-body);
  overflow-x: hidden;
  font-size: 18px;
}

.kd-lore-bg {
  display: none; /* No legacy grid */
}

.kd-lore-scan {
  display: none; /* No scanlines */
}

.kd-lore-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 64px);
  background: rgba(14, 8, 6, 0.95);
  border-bottom: 2px solid var(--line);
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-title);
  letter-spacing: 0.15em;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
}
.brand span { font-weight: 700; font-size: 20px; color: var(--accent); }
.brand small { font-size: 11px; color: var(--muted); }

.kd-lore-topbar nav { display: flex; gap: 12px; flex-wrap: wrap; }
.kd-lore-topbar nav a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 4px;
  background: rgba(209, 160, 84, 0.05);
  font-family: var(--font-title);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all 0.3s ease;
}
.kd-lore-topbar nav a:hover {
  border-color: var(--accent);
  background: rgba(209, 160, 84, 0.15);
  box-shadow: 0 0 10px rgba(209, 160, 84, 0.1);
}

main {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto 80px;
}

.kd-lore-hero {
  min-height: 500px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  padding: 60px 0 40px;
}

.hero-media {
  position: relative;
  min-height: 480px;
  border: 4px solid #1a100a;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0,0,0,0.8);
}
.hero-media img {
  width: 100%;
  height: 100%;
  min-height: 480px;
  object-fit: cover;
  filter: contrast(1.1) saturate(0.9) brightness(0.9);
  transition: transform 10s ease;
}
.hero-media:hover img {
  transform: scale(1.05);
}
.hero-media:after {
  content: "";
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(to right, rgba(0,0,0,0.6) 0%, transparent 30%),
    linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.9) 100%);
}
.hero-noise { display: none; }

.hero-copy {
  position: relative;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: linear-gradient(135deg, rgba(22, 14, 10, 0.9), rgba(12, 7, 5, 0.95));
  box-shadow: inset 0 0 60px rgba(0,0,0,0.8), 0 15px 40px rgba(0,0,0,0.6);
}
.hero-copy::before {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border: 1px solid rgba(209, 160, 84, 0.1);
  pointer-events: none;
}

.kicker {
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.kicker::after {
  content: '';
  height: 1px;
  flex: 1;
  background: linear-gradient(to right, var(--accent), transparent);
  opacity: 0.5;
}

.hero-copy h1 {
  margin: 0 0 20px;
  font-family: var(--font-title);
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.hero-copy p {
  color: var(--text);
  font-size: 20px;
  line-height: 1.6;
  margin: 0 0 32px;
  font-family: var(--font-body);
}

.tagline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.tagline span {
  color: var(--accent);
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 2px;
  font-size: 14px;
  font-family: var(--font-title);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kd-lore-dossier {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  align-items: start;
}

.lore-index {
  position: sticky;
  top: 100px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 10px 30px rgba(0,0,0,0.5);
}
.lore-index::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border: 1px solid rgba(209, 160, 84, 0.05);
  pointer-events: none;
}

.index-title {
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 20px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.lore-index a {
  display: block;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 12px 10px;
  transition: all 0.2s ease;
  font-family: var(--font-title);
  font-size: 15px;
}
.lore-index a:last-child { border-bottom: none; }
.lore-index a small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
  font-family: var(--font-body);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lore-index a.active, .lore-index a:hover {
  color: var(--accent);
  background: rgba(209, 160, 84, 0.05);
  border-left: 2px solid var(--accent);
  padding-left: 16px;
}
.lore-index a.active small { color: var(--text); }

.lore-main {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: inset 0 0 80px rgba(0,0,0,0.8), 0 20px 40px rgba(0,0,0,0.6);
  position: relative;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding: 40px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.2);
}
.intro-grid p {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1.6;
}
.intro-grid p:first-child::first-letter {
  font-family: var(--font-title);
  font-size: 3em;
  float: left;
  line-height: 0.8;
  margin-right: 8px;
  color: var(--accent);
}

.data-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.data-strip div {
  background: rgba(10, 6, 4, 0.9);
  padding: 24px;
  text-align: center;
}
.data-strip span {
  display: block;
  color: var(--muted);
  font-family: var(--font-title);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.data-strip strong {
  display: block;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.3;
  font-weight: normal;
}

.lore-section {
  padding: 40px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.lore-section h2 {
  margin: 0 0 16px;
  font-family: var(--font-title);
  font-size: 32px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
}
.lore-section h2::before {
  content: '❖';
  color: var(--accent);
  font-size: 20px;
}

.lore-section p {
  margin: 0 0 24px;
  color: var(--text);
  font-size: 19px;
  line-height: 1.6;
}

.lore-section ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.lore-section li {
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.3);
  border-radius: 2px;
  padding: 14px 18px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  display: flex;
  align-items: center;
}
.lore-section li:before {
  content: "♦";
  color: var(--accent);
  margin-right: 12px;
  font-size: 14px;
}

.lore-quote {
  margin: 0;
  padding: 40px;
  color: #fff;
  font-size: 28px;
  line-height: 1.3;
  font-family: var(--font-title);
  font-style: italic;
  text-align: center;
  background: rgba(0,0,0,0.4);
  border-top: 1px solid var(--line);
  position: relative;
}
.lore-quote::before, .lore-quote::after {
  content: '”';
  position: absolute;
  font-size: 80px;
  color: var(--line);
  font-family: serif;
  line-height: 1;
}
.lore-quote::before { top: 10px; left: 20px; content: '“'; }
.lore-quote::after { bottom: -20px; right: 20px; }

/* KD_LORE_PAGES_V2_DEEP_DOSSIER */
.deep-zone,
.matrix-zone,
.hooks-zone,
.phrase-zone {
  padding: 40px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.2);
}

.deep-title { margin-bottom: 24px; text-align: center; }
.deep-title span {
  display: block;
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.deep-title h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 36px;
  color: #fff;
}
.deep-title h2::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: var(--accent);
  margin: 16px auto 0;
}

.deep-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.deep-card {
  padding: 24px;
  border: 1px solid rgba(209, 160, 84, 0.2);
  border-radius: 2px;
  background: rgba(0,0,0,0.4);
  position: relative;
  transition: transform 0.3s ease;
}
.deep-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.deep-card small {
  display: block;
  color: var(--accent);
  font-family: var(--font-title);
  letter-spacing: 0.1em;
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.deep-card h3 {
  margin: 0 0 12px;
  font-size: 22px;
  font-family: var(--font-title);
  color: #fff;
}
.deep-card p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.matrix-grid { display: grid; gap: 16px; }
.matrix-row {
  display: grid;
  grid-template-columns: 180px 1fr 280px;
  gap: 24px;
  align-items: start;
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.05);
  border-left: 4px solid var(--accent);
  background: rgba(0,0,0,0.3);
}
.matrix-row strong {
  font-family: var(--font-title);
  color: var(--accent);
  font-size: 18px;
  letter-spacing: 0.05em;
}
.matrix-row span { color: var(--text); font-size: 17px; line-height: 1.5; }
.matrix-row em { color: var(--muted); font-size: 15px; font-style: italic; }

.hook-list {
  list-style: none;
  padding: 0; margin: 0;
  display: grid; gap: 12px;
}
.hook-list li {
  padding: 16px 20px;
  background: rgba(209, 160, 84, 0.05);
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
}

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.phrase-card {
  padding: 30px 20px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.2);
  font-family: var(--font-title);
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
  color: var(--text);
}

@media(max-width: 980px) {
  .kd-lore-hero { grid-template-columns: 1fr; min-height: auto; padding-top: 20px; }
  .hero-media { min-height: 360px; }
  .hero-media img { min-height: 360px; }
  .kd-lore-dossier { grid-template-columns: 1fr; }
  .lore-index { position: relative; top: auto; margin-bottom: 24px; }
  .intro-grid { grid-template-columns: 1fr; }
  .data-strip { grid-template-columns: 1fr; }
  .deep-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matrix-row { grid-template-columns: 1fr; gap: 8px; }
  .phrase-grid { grid-template-columns: 1fr; }
}

@media(max-width: 620px) {
  .kd-lore-topbar { flex-direction: column; align-items: flex-start; }
  .lore-section ul { grid-template-columns: 1fr; }
  .deep-card-grid { grid-template-columns: 1fr; }
}

.lore-section {
  display: block;
}
.section-marker {
  display: none;
}

/* RELATED LORE SECTION */
.related-lore {
  padding: 60px 0 0;
  margin-top: 40px;
  border-top: 2px solid rgba(209, 160, 84, 0.2);
}

.section-title {
  margin-bottom: 24px;
}
.section-title span {
  display: block;
  color: var(--accent);
  font-family: var(--font-title);
  letter-spacing: 0.2em;
  font-size: 13px;
  text-transform: uppercase;
}
.section-title h2 {
  margin: 8px 0 20px;
  font-family: var(--font-title);
  font-size: 38px;
  color: #fff;
}

/* old related grid */ .old-related-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.related-card {
  position: relative;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  background: #02070b;
  display: block;
  transition: all 0.3s ease;
}

.related-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(209, 160, 84, 0.2);
}

.related-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.6) saturate(0.9);
  transition: transform 0.6s ease, filter 0.6s ease;
}

.related-card:hover img {
  transform: scale(1.08);
  filter: brightness(0.8) saturate(1.1);
}

.related-card div {
  position: absolute;
  inset: auto 0 0;
  padding: 20px 16px;
  background: linear-gradient(transparent, rgba(14, 8, 6, 0.95) 80%);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related-card span {
  display: block;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.15em;
  font-weight: 700;
  font-family: var(--font-title);
  text-transform: uppercase;
}

.related-card strong {
  font-size: 20px;
  font-family: var(--font-title);
  color: #fff;
}

/* Fix media query for related-grid */
@media(max-width: 980px) {
  /* old related grid */ .old-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media(max-width: 620px) {
  /* old related grid */ .old-related-grid { grid-template-columns: 1fr; }
}

/* Fix Hover text pseudo-element */
.kd-lore-link, .kd-faction-link {
  position: relative;
}
.kd-lore-link:after, .kd-faction-link:after {
  content: "APRIMI";
  position: absolute;
  top: 14px; right: 14px; z-index: 4;
  color: #041019;
  background: var(--cyan);
  border-radius: 2px;
  padding: 5px 10px;
  font-family: var(--font-title);
  font-size: 10px; font-weight: 900; letter-spacing: .12em;
  opacity: 0; transform: translateY(-6px); transition: .25s ease;
}
.kd-lore-link:hover:after, .kd-faction-link:hover:after {
  opacity: 1; transform: translateY(0);
}



/* Enhanced Related Dossier Cards */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.related-card {
  position: relative;
  aspect-ratio: 16 / 11;
  border: 1px solid rgba(209, 160, 84, 0.3);
  border-radius: 6px;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  background: #0d0806;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 10px 30px rgba(0,0,0,0.9);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.related-card:hover {
  border-color: #d1a054;
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.95), 0 0 20px rgba(209, 160, 84, 0.3);
}

.related-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.65) contrast(1.1);
  transition: transform 0.5s ease, filter 0.5s ease;
}

.related-card:hover img {
  transform: scale(1.06);
  filter: brightness(0.85) contrast(1.15);
}

.related-card div {
  position: relative;
  z-index: 2;
  padding: 16px 18px;
  background: linear-gradient(180deg, transparent 0%, rgba(13, 8, 6, 0.92) 50%, #0d0806 100%);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related-card span {
  display: block;
  color: #d1a054;
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 900;
  font-family: var(--font-title);
  text-transform: uppercase;
}

.related-card strong {
  font-size: 16px;
  font-family: var(--font-title);
  color: #f0e6d2;
  line-height: 1.3;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
}


/* Carved stone frames for Lore Portal */
.lore-index,
.lore-main,
.lore-card,
.deep-card,
.hook-card,
.related-card {
  border: 4px solid #1a100a !important;
  border-top-color: #3a2215 !important;
  border-bottom-color: #080402 !important;
  border-left-color: #28160e !important;
  border-right-color: #120a06 !important;
  background-color: #0d0704 !important;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(209, 160, 84, 0.06), transparent 45%),
    linear-gradient(145deg, rgba(26, 15, 9, 0.96) 0%, rgba(10, 5, 3, 0.98) 100%) !important;
  box-shadow: 
    0 16px 45px rgba(0, 0, 0, 0.95),
    inset 0 0 0 1px rgba(209, 160, 84, 0.28),
    inset 0 0 25px rgba(0, 0, 0, 0.9) !important;
  border-radius: 4px !important;
}

.related-card:hover, .deep-card:hover {
  border-top-color: #52301e !important;
  box-shadow: 
    0 20px 55px rgba(0, 0, 0, 0.98),
    0 0 20px rgba(209, 160, 84, 0.25),
    inset 0 0 0 1px rgba(209, 160, 84, 0.45) !important;
  transform: translateY(-4px);
}
