/* ══════════════════════════════════════════════════════════════════════
   Site-wide responsive & touch fixes. Loaded last (after magazine.css).
   Found by auditing every page type at 320/375/768/1024 px.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Layout ──────────────────────────────────────────────────────────── */
/* Categories: a 1fr column never shrinks below its content, so one long word
   pushed the card past a 320px screen. Let columns shrink, words wrap. */
.categories-modern-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)) !important; }
.category-hub-card { min-width: 0; overflow-wrap: break-word; }
/* header = icon + title + count badge: let the badge drop under the title
   instead of squeezing the title into a letter-by-letter column */
.category-hub-card .hub-card-header { flex-wrap: wrap; gap: 0.6rem; }
.category-hub-card .hub-identity { flex: 1 1 12rem; min-width: 0; }
.category-hub-card .hub-title-link { word-break: normal; overflow-wrap: break-word; }

/* Home stats on very small phones: 2 x 2 instead of 4 cramped columns */
@media (max-width: 360px) {
  .lp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; row-gap: 1rem !important; }
}

/* Media and long tokens never force sideways scrolling */
#article-prose-content img,
#article-prose-content video,
#article-prose-content iframe { max-width: 100%; height: auto; }
#article-prose-content a,
#article-prose-content p > code { overflow-wrap: anywhere; }

/* ── Readable small text (nothing under ~11.5px) ─────────────────────── */
.post-nav-lbl,
.code-copy-btn span,
.mobile-nav-link .nav-badge,
.hud-label,
.step-phase,
.step-mitre,
.card-type-pill,
.card-cat-pill { font-size: 0.72rem !important; }

/* Tags page: the tag names themselves were 9.6px */
.taxonomy-tags .tag > span:first-child { font-size: 0.85rem !important; }

/* Writeups filter: the whole 2.7rem field is tappable, not a 29px strip */
.mg-filter-input input { align-self: stretch; height: auto; }

/* ── Roadmaps: the whole card opens the link, Explore stays clickable ─── */
html body .clean-card { position: relative; }
html body .clean-card .clean-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
}
html body .clean-card .clean-card-action,
html body .clean-card .clean-card-action a { position: relative; z-index: 1; }

/* ── Touch screens: comfortable tap targets (desktop unchanged) ───────── */
@media (pointer: coarse) {
  .brand-link { display: inline-flex !important; align-items: center; min-height: 44px; }
  .code-copy-btn { min-height: 34px !important; padding-inline: 0.75rem !important; }
  .post-tag-badge { display: inline-flex !important; align-items: center; min-height: 36px; }
  .post-meta a,
  .ed-post-author a { display: inline-block; padding-block: 0.4rem; }
  .ed-post-kicker,
  .mg-section-link,
  .hub-action-link,
  .hub-title-link,
  .cat-back-link,
  .card-action-url,
  .fast-solve-top-pill { display: inline-flex !important; align-items: center; min-height: 36px; }
  .mobile-nav-link { min-height: 44px; }
  .supporter-name-txt a { display: inline-block; padding-block: 0.4rem; }
  /* post share row: icon links were ~20px wide */
  .share-wrapper a,
  .share-wrapper button,
  #copy-link { min-width: 40px !important; min-height: 40px !important; display: inline-flex !important; align-items: center; justify-content: center; }
}

/* ── Wide screens: less empty gutter ─────────────────────────────────── */
/* At 1920px the 1240px frame left ~340px of blank space on each side.
   Grow the frame on wide screens; the reading column keeps its measure. */
@media (min-width: 1500px) {
  :root,
  html[data-mode="light"],
  html[data-bs-theme="light"],
  html[data-mode="dark"],
  html[data-bs-theme="dark"] { --tac-container: 1440px; }
}

/* The faint background "orbs" read as a smudge in the empty space */
body::before,
body::after { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════
   Tables v2: one soft frame, quiet header, cards on phones.
   Selectors carry extra weight (:not(.rouge-table)) because an older rule
   in tactical-core.css (.content table:not(.rouge-table) th) forced a green
   uppercase mono header and a second border inside the frame.
   ══════════════════════════════════════════════════════════════════════ */
html body .ed-table,
html body .table-wrapper {
  border: 1px solid var(--tac-border) !important;
  border-radius: 14px !important;
  background: var(--tac-surface) !important;
}
html body .ed-table table:not(.rouge-table),
html body .table-wrapper table:not(.rouge-table) {
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}
html body .ed-table table:not(.rouge-table) th,
html body .table-wrapper table:not(.rouge-table) th {
  font-family: var(--tac-font) !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--tac-text) !important;
  background: var(--tac-elevated) !important;
  padding: 0.8rem 1.1rem !important;
  border: 0 !important;
  border-bottom: 1px solid var(--tac-border) !important;
  white-space: nowrap !important;
}
html body .ed-table table:not(.rouge-table) th code,
html body .table-wrapper table:not(.rouge-table) th code { font-size: 0.95em !important; }
html body .ed-table table:not(.rouge-table) td,
html body .table-wrapper table:not(.rouge-table) td {
  padding: 0.85rem 1.1rem !important;
  border: 0 !important;
  border-bottom: 1px solid var(--tac-border) !important;
  font-size: 0.92rem !important;
  line-height: 1.6 !important;
  color: var(--tac-text) !important;
  background: transparent !important;
}
html body .ed-table table:not(.rouge-table) tbody tr:last-child td,
html body .table-wrapper table:not(.rouge-table) tbody tr:last-child td { border-bottom: 0 !important; }
/* no zebra stripes: a soft hover is enough */
html body .ed-table table:not(.rouge-table) tbody tr:nth-child(even) td,
html body .table-wrapper table:not(.rouge-table) tbody tr:nth-child(even) td { background: transparent !important; }
html body .ed-table table:not(.rouge-table) tbody tr:hover td,
html body .table-wrapper table:not(.rouge-table) tbody tr:hover td { background: color-mix(in srgb, var(--tac-elevated) 60%, transparent) !important; }
html body .ed-table table:not(.rouge-table) td:first-child { color: var(--tac-text) !important; }

/* Phones: each row becomes a small card of "Column: value" lines,
   so nothing is squeezed or needs sideways scrolling. */
@media (max-width: 640px) {
  html body .ed-table:has(table.is-stackable) {
    overflow: visible !important;
    border: 0 !important;
    background: none !important;
    border-radius: 0 !important;
  }
  html body .ed-table table.is-stackable,
  html body .ed-table table.is-stackable tbody,
  html body .ed-table table.is-stackable tr,
  html body .ed-table table.is-stackable td { display: block !important; width: 100% !important; min-width: 0 !important; }
  html body .ed-table table.is-stackable thead { display: none !important; }
  html body .ed-table table.is-stackable tbody tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--tac-border);
    border-radius: 12px;
    background: var(--tac-surface);
    overflow: hidden;
  }
  html body .ed-table table.is-stackable tbody tr:hover td { background: transparent !important; }
  html body .ed-table table.is-stackable td {
    padding: 0.55rem 0.95rem !important;
    border-bottom: 1px solid var(--tac-border) !important;
    text-align: left !important;
  }
  html body .ed-table table.is-stackable td:last-child { border-bottom: 0 !important; }
  html body .ed-table table.is-stackable td:first-child { background: var(--tac-elevated) !important; }
  html body .ed-table table.is-stackable td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tac-faint);
  }
}
/* Light-mode and zebra rules elsewhere are more specific; :root:root outweighs them */
:root:root body .ed-table table:not(.rouge-table) th,
:root:root body .table-wrapper table:not(.rouge-table) th { color: var(--tac-text) !important; background: var(--tac-elevated) !important; }
@media (max-width: 640px) {
  :root:root body .ed-table table.is-stackable tbody tr td { background: transparent !important; }
  :root:root body .ed-table table.is-stackable tbody tr td:first-child { background: var(--tac-elevated) !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   Code blocks v2: soft frame, quiet bar (language + Copy), muted line
   numbers that can't be selected, responsive. Bar markup: post.html.
   ══════════════════════════════════════════════════════════════════════ */
:root:root .code-window-frame {
  margin: 1.6rem 0;
  border: 1px solid var(--tac-border);
  border-radius: 12px;
  background: #16181c;
  box-shadow: none;
  overflow: hidden;
}
:root:root .code-window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.5rem 0.35rem 1rem;
  background: #1d1f23;
  border-bottom: 1px solid #2f3336;
  color: #8b98a5;
}
.code-window-lang {
  font-family: var(--tac-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: #8b98a5;
}
:root:root .code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 30px;
  padding: 0 0.7rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #a3a8ad;
  font: 500 0.78rem var(--tac-font);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
:root:root .code-copy-btn:hover { background: #2a2d31; color: #e7e9ea; }
:root:root .code-copy-btn.is-copied { color: #1d9bf0; }
:root:root .code-copy-btn span { font-size: 0.78rem !important; }

/* code area */
:root:root .code-window-frame pre,
:root:root .code-window-frame .highlight,
:root:root .code-window-frame table.rouge-table { background: transparent !important; }
:root:root .code-window-frame .highlight > pre,
:root:root .code-window-frame pre.highlight { padding: 0.85rem 0 !important; }
:root:root .code-window-frame code,
:root:root .code-window-frame pre {
  font-family: var(--tac-mono) !important;
  font-size: 0.86rem !important;
  line-height: 1.7 !important;
  color: #e7e9ea;
}
:root:root .code-window-frame td.rouge-code pre { padding: 0 1.1rem !important; }
/* no-line-number blocks */
:root:root .code-window-frame .highlight > pre > code { padding: 0 1.1rem; display: block; }

/* line numbers: muted, never selected or copied */
:root:root .code-window-frame td.rouge-gutter,
:root:root .code-window-frame td.rouge-gutter pre {
  -webkit-user-select: none;
          user-select: none;
  color: #5b6066 !important;
  background: transparent !important;
  border: 0 !important;
}
:root:root .code-window-frame td.rouge-gutter { padding: 0 0 0 0.9rem !important; width: 1%; }
:root:root .code-window-frame td.rouge-gutter pre { padding: 0 0.6rem 0 0 !important; text-align: right; border-right: 1px solid #2f3336 !important; }

/* scrolling inside the block, never the page */
:root:root .code-window-frame .highlight {
  overflow-x: auto !important;
  scrollbar-width: thin;
  scrollbar-color: #3e4144 transparent;
}

@media (max-width: 640px) {
  :root:root .code-window-frame { border-radius: 10px; margin: 1.25rem 0; }
  :root:root .code-window-frame code,
  :root:root .code-window-frame pre { font-size: 0.78rem !important; line-height: 1.6 !important; }
  /* line numbers take too much room on a phone */
  :root:root .code-window-frame td.rouge-gutter { display: none !important; }
  :root:root .code-window-frame td.rouge-code pre { padding: 0 0.85rem !important; }
}
/* tighter code spacing: older rules padded the code cell and the block */
:root:root .code-window-frame td.rouge-code { padding: 0 !important; }
:root:root .code-window-frame td.rouge-code pre { padding: 0 1.1rem 0 0.9rem !important; margin: 0 !important; }
:root:root .code-window-frame table.rouge-table { margin: 0 !important; border: 0 !important; }
:root:root .code-window-frame .highlight > pre,
:root:root .code-window-frame pre.highlight { padding: 0.7rem 0 !important; margin: 0 !important; }

/* Light mode: light code blocks (X style) so the light syntax colours read */
html[data-mode="light"]:root .code-window-frame,
html[data-bs-theme="light"]:root .code-window-frame { background: #f7f9f9; border-color: #e1e8ed; }
html[data-mode="light"]:root .code-window-bar,
html[data-bs-theme="light"]:root .code-window-bar { background: #eff3f4; border-bottom-color: #e1e8ed; color: #536471; }
html[data-mode="light"]:root .code-window-lang,
html[data-bs-theme="light"]:root .code-window-lang { color: #536471; }
html[data-mode="light"]:root .code-copy-btn,
html[data-bs-theme="light"]:root .code-copy-btn { color: #536471; }
html[data-mode="light"]:root .code-copy-btn:hover,
html[data-bs-theme="light"]:root .code-copy-btn:hover { background: #e1e8ed; color: #0f1419; }
html[data-mode="light"]:root .code-window-frame code,
html[data-mode="light"]:root .code-window-frame pre,
html[data-bs-theme="light"]:root .code-window-frame code,
html[data-bs-theme="light"]:root .code-window-frame pre { color: #0f1419; }
html[data-mode="light"]:root .code-window-frame td.rouge-gutter pre,
html[data-bs-theme="light"]:root .code-window-frame td.rouge-gutter pre { color: #8b98a5 !important; border-right-color: #e1e8ed !important; }
