/*
  Learn AI Here — the article (W1), "Night Shift" style: everything Views/Content/_DetailBody.cshtml renders, i.e. title,
  tip text, read-more link, byline, dates, topics and review note, "Copy code" blocks, share controls and related
  items. Only tips have pages; tip, news and video cards are styled by cards.css.

  Loaded by the public layout right after site.css, and by the admin and import previews through _AdminLayout's "Head"
  section (after fonts.css), so a preview looks like the public page: the wrapper paints the dark ground itself, and a
  preview wrapper (.content-detail-layout--preview) adds padding and rounded corners inside the light admin page.

  Scoping: every selector starts with the article's wrapper, .content-detail-layout, so this file cannot restyle the
  admin chrome around a preview (Bootstrap pages). Rules for elements and components are written as
  :where(.content-detail-layout) <selector>: :where() adds no specificity, so on the public site each rule cascades
  exactly as it did in site.css, and component classes still beat element rules.

  Tokens: the --content-* values follow site.css's tokens where site.css is loaded, and fall back to the same values
  where it is not (admin). Text #e8eaed on #0f1115 is about 15:1, muted #a0a7b4 about 7.8:1, lime links about 14:1.
  The element rules repeat site.css's base typography inside the article only (the admin pages use Bootstrap's); the
  public page renders them with identical values. The page supplies focus styles; the preview sets its own.
*/

.content-detail-layout {
  --content-bg: var(--color-bg, #0f1115);
  --content-surface: var(--color-surface, #161a21);
  --content-surface-raised: var(--color-surface-raised, #1d222b);
  --content-text: var(--color-text, #e8eaed);
  --content-heading: var(--color-heading, #f5f6f7);
  --content-muted: var(--color-muted, #a0a7b4);
  --content-subtle: var(--color-subtle, #8b93a1);
  --content-accent: var(--color-accent, #b5f23d);
  --content-accent-hover: var(--color-accent-hover, #cdf779);
  --content-on-accent: var(--color-on-accent, #0f1115);
  --content-rule: var(--color-rule, #272d38);
  --content-rule-strong: var(--color-rule-strong, #3a414d);
  --content-control-border: var(--color-control-border, #6b7382);
  --content-input-border: var(--color-input-border, #6b7382);
  --content-code-bg: var(--color-code-bg, #161a21);
  --content-code-inline-bg: var(--color-code-inline-bg, #232934);
  --content-error: var(--color-error, #ff8f87);
  --content-success: var(--color-success, #8ee0a4);
  --content-font-sans: var(--font-sans, "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif);
  --content-font-mono: var(--font-mono, "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  --content-measure: var(--measure, 70ch);
  --content-radius: var(--radius, 8px);
  --content-radius-card: var(--radius-card, 12px);

  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 3rem;
  color-scheme: dark;
  background: var(--content-bg);
  color: var(--content-text);
  font-family: var(--content-font-sans);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

/* Admin and import previews: the dark article as a framed panel on the light admin page. */
.content-detail-layout.content-detail-layout--preview {
  padding: 1.5rem;
  border-radius: var(--content-radius-card);
}

.content-detail-layout.content-detail-layout--preview :focus-visible {
  outline: 3px solid var(--content-accent);
  outline-offset: 2px;
}

/* ---------- Base typography inside the article ---------- */

:where(.content-detail-layout) :is(img, iframe, video) {
  max-width: 100%;
}

:where(.content-detail-layout) :is(h1, h2, h3, h4) {
  margin: 1.5em 0 0.5em;
  color: var(--content-heading);
  font-family: var(--content-font-sans);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

:where(.content-detail-layout) h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-top: 0.5em;
}

:where(.content-detail-layout) h2 {
  font-size: 1.4rem;
}

:where(.content-detail-layout) h3 {
  font-size: 1.15rem;
}

:where(.content-detail-layout) :is(p, ul, ol, dl, blockquote, pre, table) {
  margin: 0 0 1rem;
}

/* The browser's default list indent (Bootstrap would make it 2rem in the admin preview). */
:where(.content-detail-layout) :is(ul, ol) {
  padding-left: 40px;
}

:where(.content-detail-layout) :is(strong, b) {
  font-weight: 600;
}

:where(.content-detail-layout) a {
  color: var(--content-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

:where(.content-detail-layout) a:hover {
  color: var(--content-accent-hover);
  text-decoration-thickness: 2px;
}

:where(.content-detail-layout) :is(code, kbd, pre, samp) {
  color: inherit;
  font-family: var(--content-font-mono);
  font-size: 0.9em;
}

:where(.content-detail-layout) kbd {
  padding: 0;
  border-radius: 0;
  background: none;
}

:where(.content-detail-layout) :not(pre) > code {
  background: var(--content-code-inline-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

:where(.content-detail-layout) pre {
  background: var(--content-code-bg);
  border: 1px solid var(--content-rule);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.7;
  tab-size: 4;
  white-space: pre;
  max-width: 100%;
}

:where(.content-detail-layout) pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
}

:where(.content-detail-layout) blockquote {
  margin-left: 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--content-rule-strong);
  color: var(--content-muted);
}

:where(.content-detail-layout) hr {
  border: 0;
  border-top: 1px solid var(--content-rule);
  margin: 2rem 0;
  opacity: 1;
}

:where(.content-detail-layout) table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

:where(.content-detail-layout) :is(th, td) {
  border: 1px solid var(--content-rule);
  padding: 0.45rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

:where(.content-detail-layout) th {
  background: var(--content-surface);
}

/* ---------- Utilities and shared components the article uses (also defined globally by site.css) ---------- */

:where(.content-detail-layout) [hidden] {
  display: none !important;
}

:where(.content-detail-layout) .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:where(.content-detail-layout) .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--content-control-border);
  border-radius: var(--content-radius);
  background: transparent;
  color: var(--content-text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

:where(.content-detail-layout) .button:hover {
  border-color: var(--content-accent);
  color: var(--content-accent);
  text-decoration: none;
}

:where(.content-detail-layout) .label {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--content-rule-strong);
  border-radius: 4px;
  color: var(--content-muted);
  font-family: var(--content-font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.6;
}

:where(.content-detail-layout) .prose > :first-child {
  margin-top: 0;
}

:where(.content-detail-layout) .prose li + li {
  margin-top: 0.25rem;
}

:where(.content-detail-layout) .prose h3 {
  font-size: 1.15rem;
  margin-top: 1.5rem;
}

/* ---------- The article ---------- */

:where(.content-detail-layout) .content-detail {
  min-width: 0;
  max-width: var(--content-measure);
}

:where(.content-detail-layout) .content-detail__header {
  margin-bottom: 1.5rem;
}

/* "Tip", "News brief", "Video": a lime mono kicker with a dot, like the home page's featured tip. */
:where(.content-detail-layout) .content-detail__type {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  color: var(--content-accent);
  font-family: var(--content-font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:where(.content-detail-layout) .content-detail__type::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

:where(.content-detail-layout) .content-detail__title {
  margin: 0 0 0.75rem;
}

:where(.content-detail-layout) .content-detail__summary {
  color: var(--content-muted);
  font-size: 1.2rem;
  line-height: 1.55;
}

:where(.content-detail-layout) .content-detail__body {
  margin-bottom: 1.75rem;
  font-size: 1.0625rem;
}

/* The tip's optional "Read more on {host}" link, right after the text. */
:where(.content-detail-layout) .content-detail__more {
  margin: -0.75rem 0 1.75rem;
}

:where(.content-detail-layout) .content-detail__more-link {
  font-weight: 600;
}

:where(.content-detail-layout) .content-detail__info {
  margin: 0 0 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--content-rule);
}

:where(.content-detail-layout) .content-detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0;
  margin: 0;
  color: var(--content-muted);
  font-family: var(--content-font-mono);
  font-size: 0.8rem;
}

:where(.content-detail-layout) .content-detail__meta > span + span::before {
  content: "·";
  margin: 0 0.5rem;
  color: var(--content-subtle);
}

:where(.content-detail-layout) .content-detail__meta {
  margin-bottom: 0.75rem;
}

:where(.content-detail-layout) .content-detail__byline {
  color: var(--content-text);
  font-weight: 600;
}

:where(.content-detail-layout) .content-detail__classification {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2rem;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

:where(.content-detail-layout) .content-detail__classification-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}

:where(.content-detail-layout) .content-detail__classification dt {
  color: var(--content-muted);
  font-family: var(--content-font-mono);
  font-size: 0.8rem;
  font-weight: 500;
}

:where(.content-detail-layout) .content-detail__classification dt::after {
  content: ":";
}

:where(.content-detail-layout) .content-detail__classification dd {
  margin: 0;
}

:where(.content-detail-layout) .content-detail__topics {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

:where(.content-detail-layout) .content-detail__review {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--content-rule);
  border-radius: var(--content-radius);
  background: var(--content-surface);
  font-size: 0.95rem;
}

:where(.content-detail-layout) .content-detail__correction {
  margin: 0;
  color: var(--content-muted);
  font-size: 0.95rem;
}

/*
  Code blocks in the tip text get a "Copy code" button from share.js. The button sits in a strip across the top of the
  block, and that strip is part of every such block from the start; share.js's wrapper takes over the block's margin.
  So adding the button never moves the page (no layout shift). The copy status shows below the block only once there
  is something to say.
*/
:where(.content-detail-layout) .content-detail__body pre {
  padding-top: 3rem;
}

:where(.content-detail-layout) .code-block {
  position: relative;
  margin: 0 0 1rem;
}

:where(.content-detail-layout) .code-block > pre {
  margin: 0;
}

:where(.content-detail-layout) .code-block__toolbar {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

:where(.content-detail-layout) .code-block__button {
  min-height: 2rem;
  padding: 0.2rem 0.75rem;
  font-family: var(--content-font-mono);
  font-size: 0.8rem;
  font-weight: 500;
}

:where(.content-detail-layout) .code-block__status {
  display: block;
  margin-top: 0.4rem;
  color: var(--content-muted);
  font-size: 0.9rem;
}

:where(.content-detail-layout) .code-block__status:empty {
  display: none;
}

/* ---------- Share controls ---------- */

:where(.content-detail-layout) .share {
  margin: 0 0 1.75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--content-rule);
  border-radius: var(--content-radius-card);
  background: var(--content-surface);
}

:where(.content-detail-layout) .share__heading {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
}

:where(.content-detail-layout) .share__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

:where(.content-detail-layout) .share__status {
  min-height: 1.6em;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

:where(.content-detail-layout) .share__status:empty {
  margin: 0;
  min-height: 0;
}

:where(.content-detail-layout) .share__status[data-state="success"]::before {
  content: "✓ ";
  color: var(--content-success);
}

:where(.content-detail-layout) .share__status[data-state="error"] {
  color: var(--content-error);
}

:where(.content-detail-layout) :is(.share__fallback, .share__details) {
  margin-top: 0.5rem;
}

:where(.content-detail-layout) .share__details summary {
  cursor: pointer;
  min-height: 1.5rem;
  color: var(--content-accent);
  font-weight: 600;
}

:where(.content-detail-layout) .share__url a {
  overflow-wrap: anywhere;
  word-break: break-all;
}

:where(.content-detail-layout) .share textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--content-input-border);
  border-radius: var(--content-radius);
  background: var(--content-bg);
  color: var(--content-text);
  font-family: var(--content-font-mono);
  font-size: 0.875rem;
  resize: vertical;
}

/* ---------- Related ---------- */

:where(.content-detail-layout) .related {
  min-width: 0;
  max-width: var(--content-measure);
}

:where(.content-detail-layout) .related__heading {
  margin: 0 0 0.75rem;
  color: var(--content-muted);
  font-family: var(--content-font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:where(.content-detail-layout) .related__list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--content-rule);
}

:where(.content-detail-layout) .related__item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--content-rule);
}

:where(.content-detail-layout) .related__type {
  margin: 0 0 0.35rem;
}

:where(.content-detail-layout) .related__link {
  color: var(--content-heading);
  font-weight: 600;
  text-decoration: none;
}

:where(.content-detail-layout) .related__link:hover {
  color: var(--content-accent);
  text-decoration: underline;
}

:where(.content-detail-layout) .related__summary {
  margin: 0.3rem 0 0;
  color: var(--content-muted);
  font-size: 0.95rem;
}

/* ---------- Wider screens ---------- */

@media (min-width: 64rem) {
  /* The article keeps a ~70 character measure; related items use the extra width. */
  .content-detail-layout {
    grid-template-columns: minmax(0, var(--content-measure)) minmax(15rem, 1fr);
    align-items: start;
  }

  .content-detail-layout > * {
    grid-column: 1;
  }

  .content-detail-layout > .related {
    grid-column: 2;
    grid-row: 1 / span 2;
    padding-top: 2.75rem;
  }
}

@media print {
  .content-detail-layout {
    color-scheme: light;
    background: none;
  }

  :where(.content-detail-layout) :is(.share, .related) {
    display: none !important;
  }
}
