/* Re:Earth Places' landing page. Rules: DESIGN.md. */

:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #16191a;
  --ink-dim: #5b6164;
  --line: #e2ded5;
  /* The one accent: what was found, and the selected link. */
  --pin: #0d7a68;
  --pin-soft: rgba(13, 122, 104, 0.1);
  --code-bg: #efece4;
  --font: "IBM Plex Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111413;
    --surface: #181c1b;
    --ink: #e8e6e1;
    --ink-dim: #9aa19f;
    --line: #2a302e;
    --pin: #4cc3ac;
    --pin-soft: rgba(76, 195, 172, 0.14);
    --code-bg: #1e2321;
    color-scheme: dark;
  }
}

/* One language at a time: the address decides (index.html). */
html[data-lang="en"] [lang="ja"],
html[data-lang="ja"] [lang="en"] {
  display: none;
}

* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: calc(var(--reearth-nav-h) + 16px);
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  /* No last line of one short word. */
  text-wrap: pretty;
}
/* Japanese breaks between phrases (表示します。 whole, not 表示しま / す。),
   where the browser can tell them; elsewhere it breaks as before. */
:lang(ja) {
  word-break: auto-phrase;
}
a {
  color: inherit;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}
a:hover {
  color: var(--pin);
  text-decoration-color: currentColor;
}
code,
pre {
  font-family: var(--mono);
  font-size: 0.86em;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

reearth-nav {
  --fg: var(--ink);
  --fg-dim: var(--ink-dim);
  --bg: rgba(246, 244, 239, 0.8);
  --mark: var(--pin);
}
@media (prefers-color-scheme: dark) {
  reearth-nav {
    --fg: #e8e6e1;
    --fg-dim: rgba(232, 230, 225, 0.65);
    --bg: rgba(17, 20, 19, 0.75);
    --line: rgba(232, 230, 225, 0.08);
  }
}
.lang-switch {
  display: flex;
  gap: 12px;
  font: 500 13px/1 var(--font);
}
.lang-switch a {
  white-space: nowrap;
  color: var(--ink-dim);
  text-decoration: none;
}
html[data-lang="en"] [data-set-lang="en"],
html[data-lang="ja"] [data-set-lang="ja"] {
  color: var(--ink);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(var(--reearth-nav-h) + 40px) 24px 0;
}
section + section {
  margin-top: 96px;
}
h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}
h2 {
  font-size: 1.6rem;
}
.section-lede {
  color: var(--ink-dim);
  max-width: 40rem;
  margin: 12px 0 0;
}

/* ---- hero: the search is the page's first thing ---- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 40px;
  align-items: start;
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--pin);
  font-weight: 600;
  font-size: 0.9rem;
}
/* The headline alone in a mincho, the page's one change of face. */
.hero h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  /* English lines of even length, no word left alone on the last. */
  text-wrap: balance;
}
/* A mincho's kana are smaller than its kanji and stand apart at full width;
   Shippori Mincho B1 as Google Fonts serves it has no palt to set them by
   their own widths, so the line is drawn in by tracking. */
html[data-lang="ja"] .hero h1 {
  letter-spacing: -0.04em;
}
/* A Japanese headline breaks between its phrases, not inside a word. */
.hero h1 .line {
  display: inline-block;
}
.lede {
  margin: 16px 0 24px;
  color: var(--ink-dim);
}
.search input {
  width: 100%;
  font: 1.05rem var(--font);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search input:focus {
  border-color: var(--pin);
  box-shadow: 0 0 0 3px var(--pin-soft);
}
/* One-click queries under the box, as on Mokuji's page. */
.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.examples button {
  border: 1px solid var(--line);
  background: none;
  border-radius: 999px;
  padding: 4px 12px;
  font: 0.85rem var(--font);
  color: var(--ink-dim);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.examples button:hover,
.examples button:focus-visible {
  border-color: var(--pin);
  color: var(--ink);
}
.results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  min-height: 1px;
}
.results li button {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.results li button:hover,
.results li button:focus-visible,
.results li.selected button {
  background: var(--pin-soft);
}
.results .kind {
  grid-row: span 2;
  align-self: center;
  font: 500 11px/1 var(--mono);
  color: var(--pin);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 3px 5px;
}
.results .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.results .where {
  font-size: 0.85rem;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.results .empty {
  padding: 8px 10px;
  color: var(--ink-dim);
}
.hint {
  font-size: 0.9rem;
  color: var(--ink-dim);
  margin: 16px 0 0;
}
.credits {
  font-size: 0.75rem;
  color: var(--ink-dim);
  margin: 8px 0 0;
}
.map {
  height: min(560px, 70vh);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

/* ---- three ways: the same size, none set apart; each its words, then
   its code, the code with its own line breaks ---- */
.cards {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}
.card {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  grid-template-rows: auto 1fr;
  gap: 8px 32px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.card h3 {
  font-size: 1.1rem;
}
.card p {
  color: var(--ink-dim);
  margin: 0;
}
.card pre {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  margin: 0;
  padding: 14px;
  background: var(--code-bg);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.55;
}

/* ---- datasets ---- */
.dataset-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 28px;
}
.dataset-table th {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-dim);
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--line);
}
.dataset-table td {
  padding: 14px 12px 14px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.dataset-table .id {
  font-family: var(--mono);
  font-size: 0.9rem;
  white-space: nowrap;
}
.dataset-table .endpoint {
  display: block;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.dataset-table .count {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
}
.dataset-table .try {
  all: unset;
  cursor: pointer;
  color: var(--pin);
  white-space: nowrap;
}
.dataset-table .try:hover {
  text-decoration: underline;
}
/* Downloading is not trying: in the ink, not the accent. */
.dataset-table .download {
  font-size: 0.9rem;
  white-space: nowrap;
}
.dataset-table .download .size {
  color: var(--ink-dim);
}
.dataset-table .copy {
  all: unset;
  cursor: pointer;
  display: block;
  margin-top: 2px;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}
.dataset-table .copy:hover,
.dataset-table .copy:focus-visible {
  text-decoration-color: currentColor;
}
.dataset-table .files {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.dataset-table .command {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  white-space: normal;
  overflow-wrap: anywhere;
  user-select: all;
}
.dataset-table .license {
  font-size: 0.85rem;
  line-height: 1.5;
}
/* A license's name on one line: 公共データ利用規約 and 1.0 apart read as two. */
.dataset-table .license a {
  white-space: nowrap;
}
.license-note {
  margin: 16px 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.dataset-table .updated {
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.more {
  margin: 16px 0 0;
}

/* ---- open data ---- */
.sources {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 8px;
  max-width: 52rem;
  font-size: 0.85rem;
  color: var(--ink-dim);
}
.sources li {
  min-width: 0;
  overflow-wrap: anywhere;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}

/* ---- start: the page ends on what to do ---- */
.links {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.links a {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  background: var(--surface);
}
.links a:hover {
  border-color: var(--pin);
}

.footer {
  max-width: 1120px;
  margin: 96px auto 0;
  padding: 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 0.85rem;
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .map {
    height: 380px;
  }
  .card {
    grid-template-columns: minmax(0, 1fr);
  }
  .card pre {
    grid-column: 1;
    grid-row: auto;
    margin-top: 10px;
  }
  /* The table reads as rows of blocks on a phone. */
  .dataset-table thead {
    display: none;
  }
  .dataset-table,
  .dataset-table tbody,
  .dataset-table tr,
  .dataset-table td {
    display: block;
  }
  .dataset-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .dataset-table td {
    border: 0;
    padding: 2px 0;
  }
}
@media (max-width: 480px) {
  main {
    padding-left: 16px;
    padding-right: 16px;
  }
  section + section {
    margin-top: 64px;
  }
}

/* ---- /attribution (src/attribution.ts): each dataset's credits ---- */
main.attribution {
  max-width: 820px;
}
main.attribution h1 {
  font-size: 2rem;
}
main.attribution .eyebrow a {
  text-decoration: none;
}
.credit-set {
  margin-top: 28px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
section.credit-set + section.credit-set {
  margin-top: 16px;
}
.credit-set h2 {
  font-size: 1.1rem;
}
.credit-set .about {
  margin: 4px 0 12px;
  color: var(--ink-dim);
}
.credit-set .licenses {
  margin: 0 0 12px;
}
.credit-set .label {
  font-size: 0.8rem;
  color: var(--ink-dim);
  margin-right: 8px;
}
.credit-set .note {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--ink-dim);
}
.credit-set .sources {
  margin: 0;
  max-width: none;
}
main.attribution .json {
  margin: 28px 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.credit-set .text {
  margin: 12px 0 0;
  font-size: 0.85rem;
}
.credit-set .text span {
  display: block;
  color: var(--ink-dim);
}
.dataset-table .credits-file {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.82rem;
}
