/* learn-r.org : legacy.css
   Makes the classic pages (index.php, /r-tutorial/...) use the same design
   as the dplyr and ggplot2 tutorials WITHOUT changing their content.
   Loaded after style.css by site_head_assets() in site-theme.php.

   Classic page markup:
     <div class="w3-row-padding">
       <div class="w3-rightcol"> left sidebar  </div>
       <div class="w3-centercol"> article       </div>
       <div class="w3-rightcol"> right sidebar </div>
     </div>
*/

html { font-size: 100%; }
body > br { display: none; }

/* ---------- three-column grid (same as .layout) ---------- */
body > .w3-row-padding {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 240px;
  gap: 36px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 24px 56px;
  align-items: start;
}
body > .w3-row-padding > div { float: none !important; width: auto !important; padding: 0 !important; min-width: 0; }
body > .w3-row-padding > div > .w3-container { padding: 0 !important; }
body > .w3-row-padding::after { display: none; }

/* left column = sticky lesson menu */
body > .w3-row-padding > .w3-rightcol:first-child {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
}
/* right column = cards */
body > .w3-row-padding > .w3-rightcol:last-child {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  font: 400 .95rem/1.55 var(--font-ui);
}
/* centre column = white article card */
body > .w3-row-padding > .w3-centercol {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 40px 48px !important;
  overflow-wrap: anywhere;
}

/* ---------- article typography: override old inline fonts ---------- */
.w3-centercol, .w3-centercol p, .w3-centercol li, .w3-centercol td { font-family: var(--font-body); }
.w3-centercol [style*="font-family"] { font-family: inherit !important; }
.w3-centercol [style*="font-size"] { font-size: inherit !important; }
.w3-centercol font { font-family: inherit; }
.w3-centercol h1, .w3-centercol h1[style], .w3-centercol h1 [style],
.w3-centercol h2, .w3-centercol h2[style], .w3-centercol h2 [style],
.w3-centercol h3, .w3-centercol h3[style], .w3-centercol h3 [style],
.w3-centercol h4, .w3-centercol h4[style], .w3-centercol h4 [style] { font-family: var(--font-ui) !important; }
.w3-centercol h1, .w3-centercol h1 [style*="font-weight"],
.w3-centercol h2, .w3-centercol h2 [style*="font-weight"] { font-weight: 700 !important; }
.w3-centercol h3, .w3-centercol h3 [style*="font-weight"] { font-weight: 700 !important; }
.w3-centercol h4 { font-size: 1.05rem; font-weight: 700; margin: 1.5em 0 .4em; }
.w3-centercol h1:first-child, .w3-centercol .w3-container > h1:first-child { margin-top: 0; }
.w3-centercol h3:empty, .w3-centercol h4:empty, .w3-centercol p:empty { display: none; }
.w3-centercol p { max-width: 70ch; }
.w3-centercol a { color: var(--brand); }
.w3-centercol a font { color: var(--brand) !important; }

/* images keep their proportions on small screens */
.w3-centercol img { max-width: 100%; height: auto !important; margin: 8px 0; border-radius: 6px; }

/* old Word-style code lines (p.MsoNormal) look like a code block */
.w3-centercol p.MsoNormal {
  font-family: var(--font-mono) !important;
  font-size: .9rem;
  line-height: 1.6;
  background: #EEF2F8 !important;
  margin: 0 !important;
  padding: 3px 18px !important;
  border-left: 4px solid var(--accent);
  max-width: none;
}
.w3-centercol p.MsoNormal + p.MsoNormal { padding-top: 0 !important; }
.w3-centercol p.MsoNormal * { font-family: inherit !important; font-size: inherit !important; }
.w3-centercol p:not(.MsoNormal) + p.MsoNormal { margin-top: 1em !important; padding-top: 12px !important; border-radius: 6px 6px 0 0; }
.w3-centercol p.MsoNormal:has(+ :not(p.MsoNormal)) { padding-bottom: 12px !important; margin-bottom: 1em !important; border-radius: 0 0 6px 6px; }
.w3-centercol o\:p { display: none; }

/* inline code typed with coloured bold spans */
.w3-centercol span[style*="color: rgb(51, 51, 255)"][style*="bold"] { font-family: var(--font-mono) !important; font-size: .92em; }

/* empty three-column boxes at the bottom of old pages */
.w3-centercol .w3-third { display: none; }

/* old ad text and tables */
.w3-centercol table { margin: 1.2em 0; }
.w3-centercol pre { white-space: pre; }

/* ---------- classic sales pages that still load my3.css ---------- */
.w3-blue { background-color: var(--menu-bg) !important; color: #fff !important; }

/* ---------- responsive (same breakpoints as style.css) ---------- */
@media (max-width: 1099px) {
  body > .w3-row-padding { grid-template-columns: 230px minmax(0, 1fr); }
  body > .w3-row-padding > .w3-rightcol:last-child {
    position: static; grid-column: 2;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px;
  }
  body > .w3-row-padding > .w3-rightcol:last-child > .w3-container { display: contents; }
  body > .w3-row-padding > .w3-rightcol:last-child .side-card { margin-bottom: 0; }
}
@media (max-width: 819px) {
  body > .w3-row-padding { grid-template-columns: 1fr; gap: 20px; padding: 18px 14px 40px; }
  body > .w3-row-padding > .w3-rightcol:first-child { position: static; max-height: none; }
  body > .w3-row-padding > .w3-rightcol:last-child { grid-column: 1; }
  body > .w3-row-padding > .w3-centercol { padding: 24px 18px !important; border-radius: 8px; }
}
@media print {
  body > .w3-row-padding > .w3-rightcol { display: none; }
  body > .w3-row-padding { display: block; }
  body > .w3-row-padding > .w3-centercol { border: 0; padding: 0 !important; }
}
