/* ============================= */
/* Base Layout (Grid Page)      */
/* ============================= */

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: #f9fafb;
  color: #333;

  display: grid;
  grid-template-rows: auto 1fr auto;
  /* header | main | footer */
}

/* ============================= */
/* Main Grid Layout              */
/* ============================= */

main {
  margin: 0 10%;
  display: grid;

  /* controls | chart | table */
  grid-template-rows:
    auto minmax(0, 1fr) auto;

  overflow: hidden;
}

/* ============================= */
/* Sections                      */
/* ============================= */

.controls-section,
.table-section {
  padding: 2rem 0;
}

/* ============================= */
/* Chart Section (the magic)    */
/* ============================= */

.chart-section {
  min-height: 40px;
  /* threshold */
  overflow: hidden;
  /* hides when too small */
  position: relative;
}

/* When grid cannot give 40px, this collapses to 0 visually */
@container (max-height: 39px) {
  .chart-section {
    display: none;
  }
}

/* Wrapper must not define height */
.chart-wrapper {
  position: absolute;
  inset: 0;
}

/* Canvas obeys CSS, not Chart.js */
.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ============================= */
/* Header / Footer               */
/* ============================= */

.top-bar {
  background: #0a2540;
  color: #fff;
  padding: 1rem 0;
}

.top-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-title {
  margin: 0;
  font-size: 1.35rem;
  white-space: nowrap;
}

.portfolio-link {
  padding: 0.6rem 1.2rem;
  border: 2px solid #fff;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: 0.2s;
}

.portfolio-link:hover {
  background: #fff;
  color: #000;
}

/* ============================= */
/* Buttons                       */
/* ============================= */

.outline-button {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 2px solid #0a2540;
  background: transparent;
  color: #0a2540;
  font-weight: 700;
  transition: 0.2s;
}

.outline-button:hover {
  background: #0a2540;
  color: #fff;
  cursor: pointer;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
}

strong {
  font-weight: 700;
}

.faq-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.github-inline {
  color: inherit;
  opacity: 0.75;
  transition: opacity 0.2s ease, transform 0.2s ease;
  line-height: 1;
}

.github-inline i {
  font-size: 1.15rem;
  /* visually matches h4 size */
}

.github-inline:hover {
  opacity: 1;
  transform: translateY(-1px);
}

/* ============================= */
/* Table                         */
/* ============================= */

table {
  margin-top: 1.5rem;
}