/* Base page styling for the GitHub Pages version. */
:root {
  color-scheme: light;
  --page-bg: #f6f7fb;
  --content-bg: #ffffff;
  --text: #22252a;
  --muted: #5f6875;
  --border: rgba(22, 27, 34, 0.12);
  --accent: #3154d4;
  --accent-soft: rgba(49, 84, 212, 0.1);
  --shadow: 0 18px 55px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(49, 84, 212, 0.08), transparent 34rem), var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.72;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.page-shell {
  width: min(100% - 2rem, 1080px);
  max-width: 100%;
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.page-content {
  padding: clamp(1.25rem, 4vw, 3rem);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow-x: clip;
  overflow-wrap: anywhere;
}

.page-content > * {
  max-width: 100%;
}

a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 {
  margin-top: 0.3rem;
  font-size: clamp(2rem, 4vw, 3.1rem);
}

h2 {
  margin-top: 3rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: clamp(1.55rem, 2.6vw, 2rem);
}

h3 {
  margin-top: 2rem;
  font-size: clamp(1.2rem, 2vw, 1.45rem);
}

blockquote {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 14px 14px 0;
  background: var(--accent-soft);
  color: #293247;
}

img {
  max-width: 100%;
  height: auto;
}

p > img,
picture,
.page-content > img {
  display: block;
  margin: 1.5rem auto;
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(15, 23, 42, 0.12);
}

table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

pre {
  max-width: 100%;
  overflow-x: auto;
}

code {
  overflow-wrap: anywhere;
}

th,
td {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
}

code {
  padding: 0.12rem 0.28rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.06);
}

.page-content mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.page-content mjx-container[display="true"] {
  display: block;
  padding-bottom: 0.25rem;
}

.page-content mjx-container svg {
  max-width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2rem, 1080px);
  margin: 0 auto;
  padding: 0.9rem 0;
  gap: 1rem;
}

.site-title {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-links a {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.site-links a:hover {
  color: var(--accent);
}

.sample-carousel {
  position: relative;
  margin: 1.25rem 0 2rem;
}
.sample-track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: 0.25rem 0 1rem;
}
.sample-slide {
  position: relative;
  flex: 0 0 min(92%, 760px);
  margin: 0;
  scroll-snap-align: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}
.sample-slide img {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  background: #f7f7f7;
}
.sample-slide figcaption {
  padding: 0.75rem 1rem 0.9rem;
  color: #555;
  font-size: 0.95rem;
  line-height: 1.5;
}
.sample-nav {
  position: absolute;
  top: 45%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  text-decoration: none;
  font-size: 1.45rem;
  font-weight: 700;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.18);
}
.sample-nav.prev {
  left: 0.75rem;
}
.sample-nav.next {
  right: 0.75rem;
}
.sample-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.sample-dots a {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #bbb;
  font-size: 0;
}

.sample-carousel {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.92));
}

.sample-carousel::before {
  display: block;
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
  content: "横向滚动浏览样本，或使用图片两侧按钮切换。";
}

.sample-track {
  gap: 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(49, 84, 212, 0.45) transparent;
}

.sample-track::-webkit-scrollbar {
  height: 0.55rem;
}

.sample-track::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(49, 84, 212, 0.35);
}

.sample-slide {
  flex-basis: min(88%, 780px);
  border-color: var(--border);
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.12);
}

.sample-slide img {
  max-height: min(68vh, 660px);
}

.sample-slide figcaption {
  color: var(--muted);
  background: #fff;
}

.sample-slide figcaption strong {
  color: var(--text);
}

.sample-slide figcaption br + strong {
  display: inline-block;
  margin-top: 0.35rem;
}

.sample-nav {
  transition: transform 0.18s ease, background 0.18s ease;
}

.sample-nav:hover {
  transform: translateY(-1px);
  background: #fff;
}

.sample-dots {
  max-height: 2.2rem;
  overflow-y: auto;
  padding: 0.15rem 0.25rem;
}

.sample-dots a {
  flex: 0 0 auto;
  opacity: 0.78;
}

.sample-dots a:hover {
  opacity: 1;
  background: var(--accent);
}

.sample-carousel.is-enhanced {
  margin: 1.5rem 0 2.4rem;
  padding: clamp(0.9rem, 2vw, 1.25rem);
  border-radius: 28px;
  background:
    radial-gradient(circle at 12% 0%, rgba(49, 84, 212, 0.13), transparent 22rem),
    linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96));
}

.sample-carousel.is-enhanced::before {
  content: none;
}

.sample-gallery-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sample-gallery-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.sample-ratio-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.sample-ratio-chip {
  appearance: none;
  border: 1px solid rgba(49, 84, 212, 0.18);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.sample-ratio-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(49, 84, 212, 0.45);
  color: var(--accent);
}

.sample-ratio-chip.is-active {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(49, 84, 212, 0.25);
}

.sample-ratio-chip:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.sample-carousel.is-enhanced .sample-track {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  grid-auto-flow: dense;
  gap: 0.65rem;
  overflow: visible;
  scroll-snap-type: none;
  padding: 0;
}

.sample-carousel.is-enhanced[data-active-ratio="portrait"] .sample-track {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 118px), 1fr));
}

.sample-carousel.is-enhanced .sample-slide {
  display: flex;
  flex: initial;
  flex-direction: column;
  min-width: 0;
  border-radius: 14px;
  scroll-snap-align: none;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.sample-carousel.is-enhanced .sample-slide:hover {
  transform: translateY(-2px);
  border-color: rgba(49, 84, 212, 0.28);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
}

.sample-carousel.is-enhanced .sample-slide::before {
  content: none;
}

.sample-carousel.is-enhanced .sample-slide img {
  width: 100%;
  max-height: none;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  cursor: zoom-in;
  background: #eef1f6;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.sample-carousel.is-enhanced .sample-slide:hover img {
  filter: saturate(1.05) contrast(1.02);
  transform: scale(1.01);
}

.sample-carousel.is-enhanced .sample-slide[data-ratio="landscape"] img {
  aspect-ratio: 16 / 9;
}

.sample-carousel.is-enhanced .sample-slide[data-ratio="portrait"] img {
  aspect-ratio: 3 / 4;
}

.sample-carousel.is-enhanced .sample-slide figcaption {
  display: none;
}

.sample-carousel.is-enhanced .sample-nav {
  display: none;
}

.sample-carousel.is-enhanced .sample-dots {
  display: none;
}

.sample-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(18px);
}

.sample-lightbox.is-open {
  display: flex;
}

.has-open-lightbox {
  overflow: hidden;
}

.sample-lightbox-figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(96vw, 1180px);
  max-height: 92vh;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background: #000;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
}

.sample-lightbox-figure img {
  display: block;
  width: 100%;
  max-height: calc(92vh - 8.5rem);
  object-fit: contain;
  background: #000;
}

.sample-lightbox-figure figcaption {
  max-height: 8.5rem;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  background: #000;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  line-height: 1.55;
}

.sample-lightbox-figure figcaption strong {
  color: #fff;
}

.sample-lightbox-button {
  position: absolute;
  z-index: 101;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 1.65rem;
  font-weight: 760;
  line-height: 1;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.sample-lightbox-button:hover {
  background: #fff;
}

.sample-lightbox-close {
  top: 1rem;
  right: 1rem;
}

.sample-lightbox-prev {
  left: max(1rem, calc((100vw - 1180px) / 2 - 4rem));
}

.sample-lightbox-next {
  right: max(1rem, calc((100vw - 1180px) / 2 - 4rem));
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1080px);
    padding-top: 0.75rem;
  }

  .site-nav {
    width: min(100% - 1rem, 1080px);
    align-items: flex-start;
    flex-direction: column;
    padding: 0.75rem 0;
  }

  .site-links {
    gap: 0.75rem;
    justify-content: flex-start;
  }

  .page-content {
    padding: 1rem;
    border-radius: 18px;
  }

  .sample-carousel {
    margin-inline: -0.35rem;
    padding: 0.55rem;
    border-radius: 16px;
  }

  .sample-slide {
    flex-basis: 92%;
    border-radius: 12px;
  }

  .sample-slide img {
    max-height: 58vh;
  }

  .sample-slide figcaption {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .sample-nav {
    width: 2rem;
    height: 2rem;
    font-size: 1.15rem;
  }

  .sample-gallery-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .sample-ratio-chips {
    justify-content: flex-start;
  }

  .sample-carousel.is-enhanced .sample-track {
    grid-template-columns: 1fr;
  }

  .sample-carousel.is-enhanced .sample-slide,
  .sample-carousel.is-enhanced .sample-slide[data-ratio="landscape"],
  .sample-carousel.is-enhanced .sample-slide[data-ratio="portrait"] {
    grid-column: auto;
    grid-row: auto;
  }

  .sample-lightbox {
    padding: 0.6rem;
  }

  .sample-lightbox-figure {
    width: 100%;
    max-height: 90vh;
    border-radius: 18px;
  }

  .sample-lightbox-figure img {
    max-height: calc(90vh - 10rem);
  }

  .sample-lightbox-button {
    width: 2.35rem;
    height: 2.35rem;
    font-size: 1.35rem;
  }

  .sample-lightbox-prev {
    left: 0.8rem;
  }

  .sample-lightbox-next {
    right: 0.8rem;
  }
}
