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

:root {
  --header-h: 62px;
  --tabs-h: 46px;
  --gold: #c9a227;
  --gold-dark: #a8821a;
  --surface: rgba(0,0,0,0.75);
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --header-bg: rgba(5, 5, 15, 0.88); /* overridden by JS when a color is saved */
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #0a0a0a;
  color: #f0f0f0;
}

/* ── HEADER ──────────────────────────────────────── */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 200;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

#brand-logo {
  max-height: 44px;
  max-width: 180px;
  width: auto;
  object-fit: contain;
  display: block;
}

.brand-icon {
  width: 22px; height: 22px;
  color: var(--gold);
}

.header-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.header-search {
  flex: 1;
  display: flex;
  justify-content: center;
}

.search-wrapper {
  position: relative;
  width: 100%;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

#search-input::placeholder { color: rgba(255,255,255,0.35); }

#search-input:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.12);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: #141420;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 300;
  display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  max-height: 320px;
  overflow-y: auto;
}

.search-dropdown.open { display: block; }

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}

.search-item:hover { background: rgba(255,255,255,0.07); }

.search-item img {
  width: 38px; height: 38px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
  background: #1e1e2e;
}

.search-item-text { min-width: 0; }
.search-item-name { font-size: 0.9rem; font-weight: 500; }
.search-item-family { font-size: 0.78rem; color: rgba(255,255,255,0.55); font-style: italic; margin-top: 1px; }
.search-item-wall { font-size: 0.76rem; color: rgba(255,255,255,0.38); margin-top: 1px; }

.search-empty {
  padding: 14px 16px;
  color: rgba(255,255,255,0.4);
  font-size: 0.88rem;
}

.header-actions { flex-shrink: 0; }

.admin-link {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 0.84rem;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  transition: color 0.2s, border-color 0.2s;
}

.admin-link:hover {
  color: var(--gold);
  border-color: var(--gold);
}

/* ── LIGHT HEADER OVERRIDES ──────────────────────── */
/* Applied when the admin sets a light background color */

.site-header.header-light .search-icon {
  color: rgba(0,0,0,0.4);
}

.site-header.header-light #search-input {
  background: rgba(0,0,0,0.07);
  border-color: rgba(0,0,0,0.18);
  color: #111;
}

.site-header.header-light #search-input::placeholder {
  color: rgba(0,0,0,0.38);
}

.site-header.header-light #search-input:focus {
  background: rgba(0,0,0,0.10);
  border-color: var(--gold-dark, #a8821a);
}

.site-header.header-light .admin-link {
  color: rgba(0,0,0,0.55);
  border-color: rgba(0,0,0,0.18);
}

.site-header.header-light .admin-link:hover {
  color: var(--gold-dark, #a8821a);
  border-color: var(--gold-dark, #a8821a);
}

.site-header.header-light .header-brand h1 {
  color: var(--gold-dark, #a8821a);
}

.site-header.header-light .brand-icon {
  color: var(--gold-dark, #a8821a);
}

/* ── WALL TABS ───────────────────────────────────── */

.wall-tabs {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--tabs-h);
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 14px;
  gap: 6px;
  z-index: 150;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.wall-tabs::-webkit-scrollbar { display: none; }

.wall-tab {
  padding: 6px 20px;
  border-radius: 20px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: var(--font);
}

.wall-tab:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}

.wall-tab.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #0a0a0a;
  font-weight: 600;
}

/* ── WALL STAGE ──────────────────────────────────── */

.wall-stage {
  position: fixed;
  top: calc(var(--header-h) + var(--tabs-h));
  left: 0; right: 0; bottom: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.wall-empty {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wall-empty-inner {
  text-align: center;
  color: rgba(255,255,255,0.25);
}

.wall-empty-inner svg {
  width: 56px; height: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.wall-empty-inner p { font-size: 1rem; margin-bottom: 12px; }

.wall-empty-inner a {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.9rem;
}

.wall-display {
  position: relative;
  width: 100%;
  min-width: 800px;
  height: 100%;
  container-type: size;
  container-name: wall;
}

.wall-display[hidden] { display: none; }

.wall-bg {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.wall-bg-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1a1a2e, #0f3460);
}

.wall-bg-gradient[hidden] { display: none; }

.wall-icons {
  position: absolute;
  inset: 0;
}

/* ── TRIBUTE ICONS ───────────────────────────────── */

.tribute-icon {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s;
  user-select: none;
}

.tribute-icon:hover {
  transform: translate(-50%, -50%) scale(1.18);
  z-index: 10;
}

.tribute-icon img {
  width: 58px; height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.65));
  display: block;
  margin: 0 auto;
}

.tribute-icon-default {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 3px 12px rgba(0,0,0,0.55);
  color: #0a0a0a;
  font-size: 26px;
}

.tribute-label {
  display: block;
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.9);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 5px;
  letter-spacing: 0.01em;
}

/* Persistent highlight — gold glow that stays until cleared */
.tribute-icon.highlighted {
  z-index: 20;
}

.tribute-icon.highlighted img,
.tribute-icon.highlighted .tribute-icon-default {
  filter: drop-shadow(0 0 8px rgba(255, 210, 0, 0.95)) brightness(1.25);
}

.tribute-icon.highlighted .tribute-label {
  color: gold;
}

/* Arrival pulse — plays once when icon is first highlighted via search/navigation */
@keyframes icon-arrive {
  0%   { transform: translate(-50%, -50%) scale(1); }
  25%  { transform: translate(-50%, -50%) scale(1.45); }
  55%  { transform: translate(-50%, -50%) scale(1.2); }
  75%  { transform: translate(-50%, -50%) scale(1.38); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.tribute-icon.highlight-arrive {
  animation: icon-arrive 0.75s ease-out;
}

/* ── RESPONSIVE ICON SCALING ─────────────────────── */
/* Desktop only (hover:hover excludes touch phones so mobile keeps
   full-size icons on the scrollable 800px canvas).
   Scales with BOTH container width and height so icons shrink
   proportionally when the window is made narrower OR shorter.
   Container queries (cqw/cqh) reference wall-display's actual
   rendered size, which is always ≥ 800px — so there is no jump
   when the viewport crosses the 800px min-width boundary. */

@media (hover: hover) {
  @container wall (min-width: 1px) {
    .tribute-icon img {
      width:  clamp(15px, min(4cqw, 7.3cqh, var(--anti-overlap-scale, 4cqw)), 58px);
      height: clamp(15px, min(4cqw, 7.3cqh, var(--anti-overlap-scale, 4cqw)), 58px);
    }
    .tribute-icon-default {
      width:     clamp(15px, min(4cqw, 7.3cqh, var(--anti-overlap-scale, 4cqw)), 58px);
      height:    clamp(15px, min(4cqw, 7.3cqh, var(--anti-overlap-scale, 4cqw)), 58px);
      font-size: clamp(7px,  min(1.8cqw, 3.3cqh), 26px);
    }
    .tribute-label {
      font-size:  clamp(8px,  min(0.73cqw, 1.3cqh),  10.5px);
      max-width:  clamp(60px, min(6.25cqw, 11cqh),    90px);
      margin-top: clamp(2px,  min(0.35cqw, 0.63cqh),  5px);
    }
  }
}

/* ── HOME BUTTON ─────────────────────────────────── */

.home-btn {
  display: none;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 0.84rem;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.home-btn.visible { display: flex; }

.home-btn svg { flex-shrink: 0; }

.home-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.site-header.header-light .home-btn {
  color: rgba(0,0,0,0.55);
  border-color: rgba(0,0,0,0.18);
}

.site-header.header-light .home-btn:hover {
  color: var(--gold-dark, #a8821a);
  border-color: var(--gold-dark, #a8821a);
}

/* ── MODAL ───────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: #141420;
  border-radius: 18px;
  padding: 36px 32px 32px;
  text-align: center;
  max-width: 620px;
  width: 95%;
  position: relative;
  transform: scale(0.88) translateY(12px);
  transition: transform 0.22s;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

.modal-overlay.open .modal-box {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  color: rgba(255,255,255,0.75);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.modal-close:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}

.modal-photo-wrap {
  margin-bottom: 20px;
}

#modal-photo {
  width: 100%;
  max-width: 525px;
  max-height: 560px;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: block;
  margin: 0 auto;
}

#modal-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.3;
}

.modal-family-name {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  margin-top: 5px;
  font-style: italic;
}

.modal-family-name:empty { display: none; }

.modal-tribute {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.75);
  margin-top: 12px;
  line-height: 1.6;
  text-align: left;
  white-space: pre-wrap;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}

.modal-tribute:empty { display: none; }

/* ── MOBILE ANTI-OVERLAP SCALING ────────────────── */
/* Touch devices keep full-size icons normally but shrink them
   when icons are packed close together, same as desktop. */

@media (hover: none) {
  @container wall (min-width: 1px) {
    .tribute-icon img {
      width:  min(58px, var(--anti-overlap-scale, 58px));
      height: min(58px, var(--anti-overlap-scale, 58px));
    }
    .tribute-icon-default {
      width:     min(58px, var(--anti-overlap-scale, 58px));
      height:    min(58px, var(--anti-overlap-scale, 58px));
      font-size: clamp(7px, calc(0.45 * var(--anti-overlap-scale, 58px)), 26px);
    }
    .tribute-label {
      font-size: clamp(8px, calc(0.18 * var(--anti-overlap-scale, 58px)), 10.5px);
    }
  }
}

/* ── SHOW/HIDE LABELS ────────────────────────────── */

.wall-icons.labels-hidden .tribute-label {
  opacity: 0;
  transition: opacity 0.18s;
}

@media (hover: hover) {
  .wall-icons.labels-hidden .tribute-icon:hover .tribute-label {
    opacity: 1;
  }
}

/* ── MOBILE HEADER ───────────────────────────────── */

@media (max-width: 600px) {
  :root {
    --header-h: 106px;
  }

  .site-header {
    flex-wrap: wrap;
    padding: 8px 14px 8px;
    gap: 6px;
    align-content: center;
    height: auto;
    min-height: var(--header-h);
  }

  .header-brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-brand h1 {
    font-size: 1rem;
  }

  #brand-logo {
    max-width: 130px;
    max-height: 36px;
  }

  .home-btn {
    font-size: 0.76rem;
    padding: 4px 9px;
    gap: 4px;
  }

  .admin-link {
    font-size: 0.76rem;
    padding: 4px 9px;
  }

  .header-search {
    order: 4;
    flex: 0 0 100%;
    width: 100%;
    justify-content: stretch;
  }

  .search-wrapper {
    max-width: none;
  }

  .modal-box {
    padding: 28px 18px 22px;
    width: 96%;
  }

  #modal-photo {
    max-height: 55vh;
    border-radius: 10px;
  }
}
