@layer reset, base, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; scroll-padding-top: 6rem; }
  body { margin: 0; }
  button, input { font: inherit; }
  img, svg { max-width: 100%; }
}

@layer base {
  :root {
    color-scheme: light;
    --paper: #f9f7f0;
    --surface: #fffdf8;
    --ink: #312932;
    --muted: #605963;
    --rule: #d7d0c4;
    --accent: #963e2c;
    --plum: #332b39;
    --serif: "Iowan Old Style", Charter, "Palatino Linotype", Palatino, Georgia, serif;
    --ui: Inter, "Helvetica Neue", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  }
  body { background: var(--paper); color: var(--ink); font: 16px/1.65 var(--ui); -webkit-font-smoothing: antialiased; }
  a { color: inherit; text-underline-offset: .22em; }
  a:hover { color: var(--accent); }
  :focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
  [hidden] { display: none !important; }
  .journal-page { min-height: 100vh; overflow-wrap: break-word; }
  .journal-page :where(h1, h2, h3, p, blockquote) { margin-block-start: 0; }
  .journal-page :where(h1, h2, blockquote) { font-family: var(--serif); font-weight: 400; }
  .journal-page :where(p, li) { max-width: 72ch; }
  .journal-page :where(sup) { color: var(--accent); font: 700 .66em/1 var(--ui); padding-inline-end: .38em; vertical-align: super; }
  .journal-page :where([dir="rtl"]) { text-align: start; }
  .journal-page :where([lang="ar"], [lang="he"]) { font-family: "Noto Naskh Arabic", "Noto Serif Hebrew", Georgia, serif; line-height: 1.9; }
  .journal-page .skip-link { position: fixed; z-index: 20; inset: .5rem auto auto .5rem; transform: translateY(-160%); padding: .6rem 1rem; background: var(--surface); }
  .journal-page .skip-link:focus { transform: none; }
}

@layer components {
  .journal-header { position: relative; border-bottom: 1px solid var(--rule); }
  .journal-page > .journal-header { min-height: 72px; padding-inline: max(1.25rem, calc((100vw - 1232px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
  .journal-page > main > article { width: min(100% - 2.5rem, 1120px); margin-inline: auto; }
  .journal-header-inner, .journal-footer-inner { width: min(100% - 2.5rem, 1232px); margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
  .journal-header-inner { min-height: 72px; }
  .journal-brand { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink); text-decoration: none; font: 600 30px/1 var(--serif); letter-spacing: -.055em; white-space: nowrap; }
  .journal-brand img { width: 38px; height: 38px; }
  .journal-header nav { display: flex; align-items: center; gap: clamp(.85rem, 3vw, 2rem); font: 600 .86rem/1.3 var(--ui); }
  .journal-header nav a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
  .journal-header nav a:hover { text-decoration: underline; }
  .journal-shell { width: min(100% - 2.5rem, 1120px); margin-inline: auto; }
  .journal-hero { position: relative; max-width: 920px; padding-block: clamp(2.6rem, 4vw, 4rem) clamp(1.7rem, 2.8vw, 2.7rem); }
  .journal-page > main .journal-hero { margin-inline: auto; }
  .journal-hero .eyebrow { flex-wrap: wrap; gap: .45rem; margin-bottom: 1.6rem; }
  .journal-hero .eyebrow a { display: inline-flex; align-items: center; min-height: 32px; text-decoration: none; }
  .journal-hero .eyebrow a:hover { text-decoration: underline; }
  .journal-hero__edition { margin-bottom: .95rem; color: var(--accent); font: 700 .7rem/1.4 var(--ui); letter-spacing: .15em; text-transform: uppercase; }
  .journal-hero__reference { margin-bottom: .5rem; color: var(--accent); font: 650 1.04rem/1.4 var(--ui); }
  .journal-hero__intro { max-width: 40rem; margin-bottom: 0; color: var(--muted); font-size: 1.02rem; }
  .journal-kicker, .eyebrow, .section-kicker { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.3rem; color: var(--accent); font: 700 .7rem/1.4 var(--ui); letter-spacing: .15em; text-transform: uppercase; }
  .journal-kicker::before, .section-kicker::before { content: ""; flex: 0 0 30px; border-top: 1px solid currentColor; }
  .journal-hero h1 { max-width: 20ch; margin-bottom: 1.1rem; font-size: clamp(2.65rem, 4.2vw, 4.2rem); letter-spacing: -.05em; line-height: 1.07; text-wrap: balance; }
  .journal-deck { max-width: 48rem; margin-bottom: 1.2rem; color: #534b51; font: clamp(1.05rem, 1.5vw, 1.25rem)/1.62 var(--ui); text-wrap: pretty; }
  .journal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; color: var(--muted); font: 500 .81rem/1.5 var(--ui); }
  .journal-meta span + span::before { content: "·"; margin-inline-end: .7rem; color: #a89d9a; }
  .journal-content { max-width: 900px; margin-inline: auto; padding-bottom: 3rem; }
  .passage-card { position: relative; isolation: isolate; overflow: hidden; margin: 0 0 clamp(2.5rem, 5vw, 5rem); padding: clamp(1.6rem, 4vw, 3.6rem); border: 1px solid #d5c7b5; border-radius: 45% 45% 8px 8px / 11% 11% 8px 8px; background: #f0e9db; box-shadow: 0 16px 36px -34px #2b2023; }
  .reading-grid { max-width: 920px; margin-inline: auto; }
  .passage-card__header { display: flex; align-items: end; flex-wrap: wrap; gap: .2rem 1rem; margin-bottom: 1.3rem; padding-bottom: 1.1rem; border-bottom: 1px solid #cbbba9; }
  .passage-card__header .section-kicker { flex-basis: 100%; margin-bottom: .25rem; }
  .passage-card__header h2 { margin: 0; font: 400 clamp(1.65rem, 2.7vw, 2.35rem)/1.2 var(--serif); letter-spacing: -.035em; }
  .passage-card__header .edition-note { margin-inline-start: auto; }
  .passage-card::before { content: ""; position: absolute; z-index: -1; width: clamp(150px, 30vw, 280px); aspect-ratio: 1; inset: 0 0 auto auto; background: url('/blog/share-mark.svg') center / contain no-repeat; opacity: .31; pointer-events: none; }
  .passage-card::after { content: ""; position: absolute; inset: 8px 8px 7px; border: 1px solid #bba78e89; border-radius: inherit; pointer-events: none; }
  .passage-label { margin-bottom: 1.1rem; color: var(--accent); font: 700 .72rem/1.5 var(--ui); letter-spacing: .14em; text-transform: uppercase; }
  .passage-card blockquote, .passage-text { max-width: 28em; margin: 0; font: clamp(1.35rem, 2.5vw, 2rem)/1.56 var(--serif); letter-spacing: -.012em; }
  .passage-card .passage-full { max-width: none; font-size: clamp(1.14rem, 1.9vw, 1.4rem); line-height: 1.72; }
  .passage-card .passage-text { max-width: none; font-size: clamp(1.18rem, 1.8vw, 1.46rem); line-height: 1.72; }
  .passage-card .passage-line { margin: 0 0 .7em; max-width: none; }
  .verse-number { display: inline-block; min-width: 1.65em; color: var(--accent); font: 700 .62em/1.3 var(--ui); vertical-align: baseline; }
  .passage-card .source-link { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid #cbbba9; color: var(--accent); font: 700 .82rem/1.5 var(--ui); }
  .passage-card .source-link a { text-decoration: none; }
  .passage-card .source-link a:hover { text-decoration: underline; }
  .passage-card :where(p, blockquote) + :where(p, blockquote) { margin-top: 1em; }
  .passage-source { margin: 1.35rem 0 0; color: var(--muted); font: 600 .8rem/1.5 var(--ui); }
  .passage-card [dir="rtl"] { margin-inline: auto; }
  .share-tools, .share-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; margin-top: 1.7rem; }
  .share-tools button, .share-controls button { min-height: 44px; padding: .62rem 1rem; border: 1px solid #a99788; border-radius: 5px; background: #fffaf1; color: var(--ink); cursor: pointer; font: 650 .82rem/1.3 var(--ui); }
  .share-tools button:first-child, .share-controls button:first-child { background: var(--plum); border-color: var(--plum); color: #fff9f0; }
  .share-tools button:hover, .share-controls button:hover { border-color: var(--accent); color: var(--accent); }
  .share-tools button:first-child:hover, .share-controls button:first-child:hover { background: #4a3e50; color: #fff; }
  .share-tools button:disabled, .share-controls button:disabled { opacity: .6; cursor: wait; }
  .share-publish { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; padding: 1rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); }
  .share-publish > label { display: grid; gap: .25rem; min-width: 125px; font: 600 .82rem/1.3 var(--ui); }
  .share-publish select, .share-publish textarea { min-height: 44px; padding: .5rem; border: 1px solid #a99788; border-radius: 5px; background: var(--paper); color: var(--ink); font: inherit; }
  .share-publish .share-excerpt-label { flex-basis: 100%; }
  .share-publish textarea { width: 100%; }
  .share-source { max-height: 160px; overflow: auto; margin: .5rem 0; padding: .7rem; border: 1px solid var(--rule); font: 1rem/1.5 var(--serif); }
  .share-published { flex-basis: 100%; min-width: 0; }
  .share-result-image { display: block; width: min(240px, 100%); margin: 1rem 0; border: 1px solid var(--rule); }
  .share-result-url { display: block; overflow-wrap: anywhere; }
  .share-download { display: inline-flex; align-items: center; min-height: 44px; padding: .62rem 1rem; border: 1px solid #a99788; border-radius: 5px; background: #fffaf1; text-decoration: none; font: 650 .82rem/1.3 var(--ui); }
  @media (hover: hover) and (pointer: fine) { .share-tools button:hover, .share-controls button:hover, .share-download:hover { transform: translateY(-1px); } }
  .share-tools button, .share-controls button, .share-download { transition: background-color .14s, border-color .14s, transform .14s; }
  .share-tools button:active, .share-controls button:active { transform: scale(.99); }
  .share-status { flex-basis: 100%; min-height: 1.2em; color: var(--accent); font: 600 .78rem/1.4 var(--ui); }
  .reading-context, .journal-section { max-width: 760px; margin-inline: auto; margin-block: 0 3.75rem; }
  .reading-context .section-heading, .related-readings .section-heading { margin-bottom: 1.15rem; }
  .reading-context .section-heading h2, .related-readings .section-heading h2 { margin-bottom: 0; }
  .context-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1.5rem; margin-block: 1.5rem; }
  .context-column { padding: 1.1rem 1.3rem; border-inline-start: 2px solid #c5aa99; background: #f1ede4; }
  .context-column h3 { margin-top: 0; }
  .context-lines p { margin-bottom: .75rem; font: 1.16rem/1.7 var(--serif); }
  .edition-note { color: var(--muted); font: 500 .75rem/1.6 var(--ui); }
  .journal-section + .journal-section { border-top: 1px solid var(--rule); padding-top: 2rem; }
  .reading-context h2, .journal-section h2, .related-readings h2, .app-invitation h2 { margin-bottom: 1rem; font: 400 clamp(1.85rem, 3.2vw, 2.8rem)/1.14 var(--serif); letter-spacing: -.04em; text-wrap: balance; }
  .reading-context h3, .journal-section h3 { margin: 1.75rem 0 .45rem; color: var(--plum); font: 700 .78rem/1.4 var(--ui); letter-spacing: .09em; text-transform: uppercase; }
  .reading-context p, .journal-section p, .journal-section li { color: #484049; font: clamp(1rem, 1.2vw, 1.07rem)/1.78 var(--ui); }
  .journal-section blockquote { margin: 1.5rem 0; padding-inline-start: 1.2rem; border-inline-start: 2px solid var(--accent); font: 1.4rem/1.5 var(--serif); }
  .journal-section a { color: var(--accent); }
  .journal-section table { width: 100%; border-collapse: collapse; }
  .journal-section td, .journal-section th { padding: .75rem 1rem .75rem 0; border-top: 1px solid var(--rule); text-align: start; vertical-align: top; }
  .source-note, .source-credit { color: var(--muted) !important; font-size: .79rem !important; }
  .related-readings { max-width: 920px; margin: 3rem auto; padding-block: 2.25rem; border-top: 1px solid var(--rule); }
  .related-readings ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
  .related-readings li { min-width: 0; }
  .related-readings a { display: block; min-height: 100%; padding: 1.15rem; border: 1px solid var(--rule); border-radius: 5px; background: var(--surface); text-decoration: none; font: 600 1rem/1.4 var(--serif); }
  .related-readings a:hover { border-color: var(--accent); color: var(--accent); }
  .related-readings > a { display: inline-flex; min-height: 44px; align-items: center; margin-top: 1.2rem; color: var(--accent); font: 700 .85rem/1.4 var(--ui); }
  .app-invitation { max-width: none; margin-block: 4rem 0; padding: clamp(1.75rem, 5vw, 3.5rem); border-radius: 7px; background: var(--plum); color: #fff7eb; }
  .app-invitation .section-kicker, .app-invitation .eyebrow { color: #e4b7a3; }
  .app-invitation h2 { max-width: 20ch; }
  .app-invitation p { color: #f0e2d9; }
  .app-invitation a { display: inline-flex; align-items: center; gap: .55rem; min-height: 46px; margin-top: .75rem; padding: .65rem 1.1rem; border-radius: 5px; background: #f6e8d5; color: var(--plum); font: 700 .86rem/1.25 var(--ui); text-decoration: none; }
  .app-invitation a:hover { background: #fff7eb; }
  .app-invitation :focus-visible { outline-color: #fff0c8; }
  .journal-footer { border-top: 1px solid var(--rule); }
  .journal-page > .journal-footer { min-height: 88px; padding: 1.2rem max(1.25rem, calc((100vw - 1232px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .8rem; }
  .journal-page > .journal-footer a, .journal-footer-inner a { display: inline-flex; align-items: center; min-height: 32px; text-decoration: none; }
  .journal-footer-inner { min-height: 88px; color: var(--muted); font-size: .8rem; }
  .journal-footer-inner .journal-brand { font-size: 24px; }
  .library-index > main { width: min(100% - 2.5rem, 1120px); margin-inline: auto; }
  .library-index > main > .journal-hero { margin-inline: auto; }
  .library-index > main p > a:only-child { display: inline-flex; align-items: center; min-height: 32px; }
  .library-index > main > section:not(.app-invitation) { max-width: 920px; margin-inline: auto; }
  .library-index .section-heading h2 { margin: 0 0 1.3rem; font: 400 clamp(2rem, 3vw, 2.8rem)/1.2 var(--serif); letter-spacing: -.04em; }
  .hub-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; max-width: 920px; margin: 0 auto; padding: 0; list-style: none; }
  .hub-list li { min-width: 0; max-width: none; }
  .analysis-catalog { max-width: 920px; margin: 2rem auto; }
  .analysis-catalog details { border-bottom: 1px solid var(--rule); }
  .analysis-catalog summary { padding: .8rem 0; cursor: pointer; color: var(--ink); font: 600 1rem/1.5 var(--ui); }
  .analysis-catalog summary small { color: var(--muted); font-weight: 400; }
  .analysis-catalog ul { list-style: none; padding: 0; }
  .analysis-catalog li { margin: 0; }
  .analysis-catalog a { display: block; min-height: 44px; padding: .65rem .25rem; line-height: 1.4; overflow-wrap: anywhere; }
  .hub-list a { display: flex; flex-direction: column; justify-content: center; min-height: 100%; gap: .5rem; padding: 1.15rem 1.25rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); text-decoration: none; }
  .hub-list a:hover { border-color: var(--accent); box-shadow: 0 6px 20px -17px #352a32; }
  .hub-phrase { display: block; color: var(--ink); font: 400 1.15rem/1.35 var(--serif); }
  .hub-ref { display: block; color: var(--accent); font: 700 .77rem/1.4 var(--ui); }
  .hub-work-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hub-work-grid li:nth-child(1) { --cover: #574253; }
  .hub-work-grid li:nth-child(2) { --cover: #425747; }
  .hub-work-grid li:nth-child(3) { --cover: #355451; }
  .hub-work-grid li:nth-child(4) { --cover: #9a5d40; }
  .hub-work-grid li:nth-child(5) { --cover: #796944; }
  .hub-work-grid li:nth-child(6) { --cover: #456763; }
  .hub-work-grid li:nth-child(7) { --cover: #665568; }
  .hub-work-grid a { min-height: 242px; justify-content: flex-start; padding: 1.2rem; border-top: 6px solid var(--cover); border-radius: 48% 48% 5px 5px / 17% 17% 5px 5px; }
  .hub-work { display: block; margin-top: .3rem; color: var(--ink); font: 400 1.9rem/1.05 var(--serif); letter-spacing: -.04em; }
  .hub-edition { display: block; color: var(--muted); font: 600 .7rem/1.4 var(--ui); }
  .hub-work-grid .hub-phrase { margin-top: auto; font-size: .99rem; }
  .hub-work-grid .hub-ref { margin-top: .4rem; }
  .hub-pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .75rem; max-width: 920px; margin: 2rem auto 0; font: 650 .85rem/1.4 var(--ui); }
  .hub-pagination a { min-height: 44px; display: inline-flex; align-items: center; padding: .5rem .85rem; border: 1px solid var(--rule); border-radius: 5px; text-decoration: none; }
  .hub-pagination a:hover { border-color: var(--accent); }
  .hub-pagination span { color: var(--muted); }
  .library-index > main > .app-invitation { max-width: 920px; margin-inline: auto; }
}
@media (prefers-reduced-motion: reduce) { .share-tools button, .share-controls button, .share-download { transition: none; transform: none !important; } }
@media (forced-colors: active) { .share-tools button, .share-controls button, .share-publish select, .share-publish textarea, .share-download { border: 1px solid ButtonText; } }

@layer responsive {
  @media (max-width: 700px) {
    .journal-header-inner, .journal-footer-inner, .journal-shell { width: min(100% - 2rem, 100%); }
    .journal-page > main > article { width: min(100% - 2rem, 100%); }
    .journal-header-inner { min-height: 64px; }
    .journal-brand { font-size: 25px; }
    .journal-brand img { width: 32px; height: 32px; }
    .journal-header nav { gap: .75rem; font-size: .77rem; }
    .journal-header nav a { min-height: 44px; }
    .journal-hero { padding-block: 2.5rem 1.8rem; }
    .journal-hero h1 { font-size: clamp(2.42rem, 10.1vw, 3.6rem); }
    .passage-card { padding: 2.25rem 1.45rem 1.65rem; border-radius: 46% 46% 7px 7px / 6% 6% 7px 7px; }
    .passage-card::before { width: 160px; opacity: .22; }
    .related-readings ul { grid-template-columns: 1fr; }
    .journal-footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; padding-block: 1rem; }
  }
  @media (max-width: 390px) {
    .journal-header nav a:not(:last-child) { display: none; }
    .share-tools button, .share-controls button { flex: 1 1 auto; }
    .journal-page > .journal-footer { flex-wrap: wrap; }
    .library-index > main { width: min(100% - 2rem, 100%); }
    .hub-list, .hub-work-grid { grid-template-columns: 1fr; }
    .hub-work-grid a { min-height: 205px; border-radius: 28% 28% 5px 5px / 18% 18% 5px 5px; }
  }
  @media (min-width: 701px) and (max-width: 1000px) {
    .hub-list, .hub-work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  }
}

/* Native disclosure keeps unusually long source units readable on phones. */
.reading-excerpt { font: 1.15rem/1.65 Georgia, serif; overflow-wrap: anywhere; }
.extended-reading { margin-block: 1rem; }
.extended-reading summary { cursor: pointer; min-height: 48px; padding: .8rem 0; color: var(--accent, #963e2c); font: 600 .95rem/1.5 system-ui, sans-serif; }
.extended-reading summary span { font-weight: 400; }
.extended-reading summary:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.extended-reading[open] summary { border-bottom: 1px solid var(--rule, #d6cec2); margin-bottom: 1rem; }

@media (prefers-reduced-motion: no-preference) {
  .hub-list a, .hub-pagination a { transition: background-color 160ms ease, border-color 160ms ease, transform 110ms ease-out; }
  .hub-list a:active, .hub-pagination a:active { transform: translateY(1px); }
}

.guide-pullquote { margin: 1.2rem 0; padding-inline-start: 1rem; border-inline-start: 2px solid var(--accent); color: var(--ink); font: 400 clamp(1.05rem,2vw,1.3rem)/1.45 var(--serif); }
.guide-pullquote cite { display: block; margin-top: .35rem; color: var(--muted); font: 600 .78rem/1.5 var(--ui); }
.guide-source { margin: -.35rem 0 1.3rem; color: var(--muted); font: 500 .85rem/1.5 var(--ui); }
.guide-source a { color: var(--accent); text-underline-offset: .2em; }
.share-tools .open-passage { display: inline-flex; gap: .6rem; align-items: center; min-height: 46px; padding: .6rem 1rem; border-radius: .65rem; background: var(--accent); color: white; text-decoration: none; font: 650 .95rem/1.25 var(--ui); }
.share-tools .card-options { flex-basis: 100%; }
.card-options summary { width: fit-content; min-height: 44px; padding-block: .7rem; color: var(--muted); cursor: pointer; font: 600 .83rem/1.5 var(--ui); }
.card-options[open] { border-bottom: 1px solid var(--rule); padding-bottom: .75rem; }
