/* ============================================================
   THE CHRONICLE — Traveler's Log Stylesheet
   BG3 Second Playthrough Documentation
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=Cinzel:wght@400;500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&family=IM+Fell+English:ital@0;1&display=swap');

/* === CUSTOM PROPERTIES === */
:root {
  --leather:          #160b03;
  --leather-mid:      #2a1207;
  --leather-accent:   #3a1a09;
  --parchment-base:   #eddcae;
  --parchment-light:  #f6edd5;
  --parchment-dark:   #d4b87c;
  --ink:              #1c0c03;
  --ink-mid:          #2e1a0e;
  --ink-faded:        #6b4a32;
  --gold:             #c9a84c;
  --gold-light:       #e8c870;
  --gold-dark:        #9a7a30;
  --crimson:          #7a1515;
  --crimson-dark:     #4f0c0c;
  --font-display:     'Cinzel Decorative', serif;
  --font-heading:     'Cinzel', serif;
  --font-body:        'Lora', serif;
  --font-caps:        'Cinzel', serif;
  --page-max:         980px;
  --page-pad:         4rem;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* === BODY — LEATHER COVER === */
body {
  background-color: var(--leather);
  background-image:
    repeating-linear-gradient(
      87deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.012) 2px,
      rgba(255,255,255,0.012) 4px
    ),
    repeating-linear-gradient(
      3deg,
      transparent,
      transparent 8px,
      rgba(0,0,0,0.06) 8px,
      rgba(0,0,0,0.06) 9px
    );
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 5rem;
}

/* === OUTER WRAPPER === */
.chronicle-wrapper {
  width: 100%;
  max-width: var(--page-max);
  position: relative;
}

/* === NAV TABS — LEATHER BOOKMARKS === */
nav.tabs {
  display: flex;
  gap: 3px;
  padding-left: 2rem;
}
nav.tabs a {
  display: inline-block;
  padding: 0.45rem 1.3rem;
  background: linear-gradient(to bottom, #3e200d 0%, #271008 100%);
  color: var(--gold);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid rgba(180, 130, 60, 0.22);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  position: relative;
  top: 1px;
  transition: background 0.2s, color 0.2s;
}
nav.tabs a:hover {
  background: linear-gradient(to bottom, #5a2d12 0%, #3e200d 100%);
  color: var(--gold-light);
}
nav.tabs a.active {
  background: var(--parchment-light);
  color: var(--ink);
  border-color: rgba(180, 130, 60, 0.35);
}

/* === PAGE — PARCHMENT === */
.page {
  position: relative;
  overflow: hidden;
  background-color: var(--parchment-base);
  background-image:
    /* Top and bottom edge darkening */
    linear-gradient(to bottom, rgba(85, 50, 18, 0.14) 0%, transparent 7%),
    linear-gradient(to top,    rgba(85, 50, 18, 0.17) 0%, transparent 7%),
    /* Age spots and foxing */
    radial-gradient(ellipse at 11% 17%, rgba(140, 90, 40, 0.13) 0%, transparent 28%),
    radial-gradient(ellipse at 90% 75%, rgba(110, 70, 30, 0.09) 0%, transparent 26%),
    radial-gradient(ellipse at 55% 48%, rgba(160, 120, 60, 0.06) 0%, transparent 38%),
    /* Parchment tone */
    linear-gradient(
      163deg,
      #f8f0da 0%,
      #eeddaa 18%,
      #f3e5c2 38%,
      #e9d7a0 56%,
      #f1e3b8 76%,
      #e6d296 100%
    );
  /* Worn, non-rectangular edges */
  clip-path: polygon(
    /* Top edge: left to right, slightly uneven */
    0.3%  0.5%,
    18%   0.1%,
    40%   0.4%,
    62%   0.05%,
    82%   0.35%,
    99.4% 0.15%,
    /* Right edge: top to bottom */
    100%   8%,
    99.55% 32%,
    100%   56%,
    99.6%  80%,
    99.75% 99.3%,
    /* Bottom edge: right to left */
    80%   99.95%,
    58%   99.6%,
    38%   100%,
    18%   99.7%,
    0.6%  99.8%,
    /* Left edge: bottom to top */
    0%    80%,
    0.45% 52%,
    0%    26%
  );
  /* Shadow follows the clip-path shape */
  filter:
    drop-shadow(-6px 2px 20px rgba(0, 0, 0, 0.82))
    drop-shadow(6px 6px 16px rgba(0, 0, 0, 0.42));
  will-change: filter;
  contain: layout style;
  padding: var(--page-pad);
  min-height: calc(100vh - 7rem);
}
/* Book binding shadow */
.page::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 55px;
  background: linear-gradient(
    to right,
    rgba(22, 10, 2, 0.5) 0%,
    rgba(22, 10, 2, 0.18) 55%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 2;
}
/* Right-edge darkening */
.page::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 28px;
  background: linear-gradient(
    to left,
    rgba(22, 10, 2, 0.2) 0%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* === CANDLE FLICKER OVERLAY === */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  33%       { opacity: 0.985; }
  66%       { opacity: 0.995; }
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(180, 100, 30, 0.04) 0%,
    transparent 65%
  );
  animation: flicker 8s ease-in-out infinite;
  pointer-events: none;
  will-change: opacity;
  z-index: 9999;
}

/* === TYPOGRAPHY === */
h1 { font-family: var(--font-display); color: var(--ink); line-height: 1.2; }
h2 { font-family: var(--font-heading); color: var(--ink-mid); letter-spacing: 0.05em; }
h3 { font-family: var(--font-heading); color: var(--ink-faded); letter-spacing: 0.08em; }
p  { line-height: 1.85; color: var(--ink-mid); }

a               { color: var(--crimson); text-decoration: none; }
a:hover         { color: var(--crimson-dark); text-decoration: underline; }

/* === ORNAMENTS & DIVIDERS === */
.ornament {
  display: block;
  text-align: center;
  color: var(--gold-dark);
  font-size: 1.1rem;
  letter-spacing: 0.9rem;
  margin: 2rem 0;
  opacity: 0.65;
}
hr.divider {
  border: none;
  position: relative;
  margin: 2.5rem 0;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(140, 100, 50, 0.35) 18%,
    rgba(160, 120, 60, 0.55) 50%,
    rgba(140, 100, 50, 0.35) 82%,
    transparent 100%
  );
}
hr.divider::after {
  content: '✦';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--parchment-base);
  padding: 0 0.75rem;
  color: var(--gold-dark);
  font-size: 0.85rem;
}

/* === LANDING PAGE === */
.landing-title {
  text-align: center;
  padding: 3.5rem 0 2rem;
}
.landing-title h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  margin-bottom: 0.4rem;
}
.landing-title .vol {
  font-family: var(--font-caps);
  letter-spacing: 0.25em;
  color: var(--ink-faded);
  font-size: 0.78rem;
  margin-bottom: 1rem;
  display: block;
}
.landing-title .subtitle {
  font-family: var(--font-caps);
  letter-spacing: 0.2em;
  color: var(--ink-faded);
  font-size: 0.75rem;
}

.wax-seal {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c0392b 0%, #8b1a1a 50%, #5a0f0f 100%);
  margin: 2rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow:
    0 5px 18px rgba(0, 0, 0, 0.55),
    inset 0 -4px 10px rgba(0, 0, 0, 0.35),
    inset 0 3px 8px rgba(255, 200, 180, 0.12);
  position: relative;
  user-select: none;
}
.wax-seal::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.18) 0%, transparent 55%);
}

.intro-text {
  max-width: 580px;
  margin: 1.5rem auto 0;
  text-align: center;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.95;
  color: var(--ink-mid);
}

.nav-buttons {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 2.5rem 0 1rem;
}
.btn {
  display: inline-block;
  padding: 0.7rem 2rem;
  background: linear-gradient(to bottom, var(--leather-accent) 0%, var(--leather-mid) 100%);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid rgba(180, 130, 60, 0.38);
  border-radius: 2px;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
.btn:hover {
  background: linear-gradient(to bottom, #5a2d12 0%, var(--leather-accent) 100%);
  color: var(--gold-light);
  text-decoration: none;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.55);
  transform: translateY(-1px);
}

/* === PARTY MEMBERS — LANDING ROSTER === */
.party-roster {
  margin-top: 2rem;
  border: 1px solid rgba(140, 100, 50, 0.3);
  padding: 1.5rem 2rem;
  position: relative;
}
.party-roster::before {
  content: '✦  The Company  ✦';
  position: absolute;
  top: -0.65rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--parchment-base);
  padding: 0 1rem;
  font-family: var(--font-caps);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--gold-dark);
  white-space: nowrap;
}
.party-roster ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 2rem;
  margin-top: 0.5rem;
}
.party-roster li {
  font-family: var(--font-caps);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--ink-faded);
}
.party-roster li a {
  color: var(--ink-faded);
  text-decoration: none;
}
.party-roster li a:hover {
  color: var(--crimson);
}

/* === CHARACTERS PAGE === */
.page-title {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}
.page-title h1 { font-size: clamp(1.4rem, 4vw, 1.9rem); }
.page-title .subtitle {
  font-family: var(--font-caps);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: var(--ink-faded);
  margin-top: 0.4rem;
  display: block;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.75rem;
  margin-top: 2.5rem;
}

.character-card {
  border: 1px solid rgba(140, 100, 50, 0.38);
  padding: 1.5rem 1.4rem;
  background: linear-gradient(135deg,
    rgba(248, 235, 195, 0.5) 0%,
    rgba(210, 172, 108, 0.2) 100%
  );
  position: relative;
  transition: all 0.22s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.character-card::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(140, 100, 50, 0.2);
  pointer-events: none;
}
.character-card:hover {
  background: linear-gradient(135deg,
    rgba(248, 235, 195, 0.75) 0%,
    rgba(210, 172, 108, 0.35) 100%
  );
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
  text-decoration: none;
  transform: translateY(-2px);
}

.char-sigil {
  font-size: 2.8rem;
  text-align: center;
  margin-bottom: 0.6rem;
  display: block;
  line-height: 1;
}
.char-name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  text-align: center;
  color: var(--ink);
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}
.char-class {
  font-family: var(--font-caps);
  font-size: 0.7rem;
  text-align: center;
  color: var(--ink-faded);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.char-excerpt {
  margin-top: 0.75rem;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-mid);
  line-height: 1.65;
  text-align: center;
  border-top: 1px solid rgba(140, 100, 50, 0.28);
  padding-top: 0.7rem;
}

/* === CHARACTER INDIVIDUAL PAGE === */
.char-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.char-header-sigil {
  font-size: 4.5rem;
  display: block;
  margin-bottom: 0.75rem;
  line-height: 1;
}
.char-header h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin-bottom: 0.3rem; }
.char-header .char-meta {
  font-family: var(--font-caps);
  letter-spacing: 0.22em;
  color: var(--ink-faded);
  font-size: 0.75rem;
}

.illuminated-box {
  border: 2px solid rgba(140, 100, 50, 0.45);
  padding: 2rem 2.5rem;
  position: relative;
  margin: 2rem 0;
}
.illuminated-box::before {
  content: '✦';
  position: absolute;
  top: -0.7rem; left: 50%;
  transform: translateX(-50%);
  background: var(--parchment-base);
  padding: 0 0.6rem;
  color: var(--gold-dark);
  font-size: 0.9rem;
}
.illuminated-box::after {
  content: '✦';
  position: absolute;
  bottom: -0.7rem; left: 50%;
  transform: translateX(-50%);
  background: var(--parchment-base);
  padding: 0 0.6rem;
  color: var(--gold-dark);
  font-size: 0.9rem;
}

.char-section {
  margin-bottom: 2.5rem;
}
.char-section h3 {
  font-size: 0.73rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-dark);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(140, 100, 50, 0.32);
}
.char-section p { font-size: 1.02rem; }

.traits-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.traits-list li {
  font-family: var(--font-caps);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 0.22rem 0.8rem;
  border: 1px solid rgba(140, 100, 50, 0.38);
  color: var(--ink-faded);
  background: rgba(210, 172, 108, 0.12);
}

/* === BREADCRUMB === */
.breadcrumb {
  font-family: var(--font-caps);
  font-size: 0.73rem;
  letter-spacing: 0.14em;
  color: var(--ink-faded);
  margin-bottom: 1.8rem;
}
.breadcrumb a            { color: var(--ink-faded); text-decoration: none; }
.breadcrumb a:hover      { color: var(--crimson); }
.breadcrumb .sep         { margin: 0 0.5rem; opacity: 0.45; }

/* === LOG INDEX PAGE === */
.log-header {
  text-align: center;
  padding: 1.5rem 0;
}

.log-entries {
  list-style: none;
  margin-top: 2rem;
}
.log-entry-item {
  padding: 1.3rem 0;
  border-bottom: 1px solid rgba(140, 100, 50, 0.22);
}
.log-entry-item:last-child { border-bottom: none; }

.entry-top {
  display: flex;
  gap: 1.8rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.entry-num {
  font-family: var(--font-caps);
  font-size: 0.73rem;
  letter-spacing: 0.12em;
  color: var(--gold-dark);
  opacity: 0.8;
  white-space: nowrap;
}
.entry-link {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--crimson);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.entry-link:hover { color: var(--crimson-dark); text-decoration: underline; }

.entry-excerpt {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-faded);
  margin-top: 0.3rem;
  line-height: 1.6;
  padding-left: calc(0.68rem + 1.8rem + 1rem);
}

/* === LOG ENTRY PAGE === */
.entry-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.entry-session {
  font-family: var(--font-caps);
  letter-spacing: 0.25em;
  color: var(--gold-dark);
  font-size: 0.72rem;
  display: block;
  margin-bottom: 0.5rem;
}
.entry-header h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.entry-dateline {
  font-family: var(--font-caps);
  letter-spacing: 0.18em;
  color: var(--ink-faded);
  font-size: 0.72rem;
  margin-top: 0.3rem;
  display: block;
}

.entry-content {
  margin: 2rem auto 0;
}
.entry-content p {
  font-family: 'IM Fell English', serif;
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
  text-align: justify;
  hyphens: auto;
}
/* Drop cap on first paragraph */
.entry-content .drop-cap::first-letter {
  font-family: var(--font-display);
  font-size: 4.2rem;
  float: left;
  line-height: 0.72;
  margin: 0.08em 0.1em 0 0;
  color: var(--ink);
}

.scene-break {
  text-align: center;
  color: var(--gold-dark);
  font-size: 0.9rem;
  letter-spacing: 0.6rem;
  margin: 2rem 0;
  opacity: 0.65;
}

.entry-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(140, 100, 50, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.entry-signature {
  font-style: italic;
  color: var(--ink-faded);
  font-size: 0.92rem;
}
.entry-nav-links {
  display: flex;
  gap: 1.5rem;
}
.entry-nav-links a {
  font-family: var(--font-caps);
  font-size: 0.73rem;
  letter-spacing: 0.14em;
  color: var(--ink-faded);
  text-decoration: none;
}
.entry-nav-links a:hover { color: var(--crimson); }

/* === SITE FOOTER === */
.site-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-family: var(--font-caps);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: rgba(200, 160, 90, 0.35);
}

/* === RESPONSIVE === */
@media (max-width: 720px) {
  :root {
    --page-pad: 2rem 1.5rem;
  }

  body {
    padding: 0 0 4rem;
  }

  /* Nav: stretch tabs to full width, tap-friendly targets */
  nav.tabs {
    padding-left: 0;
    width: 100%;
  }
  nav.tabs a {
    flex: 1;
    text-align: center;
    padding: 0.7rem 0.4rem;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }
  nav.tabs a:first-child { border-radius: 0; }

  /* Simpler shadow on mobile — big perf win */
  .page {
    filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.75));
    min-height: 100svh;
  }

  /* Character grid: single column */
  .character-grid { grid-template-columns: 1fr; }

  /* Illuminated box */
  .illuminated-box { padding: 1.5rem 1rem; }

  /* Smaller drop cap */
  .entry-content .drop-cap::first-letter {
    font-size: 3rem;
    line-height: 0.8;
  }

  /* Entry footer: stack vertically */
  .entry-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .entry-nav-links {
    width: 100%;
    justify-content: space-between;
  }

  /* Log index */
  .entry-excerpt { padding-left: 0; margin-top: 0.4rem; }
  .entry-top     { flex-direction: column; gap: 0.2rem; }

  /* Landing page */
  .landing-title { padding: 2rem 0 1.5rem; }
  .nav-buttons   { flex-direction: column; align-items: center; gap: 0.85rem; }
  .btn           { width: 100%; max-width: 260px; text-align: center; }

  /* Party roster label: shrink to fit */
  .party-roster::before {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
  }
  .party-roster { padding: 1.5rem 1rem; }

  /* Character meta on individual pages */
  .char-header .char-meta {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    line-height: 1.6;
  }

  /* Entry dateline: allow wrap */
  .entry-dateline {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    line-height: 1.7;
  }
}

@media (max-width: 400px) {
  :root { --page-pad: 1.75rem 1.1rem; }

  nav.tabs a { font-size: 0.55rem; padding: 0.65rem 0.25rem; }

  .char-section p  { font-size: 0.97rem; }
  .entry-content p { font-size: 0.97rem; }

  .entry-content .drop-cap::first-letter {
    font-size: 2.6rem;
  }
}
