/* Xiangqi Software Share — vanilla CSS, no frameworks */
/* Light palette: cream/off-white backgrounds, dark gray text, soft accents */

:root {
  --color-accent: #8B4512;
  --color-accent-soft: #a0522d;
  --color-bg: #f8f6f1;
  --color-bg-card: #fff;
  --color-bg-nav: #f0ebe3;
  --color-text: #333;
  --color-text-muted: #555;
  --color-border: #ddd;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.1);
  --max-width: 1200px;
  --detail-max-width: 1000px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 1em;
  line-height: 1.5;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-weight: normal;
}

/* ----- Navbar ----- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--color-bg-nav);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.navbar__brand {
  font-size: 1.25rem;
  font-weight: normal;
  color: var(--color-accent);
  text-decoration: none;
}

.navbar__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar__links a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--color-text);
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.navbar__links a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-accent);
}

.navbar__links a.active {
  color: var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
}

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

/* ----- Hero ----- */
.hero {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
}

.hero__title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: normal;
  color: var(--color-accent);
}

.hero__tagline {
  margin: 0;
  font-size: 1.1rem;
  color: var(--color-text-muted);
}

/* Hero feature cards */
.hero__features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
  max-width: 100%;
}

.feature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1.25rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  min-height: 240px;
}

.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-accent);
}

.feature-card__img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  flex-shrink: 0;
  background: var(--color-bg-card);
  border-radius: 8px;
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.feature-card__img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.feature-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: normal;
  color: var(--color-accent);
}

.feature-card__desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  flex: 1;
}

/* ----- Sections (hash routing) ----- */
.section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.section.is-visible {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.section__title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: normal;
  color: var(--color-accent);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.section__intro {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* ----- Play with AI iframe ----- */
.play-ai-frame {
  display: block;
  width: 100%;
  min-height: 720px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-card);
}

/* ----- Software list (table only) ----- */
.software-list {
  display: block;
}

.software-list.view-table {
  display: block;
}

.btn {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  font-family: inherit;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn--primary {
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--color-accent);
}

.btn--primary:hover {
  background: var(--color-accent-soft);
  color: #fff;
  border-color: var(--color-accent-soft);
}

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Table view */
.software-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  font-size: 1.05rem;
}

.software-table th,
.software-table td {
  padding: 1.25rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-weight: normal;
  line-height: 1.5;
}

.software-table th {
  background: var(--color-bg-nav);
  color: var(--color-text);
}

.software-table tr {
  cursor: pointer;
  transition: background 0.2s;
}

.software-table tr:hover {
  background: rgba(0, 0, 0, 0.03);
}

.software-table .thumb-cell {
  width: 140px;
  min-width: 140px;
  padding: 1rem 1.25rem;
  vertical-align: middle;
}

.software-table .thumb-cell img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
}

.software-table .name-cell {
  min-width: 180px;
  width: 22%;
}

.software-table .desc-cell {
  min-width: 320px;
  width: 45%;
}

.software-table .downloads-cell {
  min-width: 100px;
  width: 10%;
}

.software-table .actions-cell {
  min-width: 120px;
  width: 15%;
  white-space: nowrap;
}

.software-card__badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: var(--color-bg-nav);
  color: var(--color-text-muted);
  border-radius: 4px;
  font-weight: normal;
}

/* ----- Tutorial videos grid ----- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.video-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.video-card:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-accent);
}

.video-card__thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--color-bg);
}

.video-card__body {
  padding: 1rem;
}

.video-card__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: normal;
  color: var(--color-accent);
}

.video-card__desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ----- Play Online list ----- */
.sites-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.site-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.site-card:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-accent);
}

.site-card__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-card__logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--color-bg);
}

.site-card__name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: normal;
  color: var(--color-accent);
}

.site-card__desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  flex: 1;
}

/* ----- Footer ----- */
.footer {
  margin-top: auto;
  padding: 1rem;
  text-align: center;
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.footer p {
  margin: 0;
}

/* ----- Detail page ----- */
.detail-page {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
}

.detail-page .navbar {
  margin-bottom: 0;
}

.detail__main {
  max-width: var(--detail-max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

.detail__back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.detail__back:hover {
  opacity: 0.9;
}

.detail__title {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: normal;
  color: var(--color-accent);
}

.detail__description {
  margin: 0 0 1.5rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* Slideshow */
.slideshow {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 0 1.5rem;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
}

.slideshow__frame {
  width: 100%;
  aspect-ratio: 16/10;
  position: relative;
  min-height: 360px;
}

.slideshow__slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
}

.slideshow__frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.slideshow__prev,
.slideshow__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
  z-index: 2;
}

.slideshow__prev:hover,
.slideshow__next:hover {
  background: var(--color-accent);
}

.slideshow__prev {
  left: 8px;
}

.slideshow__next {
  right: 8px;
}

.slideshow__dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--color-bg-card);
}

.slideshow__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: var(--color-border);
  cursor: pointer;
  transition: background 0.2s;
}

.slideshow__dot.active {
  background: var(--color-accent);
}

.detail__video-wrap {
  margin: 0 0 1.5rem;
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.detail__video-wrap iframe {
  width: 100%;
  aspect-ratio: 16/9;
  display: block;
}

.detail__download {
  margin-bottom: 2rem;
}

.detail__download .btn {
  padding: 0.75rem 1.5rem;
  font-size: 1.1rem;
}

.detail__not-found {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-muted);
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: stretch;
  }

  .navbar__links {
    justify-content: center;
  }

  .software-table .hide-mobile {
    display: none;
  }

  .software-table th,
  .software-table td {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .hero__features {
    grid-template-columns: 1fr;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .sites-list {
    grid-template-columns: 1fr;
  }
}
