/* Abel Tomy — Fab Academy 2021
   Documentation layout modelled on the Hugo Book theme (MIT, Alex Shpak):
   256px menu, 768px page, 256px table of contents. No framework. */

:root {
  color-scheme: light dark;

  --body-bg: #ffffff;
  --body-color: #1b1b1b;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --link: #0055bb;
  --link-visited: #8440f1;
  --hover-bg: #f8f9fa;

  --toc-width: 16rem;
  --page-width: 48rem;
  --padding: 1rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Dark values live in two places: the OS preference (unless the reader has
   explicitly chosen light) and the explicit toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --body-bg: #343a40;
    --body-color: #e9ecef;
    --gray-100: #3f464d;
    --gray-200: #4a5157;
    --gray-500: #868e96;
    --gray-600: #adb5bd;
    --link: #84b3ff;
    --link-visited: #c8a2ff;
    --hover-bg: #3f464d;
  }
}

:root[data-theme="dark"] {
  --body-bg: #343a40;
  --body-color: #e9ecef;
  --gray-100: #3f464d;
  --gray-200: #4a5157;
  --gray-500: #868e96;
  --gray-600: #adb5bd;
  --link: #84b3ff;
  --link-visited: #c8a2ff;
  --hover-bg: #3f464d;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--body-bg);
  color: var(--body-color);
  font-family: var(--font);
  font-size: 0.9375rem; /* 15px */
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* Off-screen but still announced by screen readers and read by crawlers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 1rem; top: 1rem; z-index: 100;
  padding: .5rem 1rem;
  background: var(--link); color: #fff; border-radius: 4px;
}

/* ---------- book layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--body-bg);
  border-bottom: 1px solid var(--gray-200);
}
/* 64rem = the 48rem page column plus the 16rem toc gutter, so the brand lines up
   with the left edge of the content on every page, landing included. */
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1.25rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: .7rem 1.5rem;
}
.brand {
  margin-right: auto;
  font-weight: 600;
  color: var(--body-color);
}
.brand:hover { text-decoration: none; }
.brand:visited { color: var(--body-color); }
.brand small {
  display: block;
  font-size: .7rem;
  font-weight: 400;
  color: var(--gray-600);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.topbar nav { display: flex; align-items: center; gap: 1.25rem; font-size: .875rem; }
.topbar nav a[aria-current="page"] { color: var(--body-color); font-weight: 600; }

.theme-toggle {
  padding: .2rem .5rem;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  background: transparent;
  color: var(--gray-600);
  font: inherit;
  font-size: .95em;
  line-height: 1.4;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--link); color: var(--link); }

/* Page + toc are centred as one 64rem block, matching .topbar-inner. */
.book {
  display: grid;
  grid-template-columns: minmax(0, var(--page-width)) var(--toc-width);
  justify-content: center;
  align-items: start;
}

.book-page {
  min-width: 0;
  padding: var(--padding) 1.5rem 3rem;
}

.book-toc {
  width: var(--toc-width);
  font-size: .8rem;
  position: sticky;
  top: 3.5rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: var(--padding);
}
.book-toc nav > ul { padding-left: 0; }
.book-toc ul { list-style: none; margin: 0; padding-left: .75rem; }
.book-toc li { margin: .15rem 0; }
.book-toc a { color: var(--body-color); }
.book-toc a:visited { color: var(--body-color); }
.book-toc-label {
  margin: 0 0 .4rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-600);
}

@media (max-width: 80rem) {
  .book-toc { display: none; }
  .book { grid-template-columns: minmax(0, var(--page-width)); }
  /* Navbar narrows with the content so the brand keeps its alignment. */
  .topbar-inner { max-width: var(--page-width); }
  .landing { max-width: var(--page-width); }
}

@media (max-width: 40rem) {
  .topbar-inner { padding: .6rem 1rem; }
  .topbar nav { gap: .9rem; font-size: .85rem; }
  .book-page { padding: var(--padding) 1rem 2rem; }
}

/* ---------- content ---------- */

.book-page h1 {
  margin: .4rem 0 1.25rem;
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.3px;
}
.book-page h2 {
  margin: 2rem 0 .75rem;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.35;
}
.book-page h3 {
  margin: 1.5rem 0 .5rem;
  font-size: 1rem;
  font-weight: 600;
}

.eyebrow {
  margin: 0;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-600);
}

.lede {
  margin: 0 0 2rem;
  padding: .75rem 1rem;
  background: var(--gray-100);
  border-left: 3px solid var(--gray-500);
  border-radius: 0 4px 4px 0;
}
.lede p { margin: .35rem 0; }
.lede p:first-child { margin-top: 0; }
.lede p:last-child { margin-bottom: 0; }

article p { margin: 0 0 1rem; }
article ul, article ol { margin: 0 0 1rem; padding-left: 1.5rem; }
article li { margin-bottom: .35rem; }
article > section { margin-bottom: 1rem; }

blockquote {
  margin: 0 0 1rem;
  padding: .5rem 1rem;
  background: var(--gray-100);
  border-left: 3px solid var(--gray-500);
  border-radius: 0 4px 4px 0;
}
blockquote p:last-child { margin-bottom: 0; }

code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--gray-100);
  padding: .1em .3em;
  border-radius: 3px;
}
pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--gray-100);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

hr { border: 0; border-top: 1px solid var(--gray-200); margin: 2rem 0; }

/* ---------- media ---------- */

figure {
  margin: 0;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  background: var(--gray-100);
}
figure img,
figure video { display: block; width: 100%; height: auto; }
figcaption {
  padding: .5rem .75rem;
  font-size: .8rem;
  line-height: 1.45;
  color: var(--gray-600);
  border-top: 1px solid var(--gray-200);
}

.statement {
  margin: 1.75rem 0 0;
  padding-left: 1rem;
  border-left: 2px solid var(--gray-200);
  font-family: var(--mono);
  font-size: .9375rem;
  line-height: 2;
  color: var(--body-color);
}

figure.portrait {
  width: 96px;
  margin: 0 0 1.5rem;
  border: 0;
  border-radius: 0;
  background: none;
  overflow: visible;
}
figure.portrait img {
  width: 96px;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
}
figure.portrait figcaption {
  padding: .35rem 0 0;
  border-top: 0;
  font-size: .75rem;
  white-space: nowrap; /* "Abel Tomy" must not wrap inside a 96px column */
}

.media {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  margin: 1.25rem 0;
}
.media.single { grid-template-columns: minmax(0, 1fr); }

.embed {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  background: var(--gray-100);
}
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.video-split {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
  margin: 1.25rem 0;
}
.video-split .text > :last-child { margin-bottom: 0; }

/* ---------- pager ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  font-size: .9rem;
}
.pager .next { margin-left: auto; text-align: right; }
.pager .dir { display: block; font-size: .75rem; color: var(--gray-600); }

.book-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  font-size: .8rem;
  color: var(--gray-600);
}
.book-footer a { color: var(--gray-600); text-decoration: underline; }
.book-footer a:visited { color: var(--gray-600); }

/* ---------- landing page ---------- */

.landing {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.landing h1 {
  margin: 0 0 .6rem;
  font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.4rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.5px;
}
.landing .intro { max-width: 42rem; margin: .9rem 0 0; }
.landing .intro p:last-child { margin-bottom: 0; }

.landing-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.75rem;
  margin-top: 1.75rem;
}
.landing-logos img { height: 56px; width: auto; object-fit: contain; }

.section-title {
  margin: 2.5rem 0 1rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--gray-200);
  font-size: 1.1rem;
  font-weight: 600;
  scroll-margin-top: 4rem; /* clears the sticky navbar when jumped to via #weeks */
}

.week-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}
.week-card {
  display: block;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  background: var(--body-bg);
  color: var(--body-color);
  height: 100%;
}
.week-card:hover { border-color: var(--link); text-decoration: none; }
.week-card:visited { color: var(--body-color); }
.week-card img {
  display: block;
  width: 100%;
  height: auto; /* without this the height attribute beats aspect-ratio and cover crops sideways */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}
.week-card .body { padding: .75rem .9rem 1rem; }
.week-card .num {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-600);
}
.week-card .name {
  display: block;
  margin: .15rem 0 .3rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--link);
}
.week-card .blurb {
  font-size: .85rem;
  line-height: 1.45;
  color: var(--gray-600);
}

.landing-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  font-size: .85rem;
  color: var(--gray-600);
}
.landing-footer a { color: var(--gray-600); text-decoration: underline; }
.landing-footer a:visited { color: var(--gray-600); }
