/* ============================================================
   BlinkOrigin — light green & black, Japanese minimalist theme.
   Square corners everywhere; thin rules; generous whitespace.
   Bootstrap is themed by overriding its per-component variables.
   ============================================================ */

:root {
  --bo-ink:        #111411;   /* near-black */
  --bo-ink-soft:   #3a403a;
  --bo-muted:      #6b746b;
  --bo-green:      #9fd6ae;   /* light green — the brand accent */
  --bo-green-wash: #eef7f0;   /* pale wash for surfaces */
  --bo-green-deep: #467a57;   /* readable green for text/links */
  --bo-line:       #dde5dd;   /* hairline rules */
  --bo-paper:      #fcfdfc;   /* page background */
  --bo-surface:    #ffffff;   /* cards / panels */
  --bo-surface-2:  #f0f3f0;   /* thumbnail wells */
  --bo-footer-bg:  var(--bo-ink);
  --bo-font-sans:  'Zen Kaku Gothic New', 'Segoe UI', system-ui, sans-serif;
  --bo-font-disp:  'Shippori Mincho', 'Yu Mincho', serif;

  --bs-body-bg: var(--bo-paper);
  --bs-body-color: var(--bo-ink);
  --bs-body-font-family: var(--bo-font-sans);
  --bs-border-color: var(--bo-line);
  --bs-link-color-rgb: 70, 122, 87;
  --bs-link-hover-color-rgb: 17, 20, 17;
}

/* ---- Night mode: the dark/light roles reversed, green accent kept ----
   Activated by data-bo-theme="night" on <html> (an admin Site setting);
   data-bs-theme="dark" flips Bootstrap's own form/dropdown/table palette. */
html[data-bo-theme="night"] {
  --bo-ink:        #e9efe9;   /* text is now light */
  --bo-ink-soft:   #c4cdc4;
  --bo-muted:      #8ea08e;
  --bo-green:      #9fd6ae;
  --bo-green-wash: #16211a;   /* dark green tint */
  --bo-green-deep: #82c795;   /* brightened for contrast on dark */
  --bo-line:       #2b332b;
  --bo-paper:      #101410;   /* page background is now near-black */
  --bo-surface:    #171d17;
  --bo-surface-2:  #1e251e;
  --bo-footer-bg:  #0b0e0b;   /* footer stays dark in both modes */
  --bs-link-color-rgb: 130, 199, 149;
  --bs-link-hover-color-rgb: 233, 239, 233;
}
/* (The Kanji mark is inline SVG with fill: currentColor — no inversion needed.) */
html[data-bo-theme="night"] .bo-credit-badge.low { background: #33240f; border-color: #7a5a2e; color: #eac88f; }
html[data-bo-theme="night"] .bo-navbar .dropdown-menu { box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }

/* ---- base ---- */
body { font-family: var(--bo-font-sans); background: var(--bo-paper); color: var(--bo-ink); }

/* Sticky footer: the content area stretches so the footer never floats up on
   short pages (contact, auth) — it sits at the bottom of the window or below. */
body { display: flex; flex-direction: column; min-height: 100vh; }
body > main { flex: 1 0 auto; }        /* top-navbar mode */
body > .bo-shell { flex: 1 0 auto; }   /* left-navigation mode */
h1, h2, h3, .bo-display { font-family: var(--bo-font-disp); font-weight: 600; letter-spacing: .01em; }
h4, h5, h6 { font-family: var(--bo-font-sans); font-weight: 700; }
a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-muted { color: var(--bo-muted) !important; }

/* Square corners — no curves anywhere, per the design brief. */
.btn, .card, .form-control, .form-select, .dropdown-menu, .alert, .badge,
.modal-content, .toast, .list-group, .list-group-item, .accordion,
.accordion-item, .accordion-button, .input-group-text, .pagination .page-link,
img, .bo-pill { border-radius: 0 !important; }

/* ---- buttons ---- */
.btn-primary {
  --bs-btn-bg: var(--bo-ink);
  --bs-btn-border-color: var(--bo-ink);
  --bs-btn-color: var(--bo-paper);
  --bs-btn-hover-bg: var(--bo-green-deep);
  --bs-btn-hover-border-color: var(--bo-green-deep);
  --bs-btn-hover-color: var(--bo-paper);
  --bs-btn-active-bg: var(--bo-green-deep);
  --bs-btn-active-border-color: var(--bo-green-deep);
  --bs-btn-active-color: var(--bo-paper);
}
.btn-outline-primary {
  --bs-btn-color: var(--bo-ink);
  --bs-btn-border-color: var(--bo-ink);
  --bs-btn-hover-bg: var(--bo-ink);
  --bs-btn-hover-border-color: var(--bo-ink);
  --bs-btn-hover-color: var(--bo-paper);
  --bs-btn-active-bg: var(--bo-ink);
  --bs-btn-active-border-color: var(--bo-ink);
  --bs-btn-active-color: var(--bo-paper);
}
.btn-success {
  --bs-btn-bg: var(--bo-green-deep);
  --bs-btn-border-color: var(--bo-green-deep);
  --bs-btn-hover-bg: var(--bo-ink);
  --bs-btn-hover-border-color: var(--bo-ink);
}

/* ---- navbar (top mode) ---- */
.bo-navbar {
  background: var(--bo-paper);
  border-bottom: 1px solid var(--bo-line);
}
.bo-navbar .navbar-brand { display: flex; align-items: center; gap: .65rem; }
.bo-brand-word {
  font-family: var(--bo-font-disp); font-size: 1.35rem; font-weight: 600;
  color: var(--bo-ink); letter-spacing: .04em;
}
.bo-brand-word .bo-brand-accent { color: var(--bo-green-deep); }
.bo-navbar .nav-link { color: var(--bo-ink-soft); font-weight: 500; }
.bo-navbar .nav-link:hover, .bo-navbar .nav-link.active { color: var(--bo-ink); }
.bo-navbar .dropdown-menu { border: 1px solid var(--bo-line); box-shadow: 0 8px 24px rgba(17,20,17,.06); }

/* ---- left navigation (left mode) ---- */
.bo-shell { display: flex; min-height: calc(100vh - 0px); }
.bo-sidenav {
  width: 240px; flex: 0 0 240px;
  border-right: 1px solid var(--bo-line);
  background: var(--bo-green-wash);
  padding: 1.5rem 1rem;
}
.bo-sidenav .nav-link {
  color: var(--bo-ink-soft); padding: .45rem .75rem; font-weight: 500;
  border-left: 2px solid transparent;
}
.bo-sidenav .nav-link:hover { color: var(--bo-ink); text-decoration: none; }
.bo-sidenav .nav-link.active {
  color: var(--bo-ink); border-left-color: var(--bo-green-deep); background: var(--bo-surface);
}
.bo-sidenav .bo-side-heading {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--bo-muted); margin: 1.25rem .75rem .35rem;
}
.bo-main { flex: 1 1 auto; min-width: 0; }
@media (max-width: 767.98px) {
  .bo-shell { display: block; }
  .bo-sidenav { width: auto; border-right: 0; border-bottom: 1px solid var(--bo-line); }
}

/* ---- hero ---- */
.bo-hero { padding: 4.5rem 0 3.5rem; border-bottom: 1px solid var(--bo-line); background:
  linear-gradient(180deg, var(--bo-green-wash) 0%, var(--bo-paper) 100%); }
.bo-hero h1 { font-size: clamp(1.9rem, 4vw, 3rem); }
.bo-hero .bo-kanji { opacity: .92; }

/* ---- photo grid (lightbox layout) ---- */
.bo-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(var(--bo-thumb-w, 240px), 1fr));
}
.bo-thumb {
  position: relative; display: block; overflow: hidden;
  background: var(--bo-surface-2); border: 1px solid var(--bo-line);
}
.bo-thumb img { width: 100%; height: var(--bo-thumb-h, 240px); object-fit: cover; display: block; }
.bo-thumb:hover img { opacity: .92; }

/* ---- basket + button (thumbnails & lightbox) ---- */
.bo-basket-add {
  position: absolute; top: 0; right: 0; z-index: 2;
  width: 30px; height: 30px; line-height: 1;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(17, 20, 17, .72); color: #fff;
  font-size: 1.15rem; font-weight: 700; cursor: pointer;
  opacity: 0; transition: opacity .15s ease, background .15s ease;
}
.bo-thumb:hover .bo-basket-add, .bo-basket-add.in-basket { opacity: 1; }
.bo-basket-add:hover { background: var(--bo-green-deep); border-color: var(--bo-green-deep); }
.bo-basket-add.in-basket { background: var(--bo-green); border-color: var(--bo-green); color: #111411; }
@media (hover: none) { .bo-basket-add { opacity: 1; } }   /* touch: always visible */
.bo-lb-basket { position: absolute; top: 0; right: 0; opacity: 1; margin: 0; }

/* ---- navbar basket badge ---- */
.bo-basket-badge {
  position: absolute; top: 2px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--bo-green-deep); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 17px; text-align: center;
}
.bo-sidenav .bo-basket-badge { position: static; display: inline-block; margin-left: .35rem; }

/* ---- thumbnail / popup title ----
   Labels sit flush in the image corners and are only as wide as their text. */
.bo-thumb-title {
  position: absolute; top: 0; left: 0;
  max-width: calc(100% - 34px);                 /* never runs under the + button */
  padding: .35rem .55rem; font-size: .74rem; line-height: 1.2;
  background: rgba(17, 20, 17, .72); color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
/* Popup overlays share the thumbnail's anatomy. */
.bo-lightbox-frame { position: relative; display: inline-block; max-width: 100%; }
.bo-lightbox-title {
  position: absolute; top: 0; left: 0;
  max-width: calc(100% - 36px);                 /* never runs under the + button */
  padding: .4rem .6rem; text-align: left;
  background: rgba(17, 20, 17, .75); color: #fff;
  font-family: var(--bo-font-disp); font-size: .95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.bo-lb-details { position: absolute; right: 0; bottom: 0; }

/* ---- pills (author / date / price) ---- */
.bo-pills { position: absolute; left: 0; bottom: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.bo-pill {
  font-size: .72rem; line-height: 1; padding: .35rem .55rem;
  background: rgba(17, 20, 17, .82); color: #fff; letter-spacing: .02em;
  white-space: nowrap;
}
.bo-pill.bo-pill-price { background: var(--bo-green-deep); }
.bo-pill.bo-pill-id {
  background: rgba(17, 20, 17, .62); color: #cfd8cf;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .03em;
}

/* ---- lightbox / photo view ---- */
.bo-lightbox { background: var(--bo-ink); }
.bo-lightbox .bo-photo-frame { position: relative; text-align: center; }
.bo-lightbox img { max-width: 100%; max-height: 78vh; border: 1px solid #2a2f2a; }
.bo-lightbox .bo-pills { position: static; justify-content: center; margin-top: .75rem; }

/* ---- Browse: two-pane app view (desktop) ----
   The page body is locked (no main scrollbar); the filter sidebar and the
   gallery pane are fixed-height siblings that each scroll independently. */
@media (min-width: 992px) {
  .bo-browse-container { padding-bottom: 0 !important; }
  .bo-browse-row { height: calc(100vh - 96px); }   /* viewport minus navbar + container padding */
  #boSidebarCol, #boGalleryCol { height: 100%; min-height: 0; }
  #boGalleryCol {
    display: flex; flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--bo-green-deep) transparent;
  }
  #boGalleryCol::-webkit-scrollbar { width: 6px; }
  #boGalleryCol::-webkit-scrollbar-track { background: transparent; }
  #boGalleryCol::-webkit-scrollbar-thumb { background: var(--bo-line); border-radius: 0; }
  #boGalleryCol:hover::-webkit-scrollbar-thumb { background: var(--bo-green-deep); }
}
.bo-pane-footer {
  margin-top: auto;                              /* hugs the bottom of the pane's content */
  padding: 1.25rem 0 1rem;
  border-top: 1px solid var(--bo-line);
  justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  font-size: .78rem; color: var(--bo-muted);
}
.bo-pane-footer a { color: var(--bo-muted); }

/* ---- filter sidebar ----
   .bo-side-sticky fills the sidebar pane; the search box / Apply / Clear
   header never moves, and only .bo-filter-rail (the groups) scrolls. */
.bo-side-sticky {
  height: 100%; max-height: 100%;
  display: flex; flex-direction: column;
}
.bo-filter-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.bo-filter-rail {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;                /* its wheel never moves the gallery */
  padding-right: 6px;
  /* Sleek thin scrollbar (Firefox + WebKit) */
  scrollbar-width: thin;
  scrollbar-color: var(--bo-green-deep) transparent;
}
.bo-filter-rail::-webkit-scrollbar { width: 6px; }
.bo-filter-rail::-webkit-scrollbar-track { background: transparent; }
.bo-filter-rail::-webkit-scrollbar-thumb { background: var(--bo-line); border-radius: 0; }
.bo-filter-rail:hover::-webkit-scrollbar-thumb { background: var(--bo-green-deep); }
/* Inside the rail, filter groups open fully — ONE scrollbar for the whole
   category area instead of nested scrolling boxes. */
.bo-filter-rail .bo-filters .bo-filter-body { max-height: none; overflow-y: visible; }
@media (max-width: 991.98px) {
  .bo-side-sticky { height: auto; max-height: none; display: block; }
  .bo-filter-rail { overflow: visible; }
  .bo-filter-rail .bo-filters .bo-filter-body { max-height: 260px; overflow-y: auto; }
}

/* ---- filter sidebar ---- */
.bo-filters { border: 1px solid var(--bo-line); background: var(--bo-surface); }
.bo-filters .bo-filter-head {
  padding: .7rem .9rem; border-bottom: 1px solid var(--bo-line);
  font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em;
}
.bo-filters .bo-filter-body {
  padding: .7rem .9rem; max-height: 260px; overflow-y: auto;
  overscroll-behavior: contain;   /* wheel stays in the box — the page doesn't scroll along */
}
.bo-filters .form-check { margin-bottom: .15rem; }
.bo-filters .form-check-label { font-size: .88rem; }
.form-check-input:checked { background-color: var(--bo-green-deep); border-color: var(--bo-green-deep); }

/* ---- cards / paper ---- */
.bo-paper { background: var(--bo-surface); border: 1px solid var(--bo-line); padding: 2rem; }
.bo-section-title { border-bottom: 1px solid var(--bo-line); padding-bottom: .6rem; }
.bo-rule { border-top: 1px solid var(--bo-line); }

/* ---- footer ---- */
.bo-footer {
  background: var(--bo-footer-bg); color: #cfd8cf; margin-top: 4rem;
  border-top: 3px solid var(--bo-green);
}
.bo-footer a { color: #e6efe6; }
.bo-footer .bo-footer-kanji { opacity: .55; }

/* ---- forms & auth ---- */
.bo-auth { max-width: 460px; margin: 3rem auto; }
.bo-key-box {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  background: var(--bo-green-wash); border: 1px dashed var(--bo-green-deep);
  padding: 1rem; letter-spacing: .12em; user-select: all; word-break: break-all;
}

/* ---- library stats strip ---- */
.bo-stats {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline;
  gap: .35rem 2rem; padding: .85rem 1rem; margin: 0 auto;
  border-top: 1px solid var(--bo-line); border-bottom: 1px solid var(--bo-line);
}
.bo-stat-num { font-family: var(--bo-font-disp); font-size: 1.25rem; font-weight: 600; color: var(--bo-ink); }
.bo-stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bo-muted); }

/* ---- About Me photo ---- */
.bo-about-photo {
  width: 140px; height: 140px; object-fit: cover;
  border-radius: 50% !important;   /* the one deliberate curve — a portrait keepsake */
  border: 1px solid var(--bo-line);
}

/* ---- thumbnail lightbox dialog ---- */
.bo-lightbox-overlay {
  position: fixed; inset: 0; z-index: 1090;
  background: rgba(17, 20, 17, .92);
  display: none; align-items: center; justify-content: center;
  padding: 3rem 1.5rem 1.5rem;
  overflow-y: auto;               /* tall content scrolls inside the dialog… */
  overscroll-behavior: contain;   /* …and never chains to the page behind */
}
.bo-lightbox-overlay.open { display: flex; }
.bo-lightbox-inner { max-width: min(1400px, 96vw); text-align: center; }
.bo-lightbox-img {
  max-width: 100%; max-height: 80vh; border: 1px solid #2a2f2a;
  opacity: 0; transition: opacity .2s ease;
}
.bo-lightbox-img.loaded { opacity: 1; }
.bo-lightbox-meta {
  position: absolute; left: 0; bottom: 0; right: 150px;   /* clear of the Details button */
  display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-start;
  align-items: center; margin: 0;
}
.bo-lightbox-close {
  position: absolute; top: .75rem; right: 1rem; z-index: 1;
  background: none; border: 1px solid #3a403a; color: #e6efe6;
  font-size: 1.8rem; line-height: 1; width: 44px; height: 44px;
  cursor: pointer;
}
.bo-lightbox-close:hover, .bo-lightbox-close:focus {
  background: var(--bo-green-deep); border-color: var(--bo-green-deep); color: #fff; outline: none;
}
.bo-lightbox-spinner {
  width: 36px; height: 36px; margin: 4rem auto;
  border: 3px solid #3a403a; border-top-color: var(--bo-green);
  animation: bo-spin .8s linear infinite;
}
@keyframes bo-spin { to { transform: rotate(360deg); } }

/* ---- live results refresh ---- */
#bo-results { transition: opacity .15s ease; }
#bo-results.bo-loading { opacity: .45; pointer-events: none; }

/* ---- author A–Z strip ---- */
.bo-az { display: flex; flex-wrap: wrap; gap: 2px; }
.bo-az-letter {
  display: inline-block; min-width: 20px; padding: 1px 3px;
  font-size: .72rem; text-align: center; line-height: 1.4;
  border: 1px solid var(--bo-line); color: var(--bo-muted);
  background: transparent; text-decoration: none; user-select: none;
}
.bo-az-letter:hover { background: var(--bo-green-wash); text-decoration: none; color: var(--bo-ink); }
/* Selected: bright green box, black text — unmistakable in day and night alike. */
.bo-az-letter.active {
  background: var(--bo-green); border-color: var(--bo-green);
  color: #111411; font-weight: 700;
}
.bo-az-letter.active:hover { background: var(--bo-green); color: #111411; }
.bo-az-letter.disabled { color: var(--bo-muted); opacity: .45; pointer-events: none; }

/* ---- credit badge ---- */
.bo-credit-badge {
  background: var(--bo-green-wash); border: 1px solid var(--bo-green);
  color: var(--bo-ink); font-weight: 700; padding: .3rem .6rem; font-size: .82rem;
}
.bo-credit-badge.low { background: #fdf1e7; border-color: #e2b184; color: #8a4b12; }

/* ---- admin ---- */
.bo-admin-side { background: var(--bo-ink); min-height: 100vh; }
.bo-admin-side .nav-link { color: #b9c4b9; padding: .5rem .9rem; }
.bo-admin-side .nav-link:hover { color: #fff; text-decoration: none; }
.bo-admin-side .nav-link.active { color: #fff; background: rgba(159, 214, 174, .14);
  border-left: 2px solid var(--bo-green); }
.bo-admin-brand { color: #fff; font-family: var(--bo-font-disp); letter-spacing: .05em; }

/* ---- tables ---- */
.table { --bs-table-border-color: var(--bo-line); }
.table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--bo-muted); border-bottom-width: 1px;
}

/* ---- cookie notice strip ---- */
.bo-cookie-strip {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .5rem 1.25rem; padding: .55rem 1rem;
  background: var(--bo-ink); color: #e6efe6;
  font-size: .82rem; border-bottom: 2px solid var(--bo-green);
}
.bo-cookie-strip a { color: var(--bo-green); }
.bo-cookie-ok {
  background: var(--bo-green); border: 1px solid var(--bo-green);
  color: #111411; font-weight: 700; white-space: nowrap;
}
.bo-cookie-ok:hover { background: #fff; border-color: #fff; color: #111411; }
html[data-bo-theme="night"] .bo-cookie-strip { background: #050705; }

/* ---- environment switch (admin) ---- */
.bo-env-active {
  border-color: var(--bo-green-deep) !important;
  background: var(--bo-green-wash) !important;
  box-shadow: 0 0 0 3px rgba(70, 122, 87, .18);
}
label.bo-env-active-label { color: var(--bo-green-deep); font-weight: 700; }

/* ---- toasts ---- */
.bo-toast-region { position: fixed; top: 1rem; right: 1rem; z-index: 1080; }
