/* The web palette. Leans on site.css for tokens and controls; this file is
   the app chrome: a full-height layout where the site pages are documents. */

html, body { height: 100%; }
body { padding: 0; display: flex; flex-direction: column; }

#login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(400px, 100%); }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card h1 span { color: var(--accent); }

#app { display: flex; flex-direction: column; height: 100%; }

#topbar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#query {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}
#query:focus { border-color: var(--accent); }
#topbar select, #topbar button, #topbar a {
  padding: 8px 12px;
  font: inherit;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
}
#topbar select:hover, #topbar button:hover, #topbar a:hover {
  color: var(--text);
  border-color: var(--accent);
}
#filter-toggle.active { color: #14110f; background: var(--accent); border-color: var(--accent); }

#filter-panel {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  /* A ceiling: a fourth group made this tall enough to hide the results it
     exists to narrow. */
  max-height: 45vh;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.filter-group { min-width: 200px; flex: 1 1 220px; }
.filter-group > label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.filter-group input[type="text"], .filter-group select {
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 7px;
}
/* Every suggestion box is capped. The character list was added without one
   and grew to its full 60 chips, pushing the filter panel over the window. */
#tag-suggestions, #owner-list, #character-suggestions {
  max-height: 130px;
  overflow-y: auto;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
#owner-list { flex-direction: column; flex-wrap: nowrap; }
.tag-option {
  padding: 3px 9px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.tag-option:hover { color: var(--text); border-color: var(--accent); }
.tag-option .count { font-size: 11px; margin-left: 4px; }
.owner-option { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.owner-option .count { color: var(--muted); margin-left: auto; }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); margin-top: 10px; cursor: pointer; }
.linkish { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 8px 0 0; }
.linkish:hover { color: var(--text); }

#chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
.chip {
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
}
.chip::after { content: " ✕"; color: var(--muted); }

#grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  /* max-content, or rows collapse: in a definite-height grid Chromium treats
     the tiles' aspect-ratio height as compressible (overflow:hidden zeroes
     their minimum), and squeezes every row to fit the box -- the more pages
     loaded, the flatter the rows, until tiles pile on top of each other.
     Same line, same reason, as the desktop palette's grid. */
  grid-auto-rows: max-content;
  gap: 8px;
  padding: 10px 12px;
  align-content: start;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel);
  border: 2px solid transparent;
  cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover { border-color: var(--line); }
.tile.selected { border-color: var(--accent); }
.tile .badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 7px;
  font-size: 10px;
  color: var(--text);
  background: rgba(20, 17, 15, .75);
  border-radius: 999px;
  pointer-events: none;
}
#sentinel { height: 1px; grid-column: 1 / -1; }

#detail, #upload-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 17, 15, .82);
}
.detail-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
#detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 6px 10px;
  font: inherit;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
#detail-close:hover { color: #fff; background: #b3261e; border-color: #b3261e; }
#detail-media { display: grid; place-items: center; margin-bottom: 12px; }
#detail-media img, #detail-media video {
  max-width: 100%;
  max-height: 55vh;
  border-radius: 9px;
}
#detail-title { font-size: 15px; overflow-wrap: anywhere; margin-bottom: 6px; }
#detail-desc { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
#detail-tags { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-bottom: 12px; font-size: 12px; }
.fact-tag { cursor: pointer; border-bottom: 1px dotted var(--muted); color: var(--muted); }
.fact-tag:hover { color: var(--accent); border-bottom-color: var(--accent); }
#copy-link { width: 100%; padding: 12px; }
#detail-status { display: block; margin-top: 8px; }

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

#statusbar {
  padding: 7px 12px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#status.good { color: #a6e3a1; }

@media (max-width: 560px) {
  #topbar { flex-wrap: wrap; }
  #query { flex-basis: 100%; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
