/* ============================================================
   Design tokens — minimalist black & white
   ============================================================ */
:root {
  --color-bg:          #ffffff;
  --color-text:        #0a0a0a;
  --color-text-muted:  #6b6b6b;
  --color-border:      #e5e5e5;
  --color-hover:       #0a0a0a;
  --color-surface-alt: #fafafa;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
               "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius-card: 8px;
  --radius-tag:  4px;

  --container-max: 1200px;
  --gutter:        24px;
  --section-gap:   96px;
  --grid-gap:      24px;

  --transition:    200ms ease;
}

/* ============================================================
   Base reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4, p { margin: 0; }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}

a:hover { color: var(--color-hover); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

img, svg { display: block; max-width: 100%; }

/* ============================================================
   Layout
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  flex: 1 0 auto;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: 96px 0 64px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--section-gap);
}

.hero__title {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 16px;
}

.hero__subtitle {
  font-size: 16px;
  color: var(--color-text-muted);
  max-width: 480px;
}

.hero__desc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-muted);
  max-width: 560px;
  margin-top: 12px;
}

/* ============================================================
   Works / Grid
   ============================================================ */
.works { padding-bottom: var(--section-gap); }

.works__title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 32px;
  letter-spacing: -0.01em;
}

.works__empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 48px 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--grid-gap);
}

/* ============================================================
   Card
   ============================================================ */
.card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition), transform var(--transition);
  will-change: transform;
}

.card:hover,
.card:focus-visible {
  border-color: var(--color-hover);
  transform: translateY(-2px);
  outline: none;
}

.card:focus-visible {
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.15);
}

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
}

.card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 12px;
}

.card__title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

.card__desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-tag);
  padding: 5px 8px;
}

.card__arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  transition: transform var(--transition), color var(--transition);
}

.card:hover .card__arrow,
.card:focus-visible .card__arrow {
  color: var(--color-hover);
  transform: translateX(2px);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: 32px 0;
  text-align: center;
}

.site-footer__icp {
  display: inline-block;
  font-size: 12px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  :root {
    --gutter: 16px;
    --section-gap: 64px;
  }

  .hero { padding: 64px 0 48px; }
  .hero__title { font-size: 32px; }
  .hero__subtitle { font-size: 15px; }

  .works__title { font-size: 20px; margin-bottom: 24px; }

  .grid { grid-template-columns: 1fr; }
  .card__body { padding: 16px 20px 20px; }
  .card__title { font-size: 17px; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ============================================================
   Detail page (used by demos/<id>/index.html)
   ============================================================ */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--gutter);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
}

.detail-header__back,
.detail-header__external {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition);
}
.detail-header__back:hover,
.detail-header__external:hover { color: var(--color-text-muted); }

.detail-header__title {
  font-size: 15px;
  font-weight: 600;
  flex: 1 1 auto;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 48px var(--gutter) 96px;
}

.detail-intro { margin-bottom: 32px; }

.detail-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.detail-desc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  max-width: 640px;
}

.detail-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.detail-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 640px) {
  .detail-main { padding: 32px var(--gutter) 64px; }
  .detail-title { font-size: 24px; }
  .detail-frame { aspect-ratio: 4 / 3; }
  .detail-header { padding: 16px var(--gutter); }
  .detail-header__title { font-size: 14px; }
}
