:root {
  color-scheme: light;
  --background: #fff;
  --foreground: #030303;
  --muted-foreground: #374151;
  --subtle: #6b7280;
  --border: #e5e5e5;
  --underline: #d4d4d4;
  --muted: #f5f5f5;
  --focus: #2f6feb;
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Lora", ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #bbe0fc;
  color: #061d2b;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--foreground);
  text-decoration-color: var(--foreground);
}

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

.site-container {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

@media (min-width: 640px) {
  .site-container {
    padding: 0 1.5rem;
  }
}

@media (min-width: 1024px) {
  .site-container {
    padding: 0;
  }
}

/* Visitors see the homepage snapshot immediately. In edit mode the page stays
   hidden until the latest saved content has loaded, so nothing stale gets edited. */
html.editor-mode body.editable-shell main {
  opacity: 0;
}

html.editor-mode body.editable-shell.content-ready main {
  opacity: 1;
  transition: opacity 0.15s ease;
}

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

.site-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding-top: 24px;
  padding-bottom: 24px;
  font-size: 14px;
}

.site-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--foreground);
  text-decoration: none;
}

.site-name:hover {
  color: var(--muted-foreground);
}

.site-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-local {
  font-size: 13px;
  line-height: 20px;
  color: var(--subtle);
}

.site-local .sep {
  color: #c4c4c4;
}

.local-clock {
  font-variant-numeric: tabular-nums;
}

.site-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  color: #a3a3a3;
}

.site-nav a {
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover {
  color: var(--foreground);
}

/* The page you're on: dark, medium weight, and underlined. */
.site-nav a[aria-current="page"] {
  color: var(--foreground);
  font-weight: 500;
  border-bottom-color: var(--foreground);
}

.site-social {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-social a {
  display: inline-flex;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.site-social a:hover {
  opacity: 0.7;
}

.site-social svg {
  width: 18px;
  height: 18px;
  display: block;
}

.site-social .icon-linkedin {
  color: #0a66c2;
}

.site-social .icon-github {
  color: #181717;
}

@media (min-width: 640px) {
  .site-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }
}

@media (min-width: 1024px) {
  .site-header {
    padding-top: 40px;
    padding-bottom: 0;
  }
}

.site-content {
  padding-top: 32px;
  padding-bottom: 80px;
}

@media (min-width: 640px) {
  .site-content {
    padding-top: 48px;
  }
}

.site-footer {
  padding-bottom: 48px;
  font-size: 12px;
  color: var(--subtle);
}

/* ---------- Subpage heading + lists (research, building) ---------- */

.page-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 32px;
  color: var(--foreground);
}

.page-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 24px;
  color: var(--muted-foreground);
}

.entry-list {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.entry-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  line-height: 28px;
  color: var(--foreground);
}

.entry-title a:hover {
  text-decoration-color: var(--foreground);
}

.entry-sub {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--subtle);
}

.entry-desc {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 24px;
  color: var(--muted-foreground);
  text-wrap: pretty;
}

.entry-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 20px;
  color: var(--subtle);
}

.entry-meta .sep {
  color: #c4c4c4;
}

/* Building page: each project gets its cover as a thumbnail beside the text. */
.work-item {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.work-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: var(--muted);
  outline: 1px solid rgba(0, 0, 0, 0.06);
  outline-offset: -1px;
}

.work-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  opacity: 0;
  animation: cover-fade-in 0.35s ease forwards;
  transition: transform 0.3s ease;
}

/* Diagrams have text, so show them whole on white instead of cropping. */
.work-thumb--diagram {
  background: #fff;
}

.work-thumb--diagram img {
  object-fit: contain;
}

.work-item:hover .work-thumb img {
  transform: scale(1.03);
}

@keyframes cover-fade-in {
  to {
    opacity: 1;
  }
}

@media (max-width: 639px) {
  .work-item {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 14px;
  }
}

/* ---------- Editable homepage content ---------- */

.page {
  min-height: 50vh;
  color: var(--muted-foreground);
  overflow-wrap: break-word;
  outline: none;
}

.page:focus {
  outline: 2px solid transparent;
}

/* Pasted text can carry its own inline fonts; keep the page typography uniform. */
.page [style*="font-family"] {
  font-family: inherit !important;
}

.page p,
.page ul,
.page ol,
.page blockquote,
.page figure {
  margin: 0 0 20px;
}

.page h1,
.page h2,
.page h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--foreground);
}

.page h1 {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 32px;
}

.page h2 {
  margin: 44px 0 12px;
  font-size: 17px;
  line-height: 28px;
}

.page h3 {
  margin: 28px 0 8px;
  font-size: 16px;
  line-height: 28px;
}

.page a.accent-link {
  color: #0a66c2;
  font-weight: 500;
  text-decoration-color: rgba(10, 102, 194, 0.4);
}

.page a.accent-link:hover {
  color: #084e96;
  text-decoration-color: currentColor;
}

.page sup {
  font-size: 0.65em;
  line-height: 0;
  vertical-align: super;
  color: var(--subtle);
}

.page b,
.page strong {
  font-weight: 600;
  color: var(--foreground);
}

.page ol,
.page ul {
  padding-left: 1.25rem;
}

.page li {
  margin-bottom: 4px;
}

.page li::marker {
  color: var(--subtle);
}

.page blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--foreground);
}

.page .homepage-intro p {
  text-align: justify;
  text-align-last: left;
  text-justify: inter-word;
}

.page .uwaterloo-icon {
  display: inline-block !important;
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  margin: 0 4px 0 2px !important;
  vertical-align: -3px;
  border-radius: 0 !important;
}

.page figure.painting {
  margin: 8px 0 20px;
}

.page figure.painting img {
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 0;
  outline: 1px solid rgba(0, 0, 0, 0.06);
  outline-offset: -1px;
}

.page figure.painting figcaption {
  font-family: var(--font-serif);
  font-style: italic;
  white-space: nowrap;
}

@media (max-width: 400px) {
  .page figure.painting figcaption {
    font-size: 11.5px;
  }
}

/* Small logo inline with text, same format as the uwaterloo seal on the About page. */
img.inline-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0 4px 0 2px;
  vertical-align: -3px;
}

.page .chart-pair {
  display: flex;
  gap: 12px;
  margin: 8px 0 20px;
}

.page .chart-pair figure {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}

.page .chart-pair img {
  width: 100%;
  margin: 0;
}

.page .chart-pair figcaption {
  margin-top: 6px;
  text-align: center;
}

.page .logo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
  margin: 32px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.page .logo-row a {
  display: inline-flex;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.page .logo-row a:hover {
  opacity: 0.75;
}

.page .logo-row img.logo {
  width: auto;
  height: 30px;
  margin: 0;
  border-radius: 0;
}

.page .logo-row img.logo-riscv {
  height: 20px;
}

.page .logo-row img.logo-bluedot {
  border-radius: 6px;
}

.page .note {
  font-size: 14px;
  line-height: 24px;
  color: var(--subtle);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px 0;
}

.page img {
  object-fit: contain;
  border-radius: 6px;
}

figure {
  margin-left: 0;
  margin-right: 0;
}

figcaption {
  margin-top: 6px;
  font-size: 14px;
  line-height: 24px;
  color: var(--subtle);
}

.image-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  clear: both;
  margin: 10px 0 20px;
}

.image-row img {
  flex: 0 1 auto;
  min-width: 0;
  width: auto;
  margin: 0;
  object-fit: contain;
}

/* ---------- Editor ---------- */

.editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: none;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  padding: 10px 14px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
}

.editor-enabled .editor-toolbar {
  display: flex;
}

.editor-toolbar button,
.editor-toolbar select,
.editor-toolbar label {
  min-height: 32px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  background: #fff;
  color: #202124;
  font: 13px/1 var(--font-sans);
}

.editor-toolbar button,
.editor-toolbar select {
  padding: 0 10px;
}

.editor-toolbar button {
  cursor: pointer;
}

.editor-toolbar label {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 0 8px;
}

.editor-toolbar input[type="color"] {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
}

.editor-toolbar input[type="range"] {
  width: 110px;
}

.save-status {
  color: #5f6368;
  font-size: 13px;
  white-space: nowrap;
}

.editor-enabled img {
  cursor: grab;
}

.editor-enabled img:active {
  cursor: grabbing;
}

.editor-enabled img.selected-image {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

#image-resize-handle {
  position: absolute;
  z-index: 20;
  display: none;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
  cursor: nwse-resize;
}

.editor-enabled #image-resize-handle.visible {
  display: block;
}

.is-resizing-image {
  cursor: nwse-resize;
  user-select: none;
}

.image-center {
  clear: both;
  display: block;
  float: none;
  margin-left: auto;
  margin-right: auto;
}

.image-left {
  clear: both;
  display: block;
  float: none;
  margin-left: 0;
  margin-right: auto;
}

.image-right {
  clear: both;
  display: block;
  float: none;
  margin-left: auto;
  margin-right: 0;
}

.image-wrap-left {
  clear: none;
  display: block;
  float: left;
  margin: 4px 16px 10px 0;
}

.image-wrap-right {
  clear: none;
  display: block;
  float: right;
  margin: 4px 0 10px 16px;
}

.drag-over {
  outline: 1px dashed var(--focus);
  outline-offset: 8px;
}

@media (max-width: 640px) {
  /* Keep each image's laptop width (a % of the column) so phones show the
     same proportions; only stop text-wrapped images from squeezing the text. */
  .page img.image-wrap-left,
  .page img.image-wrap-right {
    float: none;
    margin: 10px 0;
  }

  .page .homepage-intro p {
    text-align: left;
  }

  .editor-toolbar {
    gap: 5px;
    padding: 8px;
  }

  .editor-toolbar button,
  .editor-toolbar select,
  .editor-toolbar label {
    flex: 1 1 auto;
  }
}
