/*
 * Public surface theme — research-books.com brand.
 * Loaded AFTER app.css and ONLY on public_base.html, so the internal staff
 * app (which never loads this file) keeps its existing look.
 *
 * Tricolor system: warm cream backgrounds; navy for structure/authority;
 * coral (#e06656) as the accent; teal (#509ab6) as the interactive/link color.
 * Headings PT Serif; body/UI Josefin Sans. No top bar — the navy rail runs
 * top-to-bottom and carries the brand (top) + staff/links (bottom).
 */
:root {
  --bg: #fff0e1;        /* warm cream */
  --ink: #0b1640;       /* deep navy */
  --navy-mid: #1e4d7f;  /* medium navy */
  --teal: #509ab6;      /* interactive / links */
  --accent: #e06656;    /* coral — accent/alert */
  --muted: #58595b;     /* body gray */
  --line: #d9c9b8;      /* warm hairline */
  --warm: #fff7f0;      /* light text on dark */
  --tan: #e8dcd0;       /* table stripe */
}

body.public-site {
  background: var(--bg);
  color: var(--muted);
  font-family: "Josefin Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---- App shell: navy rail (left) + cream content, no top bar ---- */
.shell { display: flex; align-items: stretch; min-height: 100vh; }

.app-sidebar {
  flex: none; width: 255px;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0b1640 0%, #1e4d7f 100%);
}
main.app-main {
  flex: 1; min-width: 0; max-width: none; margin: 0;
  background: var(--bg); padding: 2rem 2.5rem;
}

/* Brand + search + footer that live in the rail (replacing the old top bar) */
.rail-brand {
  display: block; padding: 1.2rem 1.1rem 0.6rem;
  font-family: "PT Serif", Georgia, serif; font-weight: 700; font-size: 1.2rem;
  line-height: 1.15; color: var(--warm);
}
.rail-brand small { display: block; margin-top: 0.2rem; font-size: 0.68rem; font-weight: 400; font-family: "Josefin Sans", sans-serif; opacity: 0.7; }
.rail-search { padding: 0 1.1rem 0.6rem; }
.rail-search input {
  width: 100%; padding: 0.45rem 0.6rem; font: inherit; border-radius: 6px;
  background: rgba(255, 247, 240, 0.1); border: 1px solid rgba(255, 247, 240, 0.22); color: var(--warm);
}
.rail-search input::placeholder { color: rgba(255, 247, 240, 0.55); }
.rail-foot {
  margin-top: auto; display: flex; flex-direction: column; gap: 0.35rem;
  padding: 1rem 1.1rem 1.25rem; border-top: 1px solid rgba(255, 247, 240, 0.16);
  font-size: 0.85rem;
}

/* ---- Links: content area teal/navy; sidebar warm-on-navy ---- */
.app-main a { color: var(--navy-mid); }
.app-main a:hover { color: var(--teal); }
.app-sidebar a { color: var(--warm); }
.app-sidebar a:hover { color: var(--teal); text-decoration: none; }
.app-sidebar .rail-foot a { color: rgba(255, 247, 240, 0.8); }

.btn { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--warm); color: var(--ink); border-color: var(--line); }

/* ---- Heading treatments ---- */
/* Page title: dark navy serif on cream, centered (Repro Files style) */
.app-main h1 {
  font-family: "PT Serif", Georgia, serif; text-transform: uppercase;
  color: var(--ink); text-align: center; letter-spacing: 0.01em;
  /* auto (not 0) so a max-width'd h1 — e.g. the hero title — stays centered */
  margin: 0 auto 1.25rem; background: none; box-shadow: none; padding: 0;
}
/* Section headers: compact coral banners */
.app-main h2, .app-main section > h2 {
  font-family: "PT Serif", Georgia, serif; color: var(--warm);
  background: var(--accent); display: inline-block; border-bottom: 0;
  padding: 0.25rem 0.85rem; border-radius: 6px; letter-spacing: 0.01em;
}
.app-main h3 {
  font-family: "Josefin Sans", sans-serif; color: var(--navy-mid);
  text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 2px solid var(--accent); padding-bottom: 0.2rem;
}
.app-main hr { height: 3px; border: 0; background: linear-gradient(90deg, var(--accent), var(--teal)); }
.app-main .subject-meta { text-align: center; margin: 0.25rem 0; }

/* ---- Subject page: search-lite + faceted browse ---- */
.record-search { display: flex; gap: 0.5rem; max-width: 560px; margin: 1rem auto 1.5rem; }
.record-search input { flex: 1; }
.see-all { font-weight: 600; }

.facets-panel { display: flex; flex-direction: column; gap: 0.55rem; }
.facet-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.facet-label {
  flex: none; width: 46px; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.85rem;
  background: var(--tan); color: var(--ink); border: 1px solid transparent;
}
.app-main .chip:hover { border-color: var(--teal); text-decoration: none; }
.app-main .chip.is-active { background: var(--navy-mid); color: var(--warm); }
.chip .chip-n { font-size: 0.72rem; opacity: 0.65; }

.browse-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.5rem; margin: 1.1rem 0 0.5rem;
}
.browse-head .sort a { margin-left: 0.5rem; }
.browse-head .sort a.is-active { font-weight: 700; }
.pager { display: flex; gap: 1.25rem; align-items: center; justify-content: center; margin: 1.25rem 0; }

/* ---- Cards & tables ---- */
.app-main .card { background: var(--warm); border-color: var(--line); }
.app-main th { background: var(--ink); color: var(--warm); }
.app-main tbody tr:nth-child(even) { background: rgba(232, 220, 208, 0.45); }
.app-main td, .app-main th { border-bottom-color: var(--line); }

/* Subject/official cards: navy gradient tiles that lift on hover */
.app-main .subject-card {
  background: linear-gradient(135deg, #0b1640 0%, #1e4d7f 100%);
  color: var(--warm); border: 0;
  box-shadow: 0 4px 14px rgba(11, 22, 64, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.app-main .subject-card:hover { transform: translateY(-4px); box-shadow: 0 12px 26px rgba(11, 22, 64, 0.30); }
.app-main .subject-card .subject-name { font-family: "PT Serif", Georgia, serif; text-transform: uppercase; color: var(--warm); }
.app-main .subject-card .muted { color: rgba(255, 247, 240, 0.7); }
.app-main .subject-card .badge { background: rgba(255, 247, 240, 0.16); color: var(--warm); }

/* Tag/entity facet badges as links */
.app-main .facets .badge { background: var(--tan); color: var(--ink); }
.app-main .facets a.badge:hover { background: var(--teal); color: var(--warm); text-decoration: none; }

/* ---- Hero (home) ---- */
.hero { background: linear-gradient(180deg, #fffaf4 0%, var(--bg) 100%); border-color: var(--line); }
.hero-logo { display: inline-block; margin-bottom: 0.9rem; }
.hero-logo img { display: block; width: 132px; height: auto; }
.hero-title { font-family: "PT Serif", Georgia, serif; text-transform: uppercase; color: var(--ink); }
.hero-sub, .hero-stats { color: var(--muted); }

/* ---- Sidebar nav internals on the navy rail ---- */
.app-sidebar .sidebar-nav { background: transparent; border: 0; color: var(--warm); padding: 0.4rem 1.1rem 1rem; }
.app-sidebar .sidebar-home { color: var(--warm); border-bottom-color: rgba(255, 247, 240, 0.18); }
.app-sidebar .sidebar-home.is-current { color: var(--teal); }
.app-sidebar .sidebar-context { border-bottom-color: rgba(255, 247, 240, 0.18); }
.app-sidebar .sidebar-context-name { color: var(--warm); }
.app-sidebar .muted { color: rgba(255, 247, 240, 0.6); }
.app-sidebar .sidebar-section h3 { color: var(--teal); border-bottom: 0; padding: 0; font-family: "Josefin Sans", sans-serif; }
.app-sidebar .sidebar-list .badge { background: rgba(255, 247, 240, 0.16); color: var(--warm); }
.app-sidebar .sidebar-more summary { color: rgba(255, 247, 240, 0.7); }
.app-sidebar .sidebar-more summary:hover { color: var(--teal); }
.app-sidebar .sidebar-all { color: var(--teal); }

/* ---- Mobile bar + drawer chrome (hidden on desktop) ---- */
.mobile-bar { display: none; }
.drawer-backdrop { display: none; }
.hamburger {
  background: none; border: 0; color: var(--warm); cursor: pointer;
  font-size: 1.5rem; line-height: 1; padding: 0.2rem 0.4rem; border-radius: 6px;
}
.hamburger:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
/* .mobile-bar prefix outranks the generic `.app-main a` link color */
.mobile-bar .mobile-brand {
  font-family: "PT Serif", Georgia, serif; font-weight: 700; font-size: 1.05rem;
  color: var(--warm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mobile-bar .mobile-brand:hover { color: var(--warm); }

/* ---- Responsive: rail becomes an off-canvas drawer ---- */
@media (max-width: 820px) {
  .mobile-bar {
    display: flex; align-items: center; gap: 0.75rem;
    position: sticky; top: 0; z-index: 30;
    background: var(--ink); padding: 0.55rem 0.9rem;
    margin: -2rem -1.25rem 1.25rem;  /* bleed across the app-main padding (mobile = 1.25rem) */
  }
  main.app-main { padding: 2rem 1.25rem; }

  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 84vw; z-index: 50; overflow-y: auto;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 2px 0 22px rgba(0, 0, 0, 0.35);
  }
  body.drawer-open { overflow: hidden; }
  body.drawer-open .app-sidebar { transform: translateX(0); }
  body.drawer-open .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(11, 22, 64, 0.55);
  }
}

/* --- Search box: ? operator help + advanced panel (public only) --- */
.searchwrap .searchbar { width: 100%; }

/* Homepage hero: search row + advanced panel share one centered column. */
.hero-form { max-width: 640px; margin: 0 auto 0.75rem; }
.hero-form .hero-search { max-width: none; margin: 0 0 0.5rem; }
.hero-form .adv-search { text-align: left; }

/* Sidebar advanced-search link (the grid is too wide for the rail). */
.rail-advanced { display: block; padding: 0 1.1rem 0.7rem; font-size: 0.82rem; }

.op-help { position: relative; }
.op-help > summary {
  list-style: none; cursor: pointer; user-select: none;
  width: 2rem; height: 2rem; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 700;
  background: var(--tan); color: var(--ink); border: 1px solid var(--line);
}
.op-help > summary::-webkit-details-marker { display: none; }
.op-help[open] > summary { background: var(--teal); color: var(--warm); }
.op-help-panel {
  position: absolute; right: 0; top: 2.5rem; z-index: 45;
  width: min(440px, 86vw); padding: 0.85rem 1rem;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(11, 22, 64, 0.18);
}
.op-help-panel ul { margin: 0.45rem 0 0; padding-left: 1.1rem; }
.op-help-panel li { margin: 0.3rem 0; line-height: 1.45; }
.op-help-panel code {
  background: var(--tan); color: var(--ink);
  padding: 0 0.25rem; border-radius: 4px;
}

.adv-search { margin-top: 0.85rem; }
.adv-search > summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.adv-hint { font-size: 0.82rem; color: var(--muted); margin: 0.6rem 0 0.2rem; }
.adv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem 1rem; margin: 0.7rem 0 0.9rem;
}
.adv-grid label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.82rem; color: var(--muted);
}
.adv-grid input, .adv-grid select { width: 100%; }
.adv-actions { display: flex; gap: 0.6rem; align-items: center; }
