:root {
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --article-width: 680px;
  --article-panel-width: calc(var(--article-width) + 5rem);
  --margin-note-gutter: 292px;
  --painting-blue: #1e4f9a;
  --painting-red: #e22612;
  --accent-primary: var(--painting-blue);
  --accent-hover: var(--painting-red);
  --text-muted: #566574;
  --page-bg: #fae8d2;
  --panel-bg: rgba(247, 240, 230, 0.68);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
}

body {
  font-family: var(--font-body);
  font-optical-sizing: auto;
  line-height: 1.7;
  font-size: 1.05rem;
  color: #1a1a1a;
  background-color: var(--page-bg);
  background-image: url('../img/hat-tiling.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  margin: 0;
  padding: 0;
  counter-reset: sidenote-counter;
  max-width: none !important;
  width: 100% !important;
  isolation: isolate;
}

.site-header,
main,
footer {
  position: relative;
  z-index: 1;
}

.site-header,
main {
  max-width: 1650px;
  margin: 0 auto;
  padding-left: 3rem;
  padding-right: 3rem;
  box-sizing: border-box;
}

.site-header {
  padding-top: 1.5rem;
  padding-bottom: 1rem;
  position: relative;
}

main {
  padding-top: 2rem;
  padding-bottom: 2rem;
}


.site-title {
  margin: 0;
  padding: 0.45rem 0.75rem;
  width: fit-content;
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid rgba(26, 26, 26, 0.36);
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
  text-align: left;
  font-size: 1.5rem;
  font-weight: 400;
  font-family: var(--font-heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}


.home .site-header,
.home main {
  max-width: none;
}

.home .site-header {
  display: none;
}

.home {
  height: auto;
  overflow: visible;
}

.home main {
  height: auto;
  padding-top: 4rem;
  padding-bottom: 4rem;
  overflow: visible;
}


/* --- Mobile Layout Override --- */
@media (max-width: 768px) {
  .site-header,
  main {
    max-width: none;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .site-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .site-title {
    margin-bottom: 1rem;
    text-align: left;  
  }
}

.site-title a {
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: none;
}

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

.header-links {
  position: absolute;
  top: 1.5rem;
  right: 3rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.45rem 0.75rem;
  background: #fff;
  border: 2px solid rgba(26, 26, 26, 0.36);
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
}

.header-links a {
  color: var(--accent-primary);
  font-size: 1.1rem;
  font-weight: 500;
  border-bottom: none;
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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


/* Blog list page - center aligned */
.list main {
  margin: 0 auto;
  padding: 0 3rem 2rem 3rem;
}

.home-shell {
  --home-sidebar-panel-width: 210px;
  display: grid;
  grid-template-columns: minmax(0, 680px) 230px;
  grid-template-areas: "content sidebar";
  column-gap: 1.5rem;
  row-gap: 1.5rem;
  justify-content: center;
  align-items: start;
  height: auto;
  margin: 0 auto;
  max-width: 1050px;
}

.home-shell em,
.home-shell i,
.home-shell .post-date {
  font-style: normal;
}

.home-sidebar {
  grid-area: sidebar;
  font-family: var(--font-body);
}

.home-sidebar-inner {
  position: sticky;
  top: 0;
  max-height: none;
  overflow: visible;
}

.home-sidebar-card {
  width: 100%;
  padding: 1rem;
  border: 2px solid rgba(26, 26, 26, 0.36);
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
}

.home-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.home-sidebar-section h2 {
  margin: 0 0 0.35rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #1a1a1a;
  color: #1a1a1a;
  font-size: 1.05rem;
  font-weight: 600;
}

.home-sidebar-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.home-sidebar-section li {
  margin: 0.15rem 0;
  line-height: 1.4;
}

.home-sidebar-section a {
  color: #1a1a1a;
  font-size: 0.95rem;
}

.home-sidebar-section a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.home-sidebar-image {
  margin: 0 0 1.25rem;
  text-align: center;
}

.home-sidebar-image img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
  margin: 0;
}

.home-sidebar-image .image-caption {
  margin-top: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-style: normal;
  line-height: 1.3;
  text-align: center;
}

.home-content {
  grid-area: content;
  max-width: 680px;
  height: auto;
  margin: 0;
  padding: 2rem 2.5rem 3rem;
  background: #fff;
  border: 2px solid rgba(26, 26, 26, 0.36);
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
  overflow: visible;
  overscroll-behavior: auto;
}

.home-text {
  min-width: 0;
}

.home-title {
  color: #1a1a1a;
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.85rem;
  line-height: 1.15;
}

.home-text h2 {
  color: #1a1a1a;
  margin-top: 1.4rem;
  margin-bottom: 0.45rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.home-text h2 + p,
.home-text h2 + ul {
  margin-top: 0;
}

.image-caption {
  margin-top: 0.75rem;
  font-size: 1.1rem;
  text-align: center;
  color: var(--text-muted);
}

/* For side images */
.side-image {
    float: right;
    clear: right;
    width: 260px;
    margin-right: -292px;
    margin-top: 0;
    margin-bottom: 2em;
    font-size: 1.1rem;
    line-height: 2;
    vertical-align: baseline;
    position: relative;
}

.side-image img {
    width: 100%;
    height: auto;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--accent-primary);
  line-height: 1.3;
  font-weight: 400;
  font-family: var(--font-heading);
  letter-spacing: -0.01em;
}

article {
  max-width: var(--article-panel-width);
  margin-left: max(
    0px,
    min(
      calc((100% - var(--article-panel-width)) / 2),
      calc(100% - var(--article-panel-width) - var(--margin-note-gutter))
    )
  );
  margin-right: auto;
  padding: 2rem 2.5rem 3rem;
  background: #fff;
  border: 2px solid rgba(26, 26, 26, 0.36);
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
}

article.wide-article {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}

article.wide-article > h1 {
  color: #1a1a1a;
}

.content-panel {
  max-width: var(--article-panel-width);
  margin: 0 auto;
  padding: 2rem 2.5rem 3rem;
  background: #fff;
  border: 2px solid rgba(26, 26, 26, 0.36);
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
}

article .post-date {
  color: var(--text-muted);
  font-size: 1rem;
  font-style: normal;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

/* Text-only NPR's compact reading column, scoped to blog posts. */
.blog-post {
  --article-panel-width: calc(550px + 5rem);
  font-size: 1rem;
  line-height: 1.5;
  color: #000;
}

.blog-post .post-title {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 2rem;
  color: inherit;
  letter-spacing: normal;
  margin-bottom: 1rem;
}

.blog-post .post-date {
  color: inherit;
  margin-bottom: 1rem;
}

.blog-post .post-divider {
  height: 1px;
  margin-bottom: 1rem;
  background: #a8adb2;
}

.blog-post p:not(.post-date) {
  text-align: justify;
  hyphens: auto;
}

.blog-post h2,
.blog-post h3,
.blog-post h4 {
  font-family: inherit;
  font-weight: 700;
  color: inherit;
  letter-spacing: normal;
}

.blog-post h2 {
  font-size: 1.5rem;
  line-height: 2rem;
}

.blog-post h3 {
  font-size: 1.25rem;
}

p {
  position: relative;
  max-width: 100%;
  text-align: justify;
  hyphens: none;
}

h1 {
  font-size: 2.25rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.75rem;
  margin-top: 2rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

.standout-box {
  display: block;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  color: #1a1a1a;
  background: transparent;
  border: 1px solid #1a1a1a;
  border-radius: 0;
  box-shadow: none;
}

.standout-box > :first-child {
  margin-top: 0;
}

.standout-box > :last-child {
  margin-bottom: 0;
}

.sidenote {
  float: right;
  clear: right;
  text-align: left;
  width: 240px;
  margin-right: -292px;
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  position: relative;
  color: var(--text-muted);
  padding: 0.2rem 0.4rem;
  background: #fff;
  border: 1px solid rgba(26, 26, 26, 0.22);
  box-shadow: 0 2px 5px rgba(26, 26, 26, 0.08);
  border-radius: 3px;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidenote.sn-active {
  background-color: #fff0ec;
  border-color: var(--accent-hover);
  box-shadow: 0 3px 9px rgba(226, 38, 18, 0.2);
}

.sidenote:before {
  content: counter(sidenote-counter) ". ";
  font-weight: 600;
  color: var(--accent-hover);
  margin-right: 0.15rem;
}

.sidenote-number {
  counter-increment: sidenote-counter;
  font-size: 0.72rem;
  position: relative;
  vertical-align: super;
  color: var(--accent-hover);
  font-weight: 600;
  cursor: pointer;
  line-height: 0;
  padding: 0 1px;
  border-radius: 2px;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.sidenote-number:focus-visible {
  outline: 2px solid rgba(226, 38, 18, 0.45);
  outline-offset: 2px;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
}

.sidenote-number.sn-active {
  color: #fff;
  background-color: var(--accent-hover);
  box-shadow: 0 0 0 2px rgba(226, 38, 18, 0.22);
}

input.margin-toggle {
  display: none;
}

@media (max-width: 1068px) {
  article {
    max-width: var(--article-panel-width);
    margin-left: auto;
    margin-right: auto;
  }

  .side-image {
    float: none;
    clear: both;
    width: 100%;
    max-width: 400px;
    margin: 2em auto;
    position: static;
  }

  input.margin-toggle {
    display: none;
  }

  .sidenote {
    position: fixed;
    z-index: 1000;
    display: block;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    float: none;
    clear: none;
    width: min(300px, calc(100vw - 32px));
    margin: 0;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid rgba(226, 38, 18, 0.42);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(28, 42, 76, 0.28);
    font-size: 0.9rem;
    line-height: 1.5;
    color: #172844;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease;
  }

  .sidenote.sn-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    background: #fff;
    background-color: #fff;
    box-shadow: 0 8px 28px rgba(28, 42, 76, 0.28);
  }

  .sidenote-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    padding: 0;
    border: 0;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
  }

  .sidenote-backdrop.is-active {
    display: block;
  }
}

@media (max-width: 1200px) {
  .site-header,
  main {
    max-width: 1100px;
    margin-left: 0;
    margin-right: auto;
  }
}

@media (max-width: 1200px) {
  .home-shell {
    --home-sidebar-panel-width: 190px;
    grid-template-columns: minmax(0, 680px) 210px;
    column-gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .home {
    height: auto;
    overflow: visible;
  }

  .site-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem;
    position: static;
  }

  .site-title {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.45rem 0.75rem;
  font-size: 1.5rem;
  font-weight: 400;
  text-align: center;
  }

  .header-links {
    position: static;
    right: auto;
    top: auto;
  }

  .home main {
    height: auto;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
    overflow: visible;
  }

  .home-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    max-width: 680px;
  }

  .home-sidebar {
    order: -1;
  }

  .home-sidebar-card {
    padding: 0.8rem;
  }

  .home-sidebar-inner {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .home-sidebar {
    margin-bottom: 0.45rem;
  }

  .home-sidebar-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
    width: 100%;
    margin-bottom: 0;
    padding: 0.7rem 0.9rem 0.8rem;
    --home-sidebar-panel-width: 100%;
  }

  .home-sidebar-image {
    display: none;
  }

  .home-content {
    height: auto;
    overflow: visible;
    overscroll-behavior: auto;
    padding: 1.5rem 1.5rem 2rem;
  }

  p {
    text-align: left;
  }

  footer {
    margin-left: 1.5rem;
    padding: 1rem 1.5rem 1rem 0;
  }

}

pre, code {
  font-family: 'Courier New', monospace;
  background-color: #e8eef5;
  border: 1px solid #c2ceda;
  border-radius: 3px;
  font-size: 0.9rem;
}

pre {
  padding: 1rem;
  overflow-x: auto;
}

code {
  padding: 0.1rem 0.3rem;
}

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

footer {
  max-width: 700px;
  margin: 3rem auto 0;
  padding: 1rem 3rem 1rem 3rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.home footer {
  max-width: none;
  width: auto;
  margin: 3rem 0 0 3rem;
  padding: 1rem 3rem 1rem 0;
}

.page-size {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  margin: 0;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.85rem;
  color: black;
  font-variant-numeric: tabular-nums;
  z-index: 100;
}

@media (max-width: 900px), (max-height: 700px) {
  .page-size {
    position: static;
    display: block;
    margin: 0;
    padding: 0;
  }
}

@media (max-height: 700px) {
  .home main {
    min-height: 100vh;
  }

  .home-sidebar-inner {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

ul.post-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

ul.post-list li {
  display: flex;          
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 0.25rem;
  padding-bottom: 0.25rem;
}

ul.post-list li a {
  min-width: 0;
}

ul.post-list .post-date {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 1rem;
  font-style: normal;
  text-align: right;
  white-space: nowrap;
}

ul.post-list li:last-child {
  border-bottom: none;
}

.paper-list {
  list-style: none;
  margin: 0.75rem 0 1.8rem;
  padding-left: 0;
}

.paper-list li {
  margin-bottom: 0.75rem;
}

.paper-main {
  min-width: 0;
}

.paper-title {
  font-weight: 500;
}

.paper-authors {
  margin-top: 0.12rem;
  color: #1a1a1a;
  font-size: 0.96rem;
  line-height: 1.45;
}

.paper-venue {
  color: inherit;
}


article img {
  max-width: 100%; /* Ensures images don't overflow their container */
  height: auto;    /* Maintains aspect ratio */
  border-radius: 8px; /* Softer, rounded edges */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.05); /* Soft shadow */
  margin: 1.5rem 0; /* Add some vertical spacing around images */
  display: block;   /* Helps center images if combined with margin: auto */
}

figure {
  margin: 2.5rem 0; /* More spacing for figures with captions */
  text-align: center; /* Centers the image and caption */
}

figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px; /* Rounded corners for images in figures */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.05); /* Soft shadow */
  display: block;
  margin: 0 auto; /* Centers the image within the figure */
}

figcaption {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}

.plotly-figure {
  width: 100%;
}

.plotly-chart {
  width: 100%;
  height: clamp(22rem, 75vw, 32rem);
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(26, 26, 26, 0.22);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.05);
}

.plotly-error {
  color: var(--text-muted);
  text-align: center;
}

.plotly-error[hidden] {
  display: none;
}

.blog-container {
  display: grid;
  grid-template-columns: minmax(0, var(--article-panel-width)) 180px;
  gap: 3rem;
  justify-content: center;
  align-items: start;
  max-width: calc(var(--article-panel-width) + 180px + 3rem);
  margin: 0 auto;
}

.blog-main {
  min-width: 0;
  padding: 2rem 2.5rem 3rem;
  background: #fff;
  border: 2px solid rgba(26, 26, 26, 0.36);
  box-shadow: 0 3px 8px rgba(26, 26, 26, 0.1);
}

.blog-sidebar {
  font-size: 0.95rem;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid rgba(26, 26, 26, 0.22);
  background: #fff;
  box-shadow:
    inset 0 1px 3px rgba(26, 26, 26, 0.16),
    inset 0 -1px 0 rgba(255, 255, 255, 0.45);
  border-radius: 2px;
}

.blog-sidebar h2 {
  margin-top: 0;
  font-size: 1.15rem;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.5rem;
}

.tag-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag-list li {
  margin-bottom: 0.02rem;
}

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


/* Responsive adjustments for smaller screens */
@media (max-width: 900px) {
  .list main {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    overflow-x: hidden;
  }

  .blog-container {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
    justify-content: stretch;
    max-width: none;
    width: auto;
    min-width: 0;
  }

  .blog-main,
  .blog-sidebar {
    max-width: 100%;
    width: calc(100vw - 3rem);
    min-width: 0;
  }

  .blog-sidebar {
    border: 1px solid rgba(26, 26, 26, 0.22);
    padding: 0.85rem 1rem 1rem;
    margin-top: 0;
  }

  .blog-main p {
    text-align: left;
    overflow-wrap: break-word;
  }

  .blog-container .post-list li {
    display: block;
  }

  .blog-container .post-list .post-date {
    display: block;
    margin-top: 0.1rem;
    text-align: left;
    white-space: normal;
  }
}

/* --- Mobile: flat full-width text on a white page ---
   Kept at the end of the file so it wins over the desktop panel rules above. */
@media (max-width: 768px) {
  body {
    background-color: #fff;
    background-image: none;
  }

  main,
  .list main {
    padding-left: 0;
    padding-right: 0;
  }

  .home-shell {
    align-items: stretch;
    max-width: none;
    row-gap: 0;
  }

  .home-content,
  article,
  article.wide-article,
  .content-panel,
  .blog-main {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding: 1.5rem 1.5rem 2rem;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .home-sidebar-card,
  .blog-sidebar {
    width: 100%;
    padding: 0 1.5rem 1.25rem;
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(26, 26, 26, 0.22);
    border-radius: 0;
    box-shadow: none;
  }

  .home-sidebar-nav {
    padding: 0;
  }

  .blog-container {
    gap: 0;
  }
}
