/*
FILE: wp-content/plugins/tocipedia/tocipedia.css
VERSION: 14.2.0 (Full Restore + JS Sticky Support)
*/

/* ====================================================================== */
/* 1. Base wrapper & Reset                                                */
/* ====================================================================== */

.tocipedia--wrap {
  margin: 0 auto 2rem;
  padding: 2.2rem 2.6rem 2rem;
  font-size: 15px;
  line-height: 1.75;
}

.tocipedia--wrap *,
.tocipedia--wrap *::before,
.tocipedia--wrap *::after {
  box-sizing: border-box;
}

@media(max-width:736px){
  .tocipedia--wrap {
    padding: 2.2rem 20px 2rem;
  }
  body.is-editing .tocipedia--wrap {
    padding-top: 140px;
  }
}

/* ====================================================================== */
/* 2. Topbar                                                              */
/* ====================================================================== */

.tocipedia--topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.tocipedia--brand a img{
  width: 148px;
  height: auto;
  display: block;
}

/* ====================================================================== */
/* 3. Grid Layout (Sidebar + Main)                                        */
/* ====================================================================== */

.tocipedia--grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 2.2rem;
  align-items: start;
}

/* JSで固定するため、CSSのstickyは無効化 */
.tocipedia--side {
  position: relative; 
  z-index: 10;
}

.tocipedia--side-title {
  font-weight: 600;
  margin: 1rem 0;
  color: #202122;
  border-bottom: 1px solid #d8dce3;
}
.tocipedia--toc ul {
  list-style: none !important;
  padding: 0;
  margin: 0;
}
.tocipedia--toc li {
  margin: 0.25rem 0;
}
.tocipedia--toc li.lvl-3 {
  margin-left: 0.9rem;
}
.tocipedia--toclink{
  color: #36c !important;
  text-decoration: none;
}
.tocipedia--toclink:hover {
  text-decoration: underline;
}
.tocipedia--create-btn-side {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #36c;
    padding: 0;
    font-size: 0.95rem;
    cursor: pointer;
}
.tocipedia--create-btn-side:hover {
    text-decoration: underline;
}

/* ====================================================================== */
/* 4. Single Page Components                                              */
/* ====================================================================== */

/* Title & Tabs */
.tocipedia--titleblock {
  position: relative;
  margin-bottom: 1rem;
  border-bottom: 1px solid #c8ccd0;
  padding-bottom: 0.9rem;
}
.tocipedia--h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0.25rem 0 0.8rem;
  border-bottom: 1px solid #a1a9b0;
  line-height: 1.5;
}
#tocipedia-title-input {
  box-sizing: border-box;
  max-width: 100%;
}
.tocipedia--subtitle {
  font-size: 0.86rem;
  color: #666;
}
.tocipedia--tabs {
  position: absolute;
  right: 0;
  bottom: -1px;
  z-index: 10;
  display: inline-flex;
  gap: 0.25rem;
}
.tocipedia--tab {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid #a2a9b1;
  border-bottom: none;
  background: #f8f9fa;
  text-decoration: none;
  font-size: 0.92rem;
  color: #36c;
  line-height: 1.2;
}
.tocipedia--tab:hover {
  text-decoration: underline;
}
.tocipedia--tab.is-active {
  background: #fff;
  color: #202122;
  text-decoration: none;
}

/* Content Body */
.tocipedia--content p {
  margin: 0 0 0.95rem;
}
.tocipedia--content strong,
.tocipedia--content b {
  font-weight: 700 !important;
  color: #000;
}
.tocipedia--content h2 {
  font-size: 1.25rem;
  margin: 1.6rem 0 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #a2a9b1;
}
.tocipedia--content h3 {
  font-size: 1.1rem;
  margin: 1.2rem 0 0.4rem;
}
.tocipedia--content h2,
.tocipedia--content h3 {
  display: flow-root;
}
.tocipedia--content ul {
  list-style-type: disc !important;
  margin: 0.4rem 0 1rem 1.8rem !important;
  padding-left: 0 !important;
}
.tocipedia--content ol {
  list-style-type: decimal !important;
  margin: 0.4rem 0 1rem 1.8rem !important;
  padding-left: 0 !important;
}
.tocipedia--content li {
  margin: 0.25rem 0;
  display: list-item !important;
}
.tocipedia--content a {
  color: #36c;
  text-decoration: none;
}
.tocipedia--content a:hover {
  text-decoration: underline;
}
.tocipedia--link {
  color: #36c;
}
.tocipedia--missing {
  color: #a2a9b1;
}
.tocipedia--create {
  display: inline-block;
  margin: 0 0.2rem;
  padding: 0 0.45rem;
  font-size: 1em;
  background-color: #e9f2ff;
  border: 1px dashed #a0bce8;
  color: #202122;
  cursor: pointer;
  border-radius: 2px;
}

/* External Link Icon */
.tocipedia--content a.tocipedia--extlink::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 3px;
  background-image: url("assets/ico_link.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: .75;
}

/* Infobox (Float Image) */
.tocipedia--float {
  float: right;
  width: min(360px, 44%);
  margin: 0.25rem 0 1rem 1.2rem;
  border: 1px solid #a2a9b1;
  background: #fff;
  position: relative;
  z-index: 10;
}
.tocipedia--float-head {
  background: #cfd9e6;
  border-bottom: 1px solid #a2a9b1;
  font-weight: 700;
  text-align: center;
  padding: 0.4rem 0.6rem;
  letter-spacing: 0.04em;
}
.tocipedia--float-media {
  padding: 0.6rem;
  background: #f8f9fa;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tocipedia--float-img {
  display: block;
  width: 100%;
  height: auto;
}
.tocipedia--float-caption {
  font-size: 0.82rem;
  color: #202122;
  padding: 0.55rem 0.6rem 0.6rem;
  text-align: center;
  border-top: 1px solid #eaecf0;
}
.tocipedia--clearfix {
  clear: both;
}

/* Edit Toolbar */
.tocipedia--toolbar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 9999;
  background: #f8f9fa;
  border: 1px solid #a2a9b1;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
body.admin-bar .tocipedia--toolbar {
  top: 32px;
}
.tocipedia--btn {
  background: #fff;
  border: 1px solid #c8ccd1;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}
.tocipedia--btn:hover {
  background: #e9f2ff;
  border-color: #36c;
  color: #202122;
}
.tocipedia--btn-save-mini {
  background: #36c;
  color: #fff;
  border-color: #36c;
  margin-left: auto;
}
.tocipedia--btn-save-mini:hover {
  background: #2a4b8d;
  color: #fff;
}

/* Editor States */
.tocipedia--content.is-editable {
  outline: 2px dashed #36c;
  outline-offset: 8px;
  background-color: #f0f7ff;
  min-height: 300px;
  padding: 10px;
  border-radius: 4px;
  position: relative;
  z-index: 1;
}
.is-editing .tocipedia--content > div > *,
.is-editing .tocipedia--content > * {
  border: 1px solid rgba(162, 169, 177, 0.2);
  margin-bottom: 0.5rem;
  padding: 2px 4px;
}
.is-editing .tocipedia--content *:hover {
  border-color: rgba(51, 102, 204, 0.5);
  background-color: rgba(255, 255, 255, 0.3);
}
.is-editing .tocipedia--content *:focus {
  background-color: #ffffff;
  outline: 1px solid #36c;
  border-color: transparent;
}
.tocipedia--save-panel {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eaecf0;
  text-align: right;
  display: none;
}
.is-editing .tocipedia--save-panel {
  display: block;
}
.tocipedia--save-btn {
  background: #36c;
  color: #fff;
  border: 1px solid #36c;
  padding: 10px 32px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.tocipedia--save-btn:hover {
  background: #2a4b8d;
  border-color: #2a4b8d;
}

/* Image Overlay Buttons */
#toci-img-overlay {
    transition: all 0.2s;
    z-index: 5;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
}
#toci-img-overlay:hover {
    background: rgba(0,0,0,0.7) !important;
}
.tocipedia--overlay-btn {
    border: none;
    background: #fff;
    color: #333;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.1s;
}
.tocipedia--btn-danger {
    background: #ffebee;
    color: #c62828;
}
.is-editing .tocipedia--float-head:hover,
.is-editing .tocipedia--float-caption:hover {
    background: #e3f2fd !important;
    cursor: text;
    outline: 1px dashed #2196f3;
}

/* ====================================================================== */
/* 5. Mobile Override                                                     */
/* ====================================================================== */

@media (max-width: 900px) {
  .tocipedia--grid {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  .tocipedia--side {
    position: static;
    top: auto;
    border: 1px solid #eaecf0;
    padding: 0.8rem;
    border-radius: 6px;
  }
  .tocipedia--titleblock {
    margin-bottom: 0.6rem;
    padding-bottom: 0;
  }
  .tocipedia--tabs {
    position: static;
    display: flex;
    justify-content: flex-start;
    margin-top: 1rem;
    width: 100%;
  }
  .tocipedia--content {
    margin-top: 0.75rem;
  }
  .tocipedia--float {
    float: none;
    width: 100%;
    margin: 0.4rem 0 1rem;
  }
  .tocipedia--toolbar {
    position: fixed !important;
    top: 50px;
    left: 0;
    right: 0;
    margin: 0;
    width: 100%;
    background: rgba(233, 233, 233, 0.8);
    border-radius: 0;
    box-shadow: none;
    z-index: 999;
    padding: 10px 8px !important;
    gap: 6px;
    justify-content: space-between;
    flex-wrap: wrap !important;
    overflow: visible;
    border: none;
    border-bottom: 1px solid #e2e2e2;
    border-top: 1px solid #e2e2e2;
  }
  .tocipedia--btn {
    font-size: 0.75rem;
    padding: 6px 4px;
    flex-grow: 1;
    text-align: center;
    max-width: 32%;
    border-radius: 6px;
  }
  .tocipedia--btn-save-mini {
    flex-grow: 1;
    max-width: 100%;
    margin-top: 4px;
    padding: 8px 0;
  }
}

/* ====================================================================== */
/* 6. Archive / Portal Styles (ここから下が切れていた可能性が高いです)    */
/* ====================================================================== */

.tocipedia--portal-hero {
  background: #f8f9fa;
  border: 1px solid #a2a9b1;
  padding: 2rem;
  text-align: center;
  margin-bottom: 2rem;
  border-radius: 4px;
}
.tocipedia--portal-h1 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 2.4rem;
  margin: 0 0 0.5rem;
  color: #000;
  border: none;
}
.tocipedia--portal-desc {
  font-size: 1rem;
  color: #555;
  margin-bottom: 1.5rem;
}
.tocipedia--count {
  font-weight: bold;
  color: #36c;
}

/* 検索フォーム */
.tocipedia--search-form {
  display: flex;
  justify-content: center;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto;
}
.tocipedia--search-input {
  flex: 1;
  padding: 10px 16px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 999px;
  outline: none;
}
.tocipedia--search-input:focus {
  border-color: #36c;
  box-shadow: 0 0 0 2px rgba(51, 102, 204, 0.2);
}
.tocipedia--search-submit {
  background: #36c;
  color: #fff;
  border: none;
  padding: 0 24px;
  border-radius: 999px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}
.tocipedia--search-submit:hover {
  background: #2a4b8d;
}

/* 2カラムパネル */
.tocipedia--portal-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 3rem;
}
@media (max-width: 768px) {
  .tocipedia--portal-panels {
    grid-template-columns: 1fr;
  }
}

.tocipedia--portal-box {
  border: 1px solid #a2a9b1;
  background: #fcfdfd;
  padding: 1rem;
  height: 100%;
}
.tocipedia--portal-box.is-blue {
  background: #f0f7ff;
  border-color: #a0bce8;
}

.tocipedia--portal-box-title {
  background: #cfd9e6;
  border: 1px solid #a2a9b1;
  margin: -1rem -1rem 1rem -1rem;
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
  font-weight: bold;
  color: #000;
}
.is-blue .tocipedia--portal-box-title {
  background: #dcebff;
  border-color: #a0bce8;
}

/* カテゴリナビ */
.tocipedia--portal-cats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.tocipedia--cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #eaecf0;
  text-decoration: none;
  color: #202122;
  border-radius: 4px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.tocipedia--cat-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  color: #36c;
}
.tocipedia--cat-icon {
  font-size: 1.4rem;
}
.tocipedia--cat-item.is-random {
  background: #fff9e6;
  border-color: #f5d76e;
}

/* 新着リスト */
.tocipedia--portal-news-list {
  list-style: none !important;
  padding: 0;
  margin: 0;
}
.tocipedia--portal-news-list li {
  padding: 8px 0;
  border-bottom: 1px dashed #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tocipedia--portal-news-list li:last-child {
  border-bottom: none;
}
.tocipedia--portal-news-list a {
  font-weight: 600;
}
.tocipedia--date {
  font-size: 0.8rem;
  color: #666;
  white-space: nowrap;
}
.tocipedia--more-link {
  text-align: right;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* 全記事インデックス（ミニカード） */
.tocipedia--h2-border {
  font-size: 1.4rem;
  border-bottom: 1px solid #a2a9b1;
  padding-bottom: 0.4rem;
  margin-bottom: 1.2rem;
}
.tocipedia--archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.tocipedia--archive-card-mini {
  background: #fff;
  border: 1px solid #eaecf0;
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.tocipedia--archive-card-mini:hover {
  border-color: #36c;
}
.tocipedia--mini-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  text-decoration: none;
  color: #202122;
}
.tocipedia--mini-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 2px;
  background: #eee;
}
.tocipedia--mini-no-thumb {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  font-size: 1.2rem;
  border-radius: 2px;
}
.tocipedia--mini-title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
}