/* ==== RIS Theme (portable) ========================================= */

/* --- Theme variables (override per page if you want different looks) */
:root {
  --page-bg: url('A_digital_image_of_an_aged_parchment_map_showcases.png');
  --content-bg-image: url('Leather.png');
  --content-bg-image-alt: url('Light_leather.png');
  --portrait-image: url('Transparent_normal_ced.png');

  --brand-brown-900: rgba(82, 60, 36, 0.95);
  --brand-brown-800: #5c4024;
  --brand-brown-700: #7a5c3e;
  --brand-gold-400: #ffe58f;
  --brand-gold-300: #ffcc66;
  --brand-gold-200: #ffd97b;

  --text-body: #3e2c1b;
  --text-invert: #fff;

  /* global spacing below the nav across pages */
  --nav-gap: 28px;
}

/* --- Page baseline -------------------------------------------------- */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Spectral', serif;
  background: #f8f1dc var(--page-bg) center center / cover no-repeat fixed;
  color: var(--text-body);
  padding: 0 0 80px 0; /* adds bottom padding for space */
}

/* --- Header / Nav --------------------------------------------------- */
header {
  background: var(--brand-brown-900);
  padding: 25px;
  text-align: center;
  border-bottom: 4px solid #b29a64;
}

h1, h2 { font-family: 'Cinzel', serif; }
h1 {
  font-size: 2.8em;
  margin: 0;
  color: var(--brand-gold-400);
  text-shadow: 2px 2px #000;
}
h2 {
  font-size: 1.5em;
  margin-top: 10px;
  color: #d4c98a;
  text-shadow: 1px 1px 2px #000;
  font-weight: normal;
}

/* Nav bar baseline */
nav {
  display: flex;
  justify-content: center;
  align-items: center;    /* vertically center buttons */
  flex-wrap: wrap;

  background: #6c4f30;    /* solid brown */
  border-bottom: 2px solid #a77d45;
  width: 100%;
  box-sizing: border-box;

  padding: 14px 20px;
  margin: 0 0 var(--nav-gap, 28px) 0;
}

/* Nav links styled as uniform pill buttons */
nav a {
  display: inline-flex;          /* ensures vertical centering */
  align-items: center;
  justify-content: center;

  padding: 10px 22px;            /* consistent button size */
  margin: 6px 10px;
  line-height: 1.2;

  background: #5c4024;           /* darker brown button */
  color: #fef3c0;                /* golden text */
  border: 1px solid #d0b375;
  border-radius: 999px;          /* pill shape */
  box-shadow: inset 0 0 4px rgba(255,255,255,0.05);

  font-weight: bold;
  text-decoration: none;
  transition: background 0.25s, transform 0.1s;
}

nav a:hover {
  background: #7b5b39;
  transform: translateY(-1px);
}

nav a:active {
  transform: translateY(0);
  background: #64432a;
}

nav a:hover { background: #7b5b39; }

@media (max-width: 600px) {
  nav { flex-direction: column; align-items: center; }
  nav a { margin: 8px 0; width: 80%; text-align: center; }
}

/* --- Layout --------------------------------------------------------- */
main {
  max-width: 900px;
  margin: 4rem auto;
  padding-bottom: 3rem; /* ensures space after the last content-box */
}
section { margin-bottom: 2rem; }
section p { margin: 0.6rem 0 1.2rem; line-height: 1.6; }

article h3, h3 {
  font-family: 'Cinzel', serif;
  color: #5a3e26;
  margin-top: 28px;
  font-size: 1.5em;
}

.inline-btn {
  display: inline-block;
  margin: 10px 10px;
  padding: 10px 20px;
  background: #725539;
  border: 1px solid #d1b07a;
  color: #fff9e6;
  border-radius: 6px;
  font-size: 16px;
  text-decoration: none;
  font-family: Georgia, serif;
  transition: background 0.2s;
}
.inline-btn:hover { background: #8b6a4b; }

footer.site-footer {
  background: rgba(70, 52, 30, 0.85);
  text-align: center;
  padding: 18px;
  color: #e3cfa4;
  font-size: 0.9em;
  border-top: 2px solid #a78c5b;
}

/* --- Content boxes (merged, centered) ------------------------------- */
.content-box {
  position: relative;
  background-color: rgba(242, 230, 201, 0.85);
  background-image: var(--content-bg-image);
  background-repeat: repeat;
  background-size: 400px;
  background-blend-mode: overlay;

  border: 2px solid #a48c61;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
  border-radius: 12px;

  max-width: 1000px;
  margin: 40px auto;  /* centers horizontally and adds vertical spacing */
  padding: 2rem;
}
.content-box.scroll-style {
  background-image: var(--content-bg-image-alt);
  background-size: 400px;
  background-repeat: repeat;
}
.content-paragraph {
  max-width: 700px;
  font-size: 1.05em;
  line-height: 1.6;
  margin-top: 1.2rem;
}

/* --- Dialogue block ------------------------------------------------- */
.dialogue-container {
  position: relative;
  width: 100%;
  margin-top: 2rem;
  background: var(--brand-brown-700);
  border: 4px solid var(--brand-gold-300);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 0 10px #000;
  box-sizing: border-box;
}
.portrait-box {
  position: absolute;
  top: 15px;
  left: 2px;
  width: 128px;
  height: 128px;
  background: #7a5c3e var(--portrait-image) center center / cover no-repeat;
  border: 3px solid var(--brand-gold-300);
  border-radius: 6px;
  box-shadow: 0 0 5px #000;
  animation: bouncePortrait 2.5s ease-in-out infinite;
}
.dialogue-name {
  position: absolute;
  top: -1.4em;
  left: 20px;
  background: var(--brand-brown-800);
  padding: 2px 10px;
  font-weight: bold;
  color: var(--brand-gold-400);
  border: 2px solid var(--brand-gold-300);
  border-radius: 6px;
  font-size: 1.1em;
}
.dialogue-text {
  color: var(--text-invert);
  min-height: 4em;
  font-size: 1.05em;
  line-height: 1.5em;
  font-family: 'Courier Prime', monospace;
  padding-top: 10px;
}
.padded-start { display: block; padding-left: 140px; }

@keyframes bouncePortrait { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }

@media (max-width: 600px) {
  .content-box { padding: 1.5rem 1rem; margin: 1.5rem 0.5rem; }
  .dialogue-text { padding-left: 10px; }
  .dialogue-text .padded-start { display: block; padding-left: 140px; }
  .inline-btn { width: auto; max-width: 90%; padding: 10px 16px; font-size: 1em; text-align: center; margin: 10px auto; }
  section h2, section h3 { font-size: 1.2em; }
  section p { font-size: 1em; line-height: 1.5; }
}

/* Typewriter / glow prompt */
.typewriter-text {
  display: inline-block;
  overflow: hidden;
  border-right: 2px solid #fff;
  white-space: nowrap;
  animation: typing 4s steps(50, end), blink 0.75s step-end infinite;
  max-width: 0;
}
@keyframes typing { from { max-width: 0; } to { max-width: 100%; } }
@keyframes blink { 50% { border-color: transparent; } }

@keyframes glowPulse {
  0%, 100% { text-shadow: 0 0 6px #ffde85, 0 0 10px #ffcc66; }
  50%      { text-shadow: 0 0 12px #ffd97b, 0 0 18px #ffb347; }
}
#tap-to-know {
  position: absolute;
  top: 10px;
  left: 150px;
  font-style: italic;
  font-family: 'Cinzel', serif;
  color: var(--brand-gold-400);
  font-size: 0.95em;
  cursor: pointer;
  animation: glowPulse 2.5s infinite ease-in-out;
  transition: transform 0.2s ease;
  z-index: 2;
}
#tap-to-know:hover { transform: scale(1.05); }

/* Utility */
.footer-note { margin-top: 3rem; text-align: center; }

/* =========================
   Codex Component Styles
========================= */

.codex-row {
  display: flex;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 20px;
}

.codex-box {
  /* per-tile background via CSS var, with your defaults preserved */
  --codex-bg: url('A_digital_image_of_an_aged_parchment_map_showcases.png');

  background-image: var(--codex-bg);
  background-size: cover;
  background-repeat: no-repeat;
  background-blend-mode: multiply;

  border: 2px solid #a68a64;
  border-radius: 12px;
  width: 280px;
  padding: 16px;
  box-sizing: border-box;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.codex-box:hover { transform: scale(1.03) rotate(-0.3deg); box-shadow: 0 0 12px #ffdd99; }

.codex-title {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 6px;
  color: #ffd700;
  text-shadow: 1px 1px 2px #000;
}

.codex-sub { font-size: 0.95em; color: #ffd88a; }

/* Smooth accordion for Codex details */
.codex-details {
  max-height: 0;            /* collapsed */
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  transition:
    max-height 0.35s ease,
    opacity 0.25s ease,
    padding 0.25s ease;
  font-size: 0.9em;
  margin-top: 10px;
  color: #f2e0b8;
}

/* Make each tile its own positioning context */
.codex-box { position: relative; overflow: hidden; }

/* Overlay details: no layout shift */
.codex-details {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  /* start collapsed */
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 12px;

  /* visual layer over the background image */
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);

  transition:
    max-height 0.35s ease,
    opacity 0.25s ease,
    padding 0.25s ease;

  font-size: 0.9em;
  color: #f2e0b8;
  margin-top: 0;
}

/* Expanded state keyed off aria-expanded (JS sets this) */
.codex-box[aria-expanded="true"] .codex-details {
  max-height: 220px;    /* how tall the overlay panel can open */
  opacity: 1;
  padding: 12px;        /* adds breathing room when open */
}

.read-more {
  display: inline-block;
  margin-top: 0.6em;
  color: #ffd68c;
  text-decoration: underline;
  font-weight: bold;
}
.read-more:hover { color: #fff0c2; }

@media (max-width: 600px) {
  .codex-box { width: 90%; display: block; margin: 10px auto; }

  /* Give each tile enough vertical room for the overlay */
  .codex-box { min-height: 260px; padding: 14px; }

  /* Let the overlay open a bit taller on small screens */
  .codex-box[aria-expanded="true"] .codex-details { max-height: 320px; }

  /* If the text runs long, scroll inside the overlay (not the page) */
  .codex-details {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Slightly larger tap targets */
  .codex-title { font-size: 1.15em; }
  .codex-sub   { font-size: 1.0em;  }

  /* Avoid hover “jump” on touch devices */
  .codex-box:hover { transform: none; box-shadow: none; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .codex-details { transition: none; }
  .codex-box:hover { transform: none; box-shadow: none; }
}

/* Backdrop blur fallback for browsers without support */
.codex-details {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.content-box.newspaper-style{
  --content-bg-image: url('newspaper.png');
  --content-bg-image-alt: url('newspaper.png');
  background-image:
    linear-gradient(rgba(252,247,236,0.92), rgba(252,247,236,0.92)),
    var(--content-bg-image-alt);
  background-repeat: no-repeat, repeat;
  background-size: auto, 360px;
  background-blend-mode: normal;
  border: 1px solid #b9a277;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.12);
  border-radius: 12px;
}
