/* Hallmark · pre-emit critique: P4 H5 E4 S4 R4 V4 */
/* Art gallery shell inspired by freakphone windowed layout.
   DNA only: title tab + left rail + dense thumb stage + bottom bar.
   Palette/fonts stay site Art Deco noir. JS hooks preserved. */

@import url("../../css/variables.css");

@font-face {
  font-family: "PixelOperator";
  src: url("../../fonts/PixelOperator.ttf") format("truetype");
  font-smooth: never;
  -webkit-font-smoothing: none;
}

@font-face {
  font-family: "Lobby16Filled";
  src: url("../../fonts/Lobby16 Filled.ttf") format("truetype");
  font-display: block;
  ascent-override: 90%;
  descent-override: 10%;
  font-smooth: never;
  -webkit-font-smoothing: none;
}

@font-face {
  font-family: "FreePixel";
  src: url("../fonts/FreePixel.ttf") format("truetype");
}

:root {
  /* Art Deco / Noir -- same tokens as main site */
  --bg-dark: #0a0a0f;
  --bg-med: #1a1a24;
  --bg-light: #2a2a3a;
  --stage: #161622;
  --rail: #1a1a24;
  --text-primary: #d4c5a0;
  --text-secondary: #9a8d74;
  --accent-gold: #d4af37;
  --accent-bronze: #cd7f32;
  --accent-cream: #f5f5dc;
  --border-dark: #000000;
  --border-light: #3a3a4a;
  --bar: #12121a;
  --tab: #d4af37;
  --tab-text: #0a0a0f;
  --box-shadow: 7px 7px 0px 0px var(--border-dark);
  --box-shadow-sm: 4px 4px 0px 0px var(--border-dark);
  --transition-speed: 0.2s;
  --thumb-radius: 2px;
  --thumb-size: 138px;
  --shell-max: 1180px;
  --rail-w: 260px;
  --deco-line: rgba(212, 175, 55, 0.42);
  --deco-glow: rgba(212, 175, 55, 0.16);

  /* legacy aliases for commissions / old hooks */
  --bg: var(--bg-med);
  --bgaccent: var(--bg-dark);
  --txt: var(--text-primary);
  --accent: var(--accent-gold);
  --accent2: var(--border-light);
  --headercustom: #3a2f28;
  --boxmoment: var(--bg-light);
  --boxshadow: var(--border-dark);
  --box2: var(--bg-med);
  --danger: #c45c5c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: clip;
  /* Desktop is a fixed window shell -- no phantom page scroll */
  overflow-y: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  color: var(--text-primary);
  font-family: "PixelOperator", "FreePixel", monospace;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: none;
  font-smooth: never;
  overflow-x: clip;
  overflow-y: hidden;
  background-color: var(--bg-dark);
  background-image:
    linear-gradient(90deg, rgba(212, 175, 55, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(212, 175, 55, 0.035) 1px, transparent 1px),
    url("../../images/backgrounds/px_by_Gre3g.png"),
    linear-gradient(180deg, #12121a 0%, #0a0a0f 60%, #08080c 100%);
  background-size: 96px 96px, 96px 96px, auto, auto;
  background-repeat: repeat, repeat, repeat, no-repeat;
  background-attachment: fixed, fixed, fixed, fixed;
  background-blend-mode: soft-light, soft-light, overlay, normal;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-bronze) var(--bg-dark);
  cursor: url("../../images/assets/cursor/Normal.gif"), auto;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-light);
  border: 1px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-bronze);
}

button,
a,
.item,
.tag,
.tag-category-header,
#to-top-btn,
#close-btn,
#prev-btn,
#next-btn,
.rail-nav a {
  cursor: pointer;
}

a {
  color: var(--accent-gold);
  text-decoration: none;
}

a:hover {
  color: var(--accent-cream);
}

h1, h2, h3, h4 {
  font-family: "Lobby16Filled", monospace;
  font-weight: normal;
  margin: 0;
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 var(--border-dark);
}

hr {
  border: none;
  height: 2px;
  background: var(--border-light);
  margin: 10px 0;
}

/* =========================================================
   WINDOWED GALLERY SHELL (freakphone DNA)
   ========================================================= */

.gallery-shell {
  width: min(100% - 24px, var(--shell-max));
  /* Margins + height must fit inside the viewport (was overshooting by ~16px) */
  margin: 18px auto;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 36px);
  height: calc(100dvh - 36px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  min-height: 0;
  border: 2px solid var(--border-light);
  outline: 1px solid rgba(212, 175, 55, 0.18);
  outline-offset: 3px;
  box-shadow:
    var(--box-shadow),
    0 0 0 6px rgba(0, 0, 0, 0.28),
    0 0 42px rgba(0, 0, 0, 0.52);
  background:
    linear-gradient(90deg, transparent 0 10px, rgba(212, 175, 55, 0.1) 10px 12px, transparent 12px calc(100% - 12px), rgba(212, 175, 55, 0.1) calc(100% - 12px) calc(100% - 10px), transparent calc(100% - 10px)),
    var(--bar);
  position: relative;
  min-width: 0;
}

.gallery-shell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent-bronze) 14%,
    var(--accent-gold) 50%,
    var(--accent-bronze) 86%,
    transparent 100%
  );
  z-index: 4;
  pointer-events: none;
}

.gallery-shell::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  background:
    linear-gradient(135deg, var(--accent-gold) 0 10px, transparent 10px) top left,
    linear-gradient(225deg, var(--accent-gold) 0 10px, transparent 10px) top right,
    linear-gradient(45deg, var(--accent-bronze) 0 10px, transparent 10px) bottom left,
    linear-gradient(315deg, var(--accent-bronze) 0 10px, transparent 10px) bottom right;
  background-repeat: no-repeat;
  background-size: 26px 26px;
  pointer-events: none;
  z-index: 3;
}

/* top bar: title tab + thick rule */
.gallery-topbar {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  align-items: stretch;
  flex: 0 0 auto;
  border-bottom: 2px solid var(--border-light);
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.12), transparent 28%, rgba(212, 175, 55, 0.08)),
    linear-gradient(180deg, #222230 0%, #14141c 100%);
  min-height: 42px;
  position: relative;
  z-index: 5;
}

.gallery-title-tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 11px 16px 9px 16px;
  background: linear-gradient(
    180deg,
    #f0d878 0%,
    var(--accent-gold) 42%,
    var(--accent-bronze) 100%
  );
  color: var(--tab-text);
  font-family: "Lobby16Filled", monospace;
  font-size: 1.28em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: none;
  border-right: 2px solid var(--border-dark);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.gallery-title-tab::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 1px solid rgba(10, 10, 15, 0.55);
  background:
    linear-gradient(135deg, #1a1a24 0 45%, transparent 45% 55%, #1a1a24 55%),
    radial-gradient(circle at 50% 50%, #f5f5dc 0 35%, transparent 36%);
  box-shadow: inset 0 0 0 1px rgba(245, 245, 220, 0.25);
}

.gallery-top-stripe {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px 0 16px;
  background:
    linear-gradient(90deg, transparent 0 18px, var(--deco-line) 18px 20px, transparent 20px),
    repeating-linear-gradient(
      90deg,
      rgba(58, 58, 74, 0.55) 0 7px,
      rgba(18, 18, 26, 0.9) 7px 9px
    ),
    linear-gradient(180deg, #2e2e40 0%, #16161f 100%);
  border-left: 1px solid var(--border-dark);
  min-height: 38px;
  overflow: hidden;
}

.gallery-top-stripe::before {
  content: "";
  display: flex;
  gap: 6px;
  width: 42px;
  height: 10px;
  background:
    radial-gradient(circle at 5px 5px, var(--accent-bronze) 0 3px, transparent 3.5px),
    radial-gradient(circle at 21px 5px, var(--accent-gold) 0 3px, transparent 3.5px),
    radial-gradient(circle at 37px 5px, var(--text-secondary) 0 3px, transparent 3.5px);
  opacity: 0.9;
  flex: 0 0 auto;
}

.gallery-top-stripe::after {
  content: "selected works // visual archive";
  font-family: "Lobby16Filled", monospace;
  font-size: 0.88em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.9;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.65);
}

/* body: rail + stage */
.gallery-body {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg-dark);
  position: relative;
}

/* LEFT RAIL */
.gallery-rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(212, 175, 55, 0.04) 0%, transparent 48px),
    var(--rail);
  border-right: 2px solid var(--border-light);
  overflow: auto;
  position: relative;
  z-index: 2;
}

.rail-blurb {
  padding: 16px 14px 14px;
  color: var(--text-secondary);
  font-size: 0.98em;
  line-height: 1.45;
  border-bottom: 1px solid var(--border-light);
  background:
    linear-gradient(135deg, rgba(212, 175, 55, 0.16) 0 14px, transparent 14px),
    linear-gradient(225deg, rgba(205, 127, 50, 0.14) 0 14px, transparent 14px),
    linear-gradient(90deg, rgba(212, 175, 55, 0.08), transparent 40%),
    transparent;
  background-repeat: no-repeat;
  background-size: 46px 46px, 46px 46px, auto, auto;
  background-position: top left, top right, center, center;
  position: relative;
}

.rail-blurb::before {
  content: "";
  display: block;
  height: 5px;
  margin: 0 0 10px;
  background:
    linear-gradient(90deg, transparent 0 12px, var(--accent-bronze) 12px 24px, var(--accent-gold) 24px calc(100% - 24px), var(--accent-bronze) calc(100% - 24px) calc(100% - 12px), transparent calc(100% - 12px));
}

.rail-blurb p {
  margin: 0 0 0.75em;
}

.rail-blurb p:first-child {
  color: var(--text-primary);
  font-size: 1.04em;
}

.rail-blurb p:last-child {
  margin-bottom: 0;
}

.rail-blurb i {
  color: var(--accent-gold);
}

.rail-meta {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.08), transparent 26%, rgba(205, 127, 50, 0.06)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 11px,
      rgba(58, 58, 74, 0.25) 11px 12px
    ),
    rgba(0, 0, 0, 0.28);
}

#item-counter {
  color: var(--accent-cream);
  font-family: "Lobby16Filled", monospace;
  font-size: 0.94em;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding: 6px 8px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.1), transparent 62%),
    var(--bg-dark);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.songtitle-scroll {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  font-size: 0.8em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.songtitle-scroll::after {
  content: "";
  display: inline-block;
  padding-left: 100%;
}

@keyframes marquee-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-55%); }
}

.songtitle-scroll {
  animation: marquee-scroll 16s linear infinite;
}

.sidebar-audio {
  width: 100%;
  height: 28px;
  border: 1px solid var(--border-light);
  background: var(--bg-dark);
}

.rail-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--border-light);
}

.rail-nav li {
  margin: 0;
  border-bottom: 1px dotted var(--border-light);
}

.rail-nav li:last-child {
  border-bottom: none;
}

.rail-nav a {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: "Lobby16Filled", monospace;
  font-size: 1.05em;
  background: linear-gradient(180deg, #2a2a3a 0%, #1a1a24 100%);
  border-left: 3px solid transparent;
  transition:
    background var(--transition-speed) ease,
    color var(--transition-speed) ease,
    border-color var(--transition-speed) ease,
    padding-left var(--transition-speed) ease;
  text-shadow: none;
}

.rail-nav a:hover {
  background: linear-gradient(180deg, #38384c 0%, #242436 100%);
  color: var(--accent-gold);
  border-left-color: var(--accent-gold);
  padding-left: 14px;
  text-shadow: none;
}

.rail-nav .nav-ico {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-light);
  background: var(--bg-dark);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.08);
  overflow: hidden;
}

.rail-nav .nav-ico img {
  width: 12px;
  height: 12px;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  /* bronze tint to match rail chrome */
  filter: brightness(0) saturate(100%) invert(55%) sepia(62%) saturate(620%)
    hue-rotate(353deg) brightness(92%) contrast(90%);
  transition: filter var(--transition-speed) ease;
}

.rail-nav a:hover .nav-ico {
  border-color: var(--accent-gold);
  background: #12121a;
}

.rail-nav a:hover .nav-ico img {
  /* gold on hover */
  filter: brightness(0) saturate(100%) invert(72%) sepia(54%) saturate(570%)
    hue-rotate(5deg) brightness(91%) contrast(87%);
}

.rail-filters {
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  background:
    linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.18) 100%);
}

.rail-filters-label {
  font-family: "Lobby16Filled", monospace;
  font-size: 0.98em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold);
  padding: 4px 6px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  background:
    linear-gradient(135deg, rgba(245, 245, 220, 0.12) 0 8px, transparent 8px),
    linear-gradient(90deg, rgba(212, 175, 55, 0.12), transparent 70%),
    var(--bg-dark);
}

#tag-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-height: 0;
}

#tag-search {
  width: 100%;
  padding: 8px 10px;
  margin: 0;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-family: "PixelOperator", monospace;
  font-size: 13px;
  border-radius: 0;
}

#tag-search:focus {
  outline: none;
  border-color: var(--accent-gold);
}

#tag-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin: 0;
}

#clear-filters,
#collapse-all,
#expand-all,
#reset {
  padding: 7px 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-family: "PixelOperator", monospace;
  font-size: 12px;
  box-shadow: none;
  border-radius: 0;
}

#clear-filters:hover,
#collapse-all:hover,
#expand-all:hover,
#reset:hover {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--bg-dark);
}

#active-tags-display {
  display: none;
  padding: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.82em;
}

#active-tags-display.show {
  display: block;
}

#active-tags-list {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.active-tag-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--accent-gold);
  color: var(--bg-dark);
  border: 1px solid var(--border-dark);
  font-size: 0.85em;
}

.active-tag-remove {
  cursor: pointer;
  font-weight: bold;
}

.tag-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.08), transparent 60%),
    var(--bg-light);
  border: 1px solid rgba(212, 175, 55, 0.22);
  cursor: pointer;
  user-select: none;
  border-radius: 0;
}

.tag-category-header:hover {
  border-color: var(--accent-bronze);
}

.tag-category-title {
  font-family: "Lobby16Filled", monospace;
  font-size: 0.94em;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.tag-category-count {
  color: var(--accent-bronze);
  font-size: 0.8em;
}

.tag-category-arrow {
  color: var(--accent-gold);
  display: inline-block;
  transition: transform 0.15s ease;
}

.tag-category-header.collapsed .tag-category-arrow {
  transform: rotate(90deg);
}

.tag-category-content {
  display: none;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
  background:
    radial-gradient(circle at 1px 1px, rgba(212, 197, 160, 0.06) 1px, transparent 0),
    var(--bg-dark);
  background-size: 10px 10px, auto;
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-top: none;
  max-height: 160px;
  overflow-y: auto;
  border-radius: 0;
}

.tag-category-content:not(.collapsed) {
  display: flex;
}

.tag {
  display: inline-block;
  border: 1px solid var(--border-light);
  padding: 3px 7px;
  background: var(--bg-med);
  color: var(--accent-gold);
  font-family: "PixelOperator", monospace;
  font-size: 0.8em;
  white-space: nowrap;
  border-radius: 0;
}

.tag::before {
  content: "#";
  opacity: 0.65;
}

.tag:hover {
  border-color: var(--accent-gold);
  color: var(--accent-cream);
}

.color-coded {
  color: #e08a8a;
  border-color: #6a3a3a;
}

.tag.active,
.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--bg-dark);
}

.color-coded.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0c0c;
}

.tag.search-hidden {
  display: none !important;
}

/* MAIN STAGE -- dense thumb window */
.gallery-stage {
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(90deg, transparent 0 22px, rgba(212, 175, 55, 0.14) 22px 24px, transparent 24px calc(100% - 24px), rgba(212, 175, 55, 0.14) calc(100% - 24px) calc(100% - 22px), transparent calc(100% - 22px)),
    linear-gradient(0deg, transparent 0 22px, rgba(212, 175, 55, 0.1) 22px 24px, transparent 24px),
    radial-gradient(ellipse at top, rgba(42, 42, 58, 0.5) 0%, transparent 52%),
    radial-gradient(circle at 1px 1px, rgba(212, 197, 160, 0.05) 1px, transparent 0),
    linear-gradient(180deg, #1a1a26 0%, var(--stage) 28%, #12121c 100%);
  background-size: auto, auto, auto, 14px 14px, auto;
  padding: 18px 18px 20px;
  overflow: auto;
  border-left: 1px solid var(--border-dark);
  box-shadow:
    inset 0 0 0 1px rgba(58, 58, 74, 0.4),
    inset 0 18px 28px rgba(0, 0, 0, 0.18);
  position: relative;
  z-index: 1;
}

.gallery-stage::before {
  content: "archive floor // click a piece";
  position: sticky;
  top: 0;
  z-index: 2;
  display: inline-block;
  margin: 0 0 14px;
  padding: 5px 12px 4px;
  font-family: "Lobby16Filled", monospace;
  font-size: 0.72em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.18), transparent 72%),
    rgba(18, 18, 26, 0.94);
  border: 1px solid rgba(212, 175, 55, 0.36);
  box-shadow:
    2px 2px 0 var(--border-dark),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

#gallery {
  display: grid;
  /* Fill the stage width -- no dead strip on the right */
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size), 1fr));
  gap: 10px;
  align-content: start;
  min-width: 0;
  width: 100%;
  padding: 2px 2px 12px;
}

.item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  overflow: hidden;
  margin: 0;
  cursor: pointer;
  background:
    linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0 8px, transparent 8px),
    linear-gradient(225deg, rgba(212, 175, 55, 0.12) 0 8px, transparent 8px),
    var(--bg-dark);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: var(--thumb-radius);
  box-shadow:
    3px 3px 0 var(--border-dark),
    inset 0 0 0 1px rgba(0, 0, 0, 0.45);
  transition:
    transform var(--transition-speed) ease,
    box-shadow var(--transition-speed) ease,
    border-color var(--transition-speed) ease,
    filter var(--transition-speed) ease;
}

.item::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(245, 245, 220, 0.1);
  border-radius: calc(var(--thumb-radius) - 3px);
  pointer-events: none;
  opacity: 0.7;
  transition: border-color var(--transition-speed) ease, opacity var(--transition-speed) ease;
}

.item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(135deg, var(--accent-gold) 0 10px, transparent 10px) top left,
    linear-gradient(225deg, var(--accent-bronze) 0 10px, transparent 10px) top right,
    linear-gradient(45deg, var(--accent-bronze) 0 10px, transparent 10px) bottom left,
    linear-gradient(315deg, var(--accent-gold) 0 10px, transparent 10px) bottom right;
  background-repeat: no-repeat;
  background-size: 18px 18px;
  opacity: 0.36;
  transition: opacity var(--transition-speed) ease;
}

.item:hover,
.item:focus-within {
  transform: translate(-2px, -3px);
  border-color: var(--accent-gold);
  box-shadow:
    6px 6px 0 var(--border-dark),
    0 0 0 1px rgba(212, 175, 55, 0.45),
    0 0 18px var(--deco-glow);
  z-index: 1;
  filter: brightness(1.04) saturate(1.05);
}

.item:hover::after,
.item:focus-within::after {
  border-color: rgba(212, 175, 55, 0.45);
  opacity: 1;
}

.item:hover::before,
.item:focus-within::before {
  opacity: 0.8;
}

.item img,
.item-img {
  width: 100%;
  height: 100%;
  /* Thumbs are already custom 360x360 squares -- no random CSS crop */
  object-fit: contain;
  object-position: center;
  display: block;
  border-radius: calc(var(--thumb-radius) - 1px);
  background: #0a0a0f;
  transition: transform 0.25s ease;
  image-rendering: auto;
}

.item:hover img,
.item:focus-within img,
.item:hover .item-img,
.item:focus-within .item-img {
  transform: scale(1.04);
}

.zoom img { object-fit: none; }
.top-left img { object-position: top left; }
.top-center img { object-position: top center; }
.top-right img { object-position: top right; }
.center-left img { object-position: center left; }
.center-center img { object-position: center; }
.center-right img { object-position: center right; }
.bottom-left img { object-position: bottom left; }
.bottom-center img { object-position: bottom center; }
.bottom-right img { object-position: bottom right; }

/* title chip only on hover -- keep markup for lightbox */
.item-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 8px 7px;
  background:
    linear-gradient(180deg, transparent 0%, rgba(8, 8, 12, 0.62) 30%, rgba(8, 8, 12, 0.96) 100%),
    linear-gradient(90deg, rgba(212, 175, 55, 0.22), transparent 70%);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  display: block;
  border-radius: 0 0 var(--thumb-radius) var(--thumb-radius);
  z-index: 2;
}

.item:hover .item-info,
.item:focus-within .item-info {
  opacity: 1;
  transform: translateY(0);
}

.item-info .item-desc,
.item-info .item-date {
  display: none;
}

.item-info .item-title h1 {
  margin: 0;
  font-size: 0.74em;
  line-height: 1.2;
  color: var(--accent-cream);
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.03em;
}

.hidden {
  display: none !important;
}

.gallery-loading,
.gallery-error,
.gallery-empty {
  width: 100%;
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
  border: 1px dashed var(--border-light);
  background: rgba(10, 10, 15, 0.35);
}

.gallery-loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent-gold);
  animation: gallery-spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes gallery-spin {
  to { transform: rotate(360deg); }
}

.gallery-error {
  color: #e08a8a;
  border-color: #6a3a3a;
}

/* BOTTOM BAR */
.gallery-bottombar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 32px;
  background: linear-gradient(180deg, #222230 0%, #12121a 100%);
  border-top: 2px solid var(--border-light);
  position: relative;
  z-index: 5;
}

.gallery-bottom-credit {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  color: var(--text-secondary);
  font-size: 0.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-bottom-credit::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: var(--accent-bronze);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.gallery-bottom-credit a {
  color: var(--accent-gold);
}

.gallery-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 20px;
  background: linear-gradient(
    180deg,
    #f0d878 0%,
    var(--accent-gold) 42%,
    var(--accent-bronze) 100%
  );
  color: var(--tab-text) !important;
  font-family: "Lobby16Filled", monospace;
  font-size: 0.95em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none !important;
  border-left: 2px solid var(--border-dark);
  text-shadow: none !important;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.gallery-home-btn::before {
  content: "<";
  font-size: 0.9em;
  opacity: 0.8;
}

.gallery-home-btn:hover {
  filter: brightness(1.08);
  color: #000 !important;
}

/* floating to-top (inside stage context) */
#to-top-btn {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 10px 12px;
  border: 2px solid var(--accent-gold);
  background: var(--bg-med);
  color: var(--accent-gold);
  font-family: "Lobby16Filled", monospace;
  box-shadow: var(--box-shadow-sm);
}

#to-top-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
}

/* decorative moon/stars optional -- hide in windowed mode */
#imgmoon,
#imgstars {
  display: none;
}

/* =========================================================
   LIGHTBOX -- compact Art Deco display card
   ========================================================= */

#lightbox {
  z-index: 50;
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 18px 14px;
  color: var(--text-primary);
  background:
    radial-gradient(ellipse at center, rgba(26, 26, 36, 0.28) 0%, rgba(5, 5, 8, 0.94) 70%),
    rgba(5, 5, 8, 0.92);
  backdrop-filter: blur(3px);
}

/* When open, gallery.js sets display:block -- force flex centering */
#lightbox[style*="block"] {
  display: flex !important;
}

/* Keep donate widget out of the lightbox chrome */
body.lightbox-open #to-top-btn,
body.lightbox-open .floatingchat-container-wrap,
body.lightbox-open .floatingchat-container-wrap-mobi,
body.lightbox-open .floating-chat-kofi-popup-iframe,
body.lightbox-open iframe[src*="ko-fi.com"],
body.lightbox-open [id^="kofi-widget"],
body.lightbox-open .floatingchat-donate-button {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#close-btn {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 60;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(212, 175, 55, 0.4);
  background: linear-gradient(180deg, #2e2e40 0%, #16161f 100%);
  color: var(--accent-cream);
  font-size: 22px;
  line-height: 1;
  box-shadow: var(--box-shadow-sm);
  padding: 0;
}

#close-btn:hover {
  border-color: var(--accent-gold);
  color: var(--bg-dark);
  background: linear-gradient(180deg, #f0d878, var(--accent-gold) 55%, var(--accent-bronze));
}

#lightbox .flex {
  /* Taller + slightly roomier art pane for portraits */
  --lb-w: 980px;
  --lb-h: 620px;
  --lb-side: 236px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--lb-side);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  /* Hard shell -- image cannot change this box */
  width: min(var(--lb-w), calc(100vw - 32px));
  height: min(var(--lb-h), calc(100vh - 48px));
  min-width: min(var(--lb-w), calc(100vw - 32px));
  min-height: min(var(--lb-h), calc(100vh - 48px));
  max-width: min(var(--lb-w), calc(100vw - 32px));
  max-height: min(var(--lb-h), calc(100vh - 48px));
  flex: 0 0 auto;
  margin: auto;
  align-self: center;
  background:
    linear-gradient(180deg, #222230 0%, #14141c 100%);
  border: 2px solid rgba(212, 175, 55, 0.38);
  outline: 1px solid rgba(58, 58, 74, 0.65);
  outline-offset: 3px;
  box-shadow:
    8px 8px 0 #000,
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 18px 48px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

#lightbox .flex::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent-bronze) 12%,
    var(--accent-gold) 50%,
    var(--accent-bronze) 88%,
    transparent 100%
  );
  z-index: 4;
  pointer-events: none;
}

#lightbox-img {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(212, 197, 160, 0.045) 1px, transparent 0),
    linear-gradient(180deg, #12121a 0%, #0a0a0f 100%);
  background-size: 12px 12px, auto;
  border-right: 1px solid rgba(212, 175, 55, 0.22);
  position: relative;
  overflow: hidden;
}

#lightbox-img::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 175, 55, 0.16);
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(135deg, rgba(212, 175, 55, 0.55) 0 8px, transparent 8px) top left,
    linear-gradient(225deg, rgba(205, 127, 50, 0.55) 0 8px, transparent 8px) top right,
    linear-gradient(45deg, rgba(205, 127, 50, 0.55) 0 8px, transparent 8px) bottom left,
    linear-gradient(315deg, rgba(212, 175, 55, 0.55) 0 8px, transparent 8px) bottom right;
  background-repeat: no-repeat;
  background-size: 16px 16px;
}

/* Absolutely framed -- never contributes intrinsic size to the card */
#lightbox-img img {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: contain;
  object-position: center;
  z-index: 1;
  display: block;
  box-shadow: none;
  pointer-events: none;
}

#lightbox-info {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 26px 14px 12px;
  background:
    linear-gradient(180deg, rgba(212, 175, 55, 0.07) 0%, transparent 48px),
    var(--bg-med);
  border-left: 1px solid rgba(58, 58, 74, 0.55);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

#lightbox-info::before {
  content: "piece file";
  position: absolute;
  top: 0;
  left: 0;
  padding: 3px 10px 2px;
  font-family: "Lobby16Filled", monospace;
  font-size: 0.68em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tab-text);
  background: linear-gradient(180deg, #f0d878 0%, var(--accent-gold) 48%, var(--accent-bronze) 100%);
  border-right: 1px solid var(--border-dark);
  border-bottom: 1px solid var(--border-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

#lightbox-title {
  border-bottom: 1px solid rgba(212, 175, 55, 0.22);
  padding: 6px 0 8px;
  margin-top: 4px;
}

#lightbox-title h1 {
  margin: 0;
  font-size: 1.15em;
  color: var(--accent-cream);
  line-height: 1.25;
  letter-spacing: 0.04em;
  text-shadow: 1px 1px 0 #000;
}

#lightbox-date {
  color: var(--text-secondary);
  font-size: 0.86em;
  letter-spacing: 0.02em;
}

#lightbox-desc {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  font-size: 0.95em;
  line-height: 1.4;
  padding-right: 4px;
}

#lightbox-desc p {
  margin: 0 0 0.55em;
}

#lightbox-desc img,
#lightbox-desc video,
#lightbox-desc iframe {
  max-width: 100%;
}

#lightbox-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 0 0 auto;
}

#lightbox-tags li {
  margin: 0;
  padding: 2px 6px;
  background: var(--bg-dark);
  border: 1px solid rgba(212, 175, 55, 0.28);
  color: var(--accent-gold);
  box-shadow: 2px 2px 0 var(--border-dark);
  font-size: 0.82em;
  cursor: pointer;
}

#lightbox-tags li::before {
  content: "#";
  opacity: 0.65;
}

#lightbox-tags li:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
  border-color: var(--accent-gold);
}

#lightbox-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(212, 175, 55, 0.22);
  flex: 0 0 auto;
}

#prev-btn,
#next-btn {
  padding: 6px 10px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background:
    linear-gradient(180deg, rgba(212, 175, 55, 0.1), transparent 72%),
    var(--bg-dark);
  color: var(--text-primary);
  font-family: "PixelOperator", monospace;
  box-shadow: 2px 2px 0 var(--border-dark);
  min-width: 0;
}

#prev-btn { justify-self: start; }
#next-btn { justify-self: end; }

#prev-btn:hover,
#next-btn:hover {
  background: linear-gradient(180deg, #f0d878, var(--accent-gold) 55%, var(--accent-bronze));
  border-color: var(--accent-gold);
  color: var(--bg-dark);
}

#progress {
  text-align: center;
  color: var(--text-secondary);
  font-family: "Lobby16Filled", monospace;
  letter-spacing: 0.06em;
  font-size: 0.85em;
}

/* =========================================================
   LEGACY HOOKS (commissions / old markup)
   ========================================================= */

.entireshit {
  width: min(100% - 24px, var(--shell-max));
  margin: 24px auto;
  color: var(--text-primary);
}

.sidebar {
  background: var(--rail);
  border: 2px solid var(--border-light);
  padding: 12px;
  box-shadow: var(--box-shadow-sm);
}

.inside1,
.inside2,
.inside3,
.inside4 {
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  padding: 8px 10px;
  margin: 8px 0;
}

.container {
  margin-top: 12px;
}

.headerarea {
  background: var(--bg-med);
  border: 2px solid var(--border-light);
  box-shadow: var(--box-shadow-sm);
}

.headercustom {
  height: 120px;
  background-image:
    linear-gradient(180deg, rgba(10, 10, 15, 0.2), rgba(10, 10, 15, 0.75)),
    url("../../images/backgrounds/nacho-rochon-CG7YwmRDGvI-unsplash.jpg");
  background-size: cover;
  background-position: center 42%;
}

.nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-tv {
  display: block;
  max-width: 160px;
  width: 100%;
  margin: 10px auto 0;
  border: 1px solid var(--border-light);
}

.tags-header {
  margin: 10px;
  color: var(--accent-gold);
  text-transform: uppercase;
  font-size: 0.95em;
}

.maingallery,
#flex,
main {
  min-width: 0;
}

.icon-accent {
  filter: brightness(0) saturate(100%) invert(77%) sepia(41%) saturate(678%) hue-rotate(6deg) brightness(94%) contrast(92%);
}

.icon-bg {
  filter: brightness(0) saturate(100%) invert(8%) sepia(8%) saturate(1200%) hue-rotate(201deg) brightness(95%) contrast(95%);
}

.icon-red {
  filter: brightness(0) saturate(100%) invert(53%) sepia(59%) saturate(2636%) hue-rotate(330deg) brightness(101%) contrast(101%);
}

.icon-txt {
  filter: brightness(0) saturate(100%) invert(88%) sepia(12%) saturate(520%) hue-rotate(6deg) brightness(95%) contrast(90%);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media screen and (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  .gallery-shell {
    width: min(100% - 16px, var(--shell-max));
    margin: 12px auto 20px;
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .gallery-topbar,
  .gallery-body {
    grid-template-columns: 1fr;
  }

  .gallery-title-tab {
    border-right: none;
    border-bottom: 2px solid var(--border-dark);
  }

  .gallery-top-stripe {
    min-height: 14px;
    padding: 0 10px;
  }

  .gallery-top-stripe::before {
    display: none;
  }

  .gallery-top-stripe::after {
    display: none;
  }

  .gallery-shell {
    outline-offset: 2px;
  }

  .gallery-rail {
    border-right: none;
    border-bottom: 2px solid var(--border-light);
    max-height: none;
  }

  .gallery-stage {
    max-height: min(72vh, 680px);
  }

  .gallery-stage::before {
    margin-bottom: 10px;
  }

  #gallery {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  }

  .item {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .rail-filters {
    max-height: 280px;
    overflow: auto;
  }

  #lightbox {
    padding: 10px 10px 18px;
    align-items: center;
  }

  #lightbox .flex {
    --lb-w: 640px;
    --lb-h: 680px;
    --lb-side: auto;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.35fr) minmax(190px, 210px);
    width: min(var(--lb-w), calc(100vw - 20px));
    height: min(var(--lb-h), calc(100vh - 56px));
    min-width: min(var(--lb-w), calc(100vw - 20px));
    min-height: min(var(--lb-h), calc(100vh - 56px));
    max-width: min(var(--lb-w), calc(100vw - 20px));
    max-height: min(var(--lb-h), calc(100vh - 56px));
    margin: 8px auto;
  }

  #close-btn {
    position: fixed;
    top: 8px;
    right: 10px;
  }

  #lightbox-img {
    grid-column: 1;
    grid-row: 1;
    border-right: none;
    border-bottom: 1px solid rgba(212, 175, 55, 0.22);
    padding: 0;
    height: 100%;
    min-height: 0;
  }

  #lightbox-img img {
    inset: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
  }

  #lightbox-info {
    grid-column: 1;
    grid-row: 2;
    border-left: none;
    padding: 20px 12px 10px;
    height: 100%;
  }

  #lightbox-title h1 {
    font-size: 1.05em;
  }

  #lightbox-desc {
    max-height: 56px;
  }

  #lightbox-nav {
    order: 0;
    gap: 6px;
  }

  #prev-btn,
  #next-btn {
    padding: 7px 12px;
    min-width: 52px;
  }
}

@media screen and (max-width: 600px) {
  body {
    font-size: 14px;
  }

  :root {
    --rail-w: 100%;
  }

  .gallery-shell {
    width: calc(100% - 12px);
    margin: 8px auto 16px;
  }

  .gallery-stage {
    padding: 10px;
    max-height: 62vh;
  }

  #gallery {
    gap: 7px;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  .item {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .gallery-bottombar {
    grid-template-columns: 1fr;
  }

  .gallery-home-btn {
    border-left: none;
    border-top: 2px solid var(--border-dark);
  }

  .gallery-bottom-credit {
    white-space: normal;
  }

  #lightbox {
    padding: 8px 8px 14px;
  }

  #lightbox .flex {
    --lb-w: 100%;
    --lb-h: 640px;
    grid-template-rows: minmax(0, 1.4fr) minmax(180px, 200px);
    width: calc(100vw - 16px);
    height: min(var(--lb-h), calc(100vh - 44px));
    min-width: calc(100vw - 16px);
    min-height: min(var(--lb-h), calc(100vh - 44px));
    max-width: calc(100vw - 16px);
    max-height: min(var(--lb-h), calc(100vh - 44px));
    margin: 4px auto;
  }

  #lightbox-info {
    padding: 18px 10px 8px;
  }

  #lightbox-desc {
    max-height: 48px;
    font-size: 0.9em;
  }

  #lightbox-tags {
    gap: 4px;
  }

  #lightbox-tags li {
    font-size: 0.78em;
  }
}

@media screen and (max-width: 380px) {
  #gallery {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }

  .item {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .songtitle-scroll {
    transform: none !important;
  }
}
