/* ============================================================
   JOURNAL SHELF LAYOUT & STYLING
   CTR = green, DTR = blue, TTJ = red
   Dark overlays with color-shift hover and subtle zoom-in
   ============================================================ */

/* ===== BASE COLOR PALETTE ===== */
:root {
  --ctr-badge: #1ebc63;                    /* bright green */
  --ctr-overlay: rgba(18, 45, 28, 0.90);   /* deep forest */
  --ctr-overlay-hover: rgba(30, 80, 50, 0.90);

  --dtr-badge: #2a6cff;                    /* bright blue */
  --dtr-overlay: rgba(20, 30, 60, 0.90);   /* dark navy */
  --dtr-overlay-hover: rgba(35, 55, 110, 0.90);

  --ttj-badge: #ff3b3b;                    /* bright red */
  --ttj-overlay: rgba(60, 20, 20, 0.90);   /* dark maroon */
  --ttj-overlay-hover: rgba(100, 25, 25, 0.90);
}

/* ===== GENERAL PAGE LAYOUT ===== */
body {
  font-family: system-ui, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #222;
}

/* dark mode variant */
[data-theme="dark"] .sub-badge {
  background: #3d7aff;
}

/* Slight variation for dark theme */
[data-theme="dark"] .toolbar {
  background: #1a1a1a;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* Filters on the right */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters select {
  padding: 6px 8px;
  border-radius: 6px;
}

/* ===== SHELF GRID ===== */
.shelf {
  --thumb-min: 170px;
  --thumb-gap: 20px;
  display: block;
  padding: 20px;

  /* Repeating seamless wood pattern */
  /*
  background-image:
    url("/static/images/textures/light_wood.jpg"),
    linear-gradient(rgba(255,255,255,0.4), rgba(255,255,255,0.6));
  */
  background-blend-mode: lighten; /* keeps tone bright and soft */
}

/* ===== VOLUME CARD ===== */
.volume {
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease;
  padding: 10px;
  border: 0px solid #edcaa1; /* light oak plank divider */
  border-radius: 12px;
  position: relative;
  z-index: 1; /* ensure above any background overlay */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); /* mild shadow */
}

.volume:hover {
  transform: translateY(-4px);
  border-width: 0; /* makes hover smoother */
}

.cover {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  /* box-shadow: 0 2px 10px rgba(0,0,0,0.18); */
}

/* image zoom-in animation */
.cover img {
  width: 100%;
  display: block;
  transition: transform 0.35s ease;
}

.volume:hover .cover img {
  transform: scale(1.05);
}

/* ===== OVERLAY BAR ===== */
.overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0px;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background-color: rgba(0, 20, 0, 0.05);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.25s ease;
  flex-direction: column;
}

.j-toc {
  position: absolute;
  top: calc(50% - 40px);
  left: -2px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  height: 24px;
  padding: 4px 8px 4px 30px; /* space for the icon */
  border-radius: 0 5px 5px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.3px;
  background-color: var(--btn-info-bg);
  background-repeat: no-repeat;
  background-position: 6px center;
  background-size: 24px;
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'>\
  <rect x='3' y='5' width='3' height='3' rx='0.7'/>\
  <rect x='3' y='10.5' width='3' height='3' rx='0.7'/>\
  <rect x='3' y='16' width='3' height='3' rx='0.7'/>\
  <rect x='9' y='5' width='12' height='2.5' rx='1.25'/>\
  <rect x='9' y='10.5' width='12' height='2.5' rx='1.25'/>\
  <rect x='9' y='16' width='12' height='2.5' rx='1.25'/>\
</svg>");
}

.j-info {
  position: absolute;
  top: calc(50% + 0px);
  left: -2px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  height: 24px;
  padding: 4px 8px 4px 30px; /* room for icon */
  border-radius: 0 5px 5px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.3px;
  background-color: var(--btn-info-bg);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 24px;
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'>\
  <circle cx='12' cy='12' r='10' stroke='white' stroke-width='2' fill='none'/>\
  <rect x='11' y='10' width='2' height='8' rx='1' fill='white'/>\
  <rect x='11' y='6' width='2' height='2' rx='1' fill='white'/>\
</svg>");
}

.j-date {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 400;
  opacity: 0.9;
  letter-spacing: 0.3px;
  background-color: #000060; /* dark violet */
  color: #ffffff;
  padding: 4px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); /* slight shadow */
  border-radius: 5px;
}

.j-type {
	display: inline-block;
	background: rgba(255, 255, 255, 0.9);
	color: #002050;
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 0.75rem;
	font-weight: 600;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	margin-bottom: 4px;
}


.j-name {
  background-color: #4b0082; /* dark violet */
  color: #ffffff;
  width: auto;
  display: inline-block;
  text-align: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* ===== TOP-LEFT BADGE ===== */
.badge {
  position: absolute;
  top: calc(50% - 20px);
  left: -2px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  padding: 4px 8px;
  border-radius: 0 5px 5px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.3px;
  background-color: #000020;
}

/* ===== JOURNAL COLOR ASSIGNMENTS ===== */
/* CTR (green) */
.volume[data-journal="CTR"] .overlay {
  background: var(--ctr-overlay);
}

.volume[data-journal="CTR"]:hover .overlay {
  background: var(--ctr-overlay-hover);
}

.volume[data-journal="CTR"] .badge {
  background: var(--ctr-badge);
}

/* DTR (blue) */
.volume[data-journal="DTR"] .overlay {
  background: var(--dtr-overlay);
}

.volume[data-journal="DTR"]:hover .overlay {
  background: var(--dtr-overlay-hover);
}

.volume[data-journal="DTR"] .badge {
  background: var(--dtr-badge);
}

/* TTJ (red) */
.volume[data-journal="TTJ"] .overlay {
  background: var(--ttj-overlay);
}

.volume[data-journal="TTJ"]:hover .overlay {
  background: var(--ttj-overlay-hover);
}

.volume[data-journal="TTJ"] .badge {
  background: var(--ttj-badge);
}

/* ===== TOPIC COUNT META ===== */
.meta {
  display: flex;
  justify-content: center;
  padding: 6px 2px 0 2px;
  color: #555;
}

/* ============================================================
   TOPIC PANEL (slide-in, enhanced)
   ============================================================ */

.topic-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  background: #ffffff;
  border-left: 2px solid rgba(0, 0, 0, 0.08);
  transform: translateX(100%);
  transition: transform 0.35s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.topic-panel.visible {
  transform: translateX(0);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.12);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2a6cff;
  color: #fff;
  padding: 10px 12px;
  font-weight: 600;
}

.panel-header button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* individual topic entry */
.topic-row {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}

.topic-title {
  font-weight: 600;
  color: #2a6cff;
  text-decoration: none;
  margin-bottom: 2px;
}

.topic-title:hover {
  text-decoration: underline;
}

.topic-error {
  background-color: var(--error-bg, rgba(255, 0, 0, 0.12));
  color: var(--error-text, #c00);
}

.topic-tag {
  font-size: 11px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.topic-meta {
  font-size: 12px;
  color: #777;
  margin-top: 2px;
}

/* ===== TOPICS BUTTON IN VOLUME CARD ===== */
.topics-btn {
  background-color: #000080;
  color: #ffffff;
  border: none;
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
}

.topics-btn:hover {
  background-color: #003080;
  transform: translateY(-1px);
}

.topics-btn:active {
  transform: translateY(0);
  color: #142f8f;
}

/* ============================================================
   JOURNAL FILTER BUTTONS
   ============================================================ */

.journal-buttons {
  display: inline-flex;
  gap: 6px;
  margin-right: 16px;
}

.journal-btn {
  border: none;
  outline: none;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  color: #fff;
  transition: background 0.2s ease, transform 0.1s ease;
}

/* journal colors */
.journal-btn[data-journal="CTR"] {
  background: #1ebc63;
}

.journal-btn[data-journal="DTR"] {
  background: #2a6cff;
}

.journal-btn[data-journal="TTJ"] {
  background: #ff3b3b;
}

.journal-btn[data-journal=""] {
  background: #6b6b6b;
}

/* hover and active states */
.journal-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.journal-btn.active {
  box-shadow: 0 0 0 2px #00000022;
  transform: translateY(-1px);
}

.journal-btn:active {
  transform: translateY(0);
}

/* Search icon button in header */
.icon-button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  margin-left: 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.06);
}

.icon-search {
  width: 20px;
  height: 20px;
}

/* ==========================================================
   SEARCH BUTTON (uses app-theme variables)
   ========================================================== */

.btn-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-search svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

.icon-search {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

/* ===========================
   SEARCH PANEL
   =========================== */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.search-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ===========================
   SEARCH PANEL (LEFT SIDE)
   =========================== */
.search-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 460px;
  height: 100vh;
  background: #fafafa;
  border-right: 2px solid rgba(0, 0, 0, 0.08);
  box-shadow: none;
  z-index: 901;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.search-panel.visible {
  transform: translateX(0);
}

.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(to right, #ffffff, #f2f6ff);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.search-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.search-close {
  background: none;
  border: none;
  color: #555;
  font-size: 22px;
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 8px;
}

.search-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #000;
}

.search-body {
  padding: 14px 18px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-field label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.search-field input[type="text"] {
  padding: 7px 9px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  font-size: 13px;
}

.search-field input[type="text"]:focus {
  outline: none;
  border-color: #2a6cff;
  box-shadow: 0 0 0 1px rgba(42, 108, 255, 0.35);
}

.search-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.search-btn {
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #e8e8e8;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.search-btn.primary {
  background: #2a6cff;
  border-color: #2a6cff;
  color: #fff;
}

.search-btn:hover {
  filter: brightness(1.03);
}

/* ===========================
   SEARCH PANEL: QUERY PREVIEW
   =========================== */

.search-preview {
  background: #f7f9ff;
  border: 1px solid rgba(42, 108, 255, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: #1a1a1a;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.search-preview label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #2a3a7c;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.search-preview pre {
  margin: 0;
  font-size: 13px;
  color: #222;
  white-space: pre-wrap;
}

.search-results {
  margin-top: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 6px;
}

.result-item {
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--card, #fff);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.result-item:hover {
  background: var(--list-hover-bg, rgba(0, 0, 0, 0.05));
}

.result-item .title {
  font-weight: 600;
  font-size: 13px;
}

.result-item .meta {
  font-size: 11px;
  color: var(--muted, #666);
}

.admin-btn {
  border: none;
  cursor: pointer;
  margin-left: 4px;
  border-radius: 2px;
  background-color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  line-height: 0;
}

.admin-btn svg {
  display: block;
}

.admin-topic-row:hover {
  background: var(--hover-bg);
}

/* Make the admin panel wider than the regular topic panel */
#adminPanel {
  width: 520px; /* default topic panel is ~360px; this adds breathing room */
}

#adminPanel.visible {
  max-width: 520px;
}

/* Grid layout for admin-topic-row */
.admin-topic-row {
  display: grid;
  grid-template-columns: 40px 1.5fr 1fr 1fr; /* wider tag column */
  column-gap: 16px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.admin-topic-row .index {
  text-align: left;
  color: #888;
}

.admin-topic-row .tid {
  font-weight: 600;
  color: var(--text-color);
  word-break: break-word;
}

.admin-topic-row .pages,
.admin-topic-row .count {
  font-size: 0.9em;
  color: #666;
}

.panel-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.panel-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-color);
}

.panel-btn:hover {
  color: var(--color-accent);
}

/* ============================================================
   COVER / THUMB WRAPPER (double-image flip)
   ============================================================ */

.thumb-wrapper {
  position: relative;
  width: 100%;
  height: auto;
  display: block;
}

.thumb-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.25s ease-in-out;
}

/* Stack the two images */
.thumb-wrapper img.back {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}

/* Fade effect on hover */
.cover:hover .thumb-wrapper img.back {
  opacity: 1;
}

.cover:hover .thumb-wrapper img.front {
  opacity: 0;
}

/* ============================================================
   SHELF LAYOUT WITH SIDEBAR
   ============================================================ */

.shelf-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  padding: 20px;
}

.shelf-sidebar {
  position: sticky;
  top: 80px; /* adjust to clear your header height */
  height: fit-content;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .shelf-sidebar {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.sidebar-section {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-section label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
}

.sidebar-journals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Vertical radio buttons */
/* Wrap-style sort button list */
.btn-group-vertical {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Sort option button chip style */
.btn-radio {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #f4f4f4;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}

/* Hover */
.btn-radio:hover {
  background: #e8e8e8;
}

/* Active (selected) */
.btn-radio.active {
  background: #2a6cff;
  border-color: #2a6cff;
  color: #fff;
}

/* Dark mode adjustments */
[data-theme="dark"] .btn-radio {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.25);
  color: #ddd;
}

[data-theme="dark"] .btn-radio.active {
  background: #3d7aff;
  border-color: #3d7aff;
  color: #fff;
}

/* ============================================================
   DEFAULT SORT MODE LAYOUT FIX — SECTIONS STACK, CARDS STAY GRID
   ============================================================ */
   
.volume-section {
  width: 100%;
  margin-bottom: 32px;
  display: block;
}

/* The internal card grid */
.group-shelf {
	display: block;
  --thumb-min: 170px;
  --thumb-gap: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-min), 1fr));
  gap: var(--thumb-gap);
  padding: 20px 0;
}

/* Large mode support */
.large .group-shelf {
  --thumb-min: 230px;
  --thumb-gap: 24px;
}

.volume-section {
  width: 100%;
  margin-bottom: 28px;
  display: block;
}

.shelf.large .group-shelf,
.volume-section .group-shelf.large {
  --thumb-min: 230px;
  --thumb-gap: 24px;
}

/* Larger thumbnails */
.shelf.large {
  --thumb-min: 230px;
  --thumb-gap: 24px;
}

/* ============================================================
   YEAR / TIME FILTER BARS
   ============================================================ */

.year-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 20px;
}

.year-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: #e4e7ef;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.year-btn:hover {
  background: #d6dae5;
}

.year-btn.active {
  background: #2a6cff; /* matches default badge blue */
  color: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
  font-weight: 600;
}

.group-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: 0.3px;
  background-color: #aabbcc;
  color: #202040;
  text-align: center;
  text-transform: uppercase;
  border-radius: 5px;
}

/* Use the same layout as year bar */
.time-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 20px;
}

/* Make time buttons exactly like year buttons */
.time-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: #e4e7ef;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.time-btn:hover {
  background: #d6dae5;
}

.time-btn.active {
  background: #2a6cff;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}
