/* ——————————————————————————————————————————————
   When Are the Jewish Holidays? · v2
   An almanac for the working week.
   Editorial manuscript aesthetic: parchment, ink,
   pomegranate & gold. Fraunces / Alegreya Sans /
   Spline Sans Mono / Frank Ruhl Libre.
   —————————————————————————————————————————————— */

:root {
  --paper: #f4edde;
  --paper-deep: #ece1c8;
  --paper-card: #faf5ea;
  --ink: #292017;
  --ink-soft: #6b5d49;
  --ink-faint: #a3957d;
  --pom: #9e3a28;
  --pom-deep: #7c2c1e;
  --pom-wash: #efddd2;
  --gold: #a8821f;
  --gold-bright: #c89b35;
  --gold-wash: #f0e5c4;
  --moss: #4d5d3a;
  --moss-wash: #e2e4cd;
  --sea: #2f4858;
  --sea-wash: #dde4e0;
  --night: #1c2233;
  --night-deep: #141927;
  --cream: #efe6d0;
  --rule: #cdbd9b;
  --serif: 'Fraunces', 'Georgia', serif;
  --sans: 'Alegreya Sans', 'Gill Sans', sans-serif;
  --mono: 'Spline Sans Mono', 'Courier New', monospace;
  --hebrew: 'Frank Ruhl Libre', serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--gold-wash); color: var(--pom-deep); }

a { color: var(--pom); text-decoration-color: var(--gold-bright); text-underline-offset: 3px; }
a:hover { color: var(--pom-deep); }

/* ————— Type helpers ————— */
.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.section-no {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 144, 'wght' 340;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--pom);
}

h2.section-title {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 144, 'wght' 560;
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0.35rem 0 0.6rem;
}

.section-lede {
  max-width: 56ch;
  color: var(--ink-soft);
  font-size: 1.06rem;
  margin: 0;
}

/* Ornamental double rule */
.rule {
  border: none;
  height: 7px;
  margin: 0;
  border-top: 1px solid var(--gold);
  border-bottom: 3px double var(--gold);
  opacity: 0.65;
}

/* ————— Masthead ————— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 60, 'wght' 620;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.wordmark .he {
  font-family: var(--hebrew);
  color: var(--pom);
  font-size: 1.15rem;
}

.topnav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.topnav a {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.topnav a:hover { color: var(--pom); border-bottom-color: var(--gold-bright); }
.topnav a.api-link { color: var(--paper); background: var(--ink); padding: 0.42em 0.9em; border-radius: 999px; border: none; }
.topnav a.api-link:hover { background: var(--pom); }

/* ————— Hero ————— */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(3rem, 8vw, 6.5rem) clamp(1rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  max-width: 1280px;
  margin: 0 auto;
}

.hero-ghost {
  position: absolute;
  right: -0.05em;
  top: 45%;
  transform: translateY(-50%);
  font-family: var(--hebrew);
  font-weight: 700;
  font-size: clamp(20rem, 42vw, 36rem);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px color-mix(in srgb, var(--gold) 38%, transparent);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.hero > * { position: relative; z-index: 1; }

.hero h1 {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 144, 'wght' 500;
  font-size: clamp(2.9rem, 7.2vw, 5.6rem);
  line-height: 0.99;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 1.1rem;
}

.hero h1 em {
  font-style: italic;
  font-variation-settings: 'opsz' 144, 'wght' 420, 'WONK' 1;
  color: var(--pom);
}

.hero-sub {
  max-width: 52ch;
  font-size: 1.12rem;
  color: var(--ink-soft);
  margin: 0 0 1.6rem;
}

.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.btn {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.78em 1.5em;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.btn:hover { background: var(--pom); border-color: var(--pom); color: var(--paper); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }

/* Countdown card */
.next-card {
  background: var(--night);
  color: var(--cream);
  border-radius: 14px;
  padding: 1.6rem 1.7rem 1.5rem;
  box-shadow: 0 24px 60px -24px rgba(28, 34, 51, 0.55), 0 0 0 1px rgba(200, 155, 53, 0.25);
  position: relative;
}
.next-card::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(200, 155, 53, 0.35);
  border-radius: 9px;
  pointer-events: none;
}
.next-card .kicker { color: var(--gold-bright); }
.next-card h3 {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 100, 'wght' 540;
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  margin: 0.5rem 0 0.1rem;
  line-height: 1.08;
}
.next-card .he-name {
  font-family: var(--hebrew);
  color: var(--gold-bright);
  font-size: 1.15rem;
}
.next-count {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 0.9rem;
  border-top: 1px solid rgba(200, 155, 53, 0.3);
  padding-top: 0.9rem;
}
.next-count .num {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 144, 'wght' 600;
  font-size: 3.6rem;
  line-height: 1;
  color: var(--gold-bright);
}
.next-count .lbl { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--cream); opacity: 0.8; }
.next-card .date-line { font-family: var(--mono); font-size: 0.78rem; opacity: 0.75; margin-top: 0.5rem; }

/* ————— Sections ————— */
section.block {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(2.6rem, 6vw, 4.6rem) clamp(1rem, 4vw, 3rem);
}

.section-head { margin-bottom: 2.2rem; }

/* ————— Planner ————— */
.planner-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: clamp(1.6rem, 4vw, 3.4rem);
  align-items: start;
}

.controls {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1.5rem;
  position: sticky;
  top: 76px;
  box-shadow: 0 14px 36px -22px rgba(41, 32, 23, 0.4);
}

.control-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
  margin: 1.3rem 0 0.55rem;
}
.controls .control-label:first-child { margin-top: 0; }

.year-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
}
.year-stepper button {
  font-family: var(--mono);
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--pom);
  cursor: pointer;
  padding: 0.35rem 1rem;
  transition: background 0.15s;
}
.year-stepper button:hover { background: var(--pom-wash); }
.year-stepper input {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 100, 'wght' 600;
  font-size: 1.7rem;
  text-align: center;
  width: 6ch;
  border: none;
  background: transparent;
  color: var(--ink);
}
.year-stepper input:focus { outline: 2px solid var(--gold-bright); border-radius: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  user-select: none;
  border-radius: 999px;
  padding: 0.5em 1em;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}
.chip::before { content: '○'; font-size: 0.8em; }
.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.on::before { content: '●'; color: var(--gold-bright); }

.select-row select {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.6em 0.8em;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.controls .ics-btn { width: 100%; margin-top: 1.4rem; text-align: center; display: inline-block; }

/* Result panel */
.result-head {
  display: flex;
  align-items: flex-end;
  gap: 1.2rem;
  flex-wrap: wrap;
  border-bottom: 3px double var(--gold);
  padding-bottom: 1.2rem;
  margin-bottom: 1.6rem;
}
.big-number {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 144, 'wght' 640;
  font-size: clamp(5rem, 11vw, 8.5rem);
  line-height: 0.85;
  color: var(--pom);
  text-shadow: 4px 4px 0 var(--gold-wash);
}
.big-number-label { max-width: 24ch; }
.big-number-label strong { font-family: var(--serif); font-size: 1.25rem; font-variation-settings: 'opsz' 80, 'wght' 580; display: block; }
.big-number-label span { color: var(--ink-soft); font-size: 0.98rem; }

.holiday-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.8rem; }
.holiday-col h4 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55em;
}
.holiday-col h4 .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.holiday-col.weekday h4 { color: var(--pom); }
.holiday-col.weekday h4 .dot { background: var(--pom); }
.holiday-col.weekend h4 { color: var(--ink-faint); }
.holiday-col.weekend h4 .dot { background: var(--ink-faint); }

.holiday-list { list-style: none; margin: 0; padding: 0; }
.holiday-list li {
  display: grid;
  grid-template-columns: 5.4ch 1fr auto;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.62rem 0.4rem;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 55%, transparent);
  animation: rise 0.45s ease both;
}
.holiday-list li:nth-child(-n+18) { animation-delay: calc(var(--i, 0) * 35ms); }
.holiday-list .d {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.holiday-list .t { font-size: 0.99rem; }
.holiday-list .t .he { font-family: var(--hebrew); color: var(--ink-faint); font-size: 0.88em; margin-left: 0.45em; }
.holiday-list .t .tag {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 0.15em 0.5em;
  margin-left: 0.5em;
  vertical-align: 1px;
}
.tag.yomtov { background: var(--pom-wash); color: var(--pom-deep); }
.tag.cholhamoed { background: var(--gold-wash); color: #7a5c12; }
.tag.major-fast, .tag.minor-fast { background: var(--sea-wash); color: var(--sea); }
.tag.minor, .tag.modern { background: var(--moss-wash); color: var(--moss); }
.holiday-list .gcal {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 5px;
  padding: 0.25em 0.6em;
  white-space: nowrap;
  transition: all 0.15s;
}
.holiday-list .gcal:hover { background: var(--gold); color: var(--paper); }
.weekend .holiday-list li { opacity: 0.72; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ————— Calendar ————— */
.cal-band { background: var(--paper-deep); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }

.legend { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-bottom: 1.8rem; }
.legend span { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 0.5em; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .l-yomtov { background: var(--pom); }
.legend .l-cholhamoed { background: var(--gold-bright); }
.legend .l-fast { background: var(--sea); }
.legend .l-minor { background: var(--moss); }

.months {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 1.1rem;
}
.month {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.95rem 1rem 1.05rem;
  box-shadow: 0 10px 24px -18px rgba(41, 32, 23, 0.35);
}
.month h5 {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 80, 'wght' 580;
  font-style: italic;
  font-size: 1.06rem;
  margin: 0 0 0.6rem;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.month h5 .mono { font-family: var(--mono); font-style: normal; font-size: 0.62rem; color: var(--ink-faint); letter-spacing: 0.15em; }
.grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dow {
  font-family: var(--mono);
  font-size: 0.55rem;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-faint);
  padding-bottom: 3px;
}
.day {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  border-radius: 6px;
}
.day.we { color: var(--ink-faint); background: color-mix(in srgb, var(--paper-deep) 65%, transparent); }
.day.hol { color: var(--paper); font-weight: 700; cursor: help; }
.day.hol.c-yomtov { background: var(--pom); }
.day.hol.c-cholhamoed { background: var(--gold-bright); color: var(--ink); }
.day.hol.c-major-fast, .day.hol.c-minor-fast { background: var(--sea); }
.day.hol.c-minor, .day.hol.c-modern { background: var(--moss); }
.day.today { outline: 2px solid var(--pom); outline-offset: 1px; }
.day[data-tip]:hover { z-index: 7; }
.day[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%) translateY(3px);
  background: var(--night);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  padding: 0.5em 0.75em;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 10px 24px -10px rgba(28, 34, 51, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 6;
}
.day[data-tip]::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--night);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 6;
}
.day[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.day[data-tip]:hover::before { opacity: 1; }

/* ————— Compare ————— */
.compare-controls { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; margin-bottom: 1.6rem; }
.compare-controls .field label { display: block; }
.compare-controls input[type='number'] {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 80, 'wght' 580;
  font-size: 1.25rem;
  width: 7ch;
  padding: 0.35em 0.55em;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink);
}

.chart-frame {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1.4rem 1.2rem 0.9rem;
  box-shadow: 0 14px 36px -22px rgba(41, 32, 23, 0.4);
}
#compareChart { width: 100%; height: auto; display: block; }
.chart-note { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; color: var(--ink-faint); text-align: right; padding: 0.5rem 0.3rem 0.4rem; }

/* ————— About cards ————— */
.about-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.2rem; }
.about-card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.3rem 1.4rem;
  position: relative;
  overflow: hidden;
}
.about-card::before {
  content: attr(data-he);
  position: absolute;
  right: 0.18rem;
  bottom: -0.22em;
  font-family: var(--hebrew);
  font-weight: 700;
  font-size: 3rem;
  line-height: 1.15;
  color: color-mix(in srgb, var(--gold) 10%, transparent);
  white-space: nowrap;
  pointer-events: none;
}
.about-card h4 {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 80, 'wght' 600;
  font-size: 1.22rem;
  margin: 0 0 0.15rem;
}
.about-card .dates { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; color: var(--pom); margin-bottom: 0.55rem; }
.about-card p { font-size: 0.92rem; color: var(--ink-soft); margin: 0; position: relative; }

/* ————— API band ————— */
.api-band {
  background: var(--night);
  color: var(--cream);
  border-top: 3px double var(--gold);
}
.api-band .kicker { color: var(--gold-bright); }
.api-band h2.section-title { color: var(--cream); }
.api-band .section-lede { color: color-mix(in srgb, var(--cream) 75%, transparent); }
.api-cols { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.6rem, 4vw, 3.5rem); align-items: center; margin-top: 2rem; }
.api-points { list-style: none; padding: 0; margin: 0 0 1.6rem; }
.api-points li { padding: 0.55rem 0; border-bottom: 1px solid rgba(200, 155, 53, 0.2); display: flex; gap: 0.7em; align-items: baseline; font-size: 1.02rem; }
.api-points li::before { content: '※'; color: var(--gold-bright); }
.codeblock {
  background: var(--night-deep);
  border: 1px solid rgba(200, 155, 53, 0.3);
  border-radius: 10px;
  padding: 1.2rem 1.3rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
  overflow-x: auto;
  box-shadow: 0 20px 50px -25px rgba(0, 0, 0, 0.8);
}
.codeblock .c { color: #6e7891; }
.codeblock .g { color: var(--gold-bright); }
.codeblock .p { color: #d98a76; }
.api-band .btn { border-color: var(--gold-bright); background: var(--gold-bright); color: var(--night); }
.api-band .btn:hover { background: var(--cream); border-color: var(--cream); }
.api-band .btn.ghost { background: transparent; color: var(--gold-bright); }
.api-band .btn.ghost:hover { background: var(--gold-bright); color: var(--night); }

/* ————— Footer ————— */
footer {
  padding: 2.4rem clamp(1rem, 4vw, 3rem) 3rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
footer .he { font-family: var(--hebrew); color: var(--gold); font-size: 1.3rem; display: block; margin-bottom: 0.6rem; }

.loading { opacity: 0.45; pointer-events: none; filter: saturate(0.6); transition: opacity 0.2s; }

/* ————— Responsive ————— */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-ghost { font-size: 24rem; opacity: 0.6; }
  .next-card { transform: none; max-width: 460px; }
  .planner-grid { grid-template-columns: 1fr; }
  .controls { position: static; }
  .api-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .holiday-cols { grid-template-columns: 1fr; }
  .holiday-list li { grid-template-columns: 5.4ch 1fr; }
  .holiday-list .gcal { grid-column: 2; justify-self: start; }
  .topnav { display: none; }
}
