/* DHW-SOU public search site. */

:root {
  --ink: #1b2733;
  --ink-soft: #4a5a68;
  --ink-faint: #7b8b98;
  --card: rgba(255, 255, 255, 0.92);
  --card-line: rgba(27, 39, 51, 0.08);
  --accent: #b23a2f;
  --shadow: 0 18px 40px -22px rgba(20, 34, 48, 0.55);
  --radius: 14px;
}

/* --- themes: three hand-built backdrops ------------------------------- */
body[data-theme="mist"] {
  --sky-top: #eef3f6; --sky-bottom: #dbe4ea;
  --ridge-far-top: #c3d0da; --ridge-far-bottom: #a6b7c4;
  --ridge-mid-top: #a2b3c1; --ridge-mid-bottom: #8296a7;
  --ridge-near-top: #7b8fa0; --ridge-near-bottom: #5d7385;
  --mist: #eef3f6; --fall: #f4f8fa; --bird: #f7fafc;
}
body[data-theme="dusk"] {
  --ink: #2a2118; --ink-soft: #5d4c3c; --ink-faint: #8b7967;
  --sky-top: #fbf0e2; --sky-bottom: #f3d9c0;
  --ridge-far-top: #e7cbb2; --ridge-far-bottom: #d3ad8f;
  --ridge-mid-top: #c99e7d; --ridge-mid-bottom: #ae8261;
  --ridge-near-top: #a2704f; --ridge-near-bottom: #7d5033;
  --mist: #fdf3e8; --fall: #fff6ea; --bird: #fff8ee;
  --accent: #a8452a;
}
body[data-theme="night"] {
  --ink: #e8eef4; --ink-soft: #b3c2cf; --ink-faint: #8195a6;
  --card: rgba(20, 30, 41, 0.82);
  --card-line: rgba(232, 238, 244, 0.12);
  --sky-top: #101a24; --sky-bottom: #1b2a38;
  --ridge-far-top: #24384a; --ridge-far-bottom: #1a2a38;
  --ridge-mid-top: #1d2f3f; --ridge-mid-bottom: #142230;
  --ridge-near-top: #14202c; --ridge-near-bottom: #0c1620;
  --mist: #1a2937; --fall: #35505f; --bird: #6f8ba1;
  --accent: #e0705d;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.site {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font: 15px/1.6 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- backdrop --------------------------------------------------------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.backdrop-sky {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
}
.backdrop-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.birds { opacity: 0.7; }

/* --- corner clock ----------------------------------------------------- */
.corner-widget {
  position: absolute; top: 18px; left: 22px;
  font-size: 13px; letter-spacing: 0.02em; color: var(--ink-soft);
}
.corner-dot { margin: 0 6px; opacity: 0.5; }
.corner-time { font-variant-numeric: tabular-nums; }

/* --- shell ------------------------------------------------------------ */
.shell {
  flex: 1;
  width: min(1040px, 94vw);
  margin: 0 auto;
  padding: clamp(34px, 5vh, 62px) 0 40px;
  text-align: center;
}

/* --- brand ------------------------------------------------------------ */
.brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 34px;
}
.brand-compact { margin-bottom: 24px; }
.brand-link { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  font-size: clamp(42px, 6.4vw, 62px); font-weight: 800; letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.35);
}
.brand-badge {
  display: grid; place-items: center;
  width: clamp(40px, 5.8vw, 56px); height: clamp(40px, 5.8vw, 56px);
  border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: clamp(19px, 2.8vw, 27px); font-weight: 700;
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.6);
}
.brand-logo {
  display: block;
  max-width: min(420px, 74vw);
  max-height: 96px;
  width: auto; height: auto;
}
.brand-compact .brand-logo { max-height: 58px; max-width: min(300px, 62vw); }
.brand-compact .brand-mark { font-size: clamp(26px, 3.4vw, 34px); }
.brand-compact .brand-badge { width: 32px; height: 32px; font-size: 16px; }

/* --- search bar ------------------------------------------------------- */
.searchbar {
  display: flex; align-items: center; gap: 10px;
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 2px 6px 2px 12px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 6px;
  box-shadow: 0 6px 18px -12px rgba(20, 34, 48, 0.45);
  backdrop-filter: blur(6px);
}
.searchbar-badge {
  display: grid; place-items: center;
  width: 24px; height: 24px; flex: none;
  border-radius: 6px;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700;
}
.searchbar-input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--ink);
  font: inherit; font-size: 15px;
  padding: 8px 4px;
}
.searchbar-input::placeholder { color: var(--ink-faint); }
.searchbar-submit {
  flex: none;
  display: grid; place-items: center;
  width: 40px; height: 34px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-soft);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.searchbar-submit:hover { background: rgba(127, 145, 160, 0.16); color: var(--ink); }

/* --- category tabs ---------------------------------------------------- */
.tabs {
  display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(18px, 3.4vw, 44px);
  margin: 30px auto 30px;
}
.tab {
  position: relative;
  border: 0; background: transparent; cursor: pointer;
  color: var(--ink-soft); font: inherit; font-size: 16px; font-weight: 500;
  padding: 6px 2px;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); font-weight: 700; }
.tab.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  border-radius: 2px; background: var(--accent);
}

/* --- tiles ------------------------------------------------------------ */
.tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 24px 8px;
  width: min(1000px, 100%);
  margin: 4px auto 0;
  justify-items: start;
}
.tile.is-hidden { display: none; }
.linktable tr.is-hidden { display: none; }
.tile {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 9px;
  border-radius: 8px;
  text-decoration: none; color: var(--ink);
  transition: background 0.15s, transform 0.15s;
  min-width: 0;
}
.tile:hover { background: var(--card); transform: translateY(-1px); }
.tile-ico {
  display: grid; place-items: center;
  width: 24px; height: 24px; flex: none;
  border-radius: 6px;
  background: hsl(210 58% 52%); /* overridden by .hue-N */
  color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
}
.tile-ico-img { object-fit: cover; background: #fff; }

/* Tile colour buckets — replaces an inline style so the CSP needs no style-src 'unsafe-inline'. */
.tile-ico.hue-0 { background: hsl(0 58% 52%); }
.tile-ico.hue-1 { background: hsl(15 58% 52%); }
.tile-ico.hue-2 { background: hsl(30 58% 52%); }
.tile-ico.hue-3 { background: hsl(45 58% 52%); }
.tile-ico.hue-4 { background: hsl(60 58% 52%); }
.tile-ico.hue-5 { background: hsl(75 58% 52%); }
.tile-ico.hue-6 { background: hsl(90 58% 52%); }
.tile-ico.hue-7 { background: hsl(105 58% 52%); }
.tile-ico.hue-8 { background: hsl(120 58% 52%); }
.tile-ico.hue-9 { background: hsl(135 58% 52%); }
.tile-ico.hue-10 { background: hsl(150 58% 52%); }
.tile-ico.hue-11 { background: hsl(165 58% 52%); }
.tile-ico.hue-12 { background: hsl(180 58% 52%); }
.tile-ico.hue-13 { background: hsl(195 58% 52%); }
.tile-ico.hue-14 { background: hsl(210 58% 52%); }
.tile-ico.hue-15 { background: hsl(225 58% 52%); }
.tile-ico.hue-16 { background: hsl(240 58% 52%); }
.tile-ico.hue-17 { background: hsl(255 58% 52%); }
.tile-ico.hue-18 { background: hsl(270 58% 52%); }
.tile-ico.hue-19 { background: hsl(285 58% 52%); }
.tile-ico.hue-20 { background: hsl(300 58% 52%); }
.tile-ico.hue-21 { background: hsl(315 58% 52%); }
.tile-ico.hue-22 { background: hsl(330 58% 52%); }
.tile-ico.hue-23 { background: hsl(345 58% 52%); }

.tile-label {
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}


/* --- result page: link table ----------------------------------------- */
.linktable-card {
  width: min(1000px, 100%);
  margin: 4px auto 0;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 10px;
  box-shadow: 0 10px 30px -22px rgba(20, 34, 48, 0.5);
  backdrop-filter: blur(6px);
  overflow: hidden;
}
.linktable { width: 100%; border-collapse: collapse; text-align: left; }
.linktable th {
  padding: 11px 16px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-faint);
  border-bottom: 1px solid var(--card-line);
  white-space: nowrap;
}
.linktable td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--card-line);
  vertical-align: middle;
}
.linktable tbody tr:last-child td { border-bottom: 0; }
.linktable tbody tr:hover { background: rgba(127, 145, 160, 0.1); }

.lt-idx {
  width: 46px; color: var(--ink-faint);
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.lt-label { width: 210px; }
.lt-name {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 600;
}
.lt-name:hover { color: var(--accent); }
.lt-url { max-width: 0; }            /* lets the ellipsis kick in */
.lt-link {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-soft); text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.lt-link:hover { color: var(--accent); text-decoration: underline; }
.lt-group { width: 96px; }
.lt-chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: rgba(127, 145, 160, 0.18); color: var(--ink-soft);
  font-size: 12px; white-space: nowrap;
}
.lt-go { width: 76px; text-align: right; }
.lt-open {
  color: var(--accent); text-decoration: none; font-size: 13px; white-space: nowrap;
}
.lt-open:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .linktable th, .linktable td { padding: 9px 10px; }
  .lt-idx, .lt-group, .lt-go { display: none; }
  .lt-label { width: 42%; }
}

/* --- result header ---------------------------------------------------- */
.result-head { margin: 8px auto 4px; }
.result-title { margin: 0; font-size: clamp(22px, 3vw, 28px); font-weight: 700; }
.result-sub { margin: 6px 0 0; color: var(--ink-soft); }
.result-meta { margin: 8px 0 0; color: var(--ink-faint); font-size: 13px; }
.result-meta code {
  padding: 2px 7px; border-radius: 6px;
  background: rgba(127, 145, 160, 0.18);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hint { margin-top: 40px; color: var(--ink-faint); font-size: 14px; }

/* Shown when the search box refuses a request (too many wrong codes). */
.notice {
  margin: 18px auto 0; max-width: 520px; padding: 10px 14px;
  border-radius: 8px; font-size: 14px; text-align: center;
  color: #8a4b00; background: #fff4e5; border: 1px solid #ffd9a8;
}

/* --- footer ----------------------------------------------------------- */
.site-footer { padding: 26px 0 22px; text-align: center; }
.footer-actions { display: flex; justify-content: center; gap: 18px; margin-bottom: 8px; }
.footer-btn {
  border: 0; background: transparent; cursor: pointer;
  color: var(--ink-soft); font: inherit; font-size: 13px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}
.footer-btn:hover { color: var(--ink); }
.footer-ico { opacity: 0.75; }
.footer-copy { margin: 0; color: var(--ink-faint); font-size: 12px; }

/* --- responsive ------------------------------------------------------- */
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 6px; } }
@media (max-width: 620px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 4px; }
  .tabs { gap: 14px; margin-top: 26px; }
  .tab { font-size: 15px; }
  .tile-label { font-size: 14px; }
  .corner-widget { font-size: 12px; top: 12px; left: 14px; }
}
@media (max-width: 380px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- image viewer ------------------------------------------------------ */
/* A destination that is a bare image file is shown here instead of being
   handed to the browser's own image document, which draws the picture at its
   natural size — a tall poster then arrives cropped on a phone. */
.viewer { margin: 0 auto; text-align: center; }
.viewer-title { margin: 0 0 10px; font-size: clamp(16px, 2.2vw, 20px); font-weight: 600; }
.viewer-frame {
  margin: 0; display: flex; justify-content: center; align-items: center;
  border-radius: 14px; overflow: hidden;
  background: rgba(20, 26, 34, 0.28);
  box-shadow: 0 10px 34px rgba(15, 23, 34, 0.18);
}
.viewer-img {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: 82vh; object-fit: contain;
}
@supports (max-height: 82dvh) { .viewer-img { max-height: 82dvh; } }
.viewer-actions { margin: 12px 0 0; display: flex; justify-content: center; gap: 18px; }
.viewer-note { margin: 8px 0 0; color: var(--ink-faint); font-size: 12px; }

/* --- language switcher -------------------------------------------------- */
/* Sits in the footer: a visitor who wants another language is looking for it,
   and it must not compete with the search box for attention. */
.lang-switch {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem .7rem;
  margin: .6rem 0 .2rem;
}
/* Same ink as the footer buttons beside it. Hardcoding white was wrong: these
   tokens flip per backdrop theme, so a fixed colour is invisible on every
   theme but one. */
.lang-opt {
  font-size: .82rem; color: var(--ink-soft); text-decoration: none;
  padding: .15rem .1rem; border-bottom: 1px solid transparent;
}
.lang-opt:hover { color: var(--ink); }
.lang-opt.is-active { color: var(--ink); border-bottom-color: var(--ink-faint); }
