/* Public site shell — sticky header, hero, hamburger, footer */

body.public-site {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--bg) 28%, var(--bg) 100%);
}

/* —— Sticky header —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
  width: 100%;
  box-sizing: border-box;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
  flex: 0 1 auto;
  max-width: min(280px, 28vw);
}

.site-brand:hover {
  color: var(--ink);
}

.site-brand__crest {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.site-brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.site-brand__name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.site-brand__sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.site-nav {
  display: none;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

.site-nav > a,
.nav-item__label {
  position: relative;
  display: inline-block;
  padding: 0.35rem clamp(0.28rem, 0.55vw, 0.45rem);
  font-size: clamp(0.72rem, 0.95vw, 0.82rem);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.nav-item {
  position: relative;
}

.nav-item__label--static {
  user-select: none;
}

.site-nav > a:hover,
.site-nav > a.is-active,
.nav-item__label:hover,
.nav-item__label.is-active {
  color: var(--crimson);
}

.nav-sub {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 14rem;
  max-width: min(22rem, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.4rem 0;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 120;
}

.nav-item:hover > .nav-sub,
.nav-item:focus-within > .nav-sub,
.nav-item.is-open > .nav-sub {
  display: block;
}

.nav-sub a {
  display: block;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  white-space: normal;
  line-height: 1.3;
}

.nav-sub a:hover,
.nav-sub a.is-active {
  color: var(--crimson);
  background: rgba(139, 0, 0, 0.04);
}

.nav-drawer__acc {
  border-bottom: 1px solid var(--line);
}

.nav-drawer__acc summary {
  padding: 0.9rem 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-drawer__acc a {
  border-bottom: none;
  padding-left: 1.25rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.nav-toggle[aria-expanded='true'] {
  border-color: var(--crimson);
  color: var(--crimson);
}

/* Mobile drawer */
.nav-drawer {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: 99;
  background: rgba(10, 10, 10, 0.35);
}

.nav-drawer.is-open {
  display: block;
}

.nav-drawer__panel {
  margin-left: auto;
  width: min(320px, 88vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  animation: drawerIn 0.22s ease;
}

@keyframes drawerIn {
  from { transform: translateX(12px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.nav-drawer__panel a {
  display: block;
  padding: 0.9rem 0.75rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.nav-drawer__panel a.is-active {
  color: var(--crimson);
}

@media (min-width: 1160px) {
  .site-nav { display: flex; }
  .nav-toggle { display: none; }
  .nav-drawer { display: none !important; }
  .site-brand__sub { max-width: none; }
}

/* —— Hero —— */
.hero {
  position: relative;
  width: 100%;
  padding: clamp(2.5rem, 8vw, 5rem) 1.25rem clamp(2rem, 5vw, 3.5rem);
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.hero__crest {
  width: min(200px, 42vw);
  height: auto;
  margin: 0 auto 1.5rem;
  display: block;
}

.hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4vw, 2.45rem);
  font-weight: 600;
  line-height: 1.3;
  max-width: 22ch;
  margin: 0 auto 0.75rem;
  color: var(--ink);
  font-optical-sizing: auto;
}

.hero__subtitle {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  font-style: italic;
  font-weight: 500;
  color: var(--muted);
  margin: 0 auto 0.5rem;
  max-width: 36ch;
  line-height: 1.4;
}

.hero__patronage {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 auto 1.75rem;
  max-width: 40ch;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.hero__cta .btn {
  min-width: 10rem;
}

.hero__cta .btn-ghost {
  background: transparent !important;
  color: var(--crimson) !important;
  border: 1px solid var(--crimson) !important;
}

.hero__cta .btn-ghost:hover {
  background: rgba(139, 0, 0, 0.06) !important;
}

@media (max-width: 520px) {
  .hero__cta {
    flex-direction: column;
    align-items: stretch;
  }
  .hero__cta .btn {
    width: 100%;
  }
}

/* Reveal motion — never leave content stuck invisible (no-JS / tall pages) */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Long archive bodies: skip hide-until-scroll (tables/statute stay readable) */
.content-layout.reveal,
.events-feed.reveal {
  opacity: 1;
  transform: none;
}

/* —— Main content —— */
.public-main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--space-lg) 1.25rem 3rem;
}

.public-main .home-content,
.public-main .about-content,
.public-main .leadership-content,
.public-main .contact-content {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0;
}

.public-main .content-layout .about-content {
  margin: 0;
}

.public-main .rich-text {
  font-size: 1.05rem;
  color: var(--ink);
}

.public-main .rich-text h1,
.public-main .rich-text h2,
.public-main .rich-text h3 {
  font-family: var(--font-display);
  color: var(--ink);
  border-bottom-color: var(--line);
}

.public-main .rich-text h1 {
  border-bottom: 2px solid var(--crimson);
}

.public-main .rich-text a {
  color: var(--crimson);
}

.page-header-simple {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.page-header-simple h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0;
}

/* —— Content layout + sidebar —— */
.content-layout {
  max-width: 72rem;
  margin: 0 auto;
}

.content-layout--with-sidebar {
  display: grid;
  gap: 1.75rem;
}

@media (min-width: 900px) {
  .content-layout--with-sidebar {
    grid-template-columns: 15rem minmax(0, 1fr);
    align-items: start;
  }
}

.section-sidebar__toggle {
  display: none;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 899px) {
  .section-sidebar__toggle { display: block; }
  .section-sidebar__nav { display: none; }
  .section-sidebar__nav.is-open { display: block; }
}

.section-sidebar__heading {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

.section-sidebar__nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-sidebar__nav li + li {
  border-top: 1px solid var(--line);
}

.section-sidebar__nav a {
  display: block;
  padding: 0.55rem 0.75rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.35;
}

.section-sidebar__nav a:hover,
.section-sidebar__nav a.is-active {
  color: var(--crimson);
  background: rgba(139, 0, 0, 0.04);
}

.content-main.about-content {
  max-width: 42rem;
}

.content-layout--with-sidebar .content-main.about-content {
  max-width: none;
}

/* —— Archive article —— */
.public-main .archive-article {
  line-height: 1.7;
  max-width: 42rem;
  overflow-x: auto; /* wide WP tables (literature) */
}

.content-layout--with-sidebar .archive-article {
  max-width: 48rem;
}

.public-main .archive-article img {
  max-width: min(100%, 420px);
  height: auto;
  display: block;
  margin: 1rem auto;
}

.public-main .archive-article .archive-sep {
  height: 0;
  margin: 0.75rem 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  overflow: hidden;
}

.public-main .archive-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.public-main .archive-article td,
.public-main .archive-article th {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

/* Ranks hierarchy */
.ranks-layout h2,
.ranks-layout h3 {
  margin-top: 1.5rem;
}

.ranks-layout p {
  margin: 0.35rem 0;
}

@media (max-width: 640px) {
  .ranks-layout {
    font-size: 0.98rem;
  }
}

/* Events feed */
.events-feed {
  max-width: 42rem;
  margin: 0 auto;
}

.events-feed__list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.event-card {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.event-card__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}

.event-card__title a {
  color: var(--ink);
  text-decoration: none;
}

.event-card__title a:hover {
  color: var(--crimson);
}

.event-card__excerpt {
  font-size: 0.95rem;
  color: var(--ink);
  max-height: 8.5rem;
  overflow: hidden;
}

.event-card__excerpt img {
  max-height: 120px;
  width: auto;
  margin: 0.5rem 0;
}

.event-card__more {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--crimson);
}

.hub-quick-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hub-quick-links__heading {
  margin: 2rem 0 0.5rem;
  font-size: 1.15rem;
}

/* Org chart: Структура Великого Приората (from archived Adobe Hype) */
.priory-structure__note {
  margin: 0 0 1.25rem;
  color: var(--muted, #5c5c5c);
  font-size: 0.95rem;
}

.priory-structure {
  --ps-red: #b01010;
  --ps-box: #f0f0f0;
  --ps-line: #a0a0a0;
  max-width: 40rem;
  margin: 0 auto 1.5rem;
}

.priory-structure__top,
.priory-structure__offices,
.priory-structure__priories {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.priory-structure__top {
  grid-template-columns: 1fr;
  justify-items: center;
}

.priory-structure__offices {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.priory-structure__office {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
}

.priory-structure__priories {
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.priory-structure__box {
  display: inline-block;
  min-width: 10rem;
  padding: 0.45rem 0.75rem;
  text-align: center;
  background: var(--ps-box);
  border: 1px solid var(--ps-line);
  border-radius: 3px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.25;
}

a.priory-structure__box:hover {
  background: #fff;
  color: var(--ps-red);
  box-shadow: 0 0 0 1px var(--ps-red);
}

.priory-structure__box--chief {
  background: var(--ps-red);
  border-color: #8a0c0c;
  color: #fff;
  font-weight: 600;
  min-width: 14rem;
}

a.priory-structure__box--chief:hover {
  background: #8a0c0c;
  color: #fff;
}

.priory-structure__box--sub {
  min-width: 7rem;
  font-size: 0.85rem;
}

.priory-structure__priorat {
  background: color-mix(in srgb, var(--ps-red) 12%, #fff);
  border: 1px solid var(--ps-line);
  border-top: 4px solid var(--ps-red);
  padding: 0.75rem 0.85rem 1rem;
}

.priory-structure__priorat-title {
  margin: 0 0 0.75rem;
  text-align: center;
  font-size: 1.05rem;
  color: var(--ps-red);
}

.priory-structure__bolivat {
  margin-bottom: 0.85rem;
}

.priory-structure__bolivat:last-child {
  margin-bottom: 0;
}

.priory-structure__bolivat h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 600;
}

.priory-structure__bolivat ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.priory-structure__bolivat li {
  padding: 0.35rem 0.5rem;
  text-align: center;
  background: var(--ps-box);
  border: 1px solid var(--ps-line);
  border-radius: 3px;
  font-size: 0.88rem;
}

@media (max-width: 640px) {
  .priory-structure__offices,
  .priory-structure__priories {
    grid-template-columns: 1fr;
  }
}

.hub-quick-links li {
  border-bottom: 1px solid var(--line);
}

.hub-quick-links a {
  display: block;
  padding: 0.65rem 0;
  color: var(--ink);
  text-decoration: none;
}

.hub-quick-links a:hover {
  color: var(--crimson);
}

/* —— Footer —— */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.75rem 1.25rem 2rem;
  text-align: center;
  background: var(--surface);
}

.site-footer__meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.site-footer__meta a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer__meta a:hover {
  color: var(--crimson);
}

.site-footer__motto {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink);
  margin: 0;
  line-height: 1.45;
  max-width: 36rem;
  margin-inline: auto;
}

/* Legacy public header/nav hidden when using new shell */
body.public-site > header:not(.site-header),
body.public-site > nav.main-menu {
  display: none;
}
