/* Torah Nearby — genre: INSTITUTIONS (clarity is the whole job).
   Palette sampled from the design brief's Institutions row: #F1EADA ground,
   #181818 ink, #2779A7 accent, #BCBFB0 rule, #ECD06F mark. Muted tones are
   darkened off that row to clear 4.5:1, which the sampled greys do not.
   Type: one oversized display voice against small monospaced metadata.
   Photographs come only from each organisation's own domain; where there is
   none, type carries the page. */

:root {
  --ground: #F1EADA;
  --raise:  #F7F3E9;
  --ink:    #181818;
  --muted:  #5F584C;
  --line:   #CFC6B4;
  --accent: #1F6088;
  --mark:   #ECD06F;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --gap: clamp(1.25rem, 4vw, 3rem);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #111111; --raise: #191919; --ink: #F1EADA; --muted: #A79E8E;
    --line: #2E2E2C; --accent: #8FC3E0;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 clamp(1rem, 0.96rem + 0.2vw, 1.0625rem)/1.6 var(--sans);
  text-rendering: optimizeLegibility;
}
main { max-width: 64rem; margin: 0 auto; padding: var(--gap); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--ink); color: var(--ground); padding: .6rem 1rem; z-index: 9; }

/* --- bars ---------------------------------------------------------------- */
.bar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; padding: 1.1rem var(--gap); border-bottom: 1px solid var(--line);
}
.wordmark { font: 600 1rem/1 var(--mono); letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.bar nav { display: flex; gap: 1.25rem; }
.bar nav a, .foot a { font: 400 .8125rem/1 var(--mono); color: var(--muted); text-decoration: none; }
.bar nav a:hover, .foot a:hover { color: var(--accent); }
.foot { border-bottom: 0; border-top: 1px solid var(--line); margin-top: 4rem; }
.foot .meta { max-width: 40rem; margin: 0; }

/* --- type ---------------------------------------------------------------- */
.display {
  font: 400 clamp(2rem, 1.35rem + 2.1vw, 3.15rem)/1.08 var(--display);
  letter-spacing: -0.022em; margin: .35em 0 .5em; max-width: 18ch;
}
.entity .display { max-width: 20ch; }
.home .display { max-width: 32ch; }
.sub { font: 500 1.0625rem/1.3 var(--sans); letter-spacing: -.01em; margin: 2.5rem 0 .75rem; }
.lede { font: 400 clamp(1.125rem, 1rem + .5vw, 1.375rem)/1.45 var(--display); max-width: 34ch; margin: 0 0 1rem; }
.teaser { max-width: 56ch; color: var(--ink); }
.meta { font: 400 .8125rem/1.5 var(--mono); color: var(--muted); letter-spacing: 0; }
.count { margin: 0; }
a { color: var(--accent); }

/* --- the ask ------------------------------------------------------------- */
.ask { padding: clamp(.75rem, 3vh, 2rem) 0 0; }
.ask .display { margin-bottom: .25em; }
.where { margin: 0 0 1rem; }
.where label { display: block; margin-bottom: .5rem; }
.where .row { display: flex; gap: .5rem; max-width: 30rem; }
input, textarea {
  font: 400 1rem/1.4 var(--sans); color: var(--ink); background: var(--raise);
  border: 1px solid var(--line); border-radius: 2px; padding: .7rem .8rem; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: 500 .9375rem/1 var(--sans); background: var(--ink); color: var(--ground);
  border: 1px solid var(--ink); border-radius: 2px; padding: .75rem 1.2rem; cursor: pointer;
}
button:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.link {
  background: none; border: 0; padding: .6rem 0 0; color: var(--muted);
  font: 400 .8125rem/1 var(--mono); text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: var(--accent); background: none; }

/* --- results ------------------------------------------------------------- */
.out { margin-top: 2rem; }
.out:empty { margin: 0; }
.out ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.out li { border-bottom: 1px solid var(--line); }
.out a {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem;
  align-items: baseline; padding: 1.1rem 0; text-decoration: none; color: var(--ink);
}
.out a:hover .who { color: var(--accent); }
.who { font: 400 clamp(1.25rem, 1.1rem + .6vw, 1.75rem)/1.15 var(--display); letter-spacing: -.015em; }
.dist { font: 400 .8125rem/1 var(--mono); color: var(--muted); white-space: nowrap; }
.sub-line { grid-column: 1 / -1; font: 400 .8125rem/1.4 var(--mono); color: var(--muted); }
.out .note { font: 400 .8125rem/1.5 var(--mono); color: var(--muted); }

.reveal { opacity: 0; transform: translateY(6px); animation: rise .45s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  * { transition: none !important; }
}

/* --- lists --------------------------------------------------------------- */
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.plain.big li { padding: .9rem 0; }
.plain.big a { font: 400 1.25rem/1.25 var(--display); text-decoration: none; }
.plain.big a:hover { text-decoration: underline; text-underline-offset: 3px; }
.cities { list-style: none; margin: 0; padding: 0; columns: 3 12rem; column-gap: 2rem; }
.cities li { padding: .3rem 0; break-inside: avoid; }
.cities a { text-decoration: none; }
.cities a:hover { text-decoration: underline; text-underline-offset: 3px; }
.country { margin-bottom: 2.5rem; }
.cards li { padding: 1.5rem 0; }
.cards p { max-width: 52ch; }

/* --- the strip -----------------------------------------------------------
   Every photograph on this site comes off the organisation's own domain.
   There is no locality fallback and no stock: a place with no photograph
   shows none, and the type carries it. */
.wall { overflow: hidden; background: var(--line); border-bottom: 1px solid var(--line); }
.wall .track { display: flex; gap: 1px; width: max-content; }
.wall .tile {
  position: relative; flex: 0 0 auto; display: block;
  background: var(--raise); overflow: hidden; text-decoration: none;
}
.wall img {
  width: 214px; height: 143px; object-fit: cover; display: block;
  transition: transform .6s cubic-bezier(.2,.7,.3,1), filter .4s ease;
}
.wall .tile:hover img { transform: scale(1.05); filter: saturate(1.05); }
.wall .cap {
  position: absolute; left: .55rem; bottom: .45rem; z-index: 1;
  font: 400 .625rem/1 var(--mono); letter-spacing: .04em; color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.85);
}
.wall .tile::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,.45), transparent 42%);
}
/* It drifts rather than scrolls: the tiles are printed twice, so translating
   the track by exactly half its width loops without a seam. Hover holds it. */
@media (prefers-reduced-motion: no-preference) {
  .wall .track { animation: drift 220s linear infinite; will-change: transform; }
  .wall:hover .track, .wall:focus-within .track { animation-play-state: paused; }
}
@keyframes drift { to { transform: translateX(-50%); } }
.wall { -webkit-mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent);
        mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent); }
@media (max-width: 720px) { .wall img { width: 150px; height: 100px; } }

/* --- search, in the nav on every page ------------------------------------ */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-search { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.nav-search input {
  width: clamp(7rem, 17vw, 12rem); padding: .4rem .6rem; border-radius: 2px;
  font: 400 .875rem/1.2 var(--sans);
}
.nav-search button[type=submit] { padding: .42rem .8rem; font-size: .8125rem; }
.nav-search .link { padding: 0; white-space: nowrap; }
/* On a phone the search gets its own row. As a flex item beside the links it
   was being shrunk to a stub with the button wrapping underneath it, so the
   nav itself has to wrap and the form has to claim the whole line. */
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; row-gap: .7rem; padding-top: .9rem; padding-bottom: .9rem; }
  .wordmark { flex: 0 0 auto; }
  .bar nav { width: 100%; flex-wrap: wrap; row-gap: .7rem; align-items: center; }
  .nav-search { flex: 1 0 100%; flex-wrap: nowrap; gap: .5rem; }
  .nav-search input { flex: 1 1 auto; width: auto; min-width: 0; font-size: 1rem; }
  .nav-search button[type=submit] { flex: 0 0 auto; }
  .nav-search .link { display: none; }
}

/* --- the feed: a hairline-joined plate ------------------------------------
   Border on the item, never a gap over the background, so the cards touch. */
.plate {
  margin-top: 2.75rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.card {
  display: flex; flex-direction: column; gap: .5rem;
  padding: 1.6rem 1.5rem 1.8rem; text-decoration: none; color: var(--ink);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: transparent; transition: background .25s ease;
}
.card:hover { background: var(--raise); }
.card .shot {
  width: calc(100% + 3rem); margin: -1.6rem -1.5rem 1rem; display: block;
  /* height:auto is load-bearing. The img carries width/height attributes, which
     count as a specified height, and aspect-ratio is ignored unless one axis is
     auto — without this a portrait photo renders at full height and drags the
     whole grid row with it. */
  height: auto; aspect-ratio: 3 / 2; object-fit: cover; background: var(--raise);
}
/* Clamped so a long description cannot set the height of its row. A card with
   no photograph has the room, so it is allowed more of its own words. */
.card .said {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  line-clamp: 3; overflow: hidden;
}
.card:not(.has-photo) .said { -webkit-line-clamp: 7; line-clamp: 7; }
.card .where { font: 400 .75rem/1.4 var(--mono); color: var(--muted); }
.card .title {
  font: 400 1.5rem/1.15 var(--display); letter-spacing: -.015em; max-width: 16ch;
}
.card:hover .title { color: var(--accent); }
.card .said { font-size: .9375rem; line-height: 1.55; color: var(--ink); }
/* Reveal rides the scroll itself. A browser without view() timelines, or a
   reader who asked for less motion, gets the cards already visible — nothing
   about seeing them depends on a script running. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .plate .card {
      animation: rise .6s linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 20%;
    }
  }
}

/* --- entity + relay ------------------------------------------------------ */
.entity { max-width: 46rem; }
/* --- photographs on an entity page --------------------------------------- */
.hero { margin: 0 0 2rem; }
.hero img {
  width: 100%; height: auto; max-height: 30rem; object-fit: cover; display: block; background: var(--raise);
  border: 1px solid var(--line);
}
.gallery { margin-top: 2.75rem; border-top: 1px solid var(--line); padding-top: .25rem; }
.gallery .strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.gallery img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; display: block;
               background: var(--raise); }

/* What an organisation publishes about itself, in its own order. */
.says { margin-top: 2.75rem; border-top: 1px solid var(--line); padding-top: .25rem; }
.says p { max-width: 60ch; }
.says .meta a { word-break: break-all; }
.entity .teaser + .teaser { margin-top: -.4rem; }

.relay { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.relay form { max-width: 32rem; margin-top: 1rem; }
.relay label { display: block; margin-bottom: 1rem; font: 400 .8125rem/1.8 var(--mono); color: var(--muted); }
.relay input, .relay textarea { margin-top: .3rem; }
.back { margin-top: 3rem; font: 400 .8125rem/1.6 var(--mono); }
.go { font: 400 .9375rem/1 var(--mono); text-underline-offset: 4px; }
.floor { margin-top: 3.5rem; border-top: 1px solid var(--line); }
