/* The Cutout Encyclopedia — white-ground cutout collage.
   Pure white wall with dense, borderless cutouts; warm paper chrome,
   serif plate labels on the detail card only, one moss-green ink accent. */

:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));

  --paper: #fffdf9;
  --paper-warm: #fbf5ef;
  --ink: #061720;
  --muted: #6f7170;
  --hair: #ded6cb;
  --hair-strong: #b9ad9e;
  --accent: #2f5547;
  --accent-soft: #e6ede7;
  --plate-ink: #8a8174;
  --shadow: 0 14px 36px rgba(6, 23, 32, 0.1);

  --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  background: #ffffff;
  color: var(--ink);
  font-family: var(--sans);
}

body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #ffffff;
  border-bottom: 1px solid var(--hair);
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: 8px;
  transition: padding 0.18s ease, box-shadow 0.18s ease;
}

/* fade objects out as they slide under the sticky bar: a white gradient
   glued to the bar's bottom edge, so no cutout is ever visibly clipped */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 48px;
  background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

/* compact single-purpose bar once the page is scrolled: brand + meta rows
   shrink out, search / shuffle / finds stay on one row */
body.scrolled .topbar {
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: 6px;
  box-shadow: 0 1px 0 rgba(222, 214, 203, 0.6);
}

body.scrolled .topbar-brand-row,
body.scrolled .topbar-meta-row {
  display: none;
}

body.scrolled .topbar-control-row {
  margin-top: 0;
}

body.scrolled .topbar-morelike-row {
  margin-top: 0;
}

.topbar-row {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand-row {
  padding-top: 2px;
  justify-content: space-between;
  align-items: flex-start;
}

.brand-block {
  min-width: 0;
}

.kicker {
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-top: 2px;
}

.lang-toggle {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
  padding: 7px 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.lang-toggle option {
  font-family: var(--sans);
}

.topbar-control-row {
  margin-top: 12px;
}

.topbar-morelike-row {
  margin-top: 8px;
  justify-content: flex-start;
  gap: 8px;
}

.morelike-thumb {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 3px rgba(6, 23, 32, 0.12));
}

.morelike-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.morelike-clear {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
}

.morelike-clear:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.morelike-hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 28px 16px 0;
}

.morelike-hint[hidden] {
  display: none;
}

.search-form {
  position: relative;
  flex: 1 1 60%;
  min-width: 60%;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 44px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
  padding: 0 34px 0 10px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  appearance: none;
  -webkit-appearance: none;
}

.search-input::placeholder {
  color: #a39a8d;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.search-clear {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--plate-ink);
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: 0;
}

.search-clear:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.shuffle-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0;
  transition: filter 0.12s ease, transform 0.06s ease;
  touch-action: manipulation;
}

.shuffle-btn:hover {
  filter: brightness(1.07);
}

.shuffle-btn:active {
  transform: translateY(1px);
}

.finds-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
  white-space: nowrap;
}

.finds-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.topbar-meta-row {
  margin-top: 5px;
  align-items: center;
  justify-content: space-between;
}

.count-label {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.instruction {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--muted);
  min-width: 0;
  flex: 1 1 auto;
  margin-left: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- wall ---------------- */

#wall-viewport {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 6px 56px;
}

/* pure white ground, edge to edge: the cutouts alone are the composition */
#wall {
  position: relative;
  width: 100%;
  background: #ffffff;
}

/* each cutout is a bare button — no frame, no shadow, no label */
.obj {
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: rotate(var(--rot, 0deg));
  transform-origin: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.obj .specimen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transition: transform 0.18s ease;
}

.obj:hover {
  z-index: 3;
}

.obj:hover .specimen {
  transform: scale(1.06);
}

.obj:active .specimen {
  transform: scale(1.02);
}

.wall-fade {
  animation: wallFade 0.35s ease both;
}

@keyframes wallFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------- empty state ---------------- */

.empty-state {
  text-align: center;
  padding: 64px 20px 40px;
}

.empty-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 24px;
  color: var(--ink);
  margin-bottom: 10px;
}

.empty-body {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 420px;
  margin: 0 auto 22px;
}

.empty-hint {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--plate-ink);
  margin-top: 14px;
}

/* ---------------- overlays ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: var(--eazo-safe-area-top);
}

.overlay[hidden] {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 23, 32, 0.45);
}

/* detail sheet — the specimen source card */

.detail-sheet {
  position: relative;
  width: min(640px, 100% - 16px);
  max-height: 92dvh;
  margin-bottom: var(--eazo-safe-area-bottom);
  background: var(--paper);
  border: 1px solid var(--hair-strong);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.22s ease both;
  box-shadow: 0 18px 50px rgba(6, 23, 32, 0.28);
}

@keyframes sheetUp {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
}

.sheet-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.detail-scroll {
  overflow-y: auto;
  padding: 18px 18px calc(var(--eazo-safe-area-bottom) + 16px);
}

.detail-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 18px -18px calc(-1 * (var(--eazo-safe-area-bottom) + 16px));
  padding: 14px 18px calc(var(--eazo-safe-area-bottom) + 16px);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0), var(--paper) 22%);
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-image-wrap {
  border: 1px solid var(--hair);
  background: linear-gradient(180deg, #fff, var(--paper-warm));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  margin-bottom: 14px;
  min-height: 150px;
}

.detail-image {
  max-height: 240px;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 8px rgba(6, 23, 32, 0.12));
}

#detail-plate-no {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 5px;
}

.detail-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}

.detail-description {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  color: #293238;
  margin-bottom: 6px;
}

.detail-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 4px;
}

.detail-extract {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  line-height: 1.55;
  color: #293238;
  border-left: 2px solid var(--hair-strong);
  padding-left: 12px;
  margin: 0;
}

.detail-credit,
.detail-licence {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
}

.detail-source {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--accent);
  word-break: break-all;
  margin-top: 6px;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.btn-primary {
  flex: 1 1 auto;
  min-height: 46px;
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.12s ease;
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.btn-ghost {
  flex: 1 1 auto;
  min-height: 46px;
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost.is-pinned {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.detail-article {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* finds sheet */

.finds-sheet {
  position: relative;
  width: min(600px, 100% - 16px);
  max-height: 92dvh;
  margin-bottom: var(--eazo-safe-area-bottom);
  background: var(--paper);
  border: 1px solid var(--hair-strong);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.22s ease both;
  box-shadow: 0 18px 50px rgba(6, 23, 32, 0.28);
}

.finds-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hair);
  flex: 0 0 auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 0;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.finds-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finds-spacer {
  width: 36px;
  flex: 0 0 auto;
}

#finds-content {
  overflow-y: auto;
  padding: 16px 18px 20px;
}

.finds-empty {
  text-align: center;
  padding: 48px 20px 56px;
}

.finds-count {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink);
  margin-bottom: 12px;
}

.finds-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.finds-section {
  margin-top: 18px;
}

.finds-section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 10px;
}

.finds-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.finds-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair);
  padding: 6px 10px;
}

.finds-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.finds-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  text-align: left;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: 0;
  padding: 8px 10px;
  transition: border-color 0.12s ease;
}

.finds-card:hover {
  border-color: var(--accent);
}

.finds-card img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(6, 23, 32, 0.08));
  flex: 0 0 auto;
}

.finds-card-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finds-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.finds-strip-item {
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: 0;
  padding: 8px;
  transition: border-color 0.12s ease;
}

.finds-strip-item:hover {
  border-color: var(--accent);
}

.finds-strip-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(6, 23, 32, 0.08));
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--eazo-safe-area-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 80;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 14px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(6, 23, 32, 0.3);
}

/* ---------------- desktop ---------------- */

@media (min-width: 760px) {
  .wordmark {
    font-size: 34px;
  }

  .instruction {
    max-width: 430px;
  }

  #wall-viewport {
    padding-top: 12px;
  }

  .detail-sheet {
    width: min(600px, 100% - 16px);
  }
}

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