/* Sacralib V2.5 — owner-preview geometry + frame system.
   Original article markup, user settings and public UI are unchanged.
   This file intentionally loads LAST to correct V2.2–V2.4 layout cascade. */
body.codex-site-v2-current {
  --v25-ink: #2c241d;
  --v25-bronze: #916c43;
  --v25-border: #d8c4a7;
  --v25-hairline: rgba(119, 84, 50, .18);
  --v25-shadow: 0 2px 5px rgba(78, 49, 23, .055), 0 9px 23px rgba(84, 58, 31, .095);
  --v25-surface: linear-gradient(165deg, rgba(255,251,243,.985), rgba(244,235,219,.985));
  --v25-gutter: clamp(24px, 5vw, 104px);
  background-color: #f2ebde !important;
  /* No gray side mask: page-width content separates the scenery from the text. */
  background-image:
    url('/assets/codex-v23-art/left-scenery.webp?v=24'),
    url('/assets/codex-v23-art/right-scenery.webp?v=24'),
    radial-gradient(ellipse at 50% 12%, #fffaf0 0, #f5ecdd 52%, #efe3d0 100%) !important;
  background-size: clamp(84px, 6.4vw, 132px) auto, clamp(84px, 6.4vw, 132px) auto, cover !important;
  background-position: left 104px, right 104px, center top !important;
  background-repeat: no-repeat !important;
}

/* GRID FIX: third auto column previously pushed the preview nav to far right. */
@media (min-width: 1200px) {
  body.codex-site-v2-current .codex-navbar {
    display: grid !important;
    grid-template-columns: minmax(230px, auto) minmax(0, 1fr) auto !important;
    column-gap: clamp(22px, 3vw, 54px) !important;
    padding-inline: clamp(82px, 5.1vw, 118px) !important;
    min-height: 70px !important;
  }
  body.codex-site-v2-current .codex-navbar > .brand { grid-column: 1 !important; grid-row: 1 !important; }
  body.codex-site-v2-current .codex-navbar > #sv23MainNav {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: stretch !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: clamp(10px, 1.4vw, 25px) !important;
    min-width: 0 !important;
  }
  body.codex-site-v2-current .codex-navbar > .mobile-header-actions { display: none !important; }
  /* Search and original navigation live inside a display:contents wrapper.
     Do not hide it: that would silently disable the real site search. */
  body.codex-site-v2-current .codex-navbar > #mobileDrawer { display: contents !important; }
  body.codex-site-v2-current .codex-navbar #mobileDrawer .nav-search {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    min-width: 0 !important;
    width: clamp(132px, 11vw, 215px) !important;
    max-width: 215px !important;
  }
  body.codex-site-v2-current .sv23-top-nav :is(.sv23-top-link, .sv23-top-group > summary) {
    white-space: nowrap;
    font-size: clamp(14px, 1.05vw, 17px) !important;
  }
}
body.codex-site-v2-current .codex-navbar {
  border-bottom: 1px solid #d5bd9d !important;
  box-shadow: 0 3px 11px rgba(70, 46, 25, .13) !important;
}
body.codex-site-v2-current .codex-navbar::before { border-color: rgba(143, 102, 60, .11); }

/* HOME: use nearly the complete page width from the reference, not the old 1480px cap. */
body.codex-site-v2-home .page-shell,
body.owner-home-v26-enabled.codex-site-v2-home:has(#homeView.active) .page-shell {
  width: 100% !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: 12px var(--v25-gutter) 18px !important;
  background: transparent !important;
  box-shadow: none !important;
}
body.codex-site-v2-home .content-stage,
body.owner-home-v26-enabled.codex-site-v2-home:has(#homeView.active) .content-stage {
  width: 100% !important;
  max-width: 1880px !important;
  margin: 0 auto !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
body.codex-site-v2-home #homeView,
body.codex-site-v2-home #codexSiteHome {
  width: 100% !important;
  max-width: 1880px !important;
  min-width: 0 !important;
  margin-inline: auto !important;
}
body.codex-site-v2-home #codexSiteHome {
  gap: 10px !important;
  align-content: start;
  padding: 0 !important;
}
body.codex-site-v2-home #codexSiteHome > * { min-width: 0; }

/* Consistent borders, subtle inner paper edge and unified depth for every panel. */
body.codex-site-v2-home :is(.sv2-quick-strip, .sv2-live-card, .sv2-category, .sv2-panel, .sv2-bottom-card) {
  border: 1px solid var(--v25-border) !important;
  border-radius: 3px !important;
  box-shadow: var(--v25-shadow), inset 0 0 0 1px rgba(255,255,255,.60) !important;
}
body.codex-site-v2-home :is(.sv2-category, .sv2-panel, .sv2-bottom-card) {
  background: var(--v25-surface) !important;
}
body.codex-site-v2-home :is(.sv2-category, .sv2-panel) { position: relative; }
body.codex-site-v2-home :is(.sv2-category, .sv2-panel)::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(144, 105, 67, .075);
  border-radius: 2px;
  pointer-events: none;
  z-index: 0;
}
body.codex-site-v2-home :is(.sv2-category, .sv2-panel) > * { position: relative; z-index: 1; }
body.codex-site-v2-home .sv2-quick-strip {
  display: grid !important;
  grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
  gap: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  background: #f3e9d8 !important;
}
body.codex-site-v2-home .sv2-quick-item {
  min-height: 63px !important;
  min-width: 0 !important;
  padding: 6px clamp(7px, .8vw, 13px) !important;
  border: 0 !important;
  border-right: 1px solid #dac5a8 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: linear-gradient(145deg, #fffaf2, #f2e8d8) !important;
}
body.codex-site-v2-home .sv2-quick-item:last-child { border-right: 0 !important; }
body.codex-site-v2-home .sv2-quick-item:hover { background: #e9dcc7 !important; }
body.codex-site-v2-home .sv2-quick-item > .sv23-art-icon { width: 42px !important; height: 46px !important; }
body.codex-site-v2-home .sv2-quick-item > span:not(.sv2-icon):not(.sv2-arrow) {
  font: 500 clamp(12px,.86vw,14px)/1.16 Georgia,serif !important;
  color: #35291e;
}
body.codex-site-v2-home .sv2-title-ornament {
  margin: 0 !important;
  padding: 4px 0 7px 31px !important;
  line-height: 1.05 !important;
  border-bottom: 1px solid #d7c3a5 !important;
  font-size: clamp(21px,1.32vw,24px) !important;
  color: #251c19 !important;
}
body.codex-site-v2-home .sv2-live-wrap { gap: 8px !important; }
body.codex-site-v2-home .sv2-live-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 10px !important;
}
body.codex-site-v2-home .sv2-live-card {
  min-height: 98px !important;
  display: grid !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 9px 12px 9px 0 !important;
  overflow: hidden;
  background: linear-gradient(145deg, #fffaf3, #f3eadd) !important;
}
body.codex-site-v2-home .sv2-live-card > .sv2-icon { display: none !important; }
body.codex-site-v2-home .sv2-live-card::before {
  grid-row: 1;
  width: 100% !important;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}
body.codex-site-v2-home .sv2-online { grid-template-columns: minmax(110px, 36%) minmax(0,1fr) !important; }
body.codex-site-v2-home .sv2-online::before { width: 36% !important; }
body.codex-site-v2-home .sv2-online .sv2-live-copy {
  grid-column: 2 !important; grid-row: 1 !important; min-width:0 !important; margin: 0 !important;
}
body.codex-site-v2-home .sv2-find-player { grid-template-columns: minmax(95px,26%) minmax(0,1fr) !important; }
body.codex-site-v2-home .sv2-find-player::before { width: 26% !important; }
body.codex-site-v2-home .sv2-find-player .sv2-player-form {
  grid-column: 2 !important; grid-row: 1 !important; min-width: 0 !important; margin: 0 !important;
}
body.codex-site-v2-home .sv2-chaos { grid-template-columns: minmax(100px,29%) minmax(0,1fr) !important; }
body.codex-site-v2-home .sv2-chaos::before { width: 29% !important; }
body.codex-site-v2-home .sv2-chaos .sv2-chaos-copy {
  grid-column: 2 !important; grid-row: 1 !important; min-width:0 !important; margin: 0 !important;
}
body.codex-site-v2-home .sv2-player-controls { min-width: 0 !important; }
body.codex-site-v2-home .sv2-player-controls input { min-width: 0 !important; flex: 1 1 auto; }
body.codex-site-v2-home .sv2-player-controls button { flex: 0 0 auto; }

body.codex-site-v2-home .sv2-category-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  gap: 10px !important;
  align-items: stretch;
}
body.codex-site-v2-home .sv2-category {
  min-height: 272px !important;
  padding: 12px clamp(10px, .95vw, 17px) 11px !important;
  display: flex !important;
  flex-direction: column !important;
}
body.codex-site-v2-home .sv2-category-header {
  display: flex !important;
  min-height: 53px !important;
  align-items: center !important;
  gap: 7px !important;
  padding: 0 0 10px !important;
  margin: 0 !important;
  border-bottom: 1px solid var(--v25-hairline) !important;
}
body.codex-site-v2-home .sv2-category-header .sv23-art-icon {
  width: clamp(38px, 2.9vw, 52px) !important;
  height: clamp(38px, 2.9vw, 52px) !important;
  object-fit: contain !important;
}
body.codex-site-v2-home .sv2-category h3 {
  font: 700 clamp(15px,1.13vw,19px)/1.12 Georgia,serif !important;
  letter-spacing: -.012em !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
}
body.codex-site-v2-home .sv2-category-links { padding: 6px 0 3px !important; }
body.codex-site-v2-home .sv2-category-links a {
  font: 400 clamp(13px,.86vw,15px)/1.16 Georgia,serif !important;
  padding: 6px 2px 6px 16px !important;
  border-bottom: 1px solid var(--v25-hairline) !important;
}
body.codex-site-v2-home .sv2-category-links a:hover { color:#80502d !important; background:rgba(198,168,131,.10); }
body.codex-site-v2-home .sv2-category-more {
  margin-top: auto !important;
  padding-top: 2px;
  border-top: 0 !important;
}
body.codex-site-v2-home .sv2-category-all {
  padding: 8px 4px 3px !important;
  border-top: 1px solid var(--v25-hairline) !important;
  font: 600 14px/1.2 Georgia,serif !important;
}
body.codex-site-v2-home .sv2-category-expanded {
  border: 1px solid #c9ab82 !important;
  border-radius: 3px;
  box-shadow: 0 10px 24px rgba(63,41,23,.18) !important;
  background: #fffaf0 !important;
}
body.codex-site-v2-home .sv2-home-feeds,
body.codex-site-v2-home .sv2-bottom-links { gap: 11px !important; }
body.codex-site-v2-home .sv2-home-feeds { grid-template-columns: minmax(0,1fr) minmax(0,1fr) !important; align-items: stretch; }
body.codex-site-v2-home .sv2-panel { min-height: 0; padding: 12px 16px 11px !important; }
body.codex-site-v2-home .sv2-section-header {
  gap: 12px !important;
  padding: 0 0 9px !important;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--v25-hairline) !important;
}
body.codex-site-v2-home .sv2-section-header h2 {
  margin: 0;
  font: 700 clamp(19px,1.3vw,22px)/1.1 Georgia,serif !important;
  color: #29201b !important;
}
body.codex-site-v2-home .sv2-feed-row {
  min-height: 49px !important;
  border-bottom: 1px solid var(--v25-hairline) !important;
  padding: 4px 4px !important;
}
body.codex-site-v2-home .sv2-feed-row:last-child,
body.codex-site-v2-home .sv2-patch-row:last-child { border-bottom: 0 !important; }
body.codex-site-v2-home .sv2-patch-hero { border-radius: 3px; overflow:hidden; }
body.codex-site-v2-home .sv2-patch-row { border-bottom: 1px solid var(--v25-hairline) !important; }
body.codex-site-v2-home .sv2-bottom-links { grid-template-columns: minmax(0,1fr) minmax(0,1fr) !important; }
body.codex-site-v2-home .sv2-bottom-card {
  min-height: 86px !important; padding: 12px 22px !important;
}
/* Preserve the illustrated explore banner; generic panel fill must not cover it. */
body.codex-site-v2-home .sv2-explore {
  color: #fff4e4 !important;
  background: linear-gradient(90deg,rgba(12,20,28,.92),rgba(13,27,38,.30) 90%),url('/assets/codex-v23-art/explore-landscape.webp') center/cover !important;
}

/* ARTICLE: equal outer rhythm and wider readable content, with deliberate side rails. */
body.codex-article-v2-active .page-shell {
  max-width: none !important;
  width: 100% !important;
  padding: 16px var(--v25-gutter) 26px !important;
  background: transparent !important;
  box-shadow: none !important;
}
body.codex-article-v2-active .content-stage {
  width: 100% !important;
  max-width: 1880px !important;
  margin-inline: auto !important;
  padding: 0 !important;
}
body.codex-article-v2-active #articleFull.cv2-layout {
  width: 100% !important;
  max-width: none !important;
  grid-template-columns: minmax(210px, 235px) minmax(0,1fr) minmax(238px, 265px) !important;
  gap: 13px !important;
  align-items: start !important;
}
body.codex-article-v2-active .cv2-layout :is(.cv2-left,.cv2-right) { gap: 12px !important; }
body.codex-article-v2-active .cv2-layout :is(.cv2-main,.cv2-side-panel) {
  border: 1px solid var(--v25-border) !important;
  border-radius: 3px;
  box-shadow: var(--v25-shadow), inset 0 0 0 1px rgba(255,255,255,.58) !important;
  background: var(--v25-surface) !important;
}
body.codex-article-v2-active .cv2-layout .cv2-main {
  gap: 12px !important;
  padding: 20px clamp(17px,1.7vw,28px) 25px !important;
}
body.codex-article-v2-active .cv2-layout .cv2-side-panel { padding: 15px 14px !important; }
body.codex-article-v2-active .cv2-layout .cv2-side-title {
  margin: 0 0 9px !important;
  padding: 0 0 11px !important;
  border-bottom: 1px solid var(--v25-hairline) !important;
}
body.codex-article-v2-active .cv2-layout .cv2-nav-group { border-color: var(--v25-hairline) !important; }
body.codex-article-v2-active .cv2-layout .cv2-breadcrumbs { padding-bottom: 11px !important; border-color:var(--v25-hairline) !important; }
body.codex-article-v2-active .cv2-layout .cv2-main > h2 { margin-top: 0 !important; }
body.codex-article-v2-active .cv2-layout .cv2-main > .article-body { margin-top: 0 !important; }
body.codex-article-v2-active .cv2-layout .article-body :is(.content-table-wrap,.content-columns,.content-world-map) { min-width: 0; max-width: 100%; }
body.codex-article-v2-active .cv2-layout .article-body .content-table-wrap { overflow-x: auto; }
body.codex-article-v2-active .cv2-layout .article-body img { max-width:100%; height:auto; }
body.codex-article-v2-active .cv2-layout .cv2-related-panel .cv2-article-link {
  min-height: 61px;
  border-bottom: 1px solid var(--v25-hairline) !important;
}
body.codex-article-v2-active .cv2-layout .cv2-map-card { border-radius: 3px; box-shadow: var(--v25-shadow); }
body.codex-site-v2-current .site-footer {
  box-shadow: 0 -2px 8px rgba(78,55,32,.075) !important;
  color: #655648 !important;
}

/* RESPONSIVE: full content without horizontally scrolling or shrinking body. */
@media (max-width: 1450px) {
  body.codex-site-v2-current { --v25-gutter: clamp(18px, 3.6vw, 58px); }
  body.codex-site-v2-home .sv2-quick-item > .sv23-art-icon { width: 36px !important; height: 40px !important; }
  body.codex-site-v2-home .sv2-category-header .sv23-art-icon { width: 39px !important; height:39px !important; }
  body.codex-site-v2-home .sv2-category h3 { font-size: 15px !important; }
  body.codex-article-v2-active #articleFull.cv2-layout { grid-template-columns: minmax(180px,215px) minmax(0,1fr) minmax(205px,230px) !important; }
}
@media (max-width: 1199px) {
  body.codex-site-v2-home .sv2-quick-strip { grid-template-columns: repeat(4,minmax(0,1fr)) !important; }
  body.codex-site-v2-home .sv2-quick-item:nth-child(4n) { border-right: 0 !important; }
  body.codex-site-v2-home .sv2-quick-item:nth-child(-n + 4) { border-bottom: 1px solid #dac5a8 !important; }
  body.codex-site-v2-home .sv2-live-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.codex-site-v2-home .sv2-chaos { grid-column: 1/-1; }
  body.codex-site-v2-home .sv2-category-grid { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
  body.codex-article-v2-active #articleFull.cv2-layout { grid-template-columns: minmax(170px,210px) minmax(0,1fr) !important; }
  body.codex-article-v2-active .cv2-layout .cv2-right { grid-column: 2; }
}
@media (max-width: 820px) {
  body.codex-site-v2-current { --v25-gutter: clamp(10px,2.5vw,22px); background-image: linear-gradient(180deg,#faf5eb,#f0e5d4) !important; }
  body.codex-site-v2-home .sv2-live-grid,
  body.codex-site-v2-home .sv2-home-feeds,
  body.codex-site-v2-home .sv2-bottom-links { grid-template-columns: minmax(0,1fr) !important; }
  body.codex-site-v2-home .sv2-chaos { grid-column: auto !important; }
  body.codex-site-v2-home .sv2-category-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.codex-article-v2-active #articleFull.cv2-layout { grid-template-columns: minmax(0,1fr) !important; }
  body.codex-article-v2-active .cv2-layout .cv2-right { grid-column: 1 !important; }
  body.codex-article-v2-active .cv2-layout :is(.cv2-left,.cv2-right) { position: static !important; max-height: none !important; overflow: visible !important; }
}
@media (max-width: 560px) {
  body.codex-site-v2-home .sv2-quick-strip { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  body.codex-site-v2-home .sv2-quick-item { min-height: 56px !important; padding: 5px 8px !important; }
  body.codex-site-v2-home .sv2-quick-item:nth-child(n) { border-bottom: 1px solid #dac5a8 !important; border-right: 1px solid #dac5a8 !important; }
  body.codex-site-v2-home .sv2-quick-item:nth-child(2n) { border-right: 0 !important; }
  body.codex-site-v2-home .sv2-quick-item:nth-last-child(-n+2) { border-bottom: 0 !important; }
  body.codex-site-v2-home .sv2-live-card { min-height: 94px !important; }
  body.codex-site-v2-home .sv2-category-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; gap: 8px !important; }
  body.codex-site-v2-home .sv2-category { min-height: 220px !important; padding: 9px !important; }
  body.codex-site-v2-home .sv2-category-header .sv23-art-icon { width: 32px !important; height:32px !important; }
  body.codex-site-v2-home .sv2-category h3 { font-size: 12px !important; }
  body.codex-site-v2-home .sv2-category-links a { font-size: 12px !important; padding-left:12px!important; }
  body.codex-site-v2-home .sv2-category-all { font-size: 12px !important; }
  body.codex-article-v2-active .cv2-layout .cv2-main { padding: 14px 13px 19px !important; }
  body.codex-site-v2-current .site-footer { padding-inline: 12px !important; }
}
@media (prefers-reduced-motion: reduce) {
  body.codex-site-v2-current :is(.sv2-home,.cv2-layout) *,
  body.codex-site-v2-current :is(.sv2-home,.cv2-layout) *::before,
  body.codex-site-v2-current :is(.sv2-home,.cv2-layout) *::after { transition: none !important; }
}
