/* ==========================================================================
   The Weekly Shiur — a sefer, not a startup.
   Cream paper, near-black ink, one deep maroon accent. Nothing else.
   ========================================================================== */

:root {
  --paper: #faf6ee;
  --ink: #211d17;
  --muted: #6f6555;
  --accent: #7a2f2a;
  --rule: #e3dac7;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --hebrew: "Frank Ruhl Libre", "SBL Hebrew", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
}

body {
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
  max-width: 44rem;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- Links ---------------------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--paper);
  padding: 0.5rem 1rem;
}

.skip-link:focus { left: 0; z-index: 10; }

/* --- Masthead ------------------------------------------------------------- */

.masthead {
  padding: 1.4rem 0 0.9rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.75rem;
}

.masthead-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.site-name {
  font-variant-caps: small-caps;
  letter-spacing: 0.14em;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}

.site-name:hover { color: var(--accent); }

.besd {
  font-family: var(--hebrew);
  font-size: 0.9rem;
  color: var(--muted);
}

.site-nav {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

/* inline-block + padding gives phone-sized tap targets without changing the look */
.site-nav a {
  display: inline-block;
  padding: 0.5rem 0.25rem;
  color: var(--muted);
  text-decoration: none;
  margin-right: 1.15rem;
}

.site-nav a:hover { color: var(--accent); }

.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* --- Home ----------------------------------------------------------------- */

.featured { margin-bottom: 3.5rem; }

.featured-kicker {
  font-variant-caps: small-caps;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

.featured-title {
  font-size: clamp(1.7rem, 1.4rem + 1.6vw, 2.3rem);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.4rem;
}

.featured-title a { color: var(--ink); text-decoration: none; }

.featured-title a:hover { color: var(--accent); }

.featured-subtitle {
  font-style: italic;
  color: var(--muted);
  margin: 0 0 1.1rem;
}

.featured-excerpt { margin: 0 0 1rem; }

.featured-more { margin: 0; }

/* --- Week lists (home + archive) ------------------------------------------ */

.list-heading {
  font-variant-caps: small-caps;
  letter-spacing: 0.16em;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
  margin: 2.8rem 0 0.4rem;
}

.week-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.week-list li { border-bottom: 1px solid var(--rule); }

.week-list a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding: 0.8rem 0.1rem;
  color: var(--ink);
  text-decoration: none;
}

.week-list a:hover .week-parsha,
.week-list a:hover .week-title { color: var(--accent); }

.week-parsha { font-weight: 600; }

.week-title { font-style: italic; }

.week-date {
  margin-left: auto;
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}

.empty-sefer {
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
  padding: 0.8rem 0.1rem;
}

.sefer-heading {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2rem 0 0.2rem;
}

.page-title {
  font-size: clamp(1.6rem, 1.35rem + 1.3vw, 2.1rem);
  font-weight: 600;
  margin: 0 0 1rem;
}

/* --- Entry (a single Dvar Torah) ------------------------------------------ */

.entry-header {
  text-align: center;
  margin-bottom: 2.6rem;
}

.entry-header h1 {
  font-size: clamp(1.7rem, 1.4rem + 1.6vw, 2.3rem);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

.entry-subtitle {
  font-style: italic;
  color: var(--muted);
  margin: 0;
}

/* --- Read-aloud player ------------------------------------------------------ */

.audio-player {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.65rem 0.2rem;
  margin: 0 0 2.2rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.ap-play {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.ap-play:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.ap-play svg { margin-left: 1px; }

.ap-label {
  font-variant-caps: small-caps;
  letter-spacing: 0.12em;
}

/* The input itself is tall enough to grab by touch; the visible 2px track
   is drawn by the track pseudo-elements. */
.ap-seek {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 1.5rem;
  background: none;
  cursor: pointer;
  accent-color: var(--accent);
  min-width: 3rem;
  margin: 0;
}

.ap-seek::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--rule);
  border-radius: 1px;
}

.ap-seek::-moz-range-track {
  height: 2px;
  background: var(--rule);
  border-radius: 1px;
}

.ap-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.ap-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.ap-seek:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ap-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ap-speed {
  flex: none;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.ap-speed:hover { border-color: var(--accent); }

.entry-body p { margin: 0 0 1.15em; }

.entry-body h2 {
  font-size: 1.22rem;
  font-weight: 700;
  margin: 2.1em 0 0.7em;
}

/* Hebrew lines: centered, larger, roomy leading so nikud never clips. */
.entry-body .hebrew {
  font-family: var(--hebrew);
  font-weight: 500;
  font-size: 1.32em;
  line-height: 2;
  text-align: center;
  margin: 1.4em 0 0.15em;
}

.hebrew + .hebrew { margin-top: 0; }

.entry-body .translation {
  text-align: center;
  color: var(--muted);
  margin: 0 0 1.4em;
}

.entry-body .centered { text-align: center; }

/* Inline Hebrew inside an English sentence. */
.entry-body span[lang="he"] { font-family: var(--hebrew); }

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

.entry-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.4rem;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1.5rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.print-link {
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0.4rem 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.entry-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1.6rem;
  font-size: 0.95rem;
}

.entry-nav-prev, .entry-nav-next { max-width: 46%; }

.entry-nav-next { text-align: right; margin-left: auto; }

.entry-nav-label {
  display: block;
  font-variant-caps: small-caps;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

/* --- About ----------------------------------------------------------------- */

.about-photo {
  display: block;
  width: min(15rem, 60vw);
  height: auto;
  margin: 1.8rem auto 2.2rem;
  border-radius: 4px;
}

.about-links {
  text-align: center;
  margin-top: 2rem;
  color: var(--muted);
}

.linkedin-link {
  white-space: nowrap;
}

.linkedin-mark {
  vertical-align: -0.18em;
  margin-right: 0.3em;
}

/* --- Not-found page --------------------------------------------------------- */

.notfound {
  text-align: center;
  padding: 4rem 0 6rem;
}

.notfound h1 {
  margin-bottom: 1.2rem;
}

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

.site-footer {
  margin-top: 4.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.3rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent);
}

.site-footer a:hover { color: var(--accent); }

/* --- Small screens ---------------------------------------------------------- */

@media (max-width: 480px) {
  .week-date { margin-left: 0; width: 100%; }
  .entry-nav { flex-direction: column; gap: 1rem; }
  .entry-nav-prev, .entry-nav-next { max-width: 100%; }
  .entry-nav-next { text-align: left; margin-left: 0; }
}

/* ==========================================================================
   Print — first-class. Letter paper, בס״ד top right, page numbers,
   no navigation chrome. Many readers print these before Shabbat.
   ========================================================================== */

.print-besd { display: none; }

/* No fixed paper size: the margins work equally well on Letter and A4, and
   forcing one would fight readers whose printers default to the other.
   Page numbers via the @page margin box print in Chrome/Edge (131+); in
   Firefox/Safari readers get them from the print dialog's own
   headers-and-footers option instead. */
@page {
  margin: 0.9in 1in;

  @bottom-center {
    content: counter(page);
    font-size: 9pt;
    color: #000;
  }
}

@media print {
  html, body {
    background: #fff;
    color: #000;
    max-width: none;
    padding: 0;
    font-size: 12pt;
    line-height: 1.6;
  }

  /* No navigation chrome, and never the audio player. */
  .masthead, .site-footer, .entry-footer, .skip-link, .audio-player { display: none; }

  .print-besd {
    display: block;
    text-align: right;
    font-family: var(--hebrew);
    font-size: 10pt;
    margin-bottom: 0.35in;
  }

  .entry-header { margin-bottom: 0.3in; }

  .entry-header h1 { font-size: 17pt; }

  .entry-subtitle { color: #333; }

  .entry-body h2 {
    font-size: 12.5pt;
    break-after: avoid;
  }

  .entry-body .hebrew {
    font-size: 14pt;
    break-inside: avoid;
    break-after: avoid;
  }

  .entry-body .translation {
    color: #333;
    break-before: avoid;
  }

  .entry-body p { orphans: 3; widows: 3; }

  a { color: #000; text-decoration: none; }
}
