/* =========================================================
   common.css (Clean rebuild)
   Purpose:
   - Web-book baseline styles (readable defaults)
   - Anchor popup system (supports text + image + audio)
   - No legacy/compat blocks included (as requested)
   ========================================================= */

/* ---------- Reset-ish ---------- */
* { box-sizing: border-box; }
html, body { height: 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;
}
img, video { 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-title{
  font-size: 1.7rem;
  font-weight: 750;
  letter-spacing: .01em;
  margin: 0 0 12px;
}
.wb-subtitle{
  margin: 0 0 24px;
  color: #555;
  font-size: .98rem;
}

/* ---------- 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;
}



/* ===============================
   Theme colors (use with .wb-block)
   例: <div class="wb-block wb-theme-warning">...</div>
   =============================== */
.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;
}
.wb-toc h2{
  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; }

/* ---------- Headings ---------- */
h1,h2,h3{
  line-height: 1.35;
  margin: 1.2em 0 .5em;
}
h2{ font-size: 1.25rem; }
h3{ font-size: 1.08rem; }

/* =========================================================
   Anchor: clickable inline marker + universal popup viewer
   - Supports: 用語 / 補足 / 注意 / 関連 / 画像 / 音声 / 動画 / 表 / グラフ
   - Popup is a generic media/text container (no content limits)
   - JS places the popup near the clicked anchor (popover mode)
   ========================================================= */

/* 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; }

/* Optional: show an audio icon on anchors that open audio */
.anchor[data-anchor-type="audio"]::after{
  content: " 🔊";
  font-size: .9em;
}

/* ---------- Popup shell ---------- */
/* Backdrop is optional (use it for modal mode). */
#anchor-popup-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.20);
  display: none;              /* JS: set to flex when opening modal */
  align-items: center;
  justify-content: center;
  z-index: 999;
}

/* Popup element.
   Default is "popover mode": absolute near the clicked anchor.
   If you want modal mode, place it inside #anchor-popup-backdrop and add .is-modal.
*/
#anchor-popup{
  position: absolute;         /* popover mode */
  left: 0; top: 0;            /* JS updates these */
  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;              /* JS: set to block/flex when open */
  z-index: 1000;
}

/* Modal mode (centered) */
#anchor-popup.is-modal{
  position: relative;
  left: auto; top: auto;
  display: flex;
  flex-direction: column;
}

/* Small arrow for popover mode */
#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;                /* JS can tweak when needed */
}

/* Header row */
#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; }

/* Body content */
#anchor-popup-body{
  font-size: 0.92rem;
  overflow: auto;
  padding-right: 4px;
  color: #222;
}

/* Content inside popup: media */
#anchor-popup-body img,
#anchor-popup-body video{
  border-radius: 8px;
  border: 1px solid #eee;
}

/* Audio player styling */
#anchor-popup-body audio{
  width: 100%;
  margin-top: 8px;
}

/* Optional: caption-like text */
.anchor-caption{
  margin: 8px 0 0;
  color: #555;
  font-size: .88rem;
}

/* Optional: compact list (for term definitions etc.) */
.anchor-list{
  margin: 0;
  padding-left: 1.2em;
}
.anchor-list li{ margin: 6px 0; }

/* =========================================================
   Print (optional): hide popups
   ========================================================= */
@media print{
  #anchor-popup-backdrop,
  #anchor-popup{ display: none !important; }
  .anchor{ text-decoration: none; color: inherit; }
}
