/* ---------------------------------------------------------------------------
   michaelstraka.com — stylesheet for Org Mode HTML exports.
   Self-contained on purpose: the previous theme was loaded from a third-party
   GitHub Pages URL that started 404ing, which left every page unstyled.
   --------------------------------------------------------------------------- */

:root {
  --bg:        #fbfaf8;
  --surface:   #f3f1ec;
  --text:      #23262b;
  --muted:     #6a7078;
  --rule:      #e2ded6;
  --accent:    #2f5d8a;
  --accent-bg: #eaf1f8;

  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #16181c;
    --surface:   #1e2126;
    --text:      #d8dae0;
    --muted:     #969ba4;
    --rule:      #2e3339;
    --accent:    #82b1dd;
    --accent-bg: #1c2733;
  }
}

/* --- base ---------------------------------------------------------------- */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Flex column so the nav bar can be hoisted above the title with order:-1 —
   Org emits it after the table of contents, which reads oddly. */
#content {
  display: flex;
  flex-direction: column;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem 1.25rem 4rem;
}

/* Flex items default to min-width:auto, which lets a wide table stretch the
   whole page sideways on narrow screens. */
#content > * { min-width: 0; }

p { margin: 0 0 1.15em; }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 0.16em;
}

a:hover { text-decoration-color: currentColor; }

b, strong { font-weight: 600; }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5em 0;
}

/* --- headings ------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 2.2em 0 0.6em;
  scroll-margin-top: 4rem;
}

h1.title {
  font-size: 2.1rem;
  margin: 0.9em 0 1em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--rule);
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

.subtitle {
  font-family: var(--font-ui);
  color: var(--muted);
  margin-top: -1.5em;
}

/* Anchored heading gets a brief accent so in-page links are obvious. */
:target > h2, :target > h3, :target > h4, h2:target, h3:target, h4:target {
  background: var(--accent-bg);
  box-shadow: -0.5rem 0 0 var(--accent-bg), 0.5rem 0 0 var(--accent-bg);
  border-radius: 2px;
}

/* --- top bar (org "orgyeah-header" preamble) ------------------------------ */

.orgyeah-header {
  order: -2;
  border-bottom: 1px solid var(--rule);
  margin: 0 0 0.5rem;
  padding-bottom: 0.7rem;
}

/* Title sits between the nav bar and the table of contents. */
h1.title { order: -1; }

/* Org's preamble include leaves an empty paragraph after the nav. */
.orgyeah-header + p { display: none; }

.topbar-menu {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.topbar-menu a {
  color: var(--muted);
  text-decoration: none;
}

.topbar-menu a:hover { color: var(--accent); }

/* --- table of contents --------------------------------------------------- */

#table-of-contents {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.6rem 1.4rem 1.1rem;
  margin: 0 0 1rem;
}

#table-of-contents h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
}

#table-of-contents ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

#table-of-contents ul ul {
  padding-left: 1.1rem;
  border-left: 1px solid var(--rule);
  margin: 0.2rem 0 0.5rem 0.2rem;
}

#table-of-contents li { margin: 0.28em 0; }

#table-of-contents a { text-decoration: none; }
#table-of-contents a:hover { text-decoration: underline; }

/* --- lists --------------------------------------------------------------- */

ul, ol { padding-left: 1.4em; }
li { margin: 0.35em 0; }
li > p { margin-bottom: 0.5em; }
dt { font-weight: 600; margin-top: 1em; }
dd { margin-left: 1.4em; }

/* --- tables -------------------------------------------------------------- */
/* Org emits border/frame/rules attributes; author CSS overrides those. */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.8em 0;
  font-family: var(--font-ui);
  font-size: 0.94rem;
  border: 0;
}

/* frame="hsides" / rules="groups" draw dark borders on the groups themselves. */
thead, tbody, tfoot, tr, colgroup, col {
  border: 0;
}

th, td {
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.6em 0.8em;
  vertical-align: top;
}

thead th {
  border-bottom: 2px solid var(--rule);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}

thead th b { font-weight: 600; }

tbody tr:hover { background: var(--surface); }

tbody tr:last-child td { border-bottom: 0; }

.org-left   { text-align: left; }
.org-right  { text-align: right; }
.org-center { text-align: center; }

/* --- code ---------------------------------------------------------------- */

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

:not(pre) > code {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/* Source blocks keep a dark plate in both colour schemes: htmlize baked
   doom-one (dark theme) colours into inline style attributes, and they are
   illegible on a light background. */
pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #bbc2cf;
  background: #282c34;
  border: 1px solid #21252b;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.6em 0;
}

.org-src-container { margin: 1.6em 0; }
.org-src-container pre { margin: 0; }

/* --- figures ------------------------------------------------------------- */

img { max-width: 100%; height: auto; }

.figure {
  margin: 2em 0;
  text-align: center;
}

.figure p { margin: 0; }

.figure img {
  border-radius: 6px;
  /* Diagrams are dark-on-transparent; keep a light plate behind them so they
     stay readable when the page renders in dark mode. */
  background: #fff;
  padding: 0.5rem;
}

.figure-number {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- quotes and asides --------------------------------------------------- */

blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

p.verse { margin-left: 3%; }
.underline { text-decoration: underline; }
.todo     { font-family: var(--font-mono); color: #c0392b; }
.done     { font-family: var(--font-mono); color: #2e7d32; }
.priority { font-family: var(--font-mono); color: #d97706; }

.tag {
  font-family: var(--font-mono);
  font-size: 0.75em;
  font-weight: normal;
  background: var(--surface);
  border-radius: 3px;
  padding: 0.1em 0.4em;
}

.timestamp { color: var(--muted); }
.timestamp-kwd { color: var(--accent); }

/* --- footnotes ----------------------------------------------------------- */

#footnotes { margin-top: 3rem; }
.footdef { font-size: 0.92rem; }
.footpara { display: inline; }

/* --- math ---------------------------------------------------------------- */

mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4em 0;
}

/* --- postamble ----------------------------------------------------------- */

#postamble {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.2rem 1.25rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
}

#postamble p { margin: 0.2em 0; }

/* --- small screens ------------------------------------------------------- */

@media (max-width: 34rem) {
  body { font-size: 17px; }
  #content { padding: 0.5rem 1rem 3rem; }
  h1.title { font-size: 1.65rem; }
  h2 { font-size: 1.3rem; }
  th, td { padding: 0.5em 0.5em; }

  /* Wide tables scroll inside themselves rather than widening the page. */
  table {
    font-size: 0.86rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* --- print --------------------------------------------------------------- */

@media print {
  :root { --bg: #fff; --text: #000; --surface: #fff; }
  .orgyeah-header, #table-of-contents { display: none; }
  #content { max-width: none; }
  a { color: inherit; text-decoration: underline; }
}
