/* =====================================
   Reset & Base
====================================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Shippori Mincho', serif;
  background-color: #fdfdfd;
  color: #222;
  line-height: 1.6;
  scroll-behavior: smooth;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

h1, h2, h3 {
  font-family: 'Crimson Text', serif;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

a{
  color: inherit; 
  text-decoration: none;
}

/* =====================================
   Header & Navigation
====================================== */
header {
  width: 100%;
  background-color: #f5f5f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

header.scrolled {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
header img {
  width: 325px;
  height: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 1rem;
  padding: 0;
  margin: 0;
}

nav a {
  text-decoration: none;
  color: #444;
  font-weight: bold;
  transition: color 0.3s;
}

nav a:hover {
  color: #111;
}

@media (max-width: 768px) {
  nav ul {
    display: none;
    flex-direction: column;
    gap: 1rem;
    background: #fff;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    padding: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  }

  header.nav-open nav ul {
    display: flex;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* =====================================
   Main Visual (フルスクリーン＋中央ロゴ)
====================================== */
#main-visual {
  position: relative;
  width: 100%;
  height: 100vh;
  background-image: url("images/main-visual.webp");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: scroll; /* JSパララックス対応 */
  overflow: hidden;
  z-index: 0;
}

.main-logo {
  position: absolute;
  top: 39%;
  left: 50%;
  width: 50vw;
  max-width: 480px;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  animation: fadeIn 2s ease forwards;
}

@media (max-width: 768px) {
  .main-logo {
    width: 70vw;
  }
}


/* =====================================
   Sections & Typography
====================================== */
section {
  padding: 4rem 0;
}

h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #ccc;
}

@media (max-width: 768px) {
  section {
    padding: 2rem 0;
  }

  h2 {
    font-size: 1.5rem;
  }
}

/* =====================================
   Layout Grids
====================================== */
.grid {
  display: grid;
  gap: 1.5rem;
}

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

   .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }

@media (min-width: 600px) {
  .character-grid {
    grid-template-columns: repeat(2, 1fr);
  }
   .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
 .character-grid {
    grid-template-columns: repeat(3, 1fr);
  }
 .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}



.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.card {
  text-align: center;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.card p {
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.product-grid a {
  display: block;
}

.product-grid .card {
  padding: 0.2rem;
  box-sizing: border-box;
}

/* =====================================
   Story & Author
====================================== */
#story, #author {
  padding-top: 4rem;
}

.story-content, .author-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: center;
  width: 100%;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 1s ease forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.story-content img,
.author-content .author-img {
  width: 100%;
  border-radius: 8px;
}

@media (min-width: 768px) {
  .story-content, .author-content {
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2rem;
  }

  .story-content img {
    flex-shrink: 0;
    width: 50%;
  }

  .author-content .author-img {
    flex-shrink: 0;
    width: 40%;
  }

  .story-content p,
  .author-content p {
    width: 60%;
    margin: 0;
    text-align: left;
  }

  .author-img {
    width: 80%;
  }
}

/* =====================================
   Video
====================================== */
.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 0 0 16px 0;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 2カラム */
  gap: 1.5rem; /* 動画間の余白 */
}

@media (max-width: 768px) {
  .video-grid {
    grid-template-columns: 1fr; /* スマホは1カラム */
  }
}

/* ▼ ショート一覧（スマホ1列／PC3列） */
.shorts-grid {
  display: grid;
  grid-template-columns: 1fr;     /* スマホは1列 */
  gap: 16px;                      /* 要素間の余白 */
  padding: 16px;                  /* 外側の余白（セクション余白） */
  justify-items: center;          /* 子要素を中央寄せ */
}

/* PC以上で3列に */
@media (min-width: 1024px) {
  .shorts-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;                    /* PC時は少し広めに */
    padding: 20px;
  }
}

/* ▼ 各ショートの枠（縦長＆中央配置） */
.short-container {
  position: relative;
  width: 100%;
  max-width: 360px;               /* 縦動画の最大幅（好みで調整） */
  aspect-ratio: 9 / 16;           /* 9:16固定 */
  overflow: hidden;
  border-radius: 8px;

  /* 中央寄せの保険：グリッド外で使っても中央に */
  margin-left: auto;
  margin-right: auto;
}

/* ▼ 埋め込みのフィット */
.short-container iframe {
  position: absolute;
  inset: 0;                       /* top/right/bottom/left:0 */
  width: 100%;
  height: 100%;
  border: none;
  display: block;                 /* 余計な隙間を防ぐ */
}

/* =====================================
   Ontologia Section
====================================== */
#ontologia {
  background-color: transparent;
  padding: 4rem 0;
  text-align: left;
}

.ontologia-intro {
  font-style: italic;
  margin-bottom: 2rem;
  color: #666;
  text-align: center;
}

.ontologia-grid {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.quote-card {
  padding: 1.5rem;
  border-left: 3px solid #333;
  border-radius: 0;
  background: none;
  box-shadow: none;
  transition: none;
}

.quote-card blockquote {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.2rem;
  color: #222;
  margin: 0;
  line-height: 1.8;
}

.quote-card footer {
  text-align: right;
  margin-top: 1rem;
  font-size: 1rem;
  color: #444;
  background: none;
}

/* =====================================
   Gallery Modal
====================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.visible {
  opacity: 1;
}

.modal-content {
  text-align: center;
  max-width: 90%;
  max-height: 90%;
  animation: fadeIn 0.4s ease;
}

.modal-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
}

.modal-caption {
  color: #fff;
  margin-top: 1rem;
  font-size: 1.1rem;
  font-family: 'Shippori Mincho', serif;
}

/* =====================================
   Footer
====================================== */
footer {
  text-align: center;
  padding: 2rem 0 5rem 0;
  font-size: 0.9rem;
  color: #777;
}

/* ===============================
   フェードインアニメーション
================================ */
.quote-card {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.quote-card.fade-in {
  opacity: 1;
  transform: translateY(0);
}

/* ===============================
   Dark Mode Styles
================================ */
body.dark-mode {
  background-color: #111;
  color: #f5f5f5;
}

body.dark-mode a {
  color: #ddd;
}

body.dark-mode header {
  background-color: #222;
  color: #fff;
}

body.dark-mode .quote-card blockquote,
body.dark-mode .episode-content,
body.dark-mode .purchase-link a,
body.dark-mode .chapter-title,
body.dark-mode .episode-title {
  color: #ddd;
}

body.dark-mode .quote-card footer {
  color: #bbb;
  background: none;
}

body.dark-mode .quote-card {
  border-left-color: #888;
}

body.dark-mode footer {
  color: #aaa;
}

/* ===============================
   Dark Mode Toggle Button (square)
================================ */
#dark-mode-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 48px;
  height: 48px;
  background-color: #fff;
  color: #222;
  border: 1px solid #ccc;
  border-radius: 0;
  font-size: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

#dark-mode-toggle:hover {
  background-color: #eee;
}

body.dark-mode #dark-mode-toggle {
  background-color: #333;
  border-color: #555;
}

/* ===============================
   Episode Fixes (中央揃え＋リンクデザイン)
================================ */
#episode {
  text-align: center;
}

.episode-title{
  font-size: 1.5rem;
}

.episode-sententiae {
  text-align: left;
  line-height: 2.4;
  margin: 0 auto;
  padding: 0.1rem 0 4.5rem 0;
  max-width: 390px;
}

.episode-content {
  text-align: left;
  margin: 0 auto;
  padding: 2.1rem 0.5rem;
  max-width: 550px;
}

.episode-right {
  text-align: right;
  width: 100%;
}

.purchase-link a {
  display: inline-block;
  font-family: 'Shippori Mincho', serif;
  font-weight: 600;
  color: #444;
  text-decoration: none;
  border: 1px solid #ccc;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.purchase-link a:hover {
  background-color: #f3f3f3;
  border-color: #999;
  color: #111;
}

body.dark-mode .purchase-link a {
  color: #ddd;
  border-color: #666;
}

body.dark-mode .purchase-link a:hover {
  background-color: #222;
  color: #fff;
  border-color: #aaa;
}

@media (max-width: 768px) {
  body.dark-mode header.nav-open nav ul {
    background: #111;
  }
}

/* ===== 固定購入ボタン（右下・縦書き） ===== */
#buy-now {
  position: fixed;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1900; /* モーダル(2000)より下に */
  display: flex;
  align-items: center;
  justify-content: center;

  /* 細長い縦ボタン */
  width: 32px;
  height: 180px;
  padding: 8px 0;

  /* サイバー感のあるピンク → 白文字 */
  background: linear-gradient(180deg, #ff2db3, #ff5cc8);
  color: #fff;
  text-decoration: none;
  font-weight: normal; /* ← ここを変更 */

  /* 縦書き */
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 0.1em;

  /* 形状と影 */
  border-radius: 8px 0 0 8px;
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow:
    0 8px 20px rgba(255, 44, 179, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.25);

  /* ちょい浮き感 */
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  opacity: 0.95;
}

#buy-now:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 28px rgba(255, 44, 179, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.3);
  opacity: 1;
  transition: all 0.3s ease;
}

#buy-now:active {
  transform: translateY(0);
}

#buy-now:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

/* モバイル最適化（少し小さく） */
@media (max-width: 480px) {
  #buy-now {
    width: 40px;
    height: 150px;
    border-radius: 8px 0 0 8px;
    letter-spacing: 0.08em;
  }
}

/* ダークモードでも視認性キープ */
body.dark-mode #buy-now {
  border-color: rgba(255,255,255,0.35);
  box-shadow:
    0 8px 20px rgba(255, 44, 179, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.5);
}
