
/* assets/css/granny.css  (v24)  */
/* --- Header & Nav --- */
body {
  margin: 0;
}

.site-header {
  position: relative;
  z-index: 1;
  background: #fff;
  padding: 4px 0;
  margin-top: 8px;
}

.hero {
  min-height: 360px;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.site-photo {
  height: 360px;
  width: auto;
  cursor: pointer;
}

.site-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(32px, 4vw, 60px);
  line-height: 1.1;
  color: #1f3f8f;
  margin: 0;
  cursor: pointer;
}


.nav-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: transparent;
  transition: background-color 0.3s ease;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 4px 16px;
  padding-right: 60px;
  box-sizing: border-box;
  width: 100%;
}

.nav-bar.scrolled {
  background: #fff;
}

.nav-bar .nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.nav-bar .filters {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.nav-title {
  display: none;
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
  color: #1f3f8f;
  white-space: nowrap;
  margin-left: 1rem;
  align-self: center;
  cursor: pointer;
}

.nav-status {
  display: none;
}

@media (min-width: 801px) {
  .nav-status {
    display: none !important;
  }
}

.searchbar .count {
  white-space: nowrap;
}

.info-button {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: #1f3f8f;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.info-button svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 20px;
  cursor: pointer;
}

.searchbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 800px) {
  .nav-bar {
    position: sticky;
    align-items: center;
    flex-wrap: wrap;
  }
  .nav-bar .nav-inner {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    background: #fff;
    padding: 8px 16px 12px;
    box-sizing: border-box;
  }
  .nav-bar.open .nav-inner {
    display: flex;
    border-bottom: 1px solid rgba(0,0,0,0.06);
  }
  .menu-toggle {
    display: block;
  }
  .searchbar {
    flex-wrap: wrap;
  }
  .searchbar input[type="search"] {
    flex: 1 0 100%;
  }
  .nav-status {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    padding: 0 16px;
    padding-right: 60px;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    box-sizing: border-box;
  }
  .nav-bar.has-filters:not(.open) .nav-status {
    display: flex;
  }
  .nav-bar.open .nav-status {
    display: none;
  }
}

.searchbar input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
}

.searchbar button,
button[data-action="clear"] {
  padding: 8px 10px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: background .15s ease;
}

button[data-action="clear"] {
  opacity: .5;
  pointer-events: none;
  cursor: default;
}

button[data-action="clear"].is-active {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

button[data-action="clear"].is-active:hover { background: #f1f5f9; }
button[data-action="clear"].is-active:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

button[data-action="random"],
button[data-action="share"] {
  padding: 4px 6px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: background .15s ease;
  font-size: 13px;
  color: #555;
}

button[data-action="share"] {
  font-size: .8rem;
  padding: 2px 6px;
}

button[data-action="random"]:hover,
button[data-action="share"]:hover { background: #f1f5f9; }
button[data-action="random"]:focus-visible,
button[data-action="share"]:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

/* Status banner for diagnostics */
#status-banner {
  font: 600 14px system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 24px 0 24px;
  background: #fee;
  color: #900;
  border: 1px solid #f5c2c7;
}
#status-banner[data-level="warn"] { background:#fff9e6; color:#7a5d00; border-color:#f3e2b0; }
#status-banner[data-level="info"] { background:#eef6ff; color:#0b5cab; border-color:#cfe2ff; }

#pup {
  position: absolute;
  z-index: 3000;
  padding: 5px;
  margin-left: 10px;
  margin-top: 5px;
  border: 2px solid #69c;
  background-color: #fff;
  color: #444;
  font-size: 0.9em;
  text-align: left;
  pointer-events: none;
  box-sizing: border-box;
  max-width: calc(100vw - 20px);
}

/* Basic layout safety (no-op if your existing styles already cover this) */
main { padding: 12px 24px; }

/* Filters and collapsible groups */
.filter-group { position: relative; align-self: start; display:inline-flex; align-items:center; gap:4px; }
.filter-header { text-align: left; padding: 10px 14px; font-weight: 700; background: #f8fafc; border: 1px solid rgba(0,0,0,0.1); border-radius: 12px; position: relative; cursor: pointer; }
.filter-header.is-active { background: #1f3f8f; color: #fff; border-color: #1f3f8f; }
.filter-group.is-open > .filter-header { box-shadow: 0 0 0 2px #93c5fd; }
.filter-group.is-open > .filter-header:not(.is-active) { background: #e8ecf8; border-color: #cfd8f6; }
.filter-body { display: none; position: absolute; top: 100%; left: 0; z-index: 1000; background: #fff; border: 1px solid rgba(0,0,0,0.1); border-top: 0; border-radius: 0 0 12px 12px; padding: 10px 12px 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.06); min-width: 200px; box-sizing: border-box; }
.filter-group.filter-topic .filter-body { width: 600px; }
.filter-group.is-open .filter-body { display: block; }

@media (max-width: 800px) {
  .filter-group.filter-topic .filter-body {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
  .filter-group.filter-type .filter-body,
  .filter-group.filter-story .filter-body {
    width: calc(100vw - 76px);
    max-width: calc(100vw - 76px);
  }
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 10px; border: 1px solid rgba(0,0,0,0.18); border-radius: 999px; background: #fff; font-size: 14px; cursor: pointer; user-select: none; }
.chip:hover { background: #f1f5f9; }
.chip.is-active { background: #1f3f8f; color: #fff; border-color: #1f3f8f; }
.chip.is-active[data-value="All"] { background: #e8ecf8; color: #1f3f8f; border-color: #cfd8f6; }
.chip:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.chip-divider { flex-basis: 100%; height: 0; border-top: 1px solid rgba(0,0,0,0.18); margin: 4px 0; }

#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; align-items: start; margin-top: 18px; }
.tile {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s ease, transform .05s ease;
  cursor: pointer;
}
.tile:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.08); transform: translateY(-1px); }
.tile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: .9rem;
  position: relative;
  overflow: hidden;
}

.tile-meta::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(to left, #fff, rgba(255,255,255,0));
}

@media (pointer: coarse) {
  .tile .tile-tag {
    display: none;
  }
}
.tile-tag {
  opacity: 0;
  transition: opacity .15s ease;
  font-size: .8rem;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 999px;
  padding: 2px 6px;
  background: #fff;
  color: #475569;
  display: inline-block;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.tile-tag:hover { background: #f1f5f9; }
.tile-tag:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.tile:hover .tile-tag,
.tile:focus .tile-tag { opacity: 1; }
.media-icon {
  width: 32px;
  height: 32px;
  aspect-ratio: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  flex: none;
}
.media-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
}
.media-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: background .15s ease;
  pointer-events: none;
  z-index: 0;
}
.media-icon:hover::before { background: #e2e8f0; }
.media-icon:focus-visible::before {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.tile-title { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.tile-sub { margin: 0; color: #475569; font-size: .92rem; }

.lightbox-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: 700;
  color: #1f3f8f;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 0;
}
.lightbox-cite {
  margin: 0 0 1rem;
  color: #475569;
  font-size: .92rem;
}
p.lightbox-extended {
  margin-top: 0;
}

.lightbox-extended .quote-match {
  font-weight: 700;
  color: #1f3f8f;
}

/* Lightbox overlay */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 2000; }
.lightbox.is-open { display: flex; }
.lightbox .dialog {
  background: #fff;
  border-radius: 12px;
  max-width: 800px;
  max-height: 90vh;
  padding: 12px 24px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.btn-close {
  position: sticky;
  /* Keep a 10px gap above the Close button regardless of scroll */
  top: -14px;
  align-self: flex-end;
  padding: 4px 8px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  z-index: 1;
}

.lightbox .tile-meta {
  margin-top: 1rem;
  overflow: visible;
  flex-wrap: wrap;
}
.lightbox .tile-meta::after { display: none; }
.lightbox .tile-tag { opacity: 1; }

.tooltip {
  position: fixed;
  background: #fff;
  color: #475569;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: .8rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10000;
}

/* Audio player */
.lightbox audio {
  width: 100%;
}
.lightbox audio::-webkit-media-controls-enclosure {
  overflow: hidden;
}
.lightbox audio::-webkit-media-controls-download-button,
.lightbox audio::-webkit-media-controls-playback-speed-button,
.lightbox audio::-webkit-media-controls-playback-rate-button {
  display: none;
}

/* Book iframe sizing */
.gbooks-viewer {
  width: 100%;
  height: 500px;
}
.gbooks-viewer.gbooks-error {
  height: auto;
  min-height: 0;
  padding: 10px 0;
}
/* Info lightbox */
.lightbox.info-lightbox .dialog {
  border-radius: 0;
  border: 2px solid #000;
}
.info-title { text-align: center; margin-top: 0; }
.info-images { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin: 20px 0; }
.info-images img { width: 250px; height: auto; }
.info-quote { font-style: italic; }
.info-attrib { display: block; font-style: italic; text-align: right; margin-right: 25%; }
.info-disclaimer { font-style: italic; font-size: 0.9rem; }
.info-disclaimer a,
.gbooks-link {
  color: #1f3f8f;
  text-decoration: underline;
  font-style: italic;
  font-size: 0.9rem;
}

/* PDF viewer */
.pdf-viewer {
  height: 500px;
  overflow-y: auto;
  border: 1px solid rgba(0,0,0,0.15);
}
.pdf-viewer canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

@media (pointer: fine) {
  .pdf-viewer {
    cursor: grab;
  }
  .pdf-viewer.dragging {
    cursor: grabbing;
  }
}

