/* ---------- Base / theme ---------- */
:root{
  --bg-img: url("/assets/bg.jpg"); /* <- set your stable background image here */
  --overlay: rgba(8, 10, 14, 0.72);

  --ink: #e8edf3;
  --muted: rgba(232,237,243,.75);
  --panel: rgba(18, 22, 30, 0.72);
  --panel-border: rgba(255,255,255,.08);

  --accent: #b08d57; /* warm “parchment/gold” accent */
  --accent2: #7aa2f7;

  --maxw: 980px;
  --sidebar-w: 260px;
  --gap: 22px;

  --topbar-h: 76px; /* keeps math simple */
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
}

/* ---------- Stable background image + overlay ---------- */
.bg{
  background: var(--bg-img) center / cover no-repeat fixed;
  position: relative;
}

body.bg {
  position: relative;
}

.bg::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,.55),
    rgba(0,0,0,.78)
  );
  pointer-events: none;
  z-index: 0;
}

.topbar,
.layout {
  position: relative;
  z-index: 1;
}

/* ---------- Top banner / header ---------- */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  backdrop-filter: blur(10px);
  background: rgba(10,12,16,.55);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.topbar__inner{
  height: 100%;
  max-width: calc(var(--maxw) + var(--sidebar-w) + var(--gap));
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand__title{
  font-size: 1.25rem;
  letter-spacing: .02em;
  font-weight: 700;
}
.brand__subtitle{
  font-size: .9rem;
  color: var(--muted);
}

/* ---------- Layout grid ---------- */
.layout{
  max-width: calc(var(--maxw) + var(--sidebar-w) + var(--gap));
  margin: 0 auto;
  padding: 18px 16px 36px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar{
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  align-self: start;
}

.nav{
  background: rgba(12, 14, 18, 0.62);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.nav__section + .nav__section{ margin-top: 14px; }
.nav__heading{
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(232,237,243,.65);
  margin: 6px 0 8px;
}

.nav__link{
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
}
.nav__link:hover{
  border-color: rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
}
.nav__link:focus{
  outline: 2px solid rgba(176,141,87,.55);
  outline-offset: 2px;
}

/* ---------- Main content panel ---------- */
.content{
  min-width: 0;
}

.panel{
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 1.5rem;
  border-radius: 12px;
}

.panel h1{
  margin: 0 0 10px;
  font-size: 1.8rem;
}
.panel h2{
  margin: 22px 0 8px;
  font-size: 1.2rem;
  color: rgba(232,237,243,.95);
}
.panel a{
  color: var(--accent2);
  text-decoration: none;
}
.panel a:hover{ text-decoration: underline; }

.footer{
  margin-top: 14px;
  padding: 10px 4px;
  color: rgba(232,237,243,.65);
  font-size: .9rem;
}


.panel .card--location img {
  height: auto;
  max-height: none;
  object-fit: contain;
}


/* ---------- Mobile navigation: CSS-only drawer ---------- */
/* checkbox is visually hidden but still works */
.nav-toggle{
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Hamburger button */
.nav-toggle-btn{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: none; /* desktop default */
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  cursor: pointer;
}
.nav-toggle-btn span,
.nav-toggle-btn span::before,
.nav-toggle-btn span::after{
  content:"";
  display:block;
  width: 22px;
  height: 2px;
  background: rgba(232,237,243,.92);
  position: relative;
  transition: transform .18s ease, opacity .18s ease, top .18s ease;
}
.nav-toggle-btn span::before{ position:absolute; top:-7px; }
.nav-toggle-btn span::after{ position:absolute; top: 7px; }

/* ---------- Responsive behavior ---------- */
@media (max-width: 860px){
  /* Stack layout (sidebar becomes drawer) */
  .layout{
    grid-template-columns: 1fr;
  }

  .sidebar{
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    height: calc(100dvh - var(--topbar-h));
    width: min(86vw, 320px);
    padding: 16px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 60;
  }

  /* a dark veil behind the drawer */
  .sidebar::before{
    content:"";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    z-index: -1;
  }

  /* show hamburger */
  .nav-toggle-btn{
    display: inline-flex;
  }

  /* when checked: slide in sidebar + show overlay */
  body:has(#nav-toggle:checked) .sidebar{
    transform: translateX(0);
  }
  .nav-toggle:checked ~ .layout .sidebar::before{
    opacity: 1;
    pointer-events: auto;
  }

  /* animate hamburger to X */
  .nav-toggle:checked ~ .nav-toggle-btn span{
    background: transparent;
  }
  .nav-toggle:checked ~ .nav-toggle-btn span::before{
    top: 0;
    transform: rotate(45deg);
  }
  .nav-toggle:checked ~ .nav-toggle-btn span::after{
    top: 0;
    transform: rotate(-45deg);
  }

  /* reduce padding on small screens */
  .panel{ padding: 18px; }
}

/* Optional: respect reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Shared card grids ---------- */

.grid {
  display: grid;
  gap: 18px;
}

/* Two-column grids (characters, sessions, locations, etc.) */
.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Single-column grids */
.grid--1 {
  grid-template-columns: 1fr;
}

/* Thumbnail cards (grids) */
.grid .card img {
  height: 180px;
  object-fit: cover;
}

/* Mobile: always stack */
@media (max-width: 700px) {
  .grid--2 {
    grid-template-columns: 1fr;
   }
}
/* ---------- Cards ---------- */

.card {
  display: grid;
  grid-template-rows: auto 1fr;
  text-decoration: none;
  /* color: white; */

  background: rgba(20, 24, 32, 0.6);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  overflow: hidden;

  transition: transform .15s ease, box-shadow .15s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}

.card-title {
  margin: 12px 14px;
  text-align: center;
  color: white;
  font-size: 1.1rem;
}

.card-title a,
.card-title a:visited {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}

.card-title a:hover,
.card-title a:focus {
  color: var(--accent2);
  text-decoration: underline;
}

.card-title-link {
  text-decoration: none;
}


/* hover/focus: turns blue */
.card-primary:hover,
.card-primary:focus {
  color: var(--ink);   /* or your link blue */
  text-decoration: underline;
}

.card-body {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 12px;
  padding: 0 14px 14px;
  align-items: center;
}

.card-body--2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 14px;
  align-items: start;
}

/* Images */
.card img {
  width: 100%;
/*   object-fit: cover; */
  display: block;
}

/* Text area */
.card-meta {
  padding: 0 14px;
}

.card-image {
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel .card-image img {
  height: auto;
  width: auto;
  object-fit: contain; /* <- show entire image */
}

.card-media {
/*  padding: 12px 14px; */
}

.card-meta h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.card-meta p {
  font-size: .9rem;
  /* color: rgba(232,237,243,.75); */
}

 .card--location {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
}

.card--location .card-body:not(.card-body--2x2) {
  grid-template-columns: 1fr; 
  align-items: start;
  padding-top: 12px;
  padding-bottom: 0;
}

.card--location .card-image {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  width: auto;
  object-fit: contain;
}

.card--location .card-meta {
  margin-top: -6px;
  margin-bottom: 14px;
}

.card--location .session-image {
  border-radius: 12px;
}


/* ---------- Mobile behavior ---------- */


@media (max-width: 900px) {
  .bg {
    background-attachment: scroll;
    background-repeat: repeat-y;
    background-size: contain;
  }
}


/* --- Card link behaviour (name + image clickable, inside-card links allowed) --- */

.card-primary {
  color: white;
  text-decoration: none;
}

.card-primary:hover {
  text-decoration: underline;
}

/* Make the image link not show an underline */
.card-image a {
  text-decoration: none;
  display: inline-block;
}

/* External links inside the card meta */
.card-linkout {
  color: var(--accent2);
  text-decoration: none;
}

.card-linkout:hover {
  text-decoration: underline;
}

/* Lightbox for clicking images */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
}

.lightbox:target {
  display: flex;
}

.lightbox-close {
  position: absolute;
  inset: 0;
}

/* Optional: give keyboard users a clear focus ring */
.card-primary:focus,
.card-linkout:focus {
  outline: 2px solid rgba(122,162,247,.7);
  outline-offset: 2px;
  border-radius: 6px;
}


.session-image{
  width: 100%;
  aspect-ratio: 16 / 9;   /* pick 4/3 if you prefer */
  overflow: hidden;
  border-radius: 12px;
/*  background: rgba(255,255,255,.06); */
}

.session-image img{
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.session-title {
  margin: 10px 14px 6px;
  text-align: center;
  color: white;
  font-size: 1.1rem;
}

.session-title a,
.session-title a:visited {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}

.session-title a:hover,
.session-title a:focus {
  color: var(--accent2); /* or your blue variable */
  text-decoration: underline;
}

.session-title-link {
  text-decoration: none;
}
.session-meta {
  padding: 0;
  margin: 0 14px 14px;
/*  background: rgba(255, 0, 0, 0.15); */
}

/* ---------- Character page ---------- */

.character {
  display: grid;
  grid-template-columns: 30% 1fr;
  grid-template-rows: auto auto;
  column-gap: 24px;
  row-gap: 8px;
  align-items: start;
}

/* Character name above portrait */
.character-name {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  text-align: center;
}

/* Left column wrapper (portrait + stats) */
.character-left {
  grid-column: 1;
  grid-row: 2;

  display: flex;
  flex-direction: column;
  gap: 24px;

  min-width: 0; /* prevents grid overflow into column 2 */
}

/* Portrait */
.character-portrait {
  width: 100%;
  aspect-ratio: 1 / 1;
}

.character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.2);
}

/* Attribute stat grid */
.stat-block{
  padding: 12px;
  background: rgba(255,255,255,.03);
  border-radius: 12px;

  display: grid;
  grid-template-columns: 4em 3.5em 3.5em; /* label | score | mod */
  column-gap: 12px;
  row-gap: 8px;

  align-items: center;
  font-variant-numeric: tabular-nums; /* nicer number alignment */
}

.stat-row{ display: contents; } /* let the spans participate in the parent grid */

.stat-name{
  justify-self: start;
  letter-spacing: .08em;
  line-height: 1.2;
}

.stat-score{
  justify-self: center;
  font-weight: 600;
  opacity: .75;
  line-height: 1.2;
}

.stat-mod{
  justify-self: end;
  opacity: .75;
  line-height: 1.2;
}

.stat-row.stat-header .stat-name {
  grid-column: 1 / -1;      /* span all columns */
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: .65;
}

.stat-row.stat-header .stat-score,
.stat-row.stat-header .stat-mod {
  display: none;
}

/* Character sheet */
.character-sheet {
  grid-column: 2;
  grid-row: 2;

  border-collapse: collapse;
}

.character-sheet th,
.character-sheet td {
  padding: 6px 10px;
  vertical-align: top;

  background: rgba(255,255,255,.03);
}

.character-sheet th {
  text-align: left;
  font-weight: 600;
  color: rgba(232,237,243,.9);
  white-space: nowrap;
}

.character-sheet td {
  color: rgba(232,237,243,.75);
}

/* Subtle separators instead of striping */
.character-sheet tr + tr th,
.character-sheet tr + tr td {
  border-top: 1px solid rgba(255,255,255,.06);
}

/* Skills readability */
.skill-list {
  line-height: 1.45;
}

.skill-block {
  display: grid;
  grid-template-columns: 1fr 3em 2.5em;
  row-gap: 6px;
  column-gap: 12px;

  font-variant-numeric: tabular-nums;
}

.skill-row {
  display: contents;
}

/* Skill name */
.skill-row span:nth-child(1) {
  justify-self: start;
}

.skill-row span:nth-child(2) {
  justify-self: end;
}

.skill-row span:nth-child(3) {
  justify-self: start;
  align-self: center;
}

.skill-legend {
  margin-top: 6px;
  font-size: .75rem;
  opacity: .6;
}

.prof-dots {
  font-size: .7rem;
  letter-spacing: 2px;
  line-height: 1;
  opacity: .65;
  white-space: nowrap;
}

/* Proficient (●) */
.skill-row.proficient .prof-dots {
  opacity: .7;
}

/* Expertise (●●) */
.skill-row.expertise .prof-dots {
  opacity: .95;
}

/* Jack of All Trades (◐) */
.skill-row.jack .prof-dots {
  opacity: .5;
}

.skill-row .prof-dots::after {
  content: attr(data-title);
  display: none;
}

.skill-row:hover .prof-dots::after {
  display: inline;
}

/* ---------- Saving Throws ---------- */

.save-block {
  padding: 12px;
  background: rgba(255,255,255,.03);
  border-radius: 12px;

  display: grid;
  grid-template-columns: 4em 3.5em 3.5em; /* ✅ same as stat-block */
  column-gap: 12px;
  row-gap: 8px;                          /* ✅ same as stat-block */

  align-items: center;
  font-variant-numeric: tabular-nums;
}

.save-row {
  display: contents;
}

.save-row { display: contents; }

.save-name {
  justify-self: start;
  letter-spacing: .08em;
  line-height: 1.2;
}

.save-bonus {
  justify-self: center;
  font-weight: 600;
  opacity: .75;
  line-height: 1.2;
}

.save-prof {
  justify-self: end;
  opacity: .75;
  align-self: center;
}

.save-row.save-header .save-name {
  grid-column: 1 / -1;      /* span all columns */
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: .65;
}

.save-row.save-header .save-bonus,
.save-row.save-header .save-prof {
  display: none;
}

/* Mobile layout */
@media (max-width: 700px) {
  .character {
    grid-template-columns: 1fr;
  }

  .character-name,
  .character-left,
  .character-sheet {
    grid-column: 1;
    grid-row: auto;
  }

  .character-name {
    text-align: center;
  }

  .character-portrait {
    max-width: 320px;
    margin: 0 auto;
  }
}

/* Mobile */
@media (max-width: 700px) {
  .character {
    grid-template-columns: 1fr;
  }

  .character-portrait img {
    width: 100%;
    max-width: 280px;
    margin-bottom: 10px;
  }
}
