/* ============================================
   FONTS & TYPOGRAPHY
   ============================================ */

@font-face {
  font-family: "et-book";
  src: url("/fonts/et-book-roman-line-figures.woff2") format("woff2"),
       url("/fonts/et-book-roman-line-figures.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

body {
  font-family: "et-book";
  font-size: 17px;
  color: #33303e;
  line-height: 1.7;
  background-color: #FFFFF8;
  margin: 0 auto;
  max-width: 800px;
  padding-top: 60px;
  padding-bottom: 60px;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  color: #111;
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-weight: inherit;
}

/* Byline styling */
.byline {
  margin-top: 0;
  margin-bottom: 0;
  color: darkblue;
}

.big {
  font-size: 2.5em;
  margin-bottom: 0;
}

h2 {
  font-size: 1.8em;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

/* Paragraph */
p {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  padding-right: 0;
  vertical-align: baseline;
  text-wrap: pretty;
}

/* ============================================
   LAYOUT - BODY & SECTIONS
   ============================================ */

section {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
  margin-bottom: 0;
  /* Extend background full width beyond centered body using viewport-based calc */
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  padding-left: calc(50vw - 50%);
  padding-right: calc(50vw - 50%);
  border-top: 1px solid #e5e5e0;
}

section:first-of-type {
  border-top: none;
}

/* Alternating background colors */
section:nth-of-type(odd) {
  background-color: #f5f5e8;
}

section:nth-of-type(even) {
  background-color: transparent;
}

/* ============================================
   COMPONENTS - INTRO PANELS & LINKS
   ============================================ */

.intro-panels {
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
}

.intro-panels-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.intro-panel {
  background-color: #f5f1e6;
  border: 1px solid #e1dccf;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  box-shadow: 0 1px 4px rgba(39, 24, 0, 0.08);
}

.intro-panel summary {
  font-size: 1.1em;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.intro-panel summary::-webkit-details-marker {
  display: none;
}

.intro-panel summary::after {
  content: "+";
  float: right;
  color: #065f46;
  font-weight: 700;
}

.intro-panel[open] summary::after {
  content: "–";
}

.intro-panel p {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* Links */
a {
  color: #065f46;
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  border-bottom: 1px solid #065f46;
  transition: border-color 0.2s ease;
}

a:hover {
  border-bottom-color: transparent;
}

/* Pop-out footnote */
.footnote-pop {
  position: relative;
  display: inline-block;
  margin-left: 2px;
  font-size: 0.75em;
  vertical-align: super;
  color: #065f46;
  border-bottom: 1px dotted #065f46;
  cursor: help;
}

.footnote-pop::after {
  content: attr(data-note);
  position: absolute;
  left: 0;
  top: 1.3em;
  z-index: 10;
  max-width: 260px;
  padding: 8px 10px;
  background-color: #fffdf4;
  border: 1px solid #d7d1c4;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(39, 24, 0, 0.15);
  font-size: 0.95em;
  line-height: 1.4;
  color: #33303e;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.footnote-pop:hover::after,
.footnote-pop:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.footnote-pop .footnote-content {
  position: absolute;
  left: 0;
  top: 1.3em;
  z-index: 10;
  max-width: 260px;
  padding: 8px 10px;
  background-color: #fffdf4;
  border: 1px solid #d7d1c4;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(39, 24, 0, 0.15);
  font-size: 0.95em;
  line-height: 1.4;
  color: #33303e;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  visibility: hidden;
  white-space: normal;
}

.footnote-pop:hover .footnote-content,
.footnote-pop:focus .footnote-content,
.footnote-pop:focus-within .footnote-content {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

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

/* Section header takes full width */
.section-header {
  width: 100%;
  margin-bottom: 2rem;
}

.section-header p:last-child {
  margin-bottom: 0;
}

.section-header p {
  font-size: 1.05em;
  line-height: 1.75;
}

/* ============================================
   CHARTS & FIGURES - BASE STYLES
   ============================================ */

/* Chart container - stacks on mobile, side-by-side on wide screens */
.chart-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

/* Each chart item gets its own container */
.chart-item {
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
  box-sizing: border-box;
  overflow-wrap: break-word;
  overflow: visible;
}

.chart-item h3:first-child {
  margin-top: 0;
}

/* Ensure figures within chart-item are properly sized */
.chart-item figure {
  width: 100%;
  max-width: 100%;
}

/* Ensure figures don't overflow */
figure {
  margin: 0.75rem 0 0 0;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  border: 1px solid #e5e5e0;
  border-radius: 4px;
  padding: 0.5rem;
  background-color: #fff;
  box-sizing: border-box;
}

/* ============================================
   VEGA-SPECIFIC OVERRIDES
   ============================================ */

/* Ensure Vega charts fit their container */
figure .vega-embed {
  width: 100%;
  overflow: visible;
}

/* Hide Vega's default action menu (we set actions: false in JS) */
figure .vega-embed details,
figure .vega-embed summary {
  display: none !important;
}

/* Hide Vega bind controls - these are interactive parameter controls that we don't use */
figure .vega-embed .vega-bind {
  display: none;
}

/* Make Vega canvas/svg responsive - consolidated from multiple rules */
figure .vega-embed canvas,
figure .vega-embed svg,
.chart-item canvas,
.chart-item svg {
  max-width: 100%;
  height: auto;
  width: 100% !important;
}

/* Make sure the chart containers are responsive */
.chart-item .vega-embed {
  max-width: 100%;
}

/* ============================================
   PORTFOLIO-SPECIFIC STYLES
   ============================================ */
/* Note: These styles are only used in portfolio.html for Challenge 6 grid layout */

.challenge-6 .chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  width: 100%;
}

.challenge-6 .chart-item {
  max-width: none;
}

.challenge-6 figure {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* Responsive sizing for portfolio charts - consolidated */
.challenge-6 .chart-item canvas,
.challenge-6 .chart-item svg {
  max-width: 100% !important;
  height: auto !important;
}

@media (min-width: 900px) {
  .challenge-6 .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .challenge-6 .chart-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ============================================
   RESPONSIVE MEDIA QUERIES
   ============================================ */

/* Wide screen layout - side-by-side charts */
@media (min-width: 1200px) {
  body {
    max-width: 1400px;
  }

  .chart-container {
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
  }

  .chart-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: 50%;
  }

  figure {
    padding: 1rem;
  }
}
