/* mmallinson.com
   ----------------------------------------------------------------------
   A five-page personal site. Fixed 282px rail on the left carrying the
   name, the nav and the social links; the content card floats to the
   right of it. Below 768px everything stacks into a single column and the
   nav collapses behind a toggle.

   The three gutters are percentages rather than pixels so they keep their
   proportions when the layout goes fluid under 618px. Each one works out
   to 30px at full width.
   -------------------------------------------------------------------- */

:root {
  --page-width: 954px;
  --rail-width: 282px;
  --card-width: 64.78%; /* 618px of 954px */
  --card-offset: 35.22%; /* 336px of 954px */
  --rail-gutter: 10.638%; /* 30px of the 282px rail */
  --card-gutter: 4.854%; /* 30px of the 618px card */
  --title-indent: 4.045%; /* 25px of the 618px card */

  --ink: #36312d;
  --accent: #e94f1d;
  --accent-hover: #85aa0c;
  --rule: rgba(0, 0, 0, 0.2);
  --paper: rgba(255, 255, 255, 0.95);

  --display: Muli, Helvetica, Arial, sans-serif;
  --body: Enriqueta, georgia, serif;
  --prose: Calibri, sans-serif;

  --line: 24px; /* the vertical rhythm everything is spaced on */
}

/* Reset ---------------------------------------------------------------- */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background-color: #f6f6f6;
  background-image: url("/assets/img/background.jpg");
  background-repeat: repeat;
  background-position: 0 0;
  background-size: cover;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ul,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease-in;
}

a:hover,
a:focus,
a:active {
  color: var(--accent-hover);
}

/* Visible only to screen readers, until focused. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.visually-hidden:focus {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip-path: none;
  white-space: normal;
}

/* Layout --------------------------------------------------------------- */

.page {
  position: relative;
  max-width: var(--page-width);
  min-height: 100%;
  margin-right: 10px;
  padding-bottom: var(--line);
}

/* The translucent white rail. Drawn as a pseudo-element so it can run the
   full height of the page independently of how tall the header and social
   links actually are. */
.page::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--rail-width);
  min-height: 100%;
  background-color: var(--paper);
}

.site-header {
  position: relative;
  z-index: 2;
  float: left;
  width: var(--rail-width);
  padding-top: 48px;
}

.content {
  float: right;
  width: var(--card-width);
  margin: 120px 0 0 10px;
}

.connect {
  position: relative;
  z-index: 2;
  clear: left;
  float: left;
  width: var(--rail-width);
  overflow: hidden;
}

.site-footer {
  clear: both;
  margin-left: var(--card-offset);
  background-color: var(--paper);
  border-radius: 3px;
}

/* Header --------------------------------------------------------------- */

.site-title {
  margin: 0 var(--rail-gutter) var(--line);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 300;
  letter-spacing: -0.045em;
  line-height: 1;
}

.site-title a {
  color: var(--accent);
}

.site-title a:hover {
  color: var(--accent-hover);
}

.site-nav {
  clear: both;
  float: left;
  width: 78.723%; /* 222px of the 282px rail */
  margin: 0 var(--rail-gutter) 48px;
  font-size: 14px;
  line-height: 1.643;
}

.site-nav li {
  border-bottom: 1px solid var(--rule);
}

.site-nav a {
  display: block;
  padding: 6px 0;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 300;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent);
}

/* Shown only once the layout has stacked. */
.nav-toggle {
  display: none;
  width: 100%;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

/* Content -------------------------------------------------------------- */

.card {
  overflow: hidden; /* contains the floated images */
  margin-bottom: var(--line);
  padding-top: var(--line);
  background-color: var(--paper);
  border-radius: 3px;
}

.card > h1 {
  padding: 0 var(--card-gutter) 0 var(--title-indent);
  border-left: 5px solid var(--accent);
  color: var(--accent);
  font-family: var(--display);
  font-size: 42px;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1.143;
}

.prose {
  margin: var(--line) var(--card-gutter) 0;
  font-family: var(--prose);
}

.prose p {
  margin-bottom: var(--line);
}

.prose h3 {
  margin-bottom: var(--line);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1.6;
}

.prose ul {
  margin: 0 0 var(--line);
  list-style: disc;
}

.prose li {
  margin-left: 36px;
}

.prose em {
  font-style: italic;
}

/* Melanie styled most in-text links to sit quietly in the paragraph rather
   than stand out in the accent colour. */
.prose a.quiet {
  color: inherit;
}

.prose img.center {
  clear: both;
  display: block;
  margin: 7px auto;
}

.prose img.right {
  float: right;
  margin: 7px 0 7px var(--line);
}

/* Melanie separated these blocks with runs of empty paragraphs. Here they are
   real spacing instead, on the same 24px rhythm as everything else — one empty
   paragraph came to 48px plus the 24px margin already between them. */
.prose section {
  margin-top: calc(var(--line) * 3);
}

/* The references sat well clear of the floated photo above them. */
.prose .references {
  margin-top: calc(var(--line) * 9);
}

/* Three pages ended with runs of empty paragraphs, leaving the card taller than
   its text needs. Kept, so the cards stay the height they have always been. */
.home .prose {
  padding-bottom: calc(var(--line) * 3);
}

.work .prose {
  padding-bottom: calc(var(--line) * 6);
}

.teaching .prose {
  padding-bottom: calc(var(--line) * 7);
}

/* Social links --------------------------------------------------------- */

.connect-inner {
  margin: 0 var(--rail-gutter) 48px;
  font-size: 14px;
  line-height: 1.714;
  overflow: hidden;
}

.connect h2 {
  font-family: var(--display);
  font-size: inherit;
  font-weight: 400;
  line-height: inherit;
  text-transform: uppercase;
}

.social {
  overflow: hidden;
  line-height: 2; /* sets the row height the icon buttons sit in */
}

.social li {
  float: left;
  margin: 0 6px 12px;
}

/* Block, not inline-block: an inline button would sit on the text baseline and
   reserve a descender's worth of space under each icon. */
.social a {
  display: block;
  padding: 9px;
  background-color: #999;
  border-radius: 3px;
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.social a:hover,
.social a:focus {
  background-color: #666;
  color: #fff;
}

.social svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/* Footer --------------------------------------------------------------- */

.site-info {
  margin: 0 var(--card-gutter);
  padding: var(--line) 0;
  font-size: 13px;
  line-height: 1.846;
}

/* Responsive ----------------------------------------------------------- */

@media screen and (max-width: 840px) {
  .page::before,
  .site-header,
  .connect {
    width: 33.571%;
  }
}

@media screen and (max-width: 768px) {
  .page {
    margin-right: 0;
  }

  /* The rail stops being a rail — every band becomes its own card. */
  .page::before {
    display: none;
  }

  .site-header {
    float: none;
    width: 618px;
    margin: 0 auto 48px;
    padding: var(--line) 0;
    background-color: var(--paper);
    border-radius: 0 0 3px 3px;
  }

  .site-title {
    margin: 0 var(--card-gutter) var(--line);
  }

  .site-nav {
    float: none;
    width: auto;
    margin: 0 var(--card-gutter);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
  }

  .nav-toggle {
    display: block;
  }

  /* The toggle's aria-expanded is the single source of truth for whether the
     menu is open — no classes to keep in sync, and it stays correct for
     screen readers. */
  .site-nav ul {
    display: none;
  }

  .nav-toggle[aria-expanded="true"] + ul {
    display: block;
  }

  .content,
  .connect {
    float: none;
    width: 618px;
    margin: 0 auto;
  }

  .connect {
    background-color: var(--paper);
    border-radius: 3px;
  }

  .connect-inner {
    margin: var(--line) var(--card-gutter);
  }

  .site-footer {
    width: 618px;
    margin: var(--line) auto 0;
  }
}

@media screen and (max-width: 618px) {
  .site-header,
  .content,
  .connect,
  .site-footer {
    width: 100%;
  }

  .site-header,
  .card,
  .connect,
  .site-footer {
    border-radius: 0;
  }

  /* Let the footer's two halves stack instead of crowding one line. */
  .site-info .sep {
    display: block;
    width: 100%;
    height: 1px;
    visibility: hidden;
  }
}

@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
  .card > h1 {
    font-size: 24px;
    line-height: 1;
  }
}
