/* Ohr HaYom — warm cream parchment, gold accents, deep brown ink. */
:root {
  --bg: #faf6ec;
  --card: #fffcf4;
  --card-warm: #fbf3df;
  --ink: #2e2118;
  --ink-soft: #5e4b39;
  --muted: #9a8670;
  --gold: #c3a046;
  --gold-deep: #9c7d2c;
  --gold-soft: #eadcae;
  --gold-line: rgba(195, 160, 70, 0.45);
  --brown: #6b4a2b;
  --night: #2b1c13;
  --night-2: #3a271b;
  --night-gold: #e2c77c;
  --radius: 14px;
  --font-en: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --font-he: 'Frank Ruhl Libre', 'Noto Serif Hebrew', 'David', serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-soft);
  font-family: var(--font-en);
  font-size: 16px;
  line-height: 1.75;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(234, 214, 160, 0.35), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(234, 214, 160, 0.18), transparent 70%);
  background-attachment: fixed;
}

[lang='he'], .he {
  font-family: var(--font-he);
  direction: rtl;
  text-align: right;
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
}

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

.hero {
  text-align: center;
  padding: clamp(1.75rem, 5vw, 2.75rem) 1rem 0;
}

.logo {
  display: block;
  width: clamp(96px, 20vw, 124px);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(195, 160, 70, 0.14), 0 10px 28px rgba(80, 55, 20, 0.18);
  background: var(--gold-soft);
}

.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.app-name { margin: 1rem 0 0; font-weight: 700; line-height: 1.2; }
.app-name .he { display: block; text-align: center; font-size: clamp(1.9rem, 5vw, 2.4rem); color: var(--ink); }
.app-name .en-sub {
  display: block;
  font-family: var(--font-en);
  font-weight: 400;
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.site-nav {
  display: inline-flex;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover { color: var(--gold-deep); }
.site-nav a[aria-current='page'] { color: var(--gold-deep); border-bottom-color: var(--gold); }

.week-line {
  margin: 1.75rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem 0.5rem;
}

.week-line strong { color: var(--ink); letter-spacing: 0.02em; text-transform: none; font-size: 0.95rem; }
.week-line .he { font-size: 1rem; letter-spacing: 0; text-transform: none; color: var(--ink); }

.flame {
  color: var(--gold);
  font-size: 1rem;
  transform-origin: 50% 90%;
  animation: flicker 2.8s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { transform: rotate(-2deg) scaleY(1); opacity: 0.95; }
  30% { transform: rotate(2deg) scaleY(1.06); opacity: 1; }
  55% { transform: rotate(-1deg) scaleY(0.96); opacity: 0.85; }
  80% { transform: rotate(1deg) scaleY(1.03); opacity: 1; }
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
}

.controls .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.select-wrap .icon {
  position: absolute;
  left: 1rem;
  color: var(--gold-deep);
  pointer-events: none;
}

.select-wrap::after {
  content: '';
  position: absolute;
  right: 1rem;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--ink-soft);
  border-bottom: 1.5px solid var(--ink-soft);
  transform: translateY(-25%) rotate(45deg);
  pointer-events: none;
}

select, input[type='search'] {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: 8px;
  min-width: 0;
  max-width: 100%;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.6rem 2.5rem 0.6rem 2.6rem;
  cursor: pointer;
  text-overflow: ellipsis;
}

input[type='search'] {
  width: min(460px, 100%);
  padding: 0.65rem 1rem;
}

select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--gold);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.segmented button {
  font: inherit;
  font-size: 0.88rem;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 0.42rem 0.85rem;
  cursor: pointer;
}

.segmented button[lang='he'] { font-family: var(--font-he); font-size: 0.95rem; }
.segmented button[aria-pressed='true'] { background: var(--gold); color: #fff; }

.btn {
  font: inherit;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--gold);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.btn:hover { background: #f6ecd2; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.notice {
  max-width: 560px;
  margin: 1.1rem auto 0;
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
}

.notice .he { display: block; text-align: center; font-style: normal; font-size: 0.95rem; }

/* ---------- Main ---------- */

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 2.25rem 1rem 3rem;
}

.error { text-align: center; padding: 2rem 0; color: #8a3a1e; }
.error p { margin-top: 0; }

/* ---------- Ornament divider ---------- */

.ornament {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 300px;
  margin: 1.75rem auto;
  color: var(--gold);
  font-size: 0.8rem;
}

.ornament::before, .ornament::after {
  content: '';
  flex: 1;
  height: 1px;
}

.ornament::before { background: linear-gradient(to right, transparent, var(--gold)); }
.ornament::after { background: linear-gradient(to left, transparent, var(--gold)); }

/* ---------- Teaching ---------- */

.teaching-head { text-align: center; }

.teaching-title { margin: 0; font-weight: 700; color: var(--ink); }
.teaching-title .he { display: block; text-align: center; font-size: clamp(1.9rem, 5.5vw, 2.5rem); line-height: 1.25; }

.teaching-title .en {
  display: block;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.15rem, 3.5vw, 1.45rem);
  color: var(--ink-soft);
  margin-top: 0.35rem;
}

body[data-lang='en'] .teaching-title .en {
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
}

.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 0.8rem; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.85rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--ink);
  font-size: 0.85rem;
}

.pill.he { text-align: center; font-size: 0.95rem; }

.panel {
  background: linear-gradient(180deg, var(--card), var(--card-warm));
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 1.75rem);
  margin-top: 1.25rem;
  box-shadow: 0 1px 2px rgba(80, 55, 20, 0.05);
}

.label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brown);
}

.label .icon { color: var(--gold-deep); font-size: 0.95rem; }
.label .he { font-size: 0.85rem; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.label .dot { color: var(--muted); font-weight: 400; }

.lang-rule {
  border: 0;
  height: 1px;
  margin: 1.1rem auto;
  background: linear-gradient(to right, transparent, var(--gold-line), transparent);
}

body:not([data-lang='both']) .lang-rule,
body:not([data-lang='both']) .label .dot { display: none; }

.text p { margin: 0 0 0.8em; }
.text p:last-child { margin-bottom: 0; }
.text.he { font-size: 1.2rem; line-height: 1.9; color: var(--ink); }
.text.en { font-size: 0.98rem; }

/* Verse */
.verse-card {
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(195, 160, 70, 0.08), 0 10px 30px rgba(160, 120, 40, 0.12);
}

.verse-card .ref {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.7rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--gold-line);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.verse-card .ref .he { font-size: 0.95rem; }
.verse-card .text.he { font-size: clamp(1.4rem, 4.2vw, 1.7rem); line-height: 1.7; font-weight: 500; }
.verse-card .text.en { font-style: italic; font-size: 1.02rem; color: var(--ink-soft); }
.verse-card .lang-rule { display: none; }
.verse-card .text.en { margin-top: 0.6rem; }

/* Commentary */
.commentary-card { border-left: 4px solid var(--brown); }

/* Story */
.story-card .text.en { font-style: italic; }

/* Practice */
.practice-card {
  background: linear-gradient(160deg, var(--night-2), var(--night));
  border: 1.5px solid var(--gold);
  text-align: center;
  color: #f3e6c8;
  box-shadow: 0 12px 30px rgba(43, 28, 19, 0.28);
}

.practice-card .star { color: var(--night-gold); font-size: 1.35rem; }
.practice-card .label { justify-content: center; color: var(--night-gold); margin: 0.4rem 0 0.9rem; }
.practice-card .label .he, .practice-card .label .dot { color: #c9b27a; }
.practice-card .text.he { text-align: center; color: #fbf1d9; font-weight: 500; font-size: 1.25rem; }
.practice-card .text.en { font-style: italic; color: #eadbb8; font-size: 1.05rem; }
.practice-card .lang-rule { background: linear-gradient(to right, transparent, rgba(226, 199, 124, 0.6), transparent); }

/* Blessing */
.blessing { text-align: center; }
.blessing .text.he { text-align: center; font-size: 1.2rem; color: var(--ink-soft); }
.blessing .text.en { font-style: italic; color: var(--muted); }
.blessing .lang-rule { max-width: 120px; }

.meta {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2rem;
}

/* ---------- Language modes ---------- */

body[data-lang='en'] .he { display: none !important; }
body[data-lang='he'] .en { display: none !important; }
body[data-lang='he'] .label { direction: rtl; }
body[data-lang='he'] .label .he { font-size: 0.95rem; font-weight: 700; color: var(--brown); }
body[data-lang='he'] .practice-card .label .he { color: var(--night-gold); }
body[data-lang='he'] .commentary-card { border-left: 1px solid var(--gold-line); border-right: 4px solid var(--brown); }

/* ---------- Loading shimmer ---------- */

.skeleton { text-align: center; }

.shimmer {
  border-radius: 6px;
  height: 0.95rem;
  margin: 0.75rem auto;
  background: linear-gradient(90deg, #efe4c9 0%, #fbf5e6 45%, #efe4c9 90%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.shimmer.title { height: 2.3rem; width: 60%; }
.shimmer.sub { height: 1.2rem; width: 45%; }
.shimmer.pill-line { height: 1.4rem; width: 28%; border-radius: 999px; }
.shimmer.short { width: 72%; margin-left: 0; }
.skeleton .panel .shimmer { margin-left: 0; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.loading-text { color: var(--muted); font-style: italic; font-size: 0.9rem; margin-top: 1.25rem; }

/* ---------- Entrance animation ---------- */

.fade-in-up { animation: fadeInUp 0.7s ease-out both; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in-up, .flame, .shimmer { animation: none; }
}

/* ---------- Archive ---------- */

.archive-count { text-align: center; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 1rem; }

.archive-item { padding: 0; overflow: hidden; }
.archive-item + .archive-item { margin-top: 0.9rem; }

.archive-item summary {
  list-style: none;
  cursor: pointer;
  padding: 1.1rem 1.4rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  align-items: center;
}

.archive-item summary::-webkit-details-marker { display: none; }
.archive-item summary .titles { min-width: 0; color: var(--ink); }
.archive-item summary .titles .he { display: block; font-size: 1.3rem; font-weight: 700; }
.archive-item summary .titles .en { display: block; font-style: italic; color: var(--ink-soft); }

.archive-item summary .info { font-size: 0.78rem; color: var(--muted); text-align: right; line-height: 1.6; }
.archive-item summary .info .he { font-size: 0.9rem; margin-left: 0.4rem; }

.archive-item summary .chevron {
  display: inline-block;
  margin-left: 0.5rem;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--gold-deep);
  border-bottom: 1.5px solid var(--gold-deep);
  transform: rotate(-45deg);
  transition: transform 0.2s;
}

.archive-item[open] summary .chevron { transform: rotate(45deg); }
.archive-item[open] summary { border-bottom: 1px solid var(--gold-line); }
.archive-item .body { padding: 0.5rem clamp(0.75rem, 3vw, 1.4rem) 1.5rem; background: var(--bg); }
.archive-item .teaching-head, .archive-item .teaching-head + .ornament { display: none; }

.item-actions { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); font-style: italic; }
.empty a { color: var(--gold-deep); }

body[data-lang='he'] .archive-item summary { direction: rtl; }
body[data-lang='he'] .archive-item summary .info { text-align: left; }

.site-footer {
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 1rem 2.5rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  body { font-size: 15px; }
  .controls .row { width: 100%; }
  .select-wrap, .select-wrap select { width: 100%; }
  .archive-item summary { grid-template-columns: 1fr; }
  .archive-item summary .info { text-align: left; }
  body[data-lang='he'] .archive-item summary .info { text-align: right; }
}

/* ---------- Print ---------- */

@media print {
  @page { margin: 1.5cm; }

  body { background: #fff !important; color: #000; font-size: 11pt; }

  .no-print, .site-nav, .controls, .week-line, .notice, .site-footer, .loading-text { display: none !important; }

  .hero { padding: 0; display: flex; align-items: center; justify-content: center; gap: 0.75rem; }
  .logo { width: 56px; margin: 0; box-shadow: none; border-width: 2px; }
  .app-name { margin: 0; text-align: left; }
  .app-name .he { font-size: 1.4rem; text-align: left; }
  .app-name .en-sub { font-size: 0.8rem; margin: 0; }

  main { max-width: none; padding: 1rem 0 0; }

  .fade-in-up { animation: none !important; opacity: 1 !important; transform: none !important; }

  .panel, .practice-card, .verse-card {
    box-shadow: none !important;
    background: #fff !important;
    border: 1px solid #b89a4a;
    color: #000;
  }

  .commentary-card { border-left: 3px solid #6b4a2b; }
  .practice-card .text.he, .practice-card .text.en, .practice-card .label { color: #000 !important; }
  .practice-card .star { color: #b89a4a; }

  .panel, .teaching-head, .blessing { break-inside: avoid; page-break-inside: avoid; }
  .label { break-after: avoid; page-break-after: avoid; }

  .archive-item:not([open]) { display: none; }
  .archive-item summary { display: none; }
  .archive-item .body { background: #fff; padding: 0; }
  .archive-item .teaching-head { display: block; }
}
