/* ------------------------------------------------------------------ *
 * Blog editor Phase 4 (session 42): link modal, table modal, tables in
 * the article body, and the HTML source editor. Kept out of styles.css
 * only because that file is at PROJECT.md's 400-line cap.
 * Linked from index.html right after modules/blog/styles.css.
 * ------------------------------------------------------------------ */

/* ---- Links inside the article body ---- */
.blog-rt__body a { color: #0a5cff; text-decoration: underline; cursor: pointer; }
.blog-rt[data-bg="black"] .blog-rt__body a,
.blog-rt[data-bg="red"] .blog-rt__body a,
.blog-rt[data-bg="blue"] .blog-rt__body a { color: #93c5fd; }

/* ---- Tables inside the article body ----
 * display:block + overflow-x:auto lets a wide table scroll inside the editor
 * instead of pushing the whole page sideways at 390px. */
.blog-rt__body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}
.blog-rt__body th { white-space: nowrap; }
.blog-rt__body th,
.blog-rt__body td { min-width: 80px; }

/* ---- Link modal ---- */
.blog-lnk__note { margin: 0 0 var(--s-3); font-size: var(--fs-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.blog-lnk__type { margin: var(--s-3) 0 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.blog-lnk__type .field__label { width: 100%; }
.blog-lnk__opt { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-md); color: var(--text); cursor: pointer; }

/* ---- Table modal ---- */
.blog-tbl__grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 3px;
  max-width: 360px;
  margin: 0 auto;
}
.blog-tbl__cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--surface-3);
  cursor: pointer;
}
.blog-tbl__cell--on { background: var(--brand-soft); border-color: var(--brand); }
.blog-tbl__cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.blog-tbl__size { margin: var(--s-3) 0; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.blog-tbl__opts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }

/* ---- Source mode ---- */
.blog-rt--source .blog-rt__toolbar { opacity: 0.85; }
.blog-rt__toolbar--source .blog-rt__tbtn:disabled { opacity: 0.35; }
.blog-rt__toolbar--source .blog-rt__colorwrap,
.blog-rt__toolbar--source .blog-rt__bgwrap { opacity: 0.35; pointer-events: none; }

.blog-src {
  --src-lh: 20px;
  --src-pad: 16px;
  display: flex;
  flex-direction: column;
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: #0d1117;
  color: #e6edf3;
}
.blog-src__banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.blog-src__badge { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--success); font-weight: 600; letter-spacing: 0.02em; }
.blog-src__hint { flex: 1; min-width: 0; }
.blog-src__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.blog-src__btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.blog-src__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.blog-src__btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.blog-src__search {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.blog-src__search[hidden] { display: none; }
.blog-src__search-inp {
  flex: 1; min-width: 120px; height: 30px; padding: 0 var(--s-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-1); color: var(--text); font-size: var(--fs-sm);
}
.blog-src__search-inp:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }
.blog-src__count { min-width: 64px; text-align: center; font-size: var(--fs-xs); color: var(--text-muted); }

.blog-src__editor { display: flex; min-height: 320px; height: 60vh; max-height: 70vh; overflow: hidden; }
.blog-src__gutter,
.blog-src__ta,
.blog-src__mirror {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: var(--src-lh);
  tab-size: 2;
  white-space: pre;
}
.blog-src__gutter {
  flex: 0 0 auto;
  min-width: 3.5ch;
  padding: var(--src-pad) var(--s-2) var(--src-pad) var(--s-2);
  overflow: hidden;
  text-align: right;
  color: #6e7681;
  background: #0b0f14;
  border-right: 1px solid var(--border);
  user-select: none;
}
.blog-src__area { position: relative; flex: 1; min-width: 0; }
.blog-src__curline {
  position: absolute; left: 0; right: 0;
  background: rgba(110, 118, 129, 0.16);
  pointer-events: none;
}
.blog-src__ta,
.blog-src__mirror {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: var(--src-pad);
  border: 0;
  box-sizing: border-box;
}
.blog-src__ta {
  resize: none;
  overflow: auto;
  outline: none;
  background: transparent;
  color: #e6edf3;
  caret-color: #e6edf3;
}
.blog-src__ta:focus-visible { box-shadow: inset 0 0 0 2px var(--brand-soft); }
/* The mirror sits behind the textarea and only exists to paint match backgrounds:
 * identical metrics to the textarea, invisible text, generous bottom padding so it
 * can scroll as far as the textarea does when the textarea has a horizontal scrollbar. */
.blog-src__mirror { overflow: hidden; color: transparent; pointer-events: none; padding-bottom: calc(var(--src-pad) + 24px); }
.blog-src__hl { color: transparent; background: rgba(234, 179, 8, 0.35); border-radius: 2px; }
.blog-src__hl--cur { background: rgba(249, 115, 22, 0.6); }

@media (max-width: 640px) {
  .blog-src__hint { display: none; }
  .blog-src__editor { height: 55vh; }
  .blog-tbl__grid { max-width: 100%; }
}
