/* =========================================================
   CSS Custom Properties
   ========================================================= */

:root {
  --accent: #1a56db;
  --text: #1a1a1a;
  --text-subtle: #555;
  --border: #d1d5db;
  --border-strong: #1a1a1a;
  --bg: #ffffff;
  --bg-code: #f5f7fa;
  --bg-row: #f8f9fa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #60a5fa;
    --text: #e2e8f0;
    --text-subtle: #94a3b8;
    --border: #2d3748;
    --border-strong: #4a5568;
    --bg: #0f172a;
    --bg-code: #1e293b;
    --bg-row: #1e293b;
  }
}

:root[data-theme="dark"] {
  --accent: #60a5fa;
  --text: #e2e8f0;
  --text-subtle: #94a3b8;
  --border: #2d3748;
  --border-strong: #4a5568;
  --bg: #0f172a;
  --bg-code: #1e293b;
  --bg-row: #1e293b;
}

/* =========================================================
   Micro Reset
   ========================================================= */

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
}

button, input, select, textarea, label {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}

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

/* =========================================================
   Typography
   ========================================================= */

body {
  line-height: 1.75;
}

.title * {
  font-weight: 500;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  color: var(--text);
}

h1, h2 {
  padding: 0;
  margin: 60px 0 30px;
}

/* Only the page title block is centred */
.title h1,
.title h2 {
  text-align: center;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 24px;
}

blockquote {
  margin: 1.25em 0;
  padding: 0.75em 1.5em;
  border-left: 3px solid var(--accent);
  color: var(--text-subtle);
  font-style: italic;
}

/* =========================================================
   Code
   ========================================================= */

pre, code {
  font-size: .9em;
}

pre code {
  display: block;
  border: 1px solid var(--border);
  background: var(--bg-code);
  box-shadow: 2px 2px 8px rgba(0, 0, 0, .05);
  padding: 1em;
  overflow-x: auto;
  line-height: 1.75;
  border-radius: 4px;
}

code {
  background: var(--bg-code);
  padding: 1px 4px;
  border-radius: 3px;
}

pre code {
  background: none;
  padding: 0;
}

/* =========================================================
   Lists
   ========================================================= */

ul, ol {
  padding: 0 0 0 20px;
}

li {
  margin: 4px 0;
  padding: 0;
}

/* =========================================================
   Links
   ========================================================= */

a {
  color: var(--text);
  text-decoration: none;
  padding-bottom: 1px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.22);
  transition: color 0.15s ease, border-color 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) a {
    border-bottom-color: rgba(255, 255, 255, 0.2);
  }
}

:root[data-theme="dark"] a {
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

sup a {
  border-bottom: none;
}

/* Masthead links — no underline treatment */
.masthead a {
  border-bottom: none;
  padding-bottom: 0;
}

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

/* Active menu item */
.masthead .menu li.active a {
  color: var(--accent);
  font-weight: 500;
}

/* =========================================================
   Miscellaneous
   ========================================================= */

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid var(--border);
  margin: 50px auto;
  padding: 0;
  max-width: 400px;
}

.copyright {
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.875em;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
}

.nav-next {
  margin-left: 1em;
  text-align: right;
}

.nav-prev {
  margin-right: 1em;
}

.comments {
  margin-top: 20px;
}

/* =========================================================
   Images in content
   ========================================================= */

.main img:not(.profile-photo) {
  display: block;
  margin: 1.5em auto;
  border-radius: 3px;
}

.profile-photo {
  float: left;
  width: 220px;
  margin: 0 24px 16px 0;
  border-radius: 3px;
}

@media screen and (max-width: 480px) {
  .profile-photo {
    float: none;
    display: block;
    width: 100%;
    max-width: 220px;
    margin: 0 auto 20px;
  }
}

/* =========================================================
   Layout — CSS Grid
   ========================================================= */

body {
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 0;
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: start;
}

.masthead {
  padding: 20px 50px 20px 10px;
  position: sticky;
  top: 30px;
  align-self: start;
}

.main {
  padding: 32px 10px 20px 50px;
  border-left: 3px solid var(--border-strong);
  min-height: calc(100vh - 60px);
}

/* =========================================================
   Masthead
   ========================================================= */

.masthead h1 {
  margin-top: 0;
  margin-bottom: 34px;
  padding: 0;
  text-align: right;
  font-size: 46px;
  line-height: 58px;
}

.masthead h1 a {
  border-bottom: none;
  transition: color 0.15s ease;
}

.masthead .tagline {
  font-style: italic;
  text-align: right;
  color: var(--text-subtle);
}

.masthead .menu {
  margin-right: 20px;
  direction: rtl;
}

.masthead .menu a {
  direction: ltr;
  transition: color 0.15s ease;
}

.masthead .menu ul ul {
  list-style: none;
  margin-left: 10px;
  margin-right: 10px;
}

.masthead .menu li li::before {
  content: "•\00a0\00a0\00a0";
}

#menu-check {
  display: none;
}

#menu-label {
  display: none;
}

.masthead-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.masthead-actions .x-link,
.masthead-actions #theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-subtle);
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  padding: 0;
  text-decoration: none;
}

.masthead-actions #theme-toggle {
  font-size: 16px;
}

.masthead-actions .x-link:hover,
.masthead-actions #theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =========================================================
   Main Content
   ========================================================= */

.main .title h1 {
  margin-top: 0;
  margin-bottom: 40px;
}

.title h3 {
  text-align: center;
}

.subtitle {
  color: var(--text-subtle);
}

/* =========================================================
   Footnotes
   ========================================================= */

.footnotes {
  font-size: .9em;
  color: var(--text-subtle);
}

/* =========================================================
   Tables
   ========================================================= */

table {
  margin: 1.5em auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-collapse: collapse;
  width: 100%;
}

table thead th {
  border-bottom: 1px solid var(--border);
}

th, td {
  padding: 8px 12px;
  text-align: left;
}

thead, tfoot, tr:nth-child(even) {
  background: var(--bg-row);
}

/* =========================================================
   Utility Styles
   ========================================================= */

.unselectable {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* =========================================================
   Media Queries
   ========================================================= */

/* Tablet and smaller */
@media screen and (max-width: 960px) {

  body {
    display: block;
    max-width: 700px;
    padding: 20px 16px;
  }

  .masthead {
    position: static;
    width: auto;
    padding: 20px 0 40px;
    text-align: center;
    border-bottom: 3px solid var(--border-strong);
  }

  .main {
    width: auto;
    padding: 40px 0;
    border-left: none;
    min-height: auto;
  }

  .masthead h1 {
    text-align: center;
  }

  .masthead .tagline {
    text-align: center;
  }

  .masthead .menu {
    direction: ltr;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
  }

  .masthead .menu ul {
    text-align: left;
    margin: 0;
    padding: 0;
  }

  .masthead .menu ul ul {
    margin: 0;
  }

  .masthead .menu li {
    border-bottom: 1px solid var(--border);
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .masthead .menu li:first-child {
    border-top: 1px solid var(--border);
  }

  .masthead .menu li li:last-child {
    border-bottom: none;
  }

  .masthead .menu a {
    display: block;
    padding: 13px 20px;
    border-bottom: none;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .masthead .menu a:hover {
    background: var(--bg-code);
    color: var(--accent);
  }

  .masthead .menu li li a {
    padding-left: 30px;
  }

  .masthead .menu li li::before {
    content: none;
  }

  .masthead .menu li li a::before {
    content: "•\00a0\00a0\00a0";
  }

  #menu-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
    font-size: 15px;
    margin-top: 12px;
    transition: border-color 0.15s ease, color 0.15s ease;
  }

  #menu-label:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  #menu-label .icon {
    font-size: 18px;
  }

  #menu-check ~ label .close-icon {
    display: none;
  }

  #menu-check ~ label .open-icon {
    display: inline;
  }

  #menu-check:checked ~ label .close-icon {
    display: inline;
  }

  #menu-check:checked ~ label .open-icon {
    display: none;
  }

  #menu-check ~ ul {
    display: none;
  }

  #menu-check:checked ~ ul {
    display: block;
    margin-top: 8px;
    margin-bottom: 0;
  }

  .masthead-actions {
    justify-content: center;
    margin-top: 16px;
  }

}

/* Landscape phones */
@media screen and (max-width: 720px) {

  body {
    padding: 16px 14px;
  }

  .masthead h1 {
    font-size: 36px;
    line-height: 1.3;
  }

}

/* Portrait phones */
@media screen and (max-width: 480px) {

  body {
    font-size: 16px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 20px;
  }

  h3, h4, h5, h6 {
    font-size: 17px;
  }

  pre, code {
    font-size: 13px;
  }

  .masthead {
    padding-top: 0;
  }

}
