/* Tufte-inspired Clean Academic Theme - With Margins */

:root {
  --bg: #fffff8;
  --text: #111;
  --text-light: #555;
  --accent: #E03E3E;
  --border: #ddd;
  --font-body: "Et-Book", "Palatino Linotype", "Palatino", "Georgia", "Times New Roman", serif;
  --font-sans: "Inter", "Helvetica Neue", "Helvetica", Arial, sans-serif;

  /* Tufte Layout Vars */
  --content-width: 55%;
  --margin-width: 35%;
  --full-width: 1200px;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.2rem;
  /* Larger Tufte type */
  line-height: 1.5;
  margin: 0;
  padding: 0;
  counter-reset: sidenote-counter;
}

/* Layout */
.wrapper {
  width: 90%;
  max-width: var(--full-width);
  margin: 0 auto;
  padding: 0 2rem;
  /* Centered to allow both left and right margin notes */
}

/* Main Content Area constrained to left side */
.post-content,
.post-header,
.site-header .wrapper,
.footer-content {
  width: var(--content-width);
  /* This creates the 'empty' space on the right for notes */
}

/* Full width exceptions */
.site-header {
  width: 100%;
  border-bottom: none;
}

.site-footer {
  width: 100%;
}

/* Margin Notes */
.marginnote {
  float: right;
  clear: right;
  margin-right: -60%;
  /* Push into the empty space */
  width: 50%;
  /* Width relative to the content column */
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
  color: var(--text-light);
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
  font-size: 1rem;
  top: -0.5rem;
  left: 0.1rem;
  position: relative;
  vertical-align: baseline;
}

.sidenote {
  float: right;
  clear: right;
  margin-right: -60%;
  width: 50%;
  margin-top: 0;
  font-size: 1rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
  color: var(--text-light);
}

/* Mobile Responsiveness */
/* Mobile Responsiveness */
@media (max-width: 900px) {
  .wrapper {
    width: 90%;
    padding: 0 1rem;
    padding-left: 1rem;
  }

  .post-content,
  .post-header,
  .site-header .wrapper,
  .footer-content {
    width: 100%;
  }

  /* Reset margin notes to be hidden by default on mobile */
  .marginnote,
  .sidenote,
  .marginnote-left {
    float: none;
    clear: both;
    margin: 1rem 0;
    width: 100%;
    display: none;
    /* Hidden until toggled */
    color: var(--text-light);
    text-align: left;
    padding-right: 0;

    /* Box style when visible */
    background: #fdfdfd;
    padding: 1rem;
    border-left: 3px solid var(--accent);
    font-size: 0.95rem;
  }

  /* Visible state toggled by JS */
  .marginnote.visible,
  .sidenote.visible,
  .marginnote-left.visible {
    display: block;
  }

  /* Toggle Button Styles */
  .margin-toggle-button {
    display: inline-block;
    color: var(--accent);
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    margin: 0 0.3rem;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
  }

  .margin-toggle-button.active {
    color: var(--text);
  }

  /* Adjust Grid */
  .grid {
    width: 100%;
    max-width: 100%;
  }
}

/* Hide toggle button on desktop */
@media (min-width: 901px) {
  .margin-toggle-button {
    display: none;
  }
}

/* Typography */
h1,
h2,
h3 {
  font-weight: 400;
  margin-top: 2rem;
  line-height: 1.1;
}

h1 {
  font-size: 2.2rem;
  font-style: italic;
  margin-bottom: 2rem;
}

h2 {
  font-size: 1.5rem;
  font-style: italic;
  margin-top: 2rem;
}

h3 {
  font-size: 1.2rem;
  font-style: italic;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

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

/* Left Margin Note */
.marginnote-left {
  float: left;
  clear: left;
  margin-left: -60%;
  width: 50%;
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
  color: var(--text-light);
  text-align: right;
  /* Text aligns to content */
  padding-right: 1rem;
}

/* Medium screens: hide left margin notes (not enough space) */
@media (min-width: 901px) and (max-width: 1200px) {
  .marginnote-left {
    float: none;
    clear: both;
    margin: 1rem 0;
    margin-left: 0;
    width: 100%;
    display: none;
    color: var(--text-light);
    text-align: left;
    padding-right: 0;
    background: #fdfdfd;
    padding: 1rem;
    border-left: 3px solid var(--accent);
    font-size: 0.95rem;
  }

  .marginnote-left.visible {
    display: block;
  }
}



/* Navigation */
.site-header {
  padding: 2rem 0;
  font-family: var(--font-body);
  /* Tufte serif */
  font-size: 1.1rem;
  /* Slightly larger for serif */
}

.site-header .wrapper {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.site-title {
  font-weight: bold;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
  padding-right: 2rem;
  font-style: italic;
  /* Tufte style title */
}

.site-nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
  /* Allow wrapping on small screens */
}

.site-nav a {
  text-decoration: none;
  color: var(--text);
  /* darker for visibility */
  font-variant: small-caps;
  /* Tufte-like header links */
}

.site-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Post Images - constrained to content width */
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}

/* Figures / Full Width */
.fullwidth {
  width: 170%;
  /* Extend into margin */
  max-width: 100vw;
}

/* Team Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 3rem;
  margin: 3rem 0;
  width: 170%;
  /* Break out into margin */
  max-width: 90vw;
}

@media (max-width: 900px) {
  .grid {
    width: 100%;
    max-width: 100%;
  }
}

.card img {
  width: 100%;
  height: 350px;
  object-fit: cover;
  display: block;
  filter: grayscale(100%);
  transition: filter 0.3s;
}

.card:hover img {
  filter: grayscale(0%);
}


/* If grid is inside content-width, it's narrow. 
   Let's make team page full width? 
   Or allow grid to expand. */
.page-content.full-width-page .post-content {
  width: 100%;
}

/* We simply won't restrict width generally, specific pages can override? 
   For now, keep simple. Team grid in narrow column is okay if 2 cols. 
*/

/* Blog */
.post-list {
  list-style: none;
  padding: 0;
}

.post-item {
  margin-bottom: 1.5rem;
}

.post-meta {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-light);
}

.post-link {
  font-size: 1.3rem;
  text-decoration: none;
}

/* Footer */
.site-footer {
  padding: 4rem 0;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-light);
  text-align: left;
}

.footer-links {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
}