/* ========= Fantasy Field Guide — 5e-inspired parchment texture ========= */
/* Palette */
:root {
  color-scheme: light;                /* force light theme across devices */
  --paper: #f6f1e5;
  --paper-2: #f2ead7;
  --panel: #fffaf0;
  --ink: #312a1e;
  --ink-muted: #6b5e48;
  --line: #c9b79c;
  --accent: #7a0a0a;
  --gap: 12px;
  --radius: 10px;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font: 16px/1.6 'Crimson Text', ui-serif, Georgia, serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,.015) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.015) 0 2px, transparent 2px 4px),
    radial-gradient(1200px 600px at 10% -10%, rgba(0,0,0,.04), transparent 60%),
    radial-gradient(900px 500px at 120% 120%, rgba(0,0,0,.04), transparent 60%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #9b1111; text-decoration: underline; }
.muted { color: var(--ink-muted); font-size: 14px; }

/* ===== Header ===== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px 16px;
  border-bottom: 2px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0)),
    var(--paper);
}

header h1 {
  margin: 0;
  font: 700 26px/1 'Cinzel', serif;
  letter-spacing: .6px;
  color: var(--accent);
  text-transform: uppercase;
  padding-bottom: 4px;
}

.site-search input[type="search"] {
  padding: 6px 10px;
  min-width: 220px;
  font: 14px/1.2 'Crimson Text', serif;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fffdf6;
  border-radius: 6px;
}

/* Small headers */
@media (max-width: 560px) {
  header { flex-direction: column; align-items: stretch; gap: 8px; }
  .site-search input[type="search"] { min-width: 100%; }
}

/* ===== Top Nav ===== */
.topnav {
  position: relative;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf6, #f7f0de);
}

.topnav .nav-inner {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-family: 'Cinzel', serif;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  background: #f0e6cf;
  box-shadow: inset 0 0 0 1px #e4d7b6;
  text-decoration: none;
}

/* Mobile dropdown nav */
@media (max-width: 700px) {
  .topnav::before {
    content: "☰ Menu";
    display: block;
    padding: 10px 16px;
    font: 700 14px/1 'Cinzel', serif;
    color: var(--ink);
    background: linear-gradient(180deg, #fff7e5, #f0e6cf);
    border-bottom: 1px solid var(--line);
    border-radius: 6px 6px 0 0;
    box-shadow: inset 0 0 0 1px #e4d7b6;
    cursor: pointer;
  }

  .topnav .nav-inner {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    transition: max-height .28s ease;
    box-shadow: inset 0 0 0 1px #e4d7b6;
    border-radius: 0 0 8px 8px;
    background: #fffdf6;
  }

  .topnav:hover .nav-inner,
  .topnav:focus-within .nav-inner {
    max-height: 260px;
    padding: 8px 16px 12px;
  }

  .topnav a {
    display: block;
    padding: 10px 8px;
    border-top: 1px solid #e4d7b6;
    border-radius: 0;
    background: transparent;
  }
  .topnav a:first-child { border-top: 0; }

  .topnav a:hover,
  .topnav a[aria-current="page"] { background: #f0e6cf; box-shadow: none; }
}

/* ===== Layout ===== */
.main {
  display: grid;
  grid-template-columns: 220px 1fr 200px;  /* filters | content | ad */
  gap: var(--gap);
  padding: var(--gap);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03), 0 12px 20px rgba(0,0,0,.04);
}

/* ===== Filters ===== */
.filters {
  background: #f9f3e2;
  border: 1px solid #e3d4b5;
}

.filters h2 {
  margin: 0 0 8px 0;
  font: 700 18px/1 'Cinzel', serif;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  padding-bottom: 2px;
}

.filters label { display: block; margin: 4px 0; cursor: pointer; }
.filters input[type="checkbox"] { accent-color: var(--accent); }

/* On list pages, place search inside Filters and make it fit the column */
body:not(.index) header .site-search { display: none; }              /* hide header search */
body:not(.index) .filters .site-search { margin: 0 0 10px; }
body:not(.index) .filters .site-search input[type="search"] {
  width: 100%;
  min-width: 0;                                                        /* override global min-width */
  display: block;
}

/* ===== Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.card {
  background: #fffdf6;
  border: 1px solid #e4d7b6;
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.4),
    0 2px 6px rgba(0,0,0,.05);
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #d6c6a0;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.5),
    0 6px 12px rgba(0,0,0,.08);
}

.card h3 {
  margin: 0 0 8px 0;
  font: 700 16px/1.2 'Cinzel', serif;
  letter-spacing: .3px;
  color: #3b2a20;
  text-shadow: 0 1px 0 #fff;
}

.card a { display: block; }

.card img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #e4d7b6;
  border-radius: 12px;
  background: #fff;
}

/* ===== Home (newest trio) ===== */
.home-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
  text-align: center;
}

.home-col .card { margin: 0; }

@media (max-width: 900px) { .home-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .home-row { grid-template-columns: 1fr; } }

/* ===== Footer ===== */
footer {
  border-top: 2px solid var(--line);
  background: linear-gradient(180deg, #f3ebd7, #efe5ce);
  color: var(--ink);
  font-size: 14px;
  text-align: center;
  padding: 12px;
}

footer a { color: var(--ink); margin: 0 6px; }
footer a:hover { text-decoration: underline; }

/* ===== Mobile (≤900px): list pages stack, smaller cards, optional ad hide ===== */
@media (max-width: 900px) {
  *{
	text-align: center;
  }	  
	
  /* One-column stack for every page except the home page */
  body:not(.index) .main {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Reorder */
  body:not(.index) .main > aside.panel:not(.filters) { order: -2; }   /* ad first */
  body:not(.index) .main > aside.panel.filters   { order: -1; }       /* filters second */
  body:not(.index) .main > section.panel         { order: 0; }        /* content last */

  /* Smaller cards */
  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  /* If you need to hide a specific second ad block on mobile */
  #second-ad { display: none; }

  /* --- Filters collapse into a dropdown --- */
  body:not(.index) .filters h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    margin: 0 0 6px 0;
    background: linear-gradient(180deg, #fff7e5, #f0e6cf);
    border: 1px solid #e3d4b5;
    border-radius: 8px;
    cursor: pointer;
  }
  body:not(.index) .filters h2::after {
    content: "▾";
    font-weight: 700;
    line-height: 1;
    transform-origin: 50% 45%;
    transition: transform .25s ease;
  }

  /* Collapse everything after the heading by default */
  body:not(.index) .filters #filter-sections {
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease;
  }
  /* Fallback if #filter-sections not present — collapse any siblings after h2 */
  body:not(.index) .filters h2 ~ *:not(.site-search) {
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease;
  }

  /* Expand when interacting with the filters block */
  body:not(.index) .filters:focus-within #filter-sections,
  body:not(.index) .filters:hover #filter-sections,
  body:not(.index) .filters:focus-within h2 ~ *:not(.site-search),
  body:not(.index) .filters:hover h2 ~ *:not(.site-search) {
    max-height: 1000px;
  }
  body:not(.index) .filters:focus-within h2::after,
  body:not(.index) .filters:hover h2::after {
    transform: rotate(180deg);
  }

  /* Left-align everything inside the Filters panel on mobile */
  body:not(.index) .filters,
  body:not(.index) .filters .fbox,
  body:not(.index) .filters label { text-align: left; }

  /* Left-align each category heading like “Envs”, “Thing”, “Types” */
  body:not(.index) .filters strong {
    display: block;
    text-align: left;
    margin: 8px 0 4px;
  }
}

/* ===== Tablets: two columns for the home newest row ===== */
@media (min-width: 560px) and (max-width: 900px) {
  .home-row { grid-template-columns: repeat(2, 1fr); }
}
