/* site.css -- the one stylesheet for every page (top bar, footer, /find/).
   The homepage adds /assets/home.css for its own parts.
   Hand-written, no build step. Written phone-first: the plain rules are for
   small screens and the @media blocks near the end add the wide-screen layout.
   Uses "inline-start/end" instead of left/right so right-to-left text works. */

/* ---- Colours and sizes: change them here, they apply everywhere ---------- */
:root {
  --navy:       #1a3a5c;
  --navy-dark:  #0f2440;   /* top bar */
  --gold:       #b8860b;   /* Give button */
  --gold-light: #d4a017;
  --text:       #1f2d3d;
  --muted:      #5f6c7e;   /* grey secondary text */
  --line:       #d6d6d6;
  --soft:       #f4f4f6;
  --page:       68.75rem;  /* widest the content gets (1100px) */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

/* ---- Basics --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: #fff;
}
[hidden] { display: none !important; }
a { color: var(--navy); }
a:hover { color: #000; }
h1, h2 { color: var(--text); font-weight: 700; line-height: 1.25; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); margin-block: 0 1rem; }
h2 { font-size: 1.25rem; margin-block: 2rem .6rem; }
p, ul, dl { margin-block: 0 1rem; }

/* Keyboard focus is always clearly visible. */
:focus-visible { outline: 3px solid #000; outline-offset: 2px; border-radius: 2px; }
.site-head :focus-visible, .site-foot :focus-visible { outline-color: #fff; }

/* "Skip to content": off-screen until it gets keyboard focus. */
.skip {
  position: absolute; inset-inline-start: .5rem; top: -4rem;
  background: #fff; color: #000; padding: .5rem .9rem; z-index: 200;
}
.skip:focus { top: .5rem; }

/* ---- Prototype notice ----------------------------------------------------- */
.proto {
  margin: 0; padding: .6rem 1rem; text-align: center; font-size: .82rem;
  background: #fffbe6; color: #5a3e00; border-block-end: 2px solid var(--gold);
}

/* ---- Top bar -------------------------------------------------------------- */
.site-head { background: var(--navy-dark); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.head-in {
  max-width: var(--page); margin-inline: auto; padding-inline: 1rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
}
.brand {
  display: flex; align-items: center; gap: .6rem; padding-block: .6rem;
  color: #fff; font-size: 1.25rem; font-weight: 700; text-decoration: none; letter-spacing: -.01em;
}
.brand:hover { color: #fff; }
.brand img, .foot-brand img { border-radius: 50%; display: block; }
/* The links simply wrap under the logo on a narrow phone -- no menu button, no script. */
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; list-style: none; margin: 0; padding: 0 0 .5rem; }
.nav a {
  display: block; padding: .4rem .7rem; border-radius: 6px;
  color: rgba(255,255,255,.86); font-size: .88rem; font-weight: 500; letter-spacing: .02em; text-decoration: none;
  transition: background .18s, color .18s;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a[aria-current] { color: #fff; box-shadow: inset 0 -2px 0 #fff; border-radius: 6px 6px 0 0; }
/* Give: dark navy on gold (contrast 4.8 to 1; white on this gold was only 3.3). */
.nav a.give { background: var(--gold); color: var(--navy-dark); font-weight: 700; margin-inline-start: .35rem; }
.nav a.give:hover { background: var(--gold-light); color: var(--navy-dark); }

/* Language picker, last thing in the top bar. */
.lang-form { display: flex; align-items: center; gap: .3rem; margin: 0; margin-inline-start: .35rem; }
.lang-select {
  width: auto; max-width: 11rem; min-height: 0; padding: .3rem .5rem;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.4); border-radius: 6px;
  font-size: .82rem; font-weight: 500; cursor: pointer;
}
.lang-select:hover { background: rgba(255,255,255,.18); }
.lang-select option { color: var(--text); background: #fff; }
.lang-go, .lang-go:hover {   /* only shown when JavaScript is off */
  min-height: 0; padding: .25rem .6rem; font-size: .82rem;
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6);
}

/* ---- Page body and footer ------------------------------------------------- */
main { max-width: var(--page); margin-inline: auto; padding: 2rem 1rem 3rem; min-height: 60vh; }
main.wide { max-width: none; padding: 0; }   /* the page lays out its own full-width bands (homepage) */
.lede { color: var(--muted); max-width: 42rem; line-height: 1.7; }
.subtitle { font-size: 1.2rem; font-weight: 600; margin-block: -.5rem 1rem; }
.crumb { font-size: .9rem; }

.site-foot { background: #000; color: rgba(255,255,255,.62); padding: 2.5rem 1rem 1.75rem; font-size: .8rem; line-height: 1.8; text-align: center; }
.site-foot a { color: rgba(255,255,255,.85); text-decoration: none; }
.site-foot a:hover { color: #fff; text-decoration: underline; }
.foot-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; color: #fff; font-size: 1.05rem; font-weight: 700; }

/* ---- Forms and buttons ---------------------------------------------------- */
label { display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-block-end: .3rem; }
input, select, button { font: inherit; color: inherit; }
input[type=search], select {
  width: 100%; min-height: 2.75rem; padding: .5rem .75rem;
  border: 1px solid #8a8a8a; border-radius: 6px; background: #fff;
}
button, .btn {
  display: inline-block; min-height: 2.75rem; padding: .55rem 1.2rem;
  border: 2px solid var(--navy-dark); border-radius: 6px; background: #fff; color: var(--navy-dark);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
button:hover, .btn:hover { background: var(--soft); color: #000; }
button[type=submit], .btn-main { background: var(--navy-dark); color: #fff; }
button[type=submit]:hover, .btn-main:hover { background: var(--navy); color: #fff; }

/* ---- /find/ : search form ------------------------------------------------- */
.filters { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; margin-block: 1.5rem 1rem; }
.filters p { margin: 0; }
.filters .f-q { grid-column: 1 / -1; }
.filters .f-go { align-self: end; }
.count { margin-block-end: .5rem; }

/* ---- /find/ : the list. On a phone each translation is a stacked card ----- */
.list { width: 100%; border-collapse: collapse; }
.list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }  /* hidden, still read out */
.list, .list tbody, .list tr, .list td { display: block; }
.list tr { padding-block: .8rem; border-block-start: 1px solid var(--line); }
.list td { padding: 0; text-align: start; overflow-wrap: anywhere; }
.list td:nth-child(1) { font-weight: 700; }                      /* language */
.list td:nth-child(n+3) { display: inline; font-size: .9rem; color: var(--muted); }
.list td:nth-child(n+4)::before { content: " · "; }             /* country · contents · licence · date */
.list td:nth-child(5) { color: var(--text); }                    /* licence stays dark: it matters */
.list .v { display: block; color: var(--muted); font-weight: 400; }   /* name/title in the language itself, on its own line */
.list td:nth-child(n+3) { unicode-bidi: isolate; }               /* each of the inline pieces keeps its own direction */

/* ---- /find/details.php ---------------------------------------------------- */
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.downloads { padding-inline-start: 1.2rem; }
.downloads li { margin-block-end: .3rem; }
.facts dt { font-weight: 700; margin-block-start: .6rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
/* The licence text comes from the catalogue in English, in the translation's own
   language, or both: each paragraph takes its direction from its own first letter. */
.licence-text, .licence-text p, .licence-text li { unicode-bidi: plaintext; }
.licence { border-block-start: 1px solid var(--line); margin-block: 2rem 1.5rem; max-width: 46rem; overflow-wrap: anywhere; }

/* ---- Right-to-left pages (Arabic) ----------------------------------------- */
/* Spacing between letters would pull joined Arabic letters apart. This only
   touches text that is itself Arabic, not English names inside the page. */
:lang(ar) { letter-spacing: 0 !important; }
/* English or other left-to-right catalogue text inside a right-to-left page
   (marked dir="ltr", see en_attr() in includes/shell.php) still lines up on
   the page's starting side -- and right-to-left names inside that do too. */
[dir="rtl"] main:not(.wide) [dir="ltr"] { text-align: end; }
[dir="rtl"] main:not(.wide) [dir="ltr"] [dir="rtl"] { text-align: start; }

/* ---- Wider screens: a real table, form on one line ------------------------ */
@media (min-width: 48em) {
  /* On a wide screen the top bar is one line, so it can stay in view while scrolling. */
  html { scroll-padding-top: 4.5rem; }
  .site-head { position: sticky; top: 0; z-index: 100; }
  .head-in { padding-inline: 1.5rem; }
  .nav { padding-block-end: 0; }
  main { padding-inline: 1.5rem; }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; align-items: end; }
  .filters .f-q { grid-column: auto; }

  .list { display: table; font-size: .92rem; }
  .list thead { display: table-header-group; position: static; width: auto; height: auto; clip-path: none; }
  .list tbody { display: table-row-group; }
  .list tr { display: table-row; }
  .list td, .list td:nth-child(n+3) { display: table-cell; font-size: inherit; color: inherit; }
  .list th, .list td { padding: .55rem 0; padding-inline-end: .7rem; text-align: start; vertical-align: top; border-block-end: 1px solid var(--line); }
  .list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; border-block-end: 2px solid #000; }
  .list td:nth-child(1) { font-weight: 600; }
  .list td:nth-child(n+4)::before { content: none; }
  .list td:nth-child(6) { white-space: nowrap; }
  .list tbody tr:hover { background: var(--soft); }

  .facts { display: grid; grid-template-columns: 11rem 1fr; gap: .5rem 1rem; }
  .facts dt { margin: 0; }
}

/* ---- People who ask for less motion get none ------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---- Paper: content only, black on white, web addresses spelled out ------- */
@media print {
  .proto, .site-head, .site-foot, .filters, .skip, .crumb { display: none; }
  body { color: #000; font-size: 10pt; }
  main { max-width: none; padding: 0; }
  a { color: #000; }
  .actions a::after, .downloads a::after { content: " <" attr(href) ">"; font-weight: 400; word-break: break-all; }
  .btn { border: 0; padding: 0; min-height: 0; background: none; color: #000; display: block; }
  .list tr { break-inside: avoid; }
}
