/* ============================================================
   VeitzenRebbe.com — Site Stylesheet
   Palette: brown #2c1505 | gold #c8962a | cream #fdf8f0

   Breakpoints (mobile-first):
     sm  ≥ 480px   phones landscape / large phones
     md  ≥ 640px   large phones / tablet portrait
     lg  ≥ 768px   tablets landscape
     xl  ≥ 1024px  desktop
     2xl ≥ 1280px  wide desktop
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --brown:      #2c1505;
  --brown-mid:  #5a2d0c;
  --gold:       #c8962a;
  --gold-light: #e0ac35;
  --gold-pale:  #e0c88a;
  --cream:      #fdf8f0;
  --cream-dark: #f7f0e4;
  --text:       #2c1505;
  --text-mid:   #4a2e0d;
  --text-muted: #7a5a30;
  --link:       #8b6010;

  --radius: 4px;
  --shadow: 0 2px 8px rgba(44,21,5,0.12);
  --transition: 0.15s ease;

  /* Fluid type scale */
  --text-xs:   clamp(0.7rem,  1.5vw, 0.78rem);
  --text-sm:   clamp(0.8rem,  2vw,   0.88rem);
  --text-base: clamp(0.9rem,  2.5vw, 1rem);
  --text-lg:   clamp(1rem,    3vw,   1.1rem);
  --text-xl:   clamp(1.2rem,  4vw,   1.5rem);
  --text-2xl:  clamp(1.5rem,  5vw,   2rem);
  --text-3xl:  clamp(1.8rem,  6vw,   2.4rem);
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--cream);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
  font-family: Georgia, serif;
  color: var(--text);
  line-height: 1.3;
  margin-top: 0;
}

h1 { font-size: var(--text-2xl); margin-bottom: 0.5rem; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); color: var(--link); margin-top: 1.5rem; }

p { margin: 0 0 1rem; }

hr {
  border: none;
  border-top: 1px solid var(--gold);
  margin: 1.5rem 0;
  width: 50%;
}

sup a { color: var(--link); }

/* ---------- Layout ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 640px) {
  .container,
  .container-wide { padding: 0 1.5rem; }
}

/* ---------- Top Bar ---------- */
.top-bar {
  background: var(--brown);
  color: var(--gold);
  font-size: var(--text-xs);
  padding: 0.35rem 0;
  text-align: center;
  letter-spacing: 0.03em;
  line-height: 1.6;
}

.top-bar a { color: var(--gold); }
.top-bar a:hover { color: var(--cream); text-decoration: none; }

/* Hide address on small phones, show on sm+ */
.top-bar .top-bar-address { display: none; }
@media (min-width: 640px) {
  .top-bar .top-bar-address { display: inline; }
}

/* ---------- Header / Navbar ---------- */
.site-header {
  background: var(--cream);
  border-bottom: 3px solid var(--gold);
  padding: 0.6rem 0;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo img {
  height: 48px;
  width: auto;
}

@media (min-width: 480px) {
  .site-logo img { height: 56px; }
}

.site-logo-text { line-height: 1.2; }

.site-logo-text strong {
  display: block;
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  color: var(--brown);
  font-family: Georgia, serif;
}

.site-logo-text span {
  font-size: var(--text-xs);
  color: var(--link);
  font-style: italic;
}

/* ---------- Navigation ---------- */
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 2px solid var(--brown);
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--brown);
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  transition: background var(--transition), color var(--transition);
}

.nav-toggle:hover,
.nav-toggle[aria-expanded="true"] {
  background: var(--brown);
  color: var(--gold);
}

/* Desktop: hide toggle, show nav inline */
@media (min-width: 1024px) {
  .nav-toggle { display: none; }
}

/* Mobile nav: hidden by default, shown when .open */
.site-nav {
  display: none;
  width: 100%;
  order: 3;
  border-top: 1px solid var(--gold-pale);
  padding-top: 0.4rem;
}

.site-nav.open { display: block; }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.site-nav a {
  display: flex;
  align-items: center;
  padding: 0.7rem 0.5rem;
  font-size: var(--text-sm);
  color: var(--text);
  font-family: Georgia, serif;
  border-bottom: 1px solid var(--gold-pale);
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}

.site-nav a:hover,
.site-nav a.active {
  background: var(--brown);
  color: var(--gold);
  text-decoration: none;
  padding-left: 1rem;
}

/* Tablet: 2-row horizontal nav */
@media (min-width: 768px) {
  .site-nav {
    display: block;
    width: 100%;
    order: 3;
    border-top: none;
    padding-top: 0.5rem;
  }

  .site-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.15rem;
  }

  .site-nav a {
    padding: 0.4rem 0.7rem;
    border-bottom: none;
    border-radius: var(--radius);
    white-space: nowrap;
    min-height: 36px;
  }

  .site-nav a:hover,
  .site-nav a.active {
    padding-left: 0.7rem;
  }

  .header-inner { flex-wrap: wrap; }
}

/* Desktop: logo + nav side by side */
@media (min-width: 1024px) {
  .site-nav {
    display: block;
    width: auto;
    order: 0;
    border-top: none;
    padding-top: 0;
  }

  .header-inner { flex-wrap: nowrap; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  background: var(--brown);
  overflow: hidden;
  min-height: 280px;
  display: flex;
  align-items: center;
}

@media (min-width: 480px)  { .hero { min-height: 320px; } }
@media (min-width: 768px)  { .hero { min-height: 400px; } }
@media (min-width: 1024px) { .hero { min-height: 460px; } }

.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0.18;
}

@media (min-width: 640px) {
  .hero-bg {
    left: auto;
    right: 0;
    width: 65%;
    opacity: 1;
  }
}

/* Gradient fade from left so text stays readable */
@media (min-width: 640px) {
  .hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, var(--brown) 32%, transparent 62%);
    pointer-events: none;
  }
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 2rem 0;
  width: 100%;
}

@media (min-width: 640px) {
  .hero-content {
    max-width: 440px;
    padding: 3rem 0;
  }
}

@media (min-width: 1024px) {
  .hero-content { max-width: 480px; }
}

.hero-content h1 {
  color: var(--gold);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  margin-bottom: 0.5rem;
}

.hero-content .hero-sub {
  color: var(--cream);
  font-size: clamp(0.88rem, 2.5vw, 1rem);
  font-style: italic;
  margin-bottom: 1rem;
  line-height: 1.65;
}

.hero-content .hero-desc {
  color: #e8d5b0;
  font-size: var(--text-sm);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

/* Hero buttons — stack on phones, inline on sm+ */
.hero-cta {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: flex-start;
}

@media (min-width: 480px) {
  .hero-cta {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
}

/* ---------- Buttons ---------- */
.btn-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--brown);
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-weight: bold;
  font-size: var(--text-sm);
  font-family: Georgia, serif;
  transition: background var(--transition);
  text-decoration: none;
  min-height: 44px;
  white-space: nowrap;
}

.btn-gold:hover {
  background: var(--gold-light);
  color: var(--brown);
  text-decoration: none;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gold);
  color: var(--gold);
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius);
  font-family: Georgia, serif;
  font-size: var(--text-sm);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  min-height: 44px;
  white-space: nowrap;
}

.btn-outline:hover {
  background: var(--gold);
  color: var(--brown);
  text-decoration: none;
}

/* ---------- Quick-nav strip ---------- */
.quick-nav {
  background: var(--brown);
  padding: 0.7rem 0;
}

.quick-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 0.4rem;
}

.quick-nav a {
  color: var(--gold);
  font-size: var(--text-xs);
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(200,150,42,0.4);
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.quick-nav a:hover {
  background: var(--gold);
  color: var(--brown);
  text-decoration: none;
}

/* ---------- Welcome strip ---------- */
.welcome-strip {
  background: var(--cream-dark);
  border-top: 1px solid var(--gold-pale);
  border-bottom: 1px solid var(--gold-pale);
  padding: 2rem 0;
  text-align: center;
}

@media (min-width: 640px) { .welcome-strip { padding: 2.5rem 0; } }

.welcome-strip h2 {
  font-size: var(--text-xl);
  color: var(--brown);
  margin-bottom: 0.75rem;
}

.welcome-strip p {
  max-width: 720px;
  margin: 0 auto 1rem;
  color: var(--text-mid);
  font-size: var(--text-sm);
}

/* ---------- Feature cards (home) ---------- */
.features { padding: 2rem 0; }

@media (min-width: 640px) { .features { padding: 3rem 0; } }

.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }
}

.feature-card {
  background: #fff;
  border: 1px solid var(--gold-pale);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.25rem;
}

@media (min-width: 640px) {
  .feature-card { padding: 1.5rem; }
}

.feature-card h3 {
  font-size: var(--text-base);
  color: var(--link);
  margin-bottom: 0.5rem;
}

.feature-card p {
  font-size: var(--text-sm);
  color: var(--text-mid);
  margin: 0;
}

.feature-card a {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: var(--text-xs);
  color: var(--link);
  font-style: italic;
  min-height: 36px;
  line-height: 36px;
}

/* ---------- Main content area ---------- */
.page-content { padding: 1.5rem 0 2.5rem; }

@media (min-width: 640px) { .page-content { padding: 2.5rem 0 3rem; } }

.content-inner {
  background: #fff;
  border: 1px solid var(--gold-pale);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-size: var(--text-sm);
}

@media (min-width: 640px) { .content-inner { padding: 1.75rem 2rem; } }
@media (min-width: 768px)  { .content-inner { padding: 2rem 2.5rem; } }

.content-inner h1 {
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}

.footnote-section {
  border-top: 1px solid var(--gold-pale);
  margin-top: 2rem;
  padding-top: 1rem;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---------- Sefer / Book viewer ---------- */
.book-viewer-wrap {
  margin: 0;
}

.book-nav-bar {
  background: var(--brown);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  border-radius: var(--radius) var(--radius) 0 0;
}

.book-nav-bar button,
.book-nav-bar select {
  font-family: Georgia, serif;
  font-size: var(--text-xs);
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--gold);
  border-radius: 3px;
  background: var(--cream);
  color: var(--brown);
  cursor: pointer;
  min-height: 38px;
  touch-action: manipulation;
}

.book-nav-bar button:hover { background: var(--gold); color: var(--brown); }

.book-nav-bar label {
  color: var(--gold);
  font-size: var(--text-xs);
}

.sefer-frame-wrap {
  border: 3px solid var(--brown);
  border-top: none;
  position: relative;
}

/* 8.5×11 inch aspect ratio (11/8.5 = 1.2941...)
   iframe fills full width and grows to correct page height at every size */
.sefer-frame-wrap iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8.5 / 11;
  min-height: 400px;
  border: none;
}

/* Mobile PDF notice */
.sefer-mobile-notice {
  display: none;
  padding: 1.25rem;
  background: var(--cream-dark);
  border: 1px solid var(--gold-pale);
  text-align: center;
  font-size: var(--text-sm);
}

@media (max-width: 639px) {
  .sefer-frame-wrap iframe {
    /* Keep aspect ratio on mobile — min-height prevents collapse on very narrow screens */
    min-height: 340px;
  }
  .sefer-mobile-notice {
    display: block;
    border-top: 2px solid var(--gold);
  }
}

/* ---------- Endorsements list ---------- */
.endorsements-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  margin-top: 1rem;
}

@media (min-width: 640px) {
  .endorsements-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2rem;
  }
}

.endorsement-item a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid var(--gold);
  color: var(--text);
  font-size: var(--text-sm);
  transition: background var(--transition);
  min-height: 44px;
}

.endorsement-item a:hover {
  background: var(--cream-dark);
  text-decoration: none;
  color: var(--link);
}

.endorsement-item em {
  display: block;
  font-size: var(--text-xs);
  color: var(--link);
  font-style: italic;
}

.endorsement-download { margin-top: 0.75rem; }

.haskama-download {
  display: inline-flex;
  align-items: center;
  background: var(--brown);
  color: var(--gold);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: 1.5rem;
  min-height: 44px;
}

.haskama-download:hover {
  background: var(--gold);
  color: var(--brown);
  text-decoration: none;
}

/* ---------- Individual endorsement page ---------- */
.endorsement-img-wrap {
  text-align: center;
  margin: 1.5rem 0;
  overflow-x: auto; /* handles wide scans on small screens */
}

.endorsement-img-wrap img {
  max-width: 100%;
  border: 2px solid var(--gold);
  border-radius: 3px;
  display: inline-block;
}

.endorsement-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gold-pale);
  font-size: var(--text-sm);
}

.endorsement-nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.5rem;
}

/* ---------- Ziyun / Cemetery page ---------- */
.ziyun-address {
  background: var(--cream-dark);
  border: 1px solid var(--gold-pale);
  border-left: 4px solid var(--gold);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-size: var(--text-sm);
}

.ziyun-imgs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .ziyun-imgs { grid-template-columns: 1fr 1fr; }
}

.ziyun-text-imgs { margin-top: 1.5rem; }
.ziyun-text-imgs img { margin-bottom: 1rem; width: 100%; }

/* ---------- Donate / Contact ---------- */
.contact-table { width: 100%; border-collapse: collapse; }

.contact-table td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  vertical-align: top;
  font-size: var(--text-sm);
}

.contact-table td:first-child {
  font-weight: bold;
  color: var(--link);
  white-space: nowrap;
  width: 80px;
}

/* Stack contact table on very small screens */
@media (max-width: 479px) {
  .contact-table,
  .contact-table tbody,
  .contact-table tr,
  .contact-table td { display: block; }

  .contact-table td:first-child {
    white-space: normal;
    padding-bottom: 0.1rem;
    color: var(--gold);
  }

  .contact-table tr { margin-bottom: 1rem; }
}

.donate-address {
  background: var(--cream-dark);
  border: 1px solid var(--gold-pale);
  border-left: 4px solid var(--gold);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: var(--text-sm);
}

/* ---------- Page header band ---------- */
.page-header-band {
  background: linear-gradient(135deg, var(--brown) 60%, var(--brown-mid));
  padding: 1.5rem 0;
}

@media (min-width: 640px) { .page-header-band { padding: 2rem 0; } }

.page-header-band h1 {
  color: var(--gold);
  margin: 0 0 0.25rem;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
}

.page-header-band .breadcrumb {
  font-size: var(--text-xs);
  color: #e8d5b0;
}

.page-header-band .breadcrumb a { color: var(--gold); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--brown);
  border-top: 4px solid var(--gold);
  margin-top: 3rem;
}

.footer-banner {
  display: block;
  width: 100%;
  max-height: 80px;
  object-fit: cover;
  object-position: center;
}

@media (min-width: 640px) { .footer-banner { max-height: 110px; } }
@media (min-width: 1024px) { .footer-banner { max-height: 130px; } }

.footer-inner {
  padding: 1rem 0;
  text-align: center;
  color: var(--gold);
  font-size: var(--text-xs);
}

.footer-inner a { color: var(--gold-pale); }
.footer-inner a:hover { color: #fff; }

.footer-contact {
  margin-bottom: 0.4rem;
  font-size: var(--text-sm);
  line-height: 1.8;
}

/* Stack footer contact on mobile */
@media (max-width: 639px) {
  .footer-contact .sep { display: none; }
  .footer-contact .footer-item { display: block; }
}

/* ---------- Welcome / Message section ---------- */
.message-section {
  background: var(--cream-dark);
  padding: 2rem 0;
  border-top: 1px solid var(--gold-pale);
}

@media (min-width: 640px) { .message-section { padding: 2.5rem 0; } }

/* ---------- Utilities ---------- */
.text-gold   { color: var(--gold); }
.text-brown  { color: var(--brown); }
.bold        { font-weight: bold; }
.italic      { font-style: italic; }
.signature   { font-style: italic; font-size: 0.95rem; color: var(--brown-mid); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------- Map ---------- */
.map-wrap {
  margin: 1.5rem 0;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--cream-dark);
}

.map-wrap iframe {
  display: block;
  width: 100%;
  height: 320px;
  border: none;
}

@media (min-width: 640px) {
  .map-wrap iframe { height: 400px; }
}

@media (min-width: 1024px) {
  .map-wrap iframe { height: 460px; }
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

/* ---------- Footer credit line ---------- */
.footer-credit {
  font-size: 0.72rem;
  margin-top: 0.5rem;
  color: var(--link);
}

/* ---------- Book distributor address (gaon.html) ---------- */
.distribute-address {
  background: var(--cream-dark);
  border: 1px solid var(--gold-pale);
  border-left: 4px solid var(--gold);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: var(--text-sm);
}

/* ---------- Print ---------- */
@media print {
  .site-header,
  .top-bar,
  .quick-nav,
  .site-footer,
  .nav-toggle,
  .hero-cta,
  .book-nav-bar { display: none !important; }

  body { font-size: 11pt; color: #000; background: #fff; }
  a { color: #000; text-decoration: underline; }
  .content-inner { border: none; padding: 0; }
}
