/* ==========================================================================
   View Transition API (MPA) Demo — Style
   ベースカラーは ../common/css/theme.css から継承
   ========================================================================== */

/* --- Local overrides for this demo --- */
:root, [data-theme="light"] {
  --vt-surface: var(--pg-panel);
  --vt-shadow-hover: 0 8px 24px rgba(0,0,0,.07);
}

[data-theme="dark"] {
  --vt-surface: var(--pg-panel);
  --vt-shadow-hover: 0 8px 24px rgba(0,0,0,.3);
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }

/* ==========================================================================
   View Transition — Core
   ========================================================================== */
@view-transition { navigation: auto; }

/* Root crossfade */
::view-transition-old(root) {
  animation: vt-out .3s var(--pg-ease) both;
}
::view-transition-new(root) {
  animation: vt-in .3s var(--pg-ease) both;
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; } }

/* Hero image morph — smooth scale + crossfade */
::view-transition-old(hero) {
  animation: vt-hero-out .4s var(--pg-ease) both;
  overflow: hidden;
}
::view-transition-new(hero) {
  animation: vt-hero-in .4s var(--pg-ease) both;
  overflow: hidden;
}
@keyframes vt-hero-out {
  to { opacity: 0; transform: scale(.98); }
}
@keyframes vt-hero-in {
  from { opacity: 0; transform: scale(1.02); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  ::view-transition-old(hero),
  ::view-transition-new(hero) { animation: none; }
}

/* ==========================================================================
   Index — Card List
   ========================================================================== */
.page-index {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

.page-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-lead {
  margin-top: .75rem;
  color: var(--pg-text-secondary);
  font-size: .95rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--pg-border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--vt-surface);
  transition: transform var(--pg-dur-slow) var(--pg-ease),
              box-shadow var(--pg-dur-slow) var(--pg-ease),
              border-color var(--pg-dur-slow) var(--pg-ease);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--vt-shadow-hover);
  border-color: var(--pg-border);
}
.card:focus-visible {
  outline: 3px solid var(--pg-accent);
  outline-offset: 2px;
}

.card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--pg-border);
  overflow: hidden;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s var(--pg-ease);
}
.card:hover .card-thumb img {
  transform: scale(1.03);
}

.card-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  flex: 1;
}
.card-body h2 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}
.card-body p {
  color: var(--pg-text-secondary);
  font-size: .875rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-body .read-more {
  margin-top: auto;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--pg-accent);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; box-shadow: none; }
  .card-thumb img { transition: none; }
  .card:hover .card-thumb img { transform: none; }
}

/* ==========================================================================
   Article Page
   ========================================================================== */
.article-hero {
  width: 100%;
  aspect-ratio: 21 / 9;
  overflow: hidden;
}
.article-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  view-transition-name: hero;
}

.article-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6rem;
}
.article-content h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -.02em;
}
.article-content .meta {
  margin-top: .75rem;
  color: var(--pg-text-secondary);
  font-size: .8125rem;
}
.article-content .body-text {
  margin-top: 2rem;
  line-height: 2;
  color: var(--pg-text);
}
.article-content .body-text p + p {
  margin-top: 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  margin-top: 2.5rem;
  padding: .625rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid var(--pg-border);
  border-radius: 999px;
  color: var(--pg-text-secondary);
  transition: border-color var(--pg-dur-base) var(--pg-ease),
              color var(--pg-dur-base) var(--pg-ease),
              background var(--pg-dur-base) var(--pg-ease);
}
.back-link:hover {
  border-color: var(--pg-accent);
  color: var(--pg-text);
  background: var(--vt-surface);
}
.back-link svg {
  width: 1rem;
  height: 1rem;
}

/* Text fade-in on page load */
.article-content :where(h1, .meta, .body-text, .back-link) {
  animation: fade-up .4s var(--pg-ease) both;
}
.article-content .meta { animation-delay: .05s; }
.article-content .body-text { animation-delay: .1s; }
.article-content .back-link { animation-delay: .15s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .article-content :where(h1, .meta, .body-text, .back-link) {
    animation: none;
  }
}
