/* murasaki-book — 静的対訳リーダー */

@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@400;600&display=swap');

:root {
  --bg-base: #1a1520;
  --bg-elevated: #231e2a;
  --bg-header: #2e2840;
  --bg-surface: #2a2433;
  --text-primary: #e8e0f0;
  --text-secondary: #a89bb8;
  --text-muted: #7a6f8a;
  --accent: #b99ad8;
  --accent-glow: rgba(185, 154, 216, 0.15);
  --accent-dim: #9b7db8;
  --bookmark-color: #d4a853;
  --border-en: #b99ad8;
  --border-source: #7a6f8a;
  --font-heading: 'Shippori Mincho', serif;
  --font-body: 'Shippori Mincho', 'Hiragino Mincho ProN', serif;
  --font-sub: system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.8;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  color: var(--text-primary);
}

/* ── ナビゲーション ── */

.site-nav {
  background: var(--bg-header);
  border-bottom: 1px solid rgba(185, 154, 216, 0.2);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.site-nav-brand {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}
.site-nav-link {
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.site-nav-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}
.site-nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}

/* ── コンテナ ── */

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Portal カード ── */

.project-card {
  background: var(--bg-elevated);
  border: 1px solid rgba(185, 154, 216, 0.15);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}
.project-card:hover {
  border-color: var(--accent);
}
.project-card h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}
.project-card .meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.progress-bar-bg {
  background: var(--bg-surface);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* ── Chapter ── */

.chapter-overview {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.chapter-overview h1, .chapter-overview h2, .chapter-overview h3 {
  font-family: var(--font-heading);
  color: var(--accent);
}
.chapter-overview h1 { font-size: 1.3rem; margin-bottom: 0.75rem; }
.chapter-overview h2 { font-size: 1.1rem; margin-top: 1rem; margin-bottom: 0.5rem; }
.chapter-overview h3 { font-size: 1rem; margin-top: 0.75rem; margin-bottom: 0.5rem; }
.chapter-overview p, .chapter-overview li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}
.chapter-overview strong { color: var(--text-primary); }
.chapter-overview ul { padding-left: 1.25rem; }

/* アコーディオン */

.accordion {
  margin-bottom: 1.5rem;
}
.accordion-header {
  background: var(--bg-elevated);
  border: 1px solid rgba(185, 154, 216, 0.15);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.accordion-header:hover {
  border-color: var(--accent);
}
.accordion-header::after {
  content: '▸';
  color: var(--text-muted);
  transition: transform 0.2s;
}
.accordion-header.open::after {
  transform: rotate(90deg);
}
.accordion-body {
  display: none;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(185, 154, 216, 0.1);
  border-radius: 0 0 6px 6px;
  margin-top: -3px;
  margin-bottom: 0.5rem;
  overflow-x: auto;
}
.accordion-body.open {
  display: block;
}

/* glossary テーブル */

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.glossary-table th {
  text-align: left;
  color: var(--accent);
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--accent-dim);
}
.glossary-table td {
  padding: 0.4rem 0.5rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(185, 154, 216, 0.08);
}

/* 章リスト */

.chapter-list {
  list-style: none;
}
.chapter-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(185, 154, 216, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chapter-list .chapter-num {
  color: var(--text-muted);
  font-size: 0.8rem;
  min-width: 3rem;
}
.chapter-list .chapter-title {
  flex: 1;
}
.chapter-list .chapter-pending {
  color: var(--text-muted);
  opacity: 0.5;
}
.chapter-list .chapter-bookmark-info {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── View（対訳リーダー）── */

.view-header {
  margin-bottom: 2rem;
  text-align: center;
}
.view-header h1 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}
.view-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-size: 0.85rem;
}
.chapter-nav a {
  color: var(--accent);
}
.chapter-nav .disabled {
  color: var(--text-muted);
  opacity: 0.4;
}

/* 段落ブロック */

.para-block {
  margin-bottom: 2rem;
  padding: 0.25rem 0;
  cursor: default;
  position: relative;
}
.para-block.bookmarked {
  position: relative;
  margin-top: 2.5rem;
}
.para-block.bookmarked::before {
  content: '';
  position: absolute;
  top: -1.25rem;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--bookmark-color) 10%,
    var(--bookmark-color) 90%,
    transparent 100%
  );
  opacity: 0.7;
}
.para-ja {
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.para-en {
  font-family: var(--font-sub);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border-left: 2px solid var(--border-en);
  padding-left: 0.75rem;
  margin-bottom: 0.35rem;
}
.para-source {
  font-family: var(--font-sub);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
  border-left: 2px solid var(--border-source);
  padding-left: 0.75rem;
}

/* ブックマーク プログレスバー */

.bookmark-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(185, 154, 216, 0.1);
  z-index: 100;
}
.bookmark-progress-fill {
  height: 100%;
  background: var(--bookmark-color);
  transition: width 0.3s;
}

/* ── 折りたたみ（overview） ── */

.collapsible-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.collapsible-header::after {
  content: '▸';
  color: var(--text-muted);
  transition: transform 0.2s;
}
.collapsible-header.open::after {
  transform: rotate(90deg);
}
.collapsible-body {
  display: none;
}
.collapsible-body.open {
  display: block;
}

/* ── 巻区切り ── */

.volume-header {
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-dim);
}
.volume-header:first-child {
  margin-top: 0;
}
.volume-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.volume-progress {
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.volume-divider {
  border: none;
  border-top: 1px solid rgba(185, 154, 216, 0.15);
  margin: 2.5rem 0;
}

/* ── レスポンシブ ── */

@media (max-width: 600px) {
  .container { padding: 1rem; }
  .para-ja { font-size: 1rem; }
  .site-nav { padding: 0.5rem 1rem; gap: 1rem; }
}

/* ── アノテーション ── */

:root {
  --anno-fix: #e07878;
  --anno-fix-glow: rgba(224, 120, 120, 0.12);
  --anno-split: #d4a853;
  --anno-split-glow: rgba(212, 168, 83, 0.12);
}

/* ✎ トリガーボタン */
.anno-trigger {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--bg-base);
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  z-index: 1;
  border-radius: 3px;
}
.para-block:hover .anno-trigger,
.anno-trigger.has-annotation {
  opacity: 1;
}
.anno-trigger.has-annotation {
  color: var(--accent);
}

/* 段落のアノテーション状態 */
.para-block.anno-fix,
.para-block.anno-split,
.para-block.anno-both {
  padding-left: 0.75rem;
}
.para-block.anno-fix {
  border-left: 3px solid var(--anno-fix);
  background: var(--anno-fix-glow);
}
.para-block.anno-split {
  border-left: 3px solid var(--anno-split);
  background: var(--anno-split-glow);
}
.para-block.anno-both {
  border-left: none;
  background: linear-gradient(to right, rgba(224, 120, 120, 0.08), rgba(212, 168, 83, 0.08));
}
.para-block.anno-both::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--anno-fix), var(--anno-split));
}

/* バッジ */
.anno-badges {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}
.anno-badge {
  font-family: var(--font-sub);
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.anno-badge.fix {
  background: rgba(224, 120, 120, 0.2);
  color: var(--anno-fix);
  border: 1px solid rgba(224, 120, 120, 0.4);
}
.anno-badge.split {
  background: rgba(212, 168, 83, 0.2);
  color: var(--anno-split);
  border: 1px solid rgba(212, 168, 83, 0.4);
}

/* アノテーションパネル */
.anno-panel {
  background: var(--bg-surface);
  border: 1px solid rgba(185, 154, 216, 0.2);
  border-radius: 6px;
  padding: 0.75rem;
  margin-top: 0.75rem;
}
.anno-panel-flags {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.anno-flag-btn {
  font-family: var(--font-sub);
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--text-muted);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.anno-flag-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}
.anno-flag-btn.active.fix {
  background: rgba(224, 120, 120, 0.2);
  border-color: var(--anno-fix);
  color: var(--anno-fix);
}
.anno-flag-btn.active.split {
  background: rgba(212, 168, 83, 0.2);
  border-color: var(--anno-split);
  color: var(--anno-split);
}
.anno-comment {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid rgba(185, 154, 216, 0.15);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-sub);
  font-size: 0.85rem;
  padding: 0.5rem;
  resize: vertical;
  min-height: 4rem;
  display: block;
  margin-bottom: 0.6rem;
}
.anno-comment:focus {
  outline: none;
  border-color: var(--accent);
}
.anno-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.anno-save {
  background: var(--accent);
  color: var(--bg-base);
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.9rem;
  font-family: var(--font-sub);
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}
.anno-save:hover {
  background: var(--text-primary);
}
.anno-delete {
  background: none;
  border: 1px solid var(--text-muted);
  border-radius: 4px;
  padding: 0.3rem 0.9rem;
  font-family: var(--font-sub);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.anno-delete:hover {
  border-color: var(--anno-fix);
  color: var(--anno-fix);
}

/* エクスポートバナー */
.anno-export-banner {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(185, 154, 216, 0.15);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.anno-export-info {
  font-family: var(--font-sub);
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.anno-export-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.35rem 1rem;
  font-family: var(--font-sub);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.anno-export-btn:hover {
  background: var(--accent-glow);
}
