/* =========================================================
   common.css V2  --> wb_common.css / wb_common_complete.css
   Purpose:
   - Web-book baseline styles (readable defaults)
   - Anchor popup system (supports text + image + audio + video)
   - Text/article structure helpers
   - List / Table / Definition / Quote / Figure support
   - Lightweight and reusable
   - Tuned for the latest anchor.js complete edition
   ========================================================= */

/* ---------- Reset-ish ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

html{
  font-size: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP",
               "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  line-height: 1.75;
  color: #222;
  background: #fff;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono", monospace;
}

/* ---------- Page container ---------- */
.wb-container{
  width: min(920px, 92vw);
  margin: 0 auto;
  padding: 28px 0 56px;
}

.wb-container--narrow{
  width: min(760px, 92vw);
}

.wb-title{
  font-size: 1.7rem;
  font-weight: 750;
  letter-spacing: .01em;
  line-height: 1.4;
  margin: 0 0 12px;
}

.wb-subtitle{
  margin: 0 0 24px;
  color: #555;
  font-size: .98rem;
}

/* ---------- Basic text ---------- */
p{
  margin: 0 0 1.15em;
}

.lead{
  font-size: 1.05rem;
  color: #333;
}

.small{
  font-size: .92rem;
  color: #666;
}

.align-center{ text-align: center; }
.align-right{ text-align: right; }
.align-left{ text-align: left; }

.indent{
  padding-left: 1em;
}

.nowrap{
  white-space: nowrap;
}

/* ---------- Headings ---------- */
h1, h2, h3, h4, h5, h6{
  line-height: 1.35;
  margin: 1.2em 0 .5em;
  color: #222;
}

h1{ font-size: 1.7rem; }
h2{ font-size: 1.25rem; }
h3{ font-size: 1.08rem; }
h4{ font-size: 1rem; }
h5{ font-size: .95rem; }
h6{ font-size: .9rem; color: #555; }

h1:first-child,
h2:first-child,
h3:first-child{
  margin-top: 0;
}

/* ---------- Horizontal rule ---------- */
hr,
.wb-hr{
  border: none;
  border-top: 1px solid #ddd;
  margin: 2em 0;
}

/* ---------- Blocks ---------- */
.wb-block{
  margin: 18px 0;
  padding: 16px 18px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  background: #fff;
}

.wb-block > :first-child{ margin-top: 0; }
.wb-block > :last-child{ margin-bottom: 0; }

.wb-block--note{
  background: #fafafa;
  border-color: #e8e8e8;
}

.wb-block--warn{
  background: #fff8f6;
  border-color: #ffd8cf;
}

.wb-block--tip{
  background: #f7fbff;
  border-color: #cfe6ff;
}

.wb-block--memo{
  background: #fffdf6;
  border-color: #f1e0a6;
}

/* ---------- Theme colors ---------- */
.wb-theme-neutral{
  background: #ffffff;
  border-color: #e6e6e6;
}

.wb-theme-warning{
  background: #fff3e0;
  border-color: #ffca9c;
}

.wb-theme-data{
  background: #f1f8e9;
  border-color: #c6e6b1;
}

.wb-theme-core{
  background: #e8f4ff;
  border-color: #bcdcff;
}

.wb-theme-soft{
  background: #f7f0fa;
  border-color: #e0cdee;
}

/* ---------- TOC ---------- */
.wb-toc{
  padding: 14px 18px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  background: #fafafa;
  margin: 1.2em 0 1.6em;
}

.wb-toc h2,
.wb-toc h3{
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.wb-toc ul{
  margin: 0;
  padding-left: 1.2em;
}

.wb-toc li{
  margin: 4px 0;
}

.wb-toc a{
  text-decoration: none;
  border-bottom: 1px dashed #aaa;
}

.wb-toc a:hover{
  border-bottom-style: solid;
}

/* ---------- Lists ---------- */
ul, ol{
  margin: 0 0 1.2em 1.2em;
  padding: 0;
}

li{
  margin: .35em 0;
}

.wb-list{
  margin: 1em 0 1.2em;
  padding-left: 1.4em;
}

.wb-list li{
  margin: 6px 0;
  line-height: 1.7;
}

.wb-list--compact li{
  margin: 2px 0;
}

.wb-list--spacious li{
  margin: 10px 0;
}

.wb-list-box{
  list-style: none;
  margin: 1em 0 1.2em;
  padding: 0;
}

.wb-list-box li{
  background: #fff4ef;
  border: 1px solid #ffbfa3;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 6px;
}

.wb-list-check{
  list-style: none;
  margin: 1em 0 1.2em;
  padding: 0;
}

.wb-list-check li{
  position: relative;
  padding-left: 1.6em;
  margin: 6px 0;
}

.wb-list-check li::before{
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: #0b7a43;
  font-weight: 700;
}

/* ---------- Definition list ---------- */
dl{
  margin: 1em 0 1.2em;
}

dt{
  font-weight: 700;
}

dd{
  margin: .25em 0 1em 1.2em;
}

.wb-def dt{
  font-weight: 700;
  margin-top: 12px;
  color: #222;
}

.wb-def dd{
  margin-left: 1.2em;
  margin-bottom: 10px;
  color: #444;
}

.wb-def-card dt{
  background: #f6f6f6;
  border-left: 4px solid #cfcfcf;
  padding: 6px 10px;
  margin-top: 14px;
  border-radius: 4px;
}

.wb-def-card dd{
  margin: 8px 0 12px 0;
  padding-left: 14px;
}

/* ---------- Table ---------- */
table{
  border-collapse: collapse;
}

.wb-table{
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0 1.4em;
  font-size: .95rem;
  background: #fff;
}

.wb-table caption{
  caption-side: top;
  text-align: left;
  font-weight: 700;
  margin-bottom: .5em;
}

.wb-table th,
.wb-table td{
  border: 1px solid #ddd;
  padding: 8px 10px;
  vertical-align: top;
}

.wb-table th{
  background: #f5f5f5;
  text-align: left;
  white-space: nowrap;
}

.wb-table tbody tr:nth-child(even){
  background: #fcfcfc;
}

.wb-table-wrap{
  overflow-x: auto;
  margin: 1em 0 1.4em;
}

.wb-table--compact th,
.wb-table--compact td{
  padding: 5px 8px;
  font-size: .92rem;
}

/* ---------- Quote ---------- */
blockquote,
.wb-quote{
  border-left: 4px solid #ccc;
  padding: 8px 12px;
  background: #fafafa;
  color: #555;
  margin: 1em 0 1.4em;
}

blockquote p:last-child,
.wb-quote p:last-child{
  margin-bottom: 0;
}

.wb-quote cite{
  display: block;
  margin-top: .5em;
  font-size: .9rem;
  color: #777;
  font-style: normal;
}

/* ---------- Figure / image ---------- */
figure{
  margin: 1.5em 0;
}

.wb-figure{
  text-align: center;
  margin: 1.5em 0;
}

.wb-figure img,
.wb-figure video{
  border-radius: 8px;
}

.wb-figure figcaption{
  font-size: .85rem;
  color: #666;
  margin-top: 6px;
  line-height: 1.6;
}

.wb-image-frame{
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

/* ---------- Notes / labels ---------- */
.wb-note{
  font-size: .95rem;
  color: #555;
}

.wb-label{
  display: inline-block;
  font-size: .82rem;
  line-height: 1.2;
  padding: .25em .55em;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: #f8f8f8;
  color: #444;
  vertical-align: middle;
}

.wb-label--warn{
  background: #fff3e8;
  border-color: #ffc89d;
}

.wb-label--info{
  background: #eef7ff;
  border-color: #bfddff;
}

.wb-label--ok{
  background: #eefaf0;
  border-color: #b7e2bf;
}

/* ---------- Highlight ---------- */
mark,
.wb-mark{
  background: linear-gradient(transparent 60%, #fff3a0 60%);
  color: inherit;
  padding: 0 .08em;
}

.wb-mark-soft{
  background: linear-gradient(transparent 60%, #dff3ff 60%);
}

/* ---------- Code ---------- */
pre{
  overflow: auto;
}

code{
  background: #f6f6f6;
  padding: .12em .35em;
  border-radius: 4px;
  font-size: .95em;
}

pre code{
  display: block;
  background: #f6f6f6;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
}

/* ---------- Utility spacing ---------- */
.mt-0{ margin-top: 0 !important; }
.mb-0{ margin-bottom: 0 !important; }
.mt-1{ margin-top: .5em !important; }
.mb-1{ margin-bottom: .5em !important; }
.mt-2{ margin-top: 1em !important; }
.mb-2{ margin-bottom: 1em !important; }
.mt-3{ margin-top: 1.5em !important; }
.mb-3{ margin-bottom: 1.5em !important; }

.pt-1{ padding-top: .5em !important; }
.pb-1{ padding-bottom: .5em !important; }
.pt-2{ padding-top: 1em !important; }
.pb-2{ padding-bottom: 1em !important; }

/* =========================================================
   Anchor: clickable inline marker + universal popup viewer
   - Supports: 用語 / 補足 / 注意 / 関連 / 画像 / 音声 / 動画 / 表 / グラフ
   - Popup is a generic media/text container
   - Tuned for silent media-first display when content is empty
   ========================================================= */

/* Inline anchor */
.anchor{
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  color: #0066cc;
  cursor: pointer;
}

.anchor:hover{
  filter: brightness(0.92);
}

.anchor:active{
  opacity: 0.7;
}

.anchor[data-anchor-type="audio"]::after{
  content: " 🔊";
  font-size: .9em;
}

/* ---------- Popup shell ---------- */
#anchor-popup-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.20);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#anchor-popup{
  position: absolute;
  left: 0;
  top: 0;
  background: #ffffff;
  width: min(520px, 92vw);
  max-height: min(70vh, 520px);
  border-radius: 10px;
  border: 1px solid #e5e5e5;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
  padding: 10px 12px 12px;
  display: none;
  z-index: 1000;
}

#anchor-popup.is-modal{
  position: relative;
  left: auto;
  top: auto;
  display: flex;
  flex-direction: column;
}

#anchor-popup::before{
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  background: #fff;
  border-left: 1px solid #e5e5e5;
  border-top: 1px solid #e5e5e5;
  top: -7px;
  left: 22px;
}

#anchor-popup-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

#anchor-popup-title{
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0;
  color: #222;
}

#anchor-popup-close{
  border: none;
  background: #eeeeee;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

#anchor-popup-close:hover{
  filter: brightness(0.96);
}

#anchor-popup-close:active{
  background: #dddddd;
}

#anchor-popup-body{
  font-size: 0.92rem;
  overflow: auto;
  padding-right: 4px;
  color: #222;
  line-height: 1.7;
}

/* Silent media mode */
#anchor-popup-body.is-media-only{
  padding: 0;
  font-size: 0;
  line-height: 1;
}

#anchor-popup-body img,
#anchor-popup-body video{
  border-radius: 8px;
  border: 1px solid #eee;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
}

#anchor-popup-body audio{
  width: 100%;
  margin-top: 8px;
}

#anchor-popup-body.is-media-only audio{
  margin-top: 0;
  display: block;
}

#anchor-popup-body iframe{
  width: 100%;
  min-height: 320px;
  border: 0;
  border-radius: 8px;
  display: block;
}

.anchor-caption{
  margin: 8px 0 0;
  color: #555;
  font-size: .88rem;
}

.anchor-list{
  margin: 0;
  padding-left: 1.2em;
}

.anchor-list li{
  margin: 6px 0;
}

.anchor-link{
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-decoration: none;
  background: #fafafa;
}

.anchor-link:hover{
  background: #f3f3f3;
}

.anchor-graph{
  width: 100%;
  height: 260px;
  display: block;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
}

.anchor-table-wrap{
  overflow-x: auto;
}

.anchor-table-wrap .wb-table{
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px){
  .wb-container{
    width: min(100%, 100vw);
    padding: 18px 12px 42px;
  }

  .wb-title{
    font-size: 1.45rem;
  }

  .wb-table{
    font-size: .92rem;
  }

  .wb-table th,
  .wb-table td{
    padding: 6px 8px;
  }

  blockquote,
  .wb-quote{
    padding: 8px 10px;
  }

  #anchor-popup{
    width: min(96vw, 520px);
    max-height: 72vh;
  }

  #anchor-popup-body iframe{
    min-height: 220px;
  }

  .anchor-graph{
    height: 220px;
  }
}

/* ---------- Print ---------- */
@media print{
  #anchor-popup-backdrop,
  #anchor-popup{
    display: none !important;
  }

  .anchor{
    text-decoration: none;
    color: inherit;
  }

  .wb-block,
  .wb-toc,
  .wb-table th,
  .wb-table td{
    box-shadow: none !important;
  }

  body{
    background: #fff;
    color: #000;
  }
}


/* =========================================================
   Poem UI add-on for wb_common.css
   - quiet poem layout
   - line-based reading
   - soft inline anchors
   ========================================================= */

/* 詩ページ全体 */
.wb-poem-page{
  padding-top: 24px;
}

/* 詩の導入 */
.wb-poem-header{
  margin: 0 0 28px;
  text-align: center;
}

.wb-poem-title{
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.5;
  margin: 0 0 8px;
}

.wb-poem-meta{
  font-size: .92rem;
  color: #777;
  margin: 0;
}

/* 詩本文の器 */
.wb-poem{
  width: min(680px, 92vw);
  margin: 0 auto;
  padding: 26px 22px 34px;
  border: 1px solid #ece7e2;
  border-radius: 16px;
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.98), rgba(252,250,248,0.98));
  box-shadow: 0 8px 24px rgba(0,0,0,.04);
}

/* 1連 */
.wb-poem-stanza{
  margin: 0 0 2.4em;
}

.wb-poem-stanza:last-child{
  margin-bottom: 0;
}

/* 1行 */
.wb-poem-line{
  margin: 0 0 .72em;
  line-height: 2.05;
  font-size: 1.06rem;
  letter-spacing: .03em;
}

.wb-poem-line:last-child{
  margin-bottom: 0;
}

/* 余白を強く取りたい行 */
.wb-poem-line--spaced{
  margin-top: 1.2em;
}

/* 少し右へ寄せる行 */
.wb-poem-line--indent-1{
  padding-left: 1em;
}

.wb-poem-line--indent-2{
  padding-left: 2em;
}

/* 終行や余韻 */
.wb-poem-line--end{
  margin-top: 1.4em;
}

/* 静かな区切り */
.wb-poem-gap{
  height: 1.8em;
}

/* 詩の後の余韻スペース */
.wb-poem-afterspace{
  height: 18vh;
  min-height: 80px;
}

/* 詩用アンカー：標準anchorより少し柔らかく */
.wb-poem .anchor{
  color: #7a3f2f;
  text-decoration: none;
  border-bottom: 1px solid rgba(122, 63, 47, .45);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.wb-poem .anchor:hover{
  color: #5e2d20;
  background: linear-gradient(transparent 58%, rgba(196, 148, 120, .20) 58%);
  border-bottom-color: rgba(94, 45, 32, .7);
  filter: none;
}

/* アンカー種別で少しだけ差を出す */
.wb-poem .anchor[data-anchor-type="note"]{
  border-bottom-style: solid;
}

.wb-poem .anchor[data-anchor-type="memory"],
.wb-poem .anchor[data-anchor-type="image"],
.wb-poem .anchor[data-anchor-type="video"],
.wb-poem .anchor[data-anchor-type="graph"],
.wb-poem .anchor[data-anchor-type="table"]{
  border-bottom-style: dashed;
}

.wb-poem .anchor[data-anchor-type="audio"]{
  border-bottom-style: dotted;
}

/* 小さな前書き・後書き */
.wb-poem-note{
  width: min(680px, 92vw);
  margin: 24px auto 0;
  color: #666;
  font-size: .95rem;
  line-height: 1.9;
}

/* モバイル */
@media (max-width: 640px){
  .wb-poem{
    padding: 20px 16px 28px;
    border-radius: 12px;
  }

  .wb-poem-line{
    font-size: 1rem;
    line-height: 1.95;
  }

  .wb-poem-afterspace{
    height: 12vh;
    min-height: 56px;
  }
}
