/* Ink paper + lacquer red / gold — editorial atelier for a board-game atelier */
:root {
  --ink: #1a1410;
  --ink-soft: #2c241c;
  --paper: #f3ebe0;
  --paper-warm: #ebe1d2;
  --paper-card: #f7f1e8;
  --lacquer: #9e2a2b;
  --lacquer-deep: #7a1f20;
  --gold: #b8954a;
  --gold-soft: #d4b978;
  --muted: #6b5e52;
  --line: rgba(26, 20, 16, 0.12);
  --shadow: 0 12px 40px rgba(26, 20, 16, 0.12);
  --radius: 14px;
  --font-sans: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  position: relative;
  overflow-x: hidden;
}

.bg-wash {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(158, 42, 43, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(184, 149, 74, 0.1), transparent 50%),
    linear-gradient(180deg, #efe6d8 0%, var(--paper) 28%, #ebe3d6 100%);
}

.ink-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.hidden { display: none !important; }

/* —— Hero —— */
.site-header {
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.25rem, 4vw, 2rem) 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.header-inner {
  position: relative;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lacquer);
  font-weight: 600;
}

.hero-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.hero-mark {
  display: inline-grid;
  place-items: center;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--lacquer) 0%, var(--lacquer-deep) 100%);
  color: var(--paper);
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 8px 24px rgba(158, 42, 43, 0.28);
  flex-shrink: 0;
}

.hero-text {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5.5vw, 3.15rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--ink);
}

.hero-sub {
  margin: 1rem 0 0;
  max-width: 36em;
  color: var(--muted);
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
}

/* —— Toolbar —— */
.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem clamp(1.25rem, 4vw, 2rem) 3rem;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0.85rem 0 1rem;
  background: linear-gradient(180deg, rgba(243,235,224,0.96) 60%, rgba(243,235,224,0));
  backdrop-filter: blur(8px);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.1rem;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(26,20,16,0.04);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-wrap:focus-within {
  border-color: rgba(158, 42, 43, 0.45);
  box-shadow: 0 0 0 3px rgba(158, 42, 43, 0.12);
}

.search-icon { color: var(--muted); flex-shrink: 0; }

#search {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
  outline: none;
  min-width: 0;
}

#search::placeholder { color: #9a8b7c; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-card);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

.chip:hover { border-color: rgba(158, 42, 43, 0.35); }

.chip:active { transform: scale(0.97); }

.chip.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.chip:focus-visible {
  outline: 2px solid var(--lacquer);
  outline-offset: 2px;
}

.result-count {
  margin: 0.25rem 0 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
  min-height: 1.4em;
}

/* —— Sections —— */
.category-section {
  margin-bottom: 2.5rem;
}

.category-section[hidden] { display: none !important; }

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid var(--ink);
}

.section-heading h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.section-heading .count {
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

/* —— Cards —— */
.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem 1.2rem 1.15rem;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
  min-height: 168px;
}

.app-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1.2rem;
  right: 1.2rem;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--lacquer), var(--gold));
  opacity: 0.85;
}

.app-card:hover {
  transform: translateY(-3px);
  border-color: rgba(158, 42, 43, 0.28);
  box-shadow: 0 18px 48px rgba(26, 20, 16, 0.16);
}

.app-card[hidden] { display: none !important; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.35;
  color: var(--ink);
}

.badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  background: rgba(158, 42, 43, 0.1);
  color: var(--lacquer-deep);
  white-space: nowrap;
}

.card-blurb {
  margin: 0;
  flex: 1;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

.btn-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1;
  min-height: 46px;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}

.btn-open:hover { background: var(--lacquer); }
.btn-open:active { transform: scale(0.98); }
.btn-open:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.btn-open svg { flex-shrink: 0; opacity: 0.9; }

.btn-copy {
  appearance: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper-warm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}

.btn-copy:hover {
  border-color: var(--gold);
  color: var(--lacquer-deep);
  background: #f5edd8;
}

.btn-copy:focus-visible {
  outline: 2px solid var(--lacquer);
  outline-offset: 2px;
}

.btn-copy.is-copied {
  border-color: var(--lacquer);
  color: var(--lacquer);
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.35);
}

/* —— Footer —— */
.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2rem) 3rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.footer-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), var(--lacquer), var(--gold-soft), transparent);
  margin-bottom: 1.25rem;
  opacity: 0.7;
}

.site-footer p { margin: 0.35rem 0; }
.footer-meta { font-size: 0.8rem; opacity: 0.85; }

@media (max-width: 480px) {
  .hero-mark { width: 2.6rem; height: 2.6rem; font-size: 1.3rem; }
  .app-card { min-height: 0; }
}

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