/*
 * Unity Through Torah — one stylesheet for the whole site.
 *
 * The palette is the Kavua about page's: parchment, ink and gold. The
 * organization and its first app should not look like strangers to each other.
 *
 * Nothing here is loaded from another host. The Latin faces are whatever the
 * reader's system already has, and the one Hebrew face ships with the site. A
 * webfont CDN would put every visitor's IP in front of a third party for the
 * sake of a typeface — including someone opening /privacy specifically because
 * they are worried about that. The policy on this site can say "no third-party
 * requests" only because this file makes none.
 */

:root {
  --ink:          #1c160c;
  --ink-soft:     #5c5241;
  --ink-faint:    #75695a;   /* 4.79:1 on parchment, 5.26:1 on card — AA at any size */
  --parchment:    #f6f2e9;
  --card:         #fffdf8;
  --gold:         #a9832f;
  --gold-deep:    #836223;
  --rule:         #e5dcc8;
  --rule-soft:    #eee7d8;
  --shadow:       0 24px 50px -34px rgba(40, 30, 12, .34);

  --he:      "Vilna", "Frank Ruhl Libre", serif;
  --ui:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;   /* ~68 characters — the line length prose is read at */
  --wrap:    64rem;
}

/*
 * Dark mode is a re-pointing of the same tokens, never a second set of rules.
 * The parchment becomes the ink it was printed with; gold stays gold, lifted
 * just enough to hold contrast on a dark ground.
 */
@media (prefers-color-scheme: dark) {
  :root {
    --ink:       #f0eade;
    --ink-soft:  #b3a894;
    --ink-faint: #9c9179;   /* 5.89:1 on ground, 5.44:1 on card */
    --parchment: #17140f;
    --card:      #201c15;
    --gold:      #d9ab4d;
    --gold-deep: #edc169;
    --rule:      #332c20;
    --rule-soft: #282218;
    --shadow:    0 24px 50px -34px rgba(0, 0, 0, .7);
  }
}

@font-face {
  font-family: "Vilna";
  src: url("vilna.ttf") format("truetype");
  font-display: swap;
}

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

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

body {
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }
.heb  { font-family: var(--he); }

/* Visible only to a screen reader — labels, and the skip link before focus. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--card); color: var(--ink); padding: .75rem 1.25rem;
  border: 1px solid var(--gold); border-radius: 0 0 .5rem 0;
}
.skip:focus { left: 0; }

/* ---------- header ---------- */

header.bar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--parchment) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule-soft);
}
.bar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 4rem; flex-wrap: wrap; padding: .5rem 0;
}
.brand { display: flex; align-items: baseline; gap: .6rem; text-decoration: none; color: inherit; }
.brand b { font-size: 1.0625rem; font-weight: 650; letter-spacing: -.015em; }
.brand span { font-family: var(--he); font-size: 1.0625rem; color: var(--gold-deep); }

nav.bar-nav { display: flex; align-items: center; gap: 1.5rem; }
nav.bar-nav a {
  color: var(--ink-soft); text-decoration: none; font-size: .9375rem; font-weight: 500;
  border-bottom: 1px solid transparent; padding-bottom: 2px;
}
nav.bar-nav a:hover { color: var(--ink); border-bottom-color: var(--gold); }
nav.bar-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- type ---------- */

h1, h2, h3 { letter-spacing: -.022em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: clamp(2rem, 5.5vw, 3rem); font-weight: 750; }
h2 { font-size: clamp(1.375rem, 3vw, 1.75rem); font-weight: 700; }
h3 { font-size: 1.0625rem; font-weight: 650; letter-spacing: -.01em; }

p, li { text-wrap: pretty; }
a { color: var(--gold-deep); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--gold); }

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}

.kicker {
  font-size: .75rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold-deep);
}
.lede  { font-size: clamp(1.0625rem, 2vw, 1.1875rem); color: var(--ink-soft); max-width: var(--measure); }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
/* Exists so no page needs a style attribute — a strict Content-Security-Policy
   would otherwise need 'unsafe-inline' for styles, for one paragraph. */
.measure { max-width: var(--measure); }

/* ---------- layout ---------- */

section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
section + section { border-top: 1px solid var(--rule-soft); }

.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 2rem; }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1rem; }
.prose h2 { margin-top: 2.75rem; }
.prose h3 { margin-top: 1.75rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: .5rem; }
.prose ul ul { margin-top: .5rem; }

.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: .875rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card > * + * { margin-top: .625rem; }
.card p { font-size: .9375rem; color: var(--ink-soft); }

/* A status word on a project card. The point is that "live" and "planned" are
   never mistakable for each other at a glance. */
.status {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: .25rem .55rem; border-radius: 999px; border: 1px solid var(--rule);
  color: var(--ink-soft); background: var(--parchment);
}
.status::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.status.live     { color: var(--gold-deep); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.status.building { color: var(--ink-soft); }
.status.planned  { color: var(--ink-faint); }

.btn {
  display: inline-block; font: inherit; font-weight: 600; font-size: .9375rem;
  padding: .7rem 1.35rem; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: var(--parchment);
  border: 1px solid var(--ink); text-decoration: none;
}
.btn:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { border-color: var(--gold); color: var(--gold-deep); background: var(--card); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

dl.pairs > div { padding: .875rem 0; border-bottom: 1px solid var(--rule-soft); }
dl.pairs > div:first-child { border-top: 1px solid var(--rule-soft); }
dl.pairs dt { font-weight: 650; font-size: .9375rem; }
dl.pairs dd { color: var(--ink-soft); font-size: .9375rem; margin-top: .2rem; }

code { font-family: var(--mono); font-size: .875em; background: var(--card); border: 1px solid var(--rule-soft); padding: .1em .35em; border-radius: .25rem; }

/* ---------- form ---------- */

form.contact { max-width: 34rem; }
form.contact > * + * { margin-top: 1.125rem; }

.field label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .375rem; }
.field .hint { font-size: .8125rem; color: var(--ink-soft); margin-bottom: .375rem; }

input[type="text"], input[type="email"], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: .5rem;
  padding: .65rem .8rem;
}
textarea { min-height: 10rem; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: #b3261e; }

@media (prefers-color-scheme: dark) {
  input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: #f2b8b5; }
}

.field-error { font-size: .8125rem; color: #b3261e; margin-top: .3rem; }
@media (prefers-color-scheme: dark) { .field-error { color: #f2b8b5; } }

/* The honeypot. Off-screen rather than display:none — a bot that filters on
   display:none skips it, and skipping it is the one thing it must not do. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.notice {
  border: 1px solid var(--rule); border-left: 3px solid var(--gold);
  background: var(--card); border-radius: .5rem; padding: 1rem 1.125rem;
  font-size: .9375rem;
}
.notice.bad { border-left-color: #b3261e; }
.notice h3 { margin-bottom: .3rem; }

/* ---------- HaMevuar shop / library ---------- */

.shop-layout {
  display: grid;
  gap: 2rem;
  align-items: start;
}
@media (min-width: 56rem) {
  .shop-layout {
    grid-template-columns: minmax(0, 1fr) min(20rem, 34%);
  }
  .shop-cart {
    position: sticky;
    top: 5.5rem;
  }
}

.sefer-heading {
  font-size: 1.125rem;
  margin: 0 0 .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  align-items: baseline;
}
.sefer-heading .heb { color: var(--ink-soft); font-weight: 500; }

.volume-list { display: flex; flex-direction: column; gap: .5rem; }
.volume-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%; text-align: start; font: inherit; cursor: pointer;
  background: var(--card); border: 1px solid var(--rule); border-radius: .625rem;
  padding: .85rem 1rem; color: var(--ink);
}
.volume-row:hover { border-color: var(--gold); }
.volume-row.selected {
  border-color: var(--gold-deep);
  box-shadow: inset 3px 0 0 var(--gold);
}
.volume-titles { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.volume-titles .heb { font-size: 1.05rem; }
.volume-titles .en { font-size: .8125rem; color: var(--ink-soft); }
.volume-action {
  flex-shrink: 0; font-size: .75rem; font-weight: 650;
  letter-spacing: .04em; text-transform: uppercase; color: var(--gold-deep);
}

.cart-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.cart-list:empty { display: none; }
.cart-item {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .55rem 0; border-bottom: 1px solid var(--rule-soft);
  font-size: .9375rem;
}
.cart-remove {
  font: inherit; font-size: 1.25rem; line-height: 1; border: 0; background: transparent;
  color: var(--ink-faint); cursor: pointer; padding: .15rem .35rem;
}
.cart-remove:hover { color: var(--ink); }
.shop-checkout { max-width: none; margin-top: 1rem; }

.library-list { list-style: none; padding: 0; margin: 0; }
.library-item {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .75rem 0; border-bottom: 1px solid var(--rule-soft);
}
.library-pending { list-style: none; }
.library-pending + .library-pending { margin-top: 1rem; }

/* ---------- footer ---------- */

footer.site {
  border-top: 1px solid var(--rule);
  padding: 2.5rem 0 3rem;
  font-size: .875rem;
  color: var(--ink-soft);
}
footer.site .rows { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: baseline; }
footer.site nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
footer.site a { color: var(--ink-soft); text-decoration: none; }
footer.site a:hover { color: var(--gold-deep); text-decoration: underline; }
