/*
  site.css — the only stylesheet for akshaim.github.io.
  Hand-written, no build step, no dependencies.

  Sections:
    1. Theme (colours, fonts, sizes)   4. Profile page (index.html)
    2. Base elements                   5. Notes (archived tutorials)
    3. Site header and footer          6. Wide screens
                                       7. Small screens   8. Print
*/

/* 1. Theme ---------------------------------------------------------- */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1d2327;
  --muted: #56616b;
  --rule: #e1e5e9;
  --accent: #0b6e63;        /* teal, readable on white */
  --accent-bg: #eaf5f2;
  --code-bg: #f4f6f7;
  --quote-bg: #f7f9fa;

  --maxw: 84rem;                              /* page width on large screens */
  --gutter: clamp(1.25rem, 4vw, 3rem);        /* space at the left and right edge */
  --label: 13rem;                             /* left column on wide screens */
  --gap: 3rem;
  --measure: 46rem;                           /* longest comfortable line of text */

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101518;
    --fg: #e3e8eb;
    --muted: #9ba6ae;
    --rule: #263038;
    --accent: #4acaa8;      /* the teal of the old site */
    --accent-bg: #12302a;
    --code-bg: #182026;
    --quote-bg: #151c21;
  }
}

/* 2. Base elements --------------------------------------------------- */

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

/* Text grows with the window, so the page also fills large monitors:
   16px up to about 1300px wide, then gradually up to 20.5px. */
html {
  font-size: clamp(100%, 0.5rem + 0.55vw, 128%);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.65 var(--font);
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3, h4, h5 { line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0.75rem 0; }

img, video, iframe { max-width: 100%; }
img, video { height: auto; }
iframe { border: 1px solid var(--rule); border-radius: 0.4rem; background: #fff; }

pre, code { font-family: var(--mono); }
code { font-size: 0.92em; }
pre {
  margin: 0.6rem 0;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  font-size: 0.875rem;
  line-height: 1.5;
  tab-size: 4;
}

blockquote {
  margin: 0.8rem 0;
  padding: 0.55rem 1rem;
  background: var(--quote-bg);
  border-left: 3px solid var(--rule);
  border-radius: 0 0.35rem 0.35rem 0;
}
blockquote pre { background: var(--bg); }

.skip { position: absolute; left: -999rem; }
.skip:focus { left: 1rem; top: 1rem; padding: 0.4rem 0.7rem; background: var(--bg); z-index: 1; }

/* 3. Site header and footer ------------------------------------------ */

.site-header, main, .site-footer {
  width: min(var(--maxw), calc(100% - 2 * var(--gutter)));
  margin-inline: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.site-name { color: var(--fg); font-weight: 700; text-decoration: none; }

.site-nav, .crumbs { display: flex; flex-wrap: wrap; gap: 0.2rem 1.25rem; font-size: 0.95rem; }
.site-nav a, .crumbs a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs { gap: 0.2rem 0.5rem; color: var(--muted); }
.crumbs span[aria-hidden] { opacity: 0.6; }

.site-footer {
  margin-top: 3.5rem;
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { margin: 0.3rem 0; }

/* A page without a footer (the profile) still ends with some space. */
main:last-child { padding-bottom: 3.5rem; }

/* 4. Profile page ---------------------------------------------------- */

.top { display: grid; gap: 1.25rem var(--gap); }

.hero { padding-block: 2.75rem 1.5rem; }
.hero h1 { margin: 0; font-size: clamp(2rem, 7vw, 2.9rem); letter-spacing: -0.025em; }
.hero .headline { margin: 0.5rem 0 0; max-width: 38rem; font-size: 1.2rem; }
.hero .where { margin: 0.25rem 0 0; color: var(--muted); }

.links { display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }

.intro p { max-width: var(--measure); }
.intro > :first-child { margin-top: 0; }
.lede { font-size: 1.1rem; }

.glance {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 1.1rem 1.25rem;
  background: var(--accent-bg);
  border-radius: 0.5rem;
}
.glance dt { padding-top: 0.2rem; color: var(--muted); font: 600 0.8rem/1.5 var(--mono); }
.glance dd { margin: 0; }

/* Short list inside the summary box (affiliations): one line each, name highlighted. */
.mini { display: grid; gap: 0.3rem; margin: 0; padding: 0; list-style: none; }
.mini strong, .profile main .project h3 { color: var(--accent); }

.profile main > section { margin-top: 2.75rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.profile main h2 { margin: 0 0 0.9rem; color: var(--accent); font-size: 1.35rem; }
.profile main h3 { margin: 1.75rem 0 0.4rem; font-size: 1.08rem; }
.body > :first-child, .split > div > :first-child { margin-top: 0; }
.body > p { max-width: var(--measure); }

.areas { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.1rem 2rem; margin: 0; padding: 0; list-style: none; }
.areas li { padding-left: 1rem; border-left: 3px solid var(--accent-bg); }
.areas strong { display: block; }

/* Open source section: one highlighted block per project. */
.projects { display: grid; gap: 1.5rem var(--gap); }
.project { padding-left: 1rem; border-left: 3px solid var(--accent); }
.profile main .project h3 { margin: 0; font-size: 1.15rem; }
.project .meta { margin: 0.1rem 0 0.35rem; color: var(--muted); font: 0.8rem/1.6 var(--mono); }
.project p { margin: 0; max-width: var(--measure); }

/* Lists of short entries: square markers in the accent colour. */
.plain { margin: 0.75rem 0; padding-left: 1.15rem; max-width: 52rem; list-style: square; }
.plain li { margin: 0.6rem 0; padding-left: 0.2rem; }
.plain li::marker { color: var(--accent); }
.when { color: var(--muted); font: 0.8rem/1.6 var(--mono); white-space: nowrap; }

/* Lists that start with a year. */
.dated { padding-left: 0; list-style: none; }
.dated li { display: grid; grid-template-columns: 5.2rem 1fr; gap: 0 0.75rem; padding-left: 0; break-inside: avoid; }
.dated .when { padding-top: 0.2rem; }

.split { display: grid; gap: 0 var(--gap); }

/* 5. Notes (archived tutorials) --------------------------------------
   The tutorial bodies are the original 2015-2017 markup, so the class
   names below (.container, .major, .features, .inner, .image,
   .feature-icons) come from the old template. */

.note main { padding-block: 1.25rem 1rem; }

.toc { margin: 0 0 1rem; font-size: 0.9rem; }
.toc-title { margin: 0 0 0.3rem; color: var(--muted); font: 600 0.75rem/1.5 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.toc ul { display: flex; flex-wrap: wrap; gap: 0.15rem 1.1rem; margin: 0; padding: 0; list-style: none; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

.archived {
  margin: 0 0 1.5rem;
  padding: 0.6rem 0.9rem;
  background: var(--quote-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 0.35rem 0.35rem 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.note article h1 { margin: 0 0 0.25rem; font-size: clamp(1.8rem, 6vw, 2.3rem); letter-spacing: -0.02em; }
.note article h2 { margin: 2rem 0 0.5rem; font-size: 1.45rem; }
.note article h3 { margin: 2rem 0 0.5rem; font-size: 1.25rem; }
.note article h4 { margin: 1.5rem 0 0.4rem; font-size: 1.08rem; }
.note article h5 { margin: 1.25rem 0 0.4rem; font-size: 0.95rem; font-weight: 600; color: var(--muted); }
.note article section + section { margin-top: 2.5rem; padding-top: 0.5rem; border-top: 1px solid var(--rule); }
.note article li { margin: 0.5rem 0; }
/* Several old pages have list items without a surrounding <ul>: keep their bullets inside the column. */
.note article :not(ul):not(ol) > li { margin-left: 1.25rem; }
.note article li::marker { color: var(--accent); }

/* Screen recordings and embedded diagrams use the full text column. */
.note article video, .note article iframe { width: 100%; }

.major p { margin-top: 0; color: var(--muted); font-size: 1.1rem; }

.image { display: inline-block; }
.image img { display: block; border-radius: 0.35rem; }

.features { display: grid; gap: 1rem; margin: 1.25rem 0; }
.features article {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
}
.features article > .image img { width: 100%; }
/* The old markup left line breaks, the odd paragraph, or no picture at all inside some cards. */
.features article > br { display: none; }
.features article > p { grid-column: 1 / -1; margin: 0; }
.features article > .image:empty { display: none; }
.features article > .image:empty + .inner { grid-column: 1 / -1; }
.features .inner h4 { margin: 0 0 0.25rem; }
.features .inner p { margin: 0; color: var(--muted); }

.feature-icons { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.4rem 1.5rem; padding: 0; list-style: none; }
.feature-icons li { padding-left: 1.1rem; text-indent: -1.1rem; }
.feature-icons li::before { content: "\25B8\00A0"; color: var(--accent); }

.series {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}

/* 6. Wide screens ----------------------------------------------------
   From about 960px: section titles move into a left column.
   From about 1120px: the summary box sits beside the introduction.
   From about 1200px: lists and project blocks use two columns. */

@media (min-width: 60rem) {
  .profile main > section { display: grid; grid-template-columns: var(--label) minmax(0, 1fr); gap: 0 var(--gap); }
  .profile main > section > h2 { position: sticky; top: 1.25rem; align-self: start; margin: 0; }

  .note main { display: grid; grid-template-columns: var(--label) minmax(0, 50rem); gap: 0 var(--gap); align-items: start; }
  .toc { position: sticky; top: 1.25rem; margin: 0.4rem 0 0; }
  .toc ul { display: block; }
  .toc li { margin: 0.35rem 0; }
}

@media (min-width: 70rem) {
  /* Name and headline across the full width, then [introduction | summary box].
     The box stretches to the height of the text beside it, and its rows
     spread out to fill that height when the box has less content. */
  .hero .headline { max-width: none; }
  .top { grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); align-items: stretch; }
  .top > aside { display: flex; }
  .top .glance { flex: 1; align-content: space-between; }
}

@media (min-width: 75rem) {
  .split, .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--gap); max-width: none; }
  .dated.cols { display: block; columns: 2; column-gap: var(--gap); }
  .dated.cols li:first-child { margin-top: 0; }
}

/* 7. Small screens ---------------------------------------------------- */

@media (max-width: 34rem) {
  body { font-size: 1rem; }
  .hero { padding-top: 1.75rem; }
  .glance { grid-template-columns: 1fr; gap: 0.1rem; }
  .glance dt { margin-top: 0.6rem; }
  .glance dt:first-child { margin-top: 0; }
  .dated li { grid-template-columns: 1fr; }
  .features article { grid-template-columns: 1fr; }
  .features article > .image img { max-width: 12rem; }
}

/* 8. Print: the profile prints as a clean summary --------------------- */

@media print {
  :root {
    --bg: #fff; --fg: #000; --muted: #444; --rule: #bbb;
    --accent: #000; --accent-bg: #fff; --code-bg: #fff; --quote-bg: #fff;
  }
  html { font-size: 100%; }
  body { font-size: 9.5pt; line-height: 1.4; }
  main, .site-footer { width: auto; }
  .site-header, .skip, .series, .toc { display: none; }
  .hero { padding-top: 0; }
  .top, .profile main > section, .note main, .split, .projects { display: block; }
  .project { margin-bottom: 0.6rem; }
  .glance { margin-top: 0.8rem; padding: 0.6rem 0.8rem; gap: 0.2rem 1rem; border: 1px solid var(--rule); }
  .profile main > section { margin-top: 0.9rem; padding-top: 0.6rem; }
  .profile main > section > h2 { position: static; margin-bottom: 0.4rem; font-size: 1.15rem; break-after: avoid; }
  .areas { gap: 0.5rem 1.5rem; }
  .plain { margin: 0.3rem 0; }
  .plain li { margin: 0.25rem 0; }
  .project, .plain li, .areas li { break-inside: avoid; }
  .site-footer { margin-top: 1.25rem; padding-block: 0.6rem 0; }
  a { text-decoration: none; }
}
