/* Topical Bali — soft modern static site. All CSS local; no external dependencies. */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: #faf6ef;
  color: #2e2a24;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}
a { color: #5b4a8a; }
img { max-width: 100%; }

/* Category tints (muted pastels, matching the Topical Bali Space) */
.cat-water     { --tile-bg: #dceef7; --pill-bg: #b7d9ec; --pill-fg: #1d4e68; }
.cat-wildlife  { --tile-bg: #dff0dc; --pill-bg: #b9dfb4; --pill-fg: #2c5a24; }
.cat-food      { --tile-bg: #f6ddd0; --pill-bg: #eec0a6; --pill-fg: #6e3418; }
.cat-culture   { --tile-bg: #ecdcef; --pill-bg: #d9bde0; --pill-fg: #4e2a5c; }
.cat-arts      { --tile-bg: #f8dfe2; --pill-bg: #f0bfc6; --pill-fg: #6d2a34; }
.cat-craft     { --tile-bg: #f6e8c8; --pill-bg: #ecd29a; --pill-fg: #5f4a12; }
.cat-land      { --tile-bg: #efe4d2; --pill-bg: #e0cba6; --pill-fg: #5a4520; }
.cat-history   { --tile-bg: #dbe2ea; --pill-bg: #bccadb; --pill-fg: #2f435c; }
.cat-people    { --tile-bg: #d4ebe8; --pill-bg: #aed8d3; --pill-fg: #1e4f4a; }
.cat-practical { --tile-bg: #e8e6e2; --pill-bg: #cfcbc2; --pill-fg: #4a463e; }

.site-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 8px;
}
.site-title {
  font-size: 2rem;
  font-weight: 800;
  color: #2e2a24;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.site-tagline { margin: 2px 0 0; color: #6d675c; font-size: 1.05rem; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 20px 40px; }
.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 32px;
  color: #8a8378;
  font-size: 0.9rem;
}

/* --- Search --- */
.search-section { margin: 18px 0 8px; }
.search-section label {
  display: block;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 8px;
}
.search-section input[type="search"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.05rem;
  border: none;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(60, 45, 20, 0.10);
  outline: none;
  color: #2e2a24;
}
.search-section input[type="search"]:focus {
  box-shadow: 0 2px 14px rgba(60, 45, 20, 0.18), 0 0 0 3px #d9c9a8;
}
.search-results { margin-top: 12px; }
.search-results .result-topic { font-weight: 700; margin: 14px 0 4px; }
.search-results .result-topic a { color: #2e2a24; text-decoration: none; }
.search-results .result-topic a:hover { text-decoration: underline; }
.search-result {
  display: block;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(60, 45, 20, 0.08);
  padding: 10px 14px;
  margin: 6px 0;
  text-decoration: none;
  color: #2e2a24;
}
.search-result:hover { box-shadow: 0 4px 14px rgba(60, 45, 20, 0.14); }
.search-result .r-title { font-weight: 700; }
.search-result .r-snippet { color: #6d675c; font-size: 0.95rem; }
.search-result .r-kind {
  float: right;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eee9dd;
  color: #5a5344;
}
.search-empty { color: #6d675c; padding: 10px 2px; }

/* --- Legend / filter chips --- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 6px;
}
.legend-chip {
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--tile-bg);
  color: #2e2a24;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 4px rgba(60, 45, 20, 0.10);
}
.legend-chip .chip-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--pill-bg);
  border: 1px solid rgba(0,0,0,0.12);
}
.legend-chip .chip-count { color: #6d675c; font-size: 0.82rem; }
.legend-chip[aria-pressed="true"] {
  outline: 2px solid var(--pill-fg);
  outline-offset: 1px;
  font-weight: 700;
}
.filter-note { color: #6d675c; margin: 4px 0 0; }
.filter-note button {
  border: none; background: none; cursor: pointer;
  color: #5b4a8a; font: inherit; text-decoration: underline; padding: 0;
}

/* --- Tiles --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 32px 28px;
  margin-top: 44px;
}
.tile {
  position: relative;
  display: block;
  height: 208px;
  background: var(--tile-bg);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(60, 45, 20, 0.10);
  padding: 10px 150px 12px 18px;
  text-decoration: none;
  color: #2e2a24;
  overflow: visible;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(60, 45, 20, 0.16); }
.tile .pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  margin-bottom: 6px;
}
.tile-name {
  display: block;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.tile-summary {
  display: block;
  margin-top: 6px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #4d463c;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-updated {
  position: absolute;
  right: 14px;
  bottom: 10px;
  font-size: 0.78rem;
  color: #6d675c;
}
.tile-art {
  position: absolute;
  top: -26px;
  right: 10px;
  height: 150px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  pointer-events: none;
}
.tile-art.art-portrait { height: 150px; }
.tile-art.art-narrow { height: 120px; }
.tile-art.art-tall { height: 180px; top: -34px; }
.tile.hidden { display: none; }

/* --- Topic page --- */
.topic-nav { margin: 8px 0 18px; }
.topic-nav.bottom { margin: 28px 0 0; display: flex; justify-content: space-between; }
.topic-nav a { text-decoration: none; font-weight: 600; }
.topic-nav a:hover { text-decoration: underline; }
.topic-heading {
  background: var(--tile-bg);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(60, 45, 20, 0.10);
  padding: 20px 24px;
  margin-bottom: 26px;
}
.topic-heading .pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
}
.topic-heading h1 { margin: 8px 0 4px; font-size: 1.9rem; letter-spacing: -0.02em; }
.topic-meta { margin: 0; color: #6d675c; }

.card-list { display: grid; gap: 20px; }
.card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 3px 14px rgba(60, 45, 20, 0.09);
  padding: 22px 24px;
  scroll-margin-top: 16px;
}
.card:target { box-shadow: 0 3px 14px rgba(60, 45, 20, 0.09), 0 0 0 3px #d9c9a8; }
.card h2 { margin: 8px 0 8px; font-size: 1.25rem; line-height: 1.3; }
.card p { margin: 0 0 10px; }
.card p:last-child { margin-bottom: 0; }
.kind {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.kind-fact    { background: #dcebf7; color: #1d4e68; }
.kind-figure  { background: #f6e8c8; color: #5f4a12; }
.kind-place   { background: #dff0dc; color: #2c5a24; }
.kind-tip     { background: #f8dfe2; color: #6d2a34; }
.card-photo { margin: 4px 0 14px; }
.card-photo img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 14px;
}
.words div { padding: 2px 0; }
.see-also {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed #ddd5c4;
  font-size: 0.95rem;
  color: #6d675c;
}
.see-also-line { padding: 2px 0; }
.see-also-line a { text-decoration: none; }
.see-also-line a:hover { text-decoration: underline; }

/* --- Print --- */
@media print {
  body { background: #fff; }
  .site-header .site-tagline, .search-section, .legend, .filter-note,
  .site-footer, .topic-nav { display: none !important; }
  .tiles { display: block; }
  .tile { box-shadow: none; border: 1px solid #ccc; margin-bottom: 12px; page-break-inside: avoid; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .card-photo img { max-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile { transition: none; }
}
@media (max-width: 560px) {
  .tile { padding-right: 130px; }
  .tile-art { max-width: 120px; }
}
