.atlas {
  --atlas-ink: #2e4538;
  --atlas-body: #4b5c47;
  --atlas-border: #c7cebb;
  --atlas-paper: #faf7ee;
}

.atlas-section {
  margin-top: clamp(40px, 6vw, 84px);
  scroll-margin-top: 18px;
}

.atlas-section-heading p {
  color: var(--atlas-body);
  line-height: 1.9;
}

.atlas-section-heading {
  border-top: 1px solid var(--atlas-border);
  padding: 24px 0;
}

.atlas-section-heading h2 {
  color: var(--atlas-ink);
  font: 700 clamp(26px, 4vw, 42px)/1.4 var(--serif);
  margin: 0 0 12px;
}

.nayin-layout {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  border: 1px solid var(--atlas-border);
  background: var(--atlas-paper);
}

.atlas-catalog {
  min-width: 0;
  padding: clamp(16px, 3vw, 34px);
}

.atlas-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, .36fr);
  gap: 12px;
}

.atlas-filters label {
  color: var(--atlas-body);
  font-size: 13px;
  font-weight: 600;
}

.atlas-filters input,
.atlas-filters select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin-top: 7px;
  padding: 7px 10px;
  background: #fffdf6;
  color: var(--atlas-ink);
  border: 1px solid #a5b298;
  border-radius: 2px;
  font: inherit;
}

.nayin-index {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.nayin-index button,
.atlas-pages button,
.deity-cast button {
  min-width: 0;
  border: 1px solid #b9c4ad;
  color: var(--atlas-ink);
  background: #fffdf5;
  border-radius: 2px;
  cursor: pointer;
  transition: background-color .18s, border-color .18s;
}

.nayin-index button {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 2px;
}

.nayin-index strong {
  font: 700 clamp(17px, 2vw, 26px)/1.4 var(--serif);
}

.nayin-index small {
  font-size: 11px;
  line-height: 1.55;
}

.nayin-index button[aria-pressed="true"],
.deity-cast button[aria-pressed="true"] {
  background: #dfe9d8;
  border-color: #677e63;
}

.nayin-index button:hover,
.deity-cast button:hover,
.atlas-pages button:hover:not(:disabled) {
  background: #e9eddf;
  border-color: #7d9378;
}

.atlas-pages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--atlas-body);
  font-size: 12px;
}

.atlas-pages button {
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
}

.atlas-pages button:disabled {
  opacity: .45;
  cursor: default;
}

.nayin-index:not(:has(button)) {
  display: block;
  color: var(--atlas-body);
  line-height: 1.9;
}

.nayin-detail {
  display: grid;
  min-height: 310px;
  align-content: end;
  position: relative;
  isolation: isolate;
  background: #e9eadf;
  border-left: 1px solid var(--atlas-border);
  overflow: hidden;
}

.nayin-art {
  position: absolute;
  z-index: -2;
  inset: 0 0 auto auto;
  width: min(82%, 430px);
  aspect-ratio: 1;
  background-position: 0 0;
  background-size: 300% 200%;
  background-repeat: no-repeat;
  mask-image: linear-gradient(90deg, transparent, #000 23%);
}

.art-ready .nayin-art {
  background-image: var(--nayin-image);
}

.nayin-detail::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: linear-gradient(0deg, #faf7ee 0%, #faf7eef0 23%, #faf7ee00 74%),
    linear-gradient(90deg, #faf7ee 2%, #faf7eeb3 27%, #faf7ee00 56%);
}

.nayin-copy {
  padding: clamp(20px, 4vw, 38px);
  color: var(--atlas-ink);
}

.atlas-pair {
  font: 700 clamp(36px, 5vw, 63px)/1.12 var(--serif);
}

.nayin-copy h3,
.deity-name-line h3 {
  margin: 10px 0 7px;
  font: 700 clamp(27px, 4vw, 44px)/1.3 var(--serif);
  color: var(--atlas-ink);
}

.atlas-motif {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #4b5c47;
}

#nayin-description,
.deity-copy p {
  margin: 0;
  color: var(--atlas-ink);
  line-height: 1.95;
}

.atlas-source {
  margin: 16px 0 0;
  color: var(--atlas-body);
  font-size: 12px;
  line-height: 1.85;
}

.deity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  align-items: stretch;
  border-block: 1px solid var(--atlas-border);
  background: var(--atlas-paper);
}

.deity-cast {
  display: grid;
  align-content: center;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: clamp(10px, 2.4vw, 24px);
  border-right: 1px solid var(--atlas-border);
}

.deity-cast button {
  padding: 2px;
  border-color: #b9b1a4;
  background: #f8f4ed;
}

.deity-cast button[aria-pressed="true"] {
  background: #ebe2d4;
  border-color: #856850;
}

.deity-cast strong {
  display: block;
  padding: 6px 0;
  font: 700 15px/1.4 var(--serif);
}

.deity-feature {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  align-items: center;
  min-width: 0;
  gap: clamp(16px, 3vw, 34px);
  padding: clamp(14px, 2vw, 24px);
}

.deity-portrait,
.deity-thumb {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 5;
  background-color: #dfd5c8;
  background-size: 500% 200%;
  background-repeat: no-repeat;
}

.art-ready .deity-portrait,
.art-ready .deity-thumb {
  background-image: url("assets/atlas-deity-ensemble-v3.png");
}

.art-ready [data-portrait="jiecai"] {
  background-image: url("assets/atlas-deity-jiecai-v3.png");
  background-size: cover;
}

.deity-copy {
  min-width: 0;
}

.deity-name-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 12px;
  margin-bottom: 16px;
}

.deity-name-line h3 {
  margin: 0;
}

.deity-name-line p {
  color: #6b513f;
  font-weight: 700;
}

.atlas-entry-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 12px 0 18px;
}

.atlas-entry-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: #3d5d45;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 5px;
}

.detail-table .atlas-chart-link {
  text-decoration: underline;
  text-decoration-color: #899d7f;
  text-underline-offset: 3px;
}

@media (max-width: 850px) {
  .nayin-layout { grid-template-columns: 1fr; }
  .nayin-detail { border-left: 0; border-top: 1px solid var(--atlas-border); min-height: 280px; }
  .nayin-index { gap: 5px; }
  .deity-layout { grid-template-columns: 1fr; }
  .deity-cast { border-right: 0; border-bottom: 1px solid var(--atlas-border); }
  .deity-feature { grid-template-columns: minmax(0, 210px) minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .atlas-catalog { padding: 12px; }
  .atlas-filters { gap: 8px; }
  .atlas-filters input, .atlas-filters select { font-size: 16px; }
  .nayin-index small { font-size: 10px; }
  .nayin-detail { min-height: 262px; }
  .nayin-art { width: 88%; }
  .nayin-detail::after {
    background: linear-gradient(0deg, #faf7ee 0%, #faf7eee6 34%, #faf7ee12 93%),
      linear-gradient(90deg, #faf7eedf 2%, #faf7ee00 47%);
  }
  .deity-cast { gap: 6px; padding: 10px; }
  .deity-cast strong { font-size: 13px; }
  .deity-feature { grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); align-items: start; gap: 12px; }
  .deity-name-line { display: block; margin-bottom: 9px; }
  .deity-name-line p { font-size: 12px; }
  #deity-description { font-size: 13px; line-height: 1.85; }
}

@media (prefers-reduced-motion: reduce) {
  .atlas button { transition: none; }
}
