/* ---------- themes ----------
   The bare :root is the default "newspaper" theme. Each [data-theme="…"]
   block below only overrides the colour/typography variables, so every
   component downstream stays theme-agnostic. */
:root {
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #0a3d91;      /* the PDF's blue header line */
  --accent-soft: #e8eef9;
  --bg: #eceae4;
  --line: #e2e0d8;
  --shadow: 0 6px 24px rgba(0,0,0,.07);
  --card-shadow: 0 6px 18px rgba(0,0,0,.08);
  --radius: 6px;
  --maxw: 760px;
  --font: "Arial", "Helvetica Neue", "Arial Hebrew", "Segoe UI", system-ui, sans-serif;
  --font-head: var(--font);
  --head-weight: 700;
  --rule-style: solid;
  --rule-w: 1px;
  --paper-texture: none;
}

/* קלף — aged parchment, oxblood ink, all-serif: a manuscript / old dictionary. */
[data-theme="parchment"] {
  --paper: #f4ead2;
  --ink: #3a2c1c;
  --muted: #7c6a4f;
  --accent: #8a3324;
  --accent-soft: #e7d6b4;
  --bg: #d9c7a3;
  --line: #cdb98f;
  --shadow: 0 8px 26px rgba(74,54,28,.18);
  --card-shadow: 0 6px 18px rgba(74,54,28,.16);
  --radius: 4px;
  --font: "Frank Ruhl Libre", "Times New Roman", serif;
  --font-head: "Frank Ruhl Libre", "Times New Roman", serif;
  --paper-texture: radial-gradient(rgba(120,90,50,.05) 1px, transparent 1px);
}

/* מילון — crisp white reference book: sans body, serif red headings. */
[data-theme="lexicon"] {
  --paper: #ffffff;
  --ink: #1c1a17;
  --muted: #6a655c;
  --accent: #b3261e;
  --accent-soft: #f7e2df;
  --bg: #efeae3;
  --line: #e6e1d8;
  --shadow: 0 6px 22px rgba(40,30,20,.08);
  --card-shadow: 0 6px 18px rgba(40,30,20,.09);
  --radius: 4px;
  --font: "Heebo", "Arial", system-ui, sans-serif;
  --font-head: "Frank Ruhl Libre", Georgia, serif;
}

/* לילה — dark reading mode, warm light ink, gold accent. */
[data-theme="night"] {
  --paper: #1d2027;
  --ink: #e7e3d8;
  --muted: #9a958a;
  --accent: #d8b46a;
  --accent-soft: #2c2a20;
  --bg: #14161b;
  --line: #2c3038;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
  --card-shadow: 0 6px 18px rgba(0,0,0,.4);
  --radius: 8px;
  --font: "Heebo", "Arial", system-ui, sans-serif;
  --font-head: "Frank Ruhl Libre", Georgia, serif;
}

/* דפוס — letterpress feel: heavy display headlines, rust spot colour, double rules. */
[data-theme="vintage"] {
  --paper: #f2ede1;
  --ink: #232020;
  --muted: #6f655a;
  --accent: #b4452f;
  --accent-soft: #ecdcc9;
  --bg: #e3dccb;
  --line: #b9ad94;
  --shadow: 0 5px 18px rgba(35,30,25,.14);
  --card-shadow: 0 5px 16px rgba(35,30,25,.16);
  --radius: 0px;
  --font: "Frank Ruhl Libre", "Times New Roman", serif;
  --font-head: "Suez One", Georgia, serif;
  --head-weight: 400;
  --rule-style: double;
  --rule-w: 4px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  font-size: 17px;
  transition: background-color .25s, color .25s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- site chrome ---------- */
.site-head {
  position: relative;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  justify-content: center;
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.brand:hover { text-decoration: none; }
.brand-title {
  font-family: var(--font-head);
  font-size: 1.7rem;
  font-weight: var(--head-weight);
  color: var(--accent);
  letter-spacing: .5px;
}
.brand-tag { font-size: .85rem; color: var(--muted); margin-top: 2px; }

/* theme switcher, pinned to the inline-start (left in RTL) of the header */
.theme-switch {
  position: absolute;
  inset-inline-start: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
}
/* The <select> sits transparent on top of the palette icon: only the icon
   shows, but the control keeps full native behaviour and accessibility. */
#theme-select {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 34px;
  color: transparent;            /* hide the selected theme name when closed */
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
/* Keep the open dropdown legible despite the transparent closed control. */
#theme-select option { color: var(--ink); background: var(--paper); }
.theme-switch-icon {
  position: absolute;
  inset-inline-start: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--ink);
  pointer-events: none;          /* clicks fall through to the select */
}
#theme-select:focus-visible { outline: 2px solid var(--accent); border-color: transparent; }
.site-about {
  position: absolute;
  inset-inline-end: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
}
@media (max-width: 600px) {
  .theme-switch { inset-inline-start: 10px; }
  .site-about { inset-inline-end: 10px; }
}

main { max-width: var(--maxw); margin: 0 auto; padding: 24px 16px 48px; }

.site-foot {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--muted);
}

/* ---------- issue page ---------- */
.issue {
  background-color: var(--paper);
  background-image: var(--paper-texture);
  background-size: 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px clamp(18px, 5vw, 48px);
}
.issue-meta {
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}
.title-line {
  color: var(--accent);
  font-size: .95rem;
  text-align: center;
  border-bottom: var(--rule-w) var(--rule-style) var(--line);
  padding-bottom: 14px;
  margin: 0 0 20px;
}
.topic {
  font-family: var(--font-head);
  font-size: clamp(1.5rem, 4.8vw, 2.05rem);
  font-weight: var(--head-weight);
  line-height: 1.25;
  text-align: center;
  margin: 0 0 24px;
  color: var(--ink);
}

.issue-body { text-align: justify; text-justify: inter-word; }
.issue-body p { margin: 0 0 1.05em; unicode-bidi: plaintext; }

/* Illustrations float to the right of the text, like the PDF. The inline
   width set per-image mirrors the PDF's displayed size. */
.ill {
  float: right;
  margin: 4px 0 14px 20px;
  max-width: 45%;
}
.ill img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.issue-footer { margin-top: 28px; }
.next-teaser {
  font-weight: 600;
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 10px 14px;
}
.next-teaser span { color: var(--accent); }
.signoff {
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: 18px;
}

.issue-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
/* Bottom nav: divider above, pushed down from the article body. */
.issue-nav--bottom {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
/* Top nav: divider below, sits just under the masthead for browsing. */
.issue-nav--top {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.issue-nav a {
  background: var(--accent-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
}

/* ---------- index ---------- */
.intro { text-align: center; margin-bottom: 20px; }
.intro p { color: var(--muted); margin: 0 0 14px; }
#search {
  width: 100%;
  max-width: 460px;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}
#search:focus { outline: 2px solid var(--accent); border-color: transparent; }
.search-count { font-size: .85rem; color: var(--muted); min-height: 1.2em; }

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.card a {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  height: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}
.card a:hover {
  text-decoration: none;
  box-shadow: var(--card-shadow);
  transform: translateY(-2px);
}
/* Text column. min-width:0 lets the summary's ellipsis kick in inside flex. */
.card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* Thumbnail sits last in the DOM so, in this RTL row, it renders on the left. */
.card-thumb {
  flex: none;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
  background: var(--line);
}
.card-n { font-size: .78rem; color: var(--accent); font-weight: 700; }
.card-topic {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: var(--head-weight);
  margin: 2px 0 4px;
}
.card-summary {
  font-size: .85rem;
  color: var(--muted);
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-date { font-size: .78rem; color: var(--muted); }
.card.hidden { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .issue { padding: 22px 16px; border-radius: 0; }
  /* On narrow screens, let illustrations span the column instead of floating. */
  .ill {
    float: none;
    width: auto !important;
    max-width: 100%;
    margin: 16px auto;
    text-align: center;
  }
  .ill img { margin: 0 auto; max-width: min(320px, 80%); }
}
