/* 街头色票 Street Palette */

:root {
  --paper: #F5F1E8;
  --paper-deep: #ECE6D8;
  --ink: #1A1A17;
  --ink-soft: #55524A;
  --ink-faint: #8A867B;
  --rule: #1A1A17;
  --rule-soft: rgba(26, 26, 23, 0.18);
  --focus: #1F5BD6;

  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --max: 1280px;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, figure { margin: 0; }

button {
  font: inherit;
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Masthead ---------- */

.masthead,
.catalog,
.colophon {
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.masthead { padding-top: 20px; }

.masthead__bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.masthead__title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 22rem);
  align-items: end;
  gap: 24px 48px;
  padding: clamp(28px, 6vw, 72px) 0 clamp(24px, 4vw, 40px);
}

.masthead h1 {
  display: flex;
  flex-direction: column;
  font-weight: 400;
  line-height: 1;
}

.masthead__zh {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(56px, 11vw, 148px);
  letter-spacing: 0.04em;
}

.masthead__en {
  margin-top: 0.6em;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(20px, 2.6vw, 32px);
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.masthead__lede {
  font-family: var(--serif);
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.8;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

/* ---------- Hero strip ---------- */

.hero__strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  height: clamp(200px, 34vw, 380px);
  border: 1px solid var(--rule);
}

.hero__chip {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 14px;
  border: 0;
  border-right: 1px solid var(--rule-soft);
  background: var(--c);
  color: var(--on);
  text-align: left;
  cursor: pointer;
}
.hero__chip:last-child { border-right: 0; }

.hero__chip:focus-visible {
  outline-offset: -5px;
  outline-color: var(--on);
}

.hero__no {
  position: absolute;
  top: 12px;
  left: 14px;
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.8;
}

.hero__name {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.9;
}

.hero__hex {
  font-family: var(--mono);
  font-size: clamp(13px, 1.4vw, 17px);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hero__caption {
  padding: 10px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Catalog ---------- */

.catalog {
  padding-top: clamp(48px, 8vw, 96px);
  padding-bottom: clamp(48px, 8vw, 96px);
  outline: none;
}

.catalog__head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--rule);
}

.catalog__title {
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  min-height: 40px;
  padding: 6px 18px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.filter:hover { background: var(--paper-deep); }
.filter[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.catalog__status {
  min-height: 1.7em;
  padding-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(40px, 5vw, 64px) clamp(28px, 4vw, 56px);
  padding-top: 24px;
}

/* ---------- Palette card ---------- */

.card[hidden] { display: none; }

.card.is-entering {
  animation: card-in 0.42s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.card__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 16px;
  align-items: baseline;
  padding-bottom: 12px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}

.card__no {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
}

.card__title {
  font-family: var(--serif);
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.card__en {
  grid-column: 2;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
}

.card__tags {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.card__tags li {
  padding: 0 8px;
  border: 1px solid var(--rule-soft);
  font-size: 12px;
  line-height: 22px;
  color: var(--ink-soft);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--rule);
}

.swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--rule);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}
.swatch:last-child { border-right: 0; }

.swatch__color {
  display: block;
  height: clamp(150px, 16vw, 210px);
  background: var(--c);
  transition: filter 0.2s ease;
}

.swatch:hover .swatch__color { filter: brightness(1.04) saturate(1.05); }

.swatch:focus-visible {
  outline-offset: -4px;
  z-index: 1;
}

.swatch__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 10px 12px;
  border-top: 1px solid var(--rule);
}

.swatch__hex {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.swatch__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--ink-soft);
}

/* 复制反馈：色块上的短暂标记 */
.copied-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 4px 10px;
  background: var(--on, var(--ink));
  color: var(--c, var(--paper));
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: mark 1.2s ease both;
}

.swatch .copied-mark { top: calc(clamp(150px, 16vw, 210px) / 2); }

@keyframes mark {
  0%   { opacity: 0; transform: translate(-50%, -30%); }
  15%  { opacity: 1; transform: translate(-50%, -50%); }
  80%  { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -50%); }
}

.card__foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding-top: 14px;
}

.card__desc {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.85;
}

.copy-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 16px;
  border: 1px solid var(--rule);
  background: transparent;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.copy-all:hover { background: var(--paper-deep); }
.copy-all.is-done {
  background: var(--ink);
  color: var(--paper);
}

.copy-all__dots {
  display: inline-flex;
}
.copy-all__dots i {
  width: 8px;
  height: 14px;
  background: var(--c);
}

.noscript {
  padding: 24px 0;
  color: var(--ink-soft);
}

/* ---------- Footer & toast ---------- */

.colophon {
  padding-bottom: 40px;
}
.colophon p {
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink-soft);
}
.colophon .colophon__meta {
  padding-top: 4px;
  border-top: 0;
  font-family: var(--mono);
  color: var(--ink-faint);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast__chip {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(245, 241, 232, 0.5);
  background: var(--c);
}
.toast__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toast code { font-family: var(--mono); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .masthead__title { grid-template-columns: minmax(0, 1fr); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .swatch__color { height: clamp(140px, 30vw, 200px); }
  .swatch .copied-mark { top: calc(clamp(140px, 30vw, 200px) / 2); }
}

@media (max-width: 640px) {
  .hero__strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: auto;
  }
  .hero__chip {
    min-height: 120px;
    border-bottom: 1px solid var(--rule-soft);
  }
  .hero__chip:nth-child(3n) { border-right: 0; }
  .hero__chip:nth-child(n + 4) { border-bottom: 0; }
  .hero__name { font-size: 12px; }

  .swatch__color { height: 112px; }
  .swatch .copied-mark { top: 56px; }
  .swatch__meta { padding: 8px 6px 10px; }
  .swatch__hex { font-size: 12px; letter-spacing: 0; }
  .swatch__name { font-size: 11px; }

  .card__foot { grid-template-columns: minmax(0, 1fr); }
  .copy-all { justify-self: start; }

  .filter { padding: 6px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  .card.is-entering { animation: none; }
  .copied-mark { animation: none; }
  .toast { transform: translate(-50%, 0); }
}
